MCPcopy Create free account
hub / github.com/cloudbase/garm / TestExternal

Function TestExternal

config/external_test.go:46–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

44}
45
46func TestExternal(t *testing.T) {
47 cfg := getDefaultExternalConfig(t)
48
49 tests := []struct {
50 name string
51 cfg External
52 errString string
53 }{
54 {
55 name: "Config is valid",
56 cfg: cfg,
57 errString: "",
58 },
59 {
60 name: "Config path cannot be relative path",
61 cfg: External{
62 ConfigFile: "../test",
63 ProviderDir: cfg.ProviderDir,
64 },
65 errString: "path to config file must be an absolute path",
66 },
67 {
68 name: "Config must exist if specified",
69 cfg: External{
70 ConfigFile: "/there/is/no/config/here",
71 ProviderDir: cfg.ProviderDir,
72 },
73 errString: "failed to access config file /there/is/no/config/here",
74 },
75 {
76 name: "Provider dir path must be absolute",
77 cfg: External{
78 ConfigFile: "",
79 ProviderDir: "../test",
80 },
81 errString: "failed to get executable path: executable path must be an absolute path",
82 },
83 {
84 name: "Provider executable path must be absolute",
85 cfg: External{
86 ConfigFile: "",
87 ProviderExecutable: "../test",
88 },
89 errString: "failed to get executable path: executable path must be an absolute path",
90 },
91 {
92 name: "Provider executable not found",
93 cfg: External{
94 ConfigFile: "",
95 ProviderDir: "/tmp",
96 },
97 errString: "failed to access external provider binary /tmp/garm-external-provider",
98 },
99 }
100
101 for _, tc := range tests {
102 t.Run(tc.name, func(t *testing.T) {
103 err := tc.cfg.Validate()

Callers

nothing calls this directly

Calls 3

getDefaultExternalConfigFunction · 0.85
RunMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected