MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / TestExpandFile

Function TestExpandFile

cli/internal/specs/v0/spec_reader_test.go:872–914  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

870}
871
872func TestExpandFile(t *testing.T) {
873 cfg := []byte(`
874kind: source
875spec:
876 name: test
877 version: v1.0.0
878 spec:
879 credentials: ${file:./testdata/creds.txt}
880 otherstuff: 2
881 credentials1: [${file:./testdata/creds.txt}, ${file:./testdata/creds1.txt}]
882 `)
883 expectedCfg := []byte(`
884kind: source
885spec:
886 name: test
887 version: v1.0.0
888 spec:
889 credentials: mytestcreds
890 otherstuff: 2
891 credentials1: [mytestcreds, anothercredtest]
892 `)
893 expandedCfg, err := expandFileConfig(cfg)
894 if err != nil {
895 t.Fatal(err)
896 }
897 if !bytes.Equal(expandedCfg, expectedCfg) {
898 t.Fatalf("got: %s expected: %s", expandedCfg, expectedCfg)
899 }
900
901 badCfg := []byte(`
902kind: source
903spec:
904 name: test
905 version: v1.0.0
906 spec:
907 credentials: ${file:./testdata/creds2.txt}
908 otherstuff: 2
909 `)
910 _, err = expandFileConfig(badCfg)
911 if !os.IsNotExist(err) {
912 t.Fatalf("expected error: %s, got: %s", os.ErrNotExist, err)
913 }
914}
915
916func TestExpandEnv(t *testing.T) {
917 os.Setenv("TEST_ENV_CREDS", "mytestcreds")

Callers

nothing calls this directly

Calls 1

expandFileConfigFunction · 0.85

Tested by

no test coverage detected