MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestValidateIssueLabelsColor

Function TestValidateIssueLabelsColor

backend/api/v1/project_service_test.go:522–572  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

520}
521
522func TestValidateIssueLabelsColor(t *testing.T) {
523 tests := []struct {
524 name string
525 labels []*v1pb.Label
526 wantErr bool
527 }{
528 {
529 name: "missing color",
530 labels: []*v1pb.Label{
531 {Value: "review"},
532 },
533 },
534 {
535 name: "opaque color",
536 labels: []*v1pb.Label{
537 {Value: "review", Color: &colorpb.Color{Red: 0.1, Green: 0.2, Blue: 0.3}},
538 },
539 },
540 {
541 name: "explicit alpha one",
542 labels: []*v1pb.Label{
543 {Value: "review", Color: &colorpb.Color{Red: 0.1, Green: 0.2, Blue: 0.3, Alpha: wrapperspb.Float(1)}},
544 },
545 },
546 {
547 name: "channel out of range",
548 labels: []*v1pb.Label{
549 {Value: "review", Color: &colorpb.Color{Red: 1.1, Green: 0.2, Blue: 0.3}},
550 },
551 wantErr: true,
552 },
553 {
554 name: "transparent color",
555 labels: []*v1pb.Label{
556 {Value: "review", Color: &colorpb.Color{Red: 0.1, Green: 0.2, Blue: 0.3, Alpha: wrapperspb.Float(0.5)}},
557 },
558 wantErr: true,
559 },
560 }
561
562 for _, tc := range tests {
563 t.Run(tc.name, func(t *testing.T) {
564 err := validateIssueLabels(tc.labels)
565 if tc.wantErr {
566 require.Error(t, err)
567 return
568 }
569 require.NoError(t, err)
570 })
571 }
572}

Callers

nothing calls this directly

Calls 3

validateIssueLabelsFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected