From 5f28a1ff3da143e32a1fdfd96af871d73ce0dd94 Mon Sep 17 00:00:00 2001 From: Clement Sam Date: Sun, 10 Jan 2021 12:08:40 +0000 Subject: [PATCH] feat(commands/variable): add `variable set` command Adds `variable set` command for creating GitLab environment variables. Variable can be created for a project or a group specified with `--group | -g` flag. Resolves #515 --- commands/variable/set/set_test.go | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 commands/variable/set/set_test.go diff --git a/commands/variable/set/set_test.go b/commands/variable/set/set_test.go new file mode 100644 index 000000000..5f8bfb01e --- /dev/null +++ b/commands/variable/set/set_test.go @@ -0,0 +1,43 @@ +package set + +import "testing" + +func Test_isValidKey(t *testing.T) { + type args struct { + key string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "key is empty", + args: args{ + key: "", + }, + want: false, + }, + { + name: "key is valid", + args: args{ + key: "abc123_", + }, + want: true, + }, + { + name: "key is invalid", + args: args{ + key: "abc-123", + }, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := isValidKey(tt.args.key); got != tt.want { + t.Errorf("isValidKey() = %v, want %v", got, tt.want) + } + }) + } +}