summaryrefslogtreecommitdiffhomepage
path: root/runsc/config
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2021-07-12 16:43:01 -0700
committergVisor bot <gvisor-bot@google.com>2021-07-12 16:45:33 -0700
commit7132b9a07b55b1c2944f19bb938878d147785a72 (patch)
treec3d26f612b2b02d6c631a746e619c07235ffa556 /runsc/config
parente3fdd1593217894328d5a917bbc356d0a7d145f0 (diff)
Fix GoLand analyzer errors under runsc/...
PiperOrigin-RevId: 384344990
Diffstat (limited to 'runsc/config')
-rw-r--r--runsc/config/config_test.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/runsc/config/config_test.go b/runsc/config/config_test.go
index fb162b7eb..80ff2c0a6 100644
--- a/runsc/config/config_test.go
+++ b/runsc/config/config_test.go
@@ -41,21 +41,37 @@ func TestDefault(t *testing.T) {
}
}
-func setDefault(name string) {
+func setDefault(name string) error {
fl := flag.CommandLine.Lookup(name)
- fl.Value.Set(fl.DefValue)
+ return fl.Value.Set(fl.DefValue)
}
func TestFromFlags(t *testing.T) {
- flag.CommandLine.Lookup("root").Value.Set("some-path")
- flag.CommandLine.Lookup("debug").Value.Set("true")
- flag.CommandLine.Lookup("num-network-channels").Value.Set("123")
- flag.CommandLine.Lookup("network").Value.Set("none")
+ if err := flag.CommandLine.Lookup("root").Value.Set("some-path"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := flag.CommandLine.Lookup("debug").Value.Set("true"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := flag.CommandLine.Lookup("num-network-channels").Value.Set("123"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := flag.CommandLine.Lookup("network").Value.Set("none"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
defer func() {
- setDefault("root")
- setDefault("debug")
- setDefault("num-network-channels")
- setDefault("network")
+ if err := setDefault("root"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := setDefault("debug"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := setDefault("num-network-channels"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
+ if err := setDefault("network"); err != nil {
+ t.Errorf("Flag set: %v", err)
+ }
}()
c, err := NewFromFlags()