feat(forge): HasWriteAccess and issue author in the github and gitea extensions (archie #1830)
publish / publish (push) Successful in 2m1s
publish / publish (push) Successful in 2m1s
This commit is contained in:
10 files changed
+416
-135
No files matched your search
@@ -195,3 +195,25 @@ func TestCreateReviewCommentsSubmitsOneReview(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCanWrite(t *testing.T) {
|
||||
tests := []struct {
|
||||
name, permission, role string
|
||||
want bool
|
||||
}{
|
||||
{"admin", "admin", "admin", true},
|
||||
{"write", "write", "write", true},
|
||||
{"maintain by role", "write", "maintain", true},
|
||||
{"read", "read", "read", false},
|
||||
{"triage", "read", "triage", false},
|
||||
{"none", "none", "", false},
|
||||
{"empty", "", "", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := canWrite(tt.permission, tt.role); got != tt.want {
|
||||
t.Errorf("canWrite(%q, %q) = %v, want %v", tt.permission, tt.role, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user