mirror of https://github.com/k3s-io/k3s
Browse Source
* initial prefer-bundled-bin ci change * Add startup testlet * Convert parsing to pflag library * Fix code validation * go mod tidy Signed-off-by: Derek Nola <derek.nola@suse.com>pull/6517/head
Derek Nola
2 years ago
committed by
GitHub
6 changed files with 133 additions and 23 deletions
@ -0,0 +1,59 @@
|
||||
package main |
||||
|
||||
import "testing" |
||||
|
||||
func Test_UnitFindPreferBundledBin(t *testing.T) { |
||||
tests := []struct { |
||||
name string |
||||
args []string |
||||
want bool |
||||
}{ |
||||
{ |
||||
name: "Single argument", |
||||
args: []string{"--prefer-bundled-bin"}, |
||||
want: true, |
||||
}, |
||||
{ |
||||
name: "no argument", |
||||
args: []string{""}, |
||||
want: false, |
||||
}, |
||||
{ |
||||
name: "Argument with equal true", |
||||
args: []string{"--prefer-bundled-bin=true"}, |
||||
want: true, |
||||
}, |
||||
{ |
||||
name: "Argument with equal false", |
||||
args: []string{"--prefer-bundled-bin=false"}, |
||||
want: false, |
||||
}, |
||||
{ |
||||
name: "Argument with equal 1", |
||||
args: []string{"--prefer-bundled-bin=1"}, |
||||
want: true, |
||||
}, |
||||
{ |
||||
name: "Argument with equal 0", |
||||
args: []string{"--prefer-bundled-bin=0"}, |
||||
want: false, |
||||
}, |
||||
{ |
||||
name: "Multiple arguments", |
||||
args: []string{"--abcd", "--prefer-bundled-bin", "--efgh"}, |
||||
want: true, |
||||
}, |
||||
{ |
||||
name: "Repeated arguments", |
||||
args: []string{"--abcd", "--prefer-bundled-bin=false", "--prefer-bundled-bin"}, |
||||
want: true, |
||||
}, |
||||
} |
||||
for _, tt := range tests { |
||||
t.Run(tt.name, func(t *testing.T) { |
||||
if got := findPreferBundledBin(tt.args); got != tt.want { |
||||
t.Errorf("findPreferBundledBin() = %+v\nWant = %+v", got, tt.want) |
||||
} |
||||
}) |
||||
} |
||||
} |
Loading…
Reference in new issue