-
Notifications
You must be signed in to change notification settings - Fork 0
/
claim_test.go
51 lines (48 loc) · 1.35 KB
/
claim_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"testing"
)
func TestCheckIfClaimContainsAllClaimContainsCheck(t *testing.T) {
// Define some test cases
testCases := []struct {
claims map[string]interface{}
claimContainsCheck []string
expectedResult bool
description string
}{
{
claims: map[string]interface{}{
"name": "John",
"tags": []interface{}{"student", "admin"},
},
claimContainsCheck: []string{"name=John", "tags=admin"},
expectedResult: true,
description: "Case 1: Expected to return true",
},
{
claims: map[string]interface{}{
"name": "John",
"tags": []string{"student", "developer"},
},
claimContainsCheck: []string{"name=John", "tags=admin"},
expectedResult: false,
description: "Case 2: Expected to return false",
},
{
claims: map[string]interface{}{
"name": "Ralle",
"tags": []string{"student", "developer"},
},
claimContainsCheck: []string{"name=John", "tags=admin"},
expectedResult: false,
description: "Case 2: Expected to return false",
},
}
for _, tc := range testCases {
result := checkIfClaimContainsAllClaimContainsCheck(tc.claims, tc.claimContainsCheck)
if result != tc.expectedResult {
t.Errorf("%s: checkIfClaimContainsAllClaimContainsCheck() = %v;"+
"want %v", tc.description, result, tc.expectedResult)
}
}
}