MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestGetAuthConfig

Function TestGetAuthConfig

pkg/devspace/docker/auth_test.go:116–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

114}
115
116func TestGetAuthConfig(t *testing.T) {
117 testCases := []getAuthConfigTestCase{
118 {
119 name: "Use default server",
120 checkCredentialsStore: true,
121 expectedAuthConfig: &dockerregistry.AuthConfig{
122 ServerAddress: "IndexServerAddress",
123 },
124 },
125 {
126 name: "Use custom server",
127 registryURL: "http://custom",
128 checkCredentialsStore: true,
129 expectedAuthConfig: &dockerregistry.AuthConfig{
130 ServerAddress: "custom",
131 },
132 },
133 }
134
135 dir := t.TempDir()
136
137 wdBackup, err := os.Getwd()
138 if err != nil {
139 t.Fatalf("Error getting current working directory: %v", err)
140 }
141 err = os.Chdir(dir)
142 if err != nil {
143 t.Fatalf("Error changing working directory: %v", err)
144 }
145 dir, err = filepath.EvalSymlinks(dir)
146 if err != nil {
147 t.Fatal(err)
148 }
149
150 defer func() {
151 err = os.Chdir(wdBackup)
152 if err != nil {
153 t.Fatalf("Error changing dir back: %v", err)
154 }
155 }()
156
157 configDir = dir
158
159 for _, testCase := range testCases {
160 for path, content := range testCase.files {
161 asJSON, err := json.Marshal(content)
162 assert.NilError(t, err, "Error parsing content to json in testCase %s", testCase.name)
163 if content == "" {
164 asJSON = []byte{}
165 }
166 err = fsutil.WriteToFile(asJSON, path)
167 assert.NilError(t, err, "Error writing file in testCase %s", testCase.name)
168 }
169
170 client := &client{
171 APIClient: &fakeDockerClient{},
172 }
173

Callers

nothing calls this directly

Calls 5

GetAuthConfigMethod · 0.95
WriteToFileFunction · 0.92
EqualMethod · 0.80
FatalfMethod · 0.45
FatalMethod · 0.45

Tested by

no test coverage detected