github.com/jenkins-x/jx/v2@v2.1.155/pkg/dependencymatrix/verify_test.go (about)

     1  // +build unit
     2  
     3  package dependencymatrix_test
     4  
     5  import (
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/jenkins-x/jx/v2/pkg/dependencymatrix"
    10  )
    11  
    12  func TestVerifyDependencyMatrixHasConsistentVersions(t *testing.T) {
    13  	type args struct {
    14  		dir string
    15  	}
    16  	tests := []struct {
    17  		name    string
    18  		args    args
    19  		wantErr bool
    20  	}{
    21  		{
    22  			name: "two_degree_ok",
    23  			args: args{
    24  				dir: filepath.Join("testdata", "two_degree_matrix"),
    25  			},
    26  		},
    27  		{
    28  			name: "two_paths_ok",
    29  			args: args{
    30  				dir: filepath.Join("testdata", "two_paths_matrix"),
    31  			},
    32  		},
    33  		{
    34  			name: "two_paths_inconsistent",
    35  			args: args{
    36  				dir: filepath.Join("testdata", "two_paths_matrix_inconsistent"),
    37  			},
    38  			wantErr: true,
    39  		},
    40  		{
    41  			name: "two_versions_two_paths_inconsistent",
    42  			args: args{
    43  				dir: filepath.Join("testdata", "two_versions_two_paths_matrix_inconsistent"),
    44  			},
    45  			wantErr: true,
    46  		},
    47  	}
    48  	for _, tt := range tests {
    49  		t.Run(tt.name, func(t *testing.T) {
    50  			if err := dependencymatrix.VerifyDependencyMatrixHasConsistentVersions(tt.args.dir); (err != nil) != tt.wantErr {
    51  				t.Errorf("VerifyDependencyMatrixHasConsistentVersions() error = %v, wantErr %v", err, tt.wantErr)
    52  			}
    53  		})
    54  	}
    55  }