refactor: remove utils pkg

BREAKING CHANGE: utils package has been removed in favor of specific new
packages (http, crypto, strings)
This commit is contained in:
Livio Amstutz 2021-09-27 11:58:28 +02:00
parent 251c476e17
commit 0ab5ea5a57
40 changed files with 131 additions and 126 deletions

10
pkg/strings/strings.go Normal file
View file

@ -0,0 +1,10 @@
package strings
func Contains(list []string, needle string) bool {
for _, item := range list {
if item == needle {
return true
}
}
return false
}

View file

@ -0,0 +1,48 @@
package strings
import "testing"
func TestContains(t *testing.T) {
type args struct {
list []string
needle string
}
tests := []struct {
name string
args args
want bool
}{
{
"empty list false",
args{[]string{}, "needle"},
false,
},
{
"list not containing false",
args{[]string{"list"}, "needle"},
false,
},
{
"list not containing empty needle false",
args{[]string{"list", "needle"}, ""},
false,
},
{
"list containing true",
args{[]string{"list", "needle"}, "needle"},
true,
},
{
"list containing empty needle true",
args{[]string{"list", "needle", ""}, ""},
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Contains(tt.args.list, tt.args.needle); got != tt.want {
t.Errorf("Contains() = %v, want %v", got, tt.want)
}
})
}
}