Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/docker-up/dockerd/args_test.go
2498 views
1
// Copyright (c) 2025 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package dockerd
6
7
import (
8
"reflect"
9
"sort"
10
"testing"
11
12
"github.com/sirupsen/logrus"
13
)
14
15
func TestMapUserArgs(t *testing.T) {
16
tests := []struct {
17
name string
18
input map[string]interface{}
19
expected []string
20
wantErr bool
21
}{
22
{
23
name: "empty input",
24
input: map[string]interface{}{},
25
expected: []string{},
26
wantErr: false,
27
},
28
{
29
name: "tls and proxy settings",
30
input: map[string]interface{}{
31
"proxies": map[string]interface{}{
32
"http-proxy": "localhost:38080",
33
"https-proxy": "localhost:38081",
34
},
35
},
36
expected: []string{
37
"--http-proxy=localhost:38080",
38
"--https-proxy=localhost:38081",
39
},
40
wantErr: false,
41
},
42
}
43
44
for _, tt := range tests {
45
t.Run(tt.name, func(t *testing.T) {
46
log := logrus.New().WithField("test", t.Name())
47
got, err := mapUserArgs(log, tt.input)
48
if (err != nil) != tt.wantErr {
49
t.Errorf("mapUserArgs() error = %v, wantErr %v", err, tt.wantErr)
50
return
51
}
52
if !tt.wantErr {
53
sort.Strings(got)
54
sort.Strings(tt.expected)
55
// Sort both slices to ensure consistent comparison
56
if !reflect.DeepEqual(got, tt.expected) {
57
t.Errorf("mapUserArgs() = %v, want %v", got, tt.expected)
58
}
59
}
60
})
61
}
62
}
63
64