go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/size_diff/common_test.go (about)

     1  // Copyright 2024 The Fuchsia Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style license that can be
     3  // found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"testing"
     9  
    10  	buildbucketpb "go.chromium.org/luci/buildbucket/proto"
    11  )
    12  
    13  func Test_hasEnded(t *testing.T) {
    14  	t.Parallel()
    15  
    16  	tests := []struct {
    17  		status buildbucketpb.Status
    18  		want   bool
    19  	}{
    20  		{
    21  			status: buildbucketpb.Status_SCHEDULED,
    22  			want:   false,
    23  		},
    24  		{
    25  			status: buildbucketpb.Status_STARTED,
    26  			want:   false,
    27  		},
    28  		{
    29  			status: buildbucketpb.Status_SUCCESS,
    30  			want:   true,
    31  		},
    32  		{
    33  			status: buildbucketpb.Status_FAILURE,
    34  			want:   true,
    35  		},
    36  		{
    37  			status: buildbucketpb.Status_CANCELED,
    38  			want:   true,
    39  		},
    40  	}
    41  	for _, tc := range tests {
    42  		t.Run(tc.status.String(), func(t *testing.T) {
    43  			t.Parallel()
    44  			if got := hasEnded(&buildbucketpb.Build{Status: tc.status}); got != tc.want {
    45  				t.Errorf("hasEnded() = %v, want %v", got, tc.want)
    46  			}
    47  		})
    48  	}
    49  }