aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-14 09:53:02 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-14 10:51:59 +0100
commitcf1f3191d2be691b482ac86f9476c180f608ddbe (patch)
tree16b5c74883be69aef8e567bc089b3656b6fb14fa /cmd
parenta1028697465029f3e7b100de843eb7e5e2948246 (diff)
downloadpodman-cf1f3191d2be691b482ac86f9476c180f608ddbe.tar.gz
podman-cf1f3191d2be691b482ac86f9476c180f608ddbe.tar.bz2
podman-cf1f3191d2be691b482ac86f9476c180f608ddbe.zip
make lint: include unit tests
Include the unit tests (i.e., _test.go files) for linting to make the tests more robust and enforce the linters' coding styles etc. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common_test.go15
-rw-r--r--cmd/podman/remoteclientconfig/configfile_test.go39
2 files changed, 21 insertions, 33 deletions
diff --git a/cmd/podman/common_test.go b/cmd/podman/common_test.go
deleted file mode 100644
index a24173003..000000000
--- a/cmd/podman/common_test.go
+++ /dev/null
@@ -1,15 +0,0 @@
-package main
-
-import (
- "os/user"
- "testing"
-)
-
-func skipTestIfNotRoot(t *testing.T) {
- u, err := user.Current()
- if err != nil {
- t.Skip("Could not determine user. Running without root may cause tests to fail")
- } else if u.Uid != "0" {
- t.Skip("tests will fail unless run as root")
- }
-}
diff --git a/cmd/podman/remoteclientconfig/configfile_test.go b/cmd/podman/remoteclientconfig/configfile_test.go
index 1710ee83f..4ad2c2100 100644
--- a/cmd/podman/remoteclientconfig/configfile_test.go
+++ b/cmd/podman/remoteclientconfig/configfile_test.go
@@ -92,14 +92,15 @@ func TestReadRemoteConfig(t *testing.T) {
{"nouser", args{reader: strings.NewReader(noUser)}, makeNoUserResult(), false},
}
for _, tt := range tests {
+ test := tt
t.Run(tt.name, func(t *testing.T) {
- got, err := ReadRemoteConfig(tt.args.reader)
- if (err != nil) != tt.wantErr {
- t.Errorf("ReadRemoteConfig() error = %v, wantErr %v", err, tt.wantErr)
+ got, err := ReadRemoteConfig(test.args.reader)
+ if (err != nil) != test.wantErr {
+ t.Errorf("ReadRemoteConfig() error = %v, wantErr %v", err, test.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("ReadRemoteConfig() = %v, want %v", got, tt.want)
+ if !reflect.DeepEqual(got, test.want) {
+ t.Errorf("ReadRemoteConfig() = %v, want %v", got, test.want)
}
})
}
@@ -150,17 +151,18 @@ func TestRemoteConfig_GetDefault(t *testing.T) {
{"single", fields{Connections: none}, nil, true},
}
for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
+ test := tt
+ t.Run(test.name, func(t *testing.T) {
r := &RemoteConfig{
- Connections: tt.fields.Connections,
+ Connections: test.fields.Connections,
}
got, err := r.GetDefault()
- if (err != nil) != tt.wantErr {
- t.Errorf("RemoteConfig.GetDefault() error = %v, wantErr %v", err, tt.wantErr)
+ if (err != nil) != test.wantErr {
+ t.Errorf("RemoteConfig.GetDefault() error = %v, wantErr %v", err, test.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("RemoteConfig.GetDefault() = %v, want %v", got, tt.want)
+ if !reflect.DeepEqual(got, test.want) {
+ t.Errorf("RemoteConfig.GetDefault() = %v, want %v", got, test.want)
}
})
}
@@ -192,17 +194,18 @@ func TestRemoteConfig_GetRemoteConnection(t *testing.T) {
{"none", fields{Connections: blank}, args{name: "foobar"}, nil, true},
}
for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
+ test := tt
+ t.Run(test.name, func(t *testing.T) {
r := &RemoteConfig{
- Connections: tt.fields.Connections,
+ Connections: test.fields.Connections,
}
- got, err := r.GetRemoteConnection(tt.args.name)
- if (err != nil) != tt.wantErr {
- t.Errorf("RemoteConfig.GetRemoteConnection() error = %v, wantErr %v", err, tt.wantErr)
+ got, err := r.GetRemoteConnection(test.args.name)
+ if (err != nil) != test.wantErr {
+ t.Errorf("RemoteConfig.GetRemoteConnection() error = %v, wantErr %v", err, test.wantErr)
return
}
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("RemoteConfig.GetRemoteConnection() = %v, want %v", got, tt.want)
+ if !reflect.DeepEqual(got, test.want) {
+ t.Errorf("RemoteConfig.GetRemoteConnection() = %v, want %v", got, test.want)
}
})
}