mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 18:42:30 +03:00
e75edb0629
closes https://hasurahq.atlassian.net/browse/PLAT-181 PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7178 GitOrigin-RevId: f4c1c39ac33586870e38623bb85f09d5c98a3817
59 lines
1.0 KiB
Go
59 lines
1.0 KiB
Go
package sources
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
func TestGetTableYamlFileName(t *testing.T) {
|
|
yamlStr := `
|
|
- table:
|
|
name: bookings
|
|
schema: cd
|
|
- table:
|
|
name: facilities
|
|
schema: cd
|
|
- table:
|
|
name: members
|
|
dataset: cd
|
|
object_relationship:
|
|
- name: from_author
|
|
- table:
|
|
- chinook
|
|
- sqlite
|
|
- album
|
|
- artist
|
|
object_relationship:
|
|
- name: from_author
|
|
- table:
|
|
- chinook
|
|
- sqlite
|
|
- artist
|
|
- album
|
|
- table:
|
|
- chinook123
|
|
`
|
|
want := []string{
|
|
"cd_bookings.yaml",
|
|
"cd_facilities.yaml",
|
|
"cd_members.yaml",
|
|
"chinook_sqlite_album_artist.yaml",
|
|
"chinook_sqlite_artist_album.yaml",
|
|
"chinook123.yaml",
|
|
}
|
|
var tablesKey []struct {
|
|
Table yaml.Node `yaml:"table"`
|
|
}
|
|
err := yaml.Unmarshal([]byte(yamlStr), &tablesKey)
|
|
require.NoError(t, err)
|
|
var filenames []string
|
|
for _, table := range tablesKey {
|
|
name, err := getTableYamlFileName(table.Table)
|
|
require.NoError(t, err)
|
|
filenames = append(filenames, name)
|
|
}
|
|
require.Equal(t, want, filenames)
|
|
}
|