summaryrefslogtreecommitdiff
path: root/pkg/systemdgen/systemdgen_test.go
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 /pkg/systemdgen/systemdgen_test.go
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 'pkg/systemdgen/systemdgen_test.go')
-rw-r--r--pkg/systemdgen/systemdgen_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/systemdgen/systemdgen_test.go b/pkg/systemdgen/systemdgen_test.go
index e1da7e8e0..3894a0205 100644
--- a/pkg/systemdgen/systemdgen_test.go
+++ b/pkg/systemdgen/systemdgen_test.go
@@ -24,9 +24,10 @@ func TestValidateRestartPolicy(t *testing.T) {
{"failblank", ContainerInfo{restart: ""}, true},
}
for _, tt := range tests {
+ test := tt
t.Run(tt.name, func(t *testing.T) {
- if err := validateRestartPolicy(tt.ContainerInfo.restart); (err != nil) != tt.wantErr {
- t.Errorf("ValidateRestartPolicy() error = %v, wantErr %v", err, tt.wantErr)
+ if err := validateRestartPolicy(test.ContainerInfo.restart); (err != nil) != test.wantErr {
+ t.Errorf("ValidateRestartPolicy() error = %v, wantErr %v", err, test.wantErr)
}
})
}
@@ -221,18 +222,19 @@ WantedBy=multi-user.target`
},
}
for _, tt := range tests {
+ test := tt
t.Run(tt.name, func(t *testing.T) {
opts := Options{
Files: false,
- New: tt.info.New,
+ New: test.info.New,
}
- got, err := CreateContainerSystemdUnit(&tt.info, opts)
- if (err != nil) != tt.wantErr {
- t.Errorf("CreateContainerSystemdUnit() error = \n%v, wantErr \n%v", err, tt.wantErr)
+ got, err := CreateContainerSystemdUnit(&test.info, opts)
+ if (err != nil) != test.wantErr {
+ t.Errorf("CreateContainerSystemdUnit() error = \n%v, wantErr \n%v", err, test.wantErr)
return
}
- if got != tt.want {
- t.Errorf("CreateContainerSystemdUnit() = \n%v\n---------> want\n%v", got, tt.want)
+ if got != test.want {
+ t.Errorf("CreateContainerSystemdUnit() = \n%v\n---------> want\n%v", got, test.want)
}
})
}