forked from Gitlink/gitlink-cli
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package engine
|
|
|
|
import (
|
|
"testing"
|
|
|
|
wf "github.com/gitlink-org/gitlink-cli/shortcuts/workflow"
|
|
)
|
|
|
|
func TestActionAllowed(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
action wf.AIAction
|
|
allowed bool
|
|
}{
|
|
{"api GET", wf.AIAction{Type: "api", Method: "GET"}, true},
|
|
{"api POST", wf.AIAction{Type: "api", Method: "POST"}, true},
|
|
{"api PATCH", wf.AIAction{Type: "api", Method: "PATCH"}, true},
|
|
{"api DELETE blocked", wf.AIAction{Type: "api", Method: "DELETE"}, false},
|
|
{"cli issue comment", wf.AIAction{Type: "cli", Module: "issue", Command: "+comment"}, true},
|
|
{"cli delete blocked", wf.AIAction{Type: "cli", Module: "repo", Command: "+delete"}, false},
|
|
{"cli fork blocked", wf.AIAction{Type: "cli", Module: "repo", Command: "+fork"}, false},
|
|
{"cli repo module blocked", wf.AIAction{Type: "cli", Module: "org", Command: "+list"}, false},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := isActionAllowed(tc.action); got != tc.allowed {
|
|
t.Errorf("isActionAllowed(%+v) = %v, want %v", tc.action, got, tc.allowed)
|
|
}
|
|
})
|
|
}
|
|
}
|