Skip to content

Commit

Permalink
Add unit test for GALASA_TOKEN=: case
Browse files Browse the repository at this point in the history
Signed-off-by: Eamonn Mansour <47121388+eamansour@users.noreply.github.com>
  • Loading branch information
eamansour committed Feb 5, 2024
1 parent d7ed8eb commit 79f9433
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/auth/authProperties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ func TestGetAuthPropertiesWithNoClientIdInTokenReturnsError(t *testing.T) {
assert.Contains(t, err.Error(), "GALASA_TOKEN")
}

func TestGetAuthPropertiesWithOnlySeparatorReturnsError(t *testing.T) {
// Given...
mockFileSystem := files.NewMockFileSystem()
mockEnvironment := utils.NewMockEnv()
mockGalasaHome, _ := utils.NewGalasaHome(mockFileSystem, mockEnvironment, "")

mockFileSystem.WriteTextFile(
mockGalasaHome.GetNativeFolderPath()+"/galasactl.properties",
fmt.Sprintf("GALASA_TOKEN=%s", TOKEN_SEPARATOR))

// When...
_, err := GetAuthProperties(mockFileSystem, mockGalasaHome, mockEnvironment)

// Then...
assert.NotNil(t, err, "Should return an error as the galasactl.properties exists but is missing the access token and client ID parts of the token.")
assert.Contains(t, err.Error(), "GAL1125E")
assert.Contains(t, err.Error(), "GALASA_TOKEN")
}

func TestGetAuthPropertiesWithSeparatorButNoClientIdReturnsError(t *testing.T) {
// Given...
mockFileSystem := files.NewMockFileSystem()
Expand Down

0 comments on commit 79f9433

Please sign in to comment.