github.com/jaylevin/jenkins-library@v1.230.4/pkg/gcs/targetFolderHandler_test.go (about)

     1  package gcs
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestGetTargetFolder(t *testing.T) {
     9  	tests := []struct {
    10  		folderPath     string
    11  		stepResultType string
    12  		subFolder      string
    13  		expected       string
    14  	}{
    15  		{folderPath: "folder/path/", stepResultType: "general", subFolder: "sub/folder", expected: "folder/path/general/sub/folder"},
    16  		{folderPath: "folder/path/", subFolder: "sub/folder", expected: "folder/path/sub/folder"},
    17  		{folderPath: "folder/path/", stepResultType: "general", expected: "folder/path/general"},
    18  		{folderPath: "folder1", stepResultType: "general", subFolder: "folder2/", expected: "folder1/general/folder2"}}
    19  
    20  	for key, tt := range tests {
    21  		t.Run(fmt.Sprintf("Row %v", key+1), func(t *testing.T) {
    22  			actualTargetFolder := GetTargetFolder(tt.folderPath, tt.stepResultType, tt.subFolder)
    23  			if actualTargetFolder != tt.expected {
    24  				t.Errorf("Expected '%v' was '%v'", tt.expected, actualTargetFolder)
    25  			}
    26  		})
    27  	}
    28  }