0
0
mirror of https://github.com/thegeeklab/wp-docker-buildx.git synced 2024-11-28 18:20:35 +00:00
wp-docker-buildx/plugin/plugin_test.go

42 lines
820 B
Go
Raw Normal View History

package plugin
2023-08-21 09:35:52 +00:00
import (
"context"
"reflect"
"testing"
)
func TestFlags(t *testing.T) {
2023-08-21 09:35:52 +00:00
tests := []struct {
name string
envs map[string]string
want []string
}{
{
name: "parse secrets list with escape",
envs: map[string]string{
"PLUGIN_SECRETS": "id=raw_file_secret\\,src=file.txt,id=SECRET_TOKEN",
},
want: []string{
"id=raw_file_secret,src=file.txt",
"id=SECRET_TOKEN",
},
},
}
for _, tt := range tests {
for key, value := range tt.envs {
t.Setenv(key, value)
}
got := New(func(_ context.Context) error { return nil })
2023-08-21 09:35:52 +00:00
_ = got.App.Run([]string{"wp-docker-buildx"})
_ = got.FlagsFromContext()
if !reflect.DeepEqual(got.Settings.Build.Secrets, tt.want) {
t.Errorf("%q. Build.Secrets = %v, want %v", tt.name, got.Settings.Build.Secrets, tt.want)
}
}
}