github.com/jfrog/jfrog-cli-core/v2@v2.51.0/pipelines/status/status_test.go (about) 1 package status 2 3 import ( 4 "github.com/gookit/color" 5 "testing" 6 ) 7 8 func TestGetStatusColorCode(t *testing.T) { 9 type args struct { 10 status PipelineStatus 11 } 12 testCases := []struct { 13 name string 14 args args 15 want color.Color 16 }{ 17 {"get color code when status is success", args{SUCCESS}, color.Green}, 18 {"get color code when status is failure", args{FAILURE}, color.Red}, 19 {"get color code when status is processing", args{PROCESSING}, color.Blue}, 20 } 21 for _, testCase := range testCases { 22 t.Run(testCase.name, func(t *testing.T) { 23 if got := GetStatusColorCode(testCase.args.status); got != testCase.want { 24 t.Errorf("GetStatusColorCode() = %v, want %v", got, testCase.want) 25 } 26 }) 27 } 28 } 29 30 func TestGetPipelineStatus(t *testing.T) { 31 type args struct { 32 statusCode int 33 } 34 testCases := []struct { 35 name string 36 args args 37 want string 38 }{ 39 {"should return queued for status code 4000", args{4000}, "queued"}, 40 {"should return processing for status code 4001", args{4001}, "processing"}, 41 {"should return success for status code 4002", args{4002}, "success"}, 42 {"should return failure for status code 4003", args{4003}, "failure"}, 43 {"should return error for status code 4004", args{4004}, "error"}, 44 {"should return waiting for status code 4005", args{4005}, "waiting"}, 45 {"should return cancelled for status code 4006", args{4006}, "cancelled"}, 46 {"should return unstable for status code 4007", args{4007}, "unstable"}, 47 {"should return skipped for status code 4008", args{4008}, "skipped"}, 48 {"should return timeout for status code 4009", args{4009}, "timeout"}, 49 {"should return stopped for status code 4010", args{4010}, "stopped"}, 50 {"should return deleted for status code 4011", args{4011}, "deleted"}, 51 {"should return cached for status code 4012", args{4012}, "cached"}, 52 {"should return cancelling for status code 4013", args{4013}, "cancelling"}, 53 {"should return timingOut for status code 4014", args{4014}, "timingOut"}, 54 {"should return creating for status code 4015", args{4015}, "creating"}, 55 {"should return ready for status code 4016", args{4016}, "ready"}, 56 {"should return online for status code 4017", args{4017}, "online"}, 57 {"should return offline for status code 4018", args{4018}, "offline"}, 58 {"should return unhealthy for status code 4019", args{4019}, "unhealthy"}, 59 {"should return onlineRequested for status code 4020", args{4020}, "onlineRequested"}, 60 {"should return offlineRequested for status code 4021", args{4021}, "offlineRequested"}, 61 {"should return pendingApproval for status code 4022", args{4022}, "pendingApproval"}, 62 {"should return un defined for status code other than in range [4000 - 4022]", args{9999}, "notDefined"}, 63 } 64 for _, testCase := range testCases { 65 t.Run(testCase.name, func(t *testing.T) { 66 if got := GetPipelineStatus(testCase.args.statusCode); string(got) != testCase.want { 67 t.Errorf("GetPipelineStatus() = %v, want %v", got, testCase.want) 68 } 69 }) 70 } 71 }