github.com/Aoi-hosizora/ahlib@v1.5.1-0.20230404072829-241b93cf91c7/xstatus/xstatus_test.go (about) 1 package xstatus 2 3 import ( 4 "fmt" 5 "github.com/Aoi-hosizora/ahlib/xtesting" 6 "testing" 7 ) 8 9 func TestDbStatus(t *testing.T) { 10 xtesting.Equal(t, DbUnknown.String(), "db-unknown") 11 xtesting.Equal(t, DbSuccess.String(), "db-success") 12 xtesting.Equal(t, DbNotFound.String(), "db-not-found") 13 xtesting.Equal(t, DbExisted.String(), "db-existed") 14 xtesting.Equal(t, DbFailed.String(), "db-failed") 15 xtesting.Equal(t, DbTagA.String(), "db-tag-a") 16 xtesting.Equal(t, DbTagB.String(), "db-tag-b") 17 xtesting.Equal(t, DbTagC.String(), "db-tag-c") 18 xtesting.Equal(t, DbTagD.String(), "db-tag-d") 19 xtesting.Equal(t, DbTagE.String(), "db-tag-e") 20 xtesting.Equal(t, DbTagF.String(), "db-tag-f") 21 xtesting.Equal(t, DbTagG.String(), "db-tag-g") 22 23 xtesting.Equal(t, fmt.Sprintf("%v", DbSuccess), "db-success") 24 xtesting.Equal(t, DbStatus(999).String(), "db-?") 25 } 26 27 func TestFsmStatus(t *testing.T) { 28 xtesting.Equal(t, FsmNone.String(), "fsm-none") 29 xtesting.Equal(t, FsmState.String(), "fsm-state") 30 xtesting.Equal(t, FsmFinal.String(), "fsm-final") 31 xtesting.Equal(t, FsmTagA.String(), "fsm-tag-a") 32 xtesting.Equal(t, FsmTagB.String(), "fsm-tag-b") 33 xtesting.Equal(t, FsmTagC.String(), "fsm-tag-c") 34 xtesting.Equal(t, FsmTagD.String(), "fsm-tag-d") 35 xtesting.Equal(t, FsmTagE.String(), "fsm-tag-e") 36 xtesting.Equal(t, FsmTagF.String(), "fsm-tag-f") 37 xtesting.Equal(t, FsmTagG.String(), "fsm-tag-g") 38 39 xtesting.Equal(t, fmt.Sprintf("%v", FsmNone), "fsm-none") 40 xtesting.Equal(t, FsmStatus(999).String(), "fsm-?") 41 } 42 43 func TestJwtStatus(t *testing.T) { 44 xtesting.Equal(t, JwtUnknown.String(), "jwt-unknown") 45 xtesting.Equal(t, JwtSuccess.String(), "jwt-success") 46 xtesting.Equal(t, JwtBlank.String(), "jwt-blank") 47 xtesting.Equal(t, JwtInvalid.String(), "jwt-invalid") 48 xtesting.Equal(t, JwtTokenNotFound.String(), "jwt-token-not-found") 49 xtesting.Equal(t, JwtUserNotFound.String(), "jwt-user-not-found") 50 xtesting.Equal(t, JwtFailed.String(), "jwt-failed") 51 xtesting.Equal(t, JwtTagA.String(), "jwt-tag-a") 52 xtesting.Equal(t, JwtTagB.String(), "jwt-tag-b") 53 xtesting.Equal(t, JwtTagC.String(), "jwt-tag-c") 54 xtesting.Equal(t, JwtTagD.String(), "jwt-tag-d") 55 xtesting.Equal(t, JwtTagE.String(), "jwt-tag-e") 56 xtesting.Equal(t, JwtTagF.String(), "jwt-tag-f") 57 xtesting.Equal(t, JwtTagG.String(), "jwt-tag-g") 58 59 xtesting.Equal(t, JwtAudience.String(), "jwt-audience") 60 xtesting.Equal(t, JwtExpired.String(), "jwt-expired") 61 xtesting.Equal(t, JwtId.String(), "jwt-id") 62 xtesting.Equal(t, JwtIssuedAt.String(), "jwt-issued-at") 63 xtesting.Equal(t, JwtIssuer.String(), "jwt-issuer") 64 xtesting.Equal(t, JwtNotValidYet.String(), "jwt-not-valid-yet") 65 xtesting.Equal(t, JwtSubject.String(), "jwt-subject") 66 xtesting.Equal(t, JwtClaimsInvalid.String(), "jwt-claims-invalid") 67 68 xtesting.Equal(t, fmt.Sprintf("%v", JwtSuccess), "jwt-success") 69 xtesting.Equal(t, JwtStatus(999).String(), "jwt-?") 70 71 s := JwtAudience | JwtExpired | JwtId | JwtIssuedAt | JwtIssuer | JwtNotValidYet | JwtSubject | JwtClaimsInvalid 72 xtesting.NotEqual(t, s&JwtAudience, 0) 73 xtesting.NotEqual(t, s&JwtExpired, 0) 74 xtesting.NotEqual(t, s&JwtId, 0) 75 xtesting.NotEqual(t, s&JwtIssuedAt, 0) 76 xtesting.NotEqual(t, s&JwtIssuer, 0) 77 xtesting.NotEqual(t, s&JwtNotValidYet, 0) 78 xtesting.NotEqual(t, s&JwtSubject, 0) 79 xtesting.NotEqual(t, s&JwtClaimsInvalid, 0) 80 }