-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more tests and document test cases
- Loading branch information
1 parent
a77cc26
commit 023b496
Showing
11 changed files
with
262 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fireboltgosdk | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// TestAuthHappyPath tests normal authentication, and that the access token is actually set | ||
func TestAuthHappyPath(t *testing.T) { | ||
markIntegrationTest(t) | ||
|
||
if len(clientMock.AccessToken) == 0 { | ||
t.Errorf("Token is not set properly") | ||
} | ||
} | ||
|
||
// TestAuthWrongCredential checks that authentication with wrong credentials returns an error | ||
func TestAuthWrongCredential(t *testing.T) { | ||
markIntegrationTest(t) | ||
|
||
if _, err := Authenticate(usernameMock, "wrong_password"); err == nil { | ||
t.Errorf("Authentication with wrong credentials didn't return an error") | ||
} | ||
} | ||
|
||
// TestAuthEmptyCredential checks that authentication with empty password returns an error | ||
func TestAuthEmptyCredential(t *testing.T) { | ||
markIntegrationTest(t) | ||
|
||
if _, err := Authenticate(usernameMock, ""); err == nil { | ||
t.Errorf("Authentication with empty password didn't return an error") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fireboltgosdk | ||
|
||
import "testing" | ||
|
||
// TestConnectionPrepareStatement, tests that prepare statement doesn't result into an error | ||
func TestConnectionPrepareStatement(t *testing.T) { | ||
emptyClient := Client{} | ||
fireboltConnection := fireboltConnection{&emptyClient, "database_name", "engine_url"} | ||
|
||
queryMock := "SELECT 1" | ||
_, err := fireboltConnection.Prepare(queryMock) | ||
if err != nil { | ||
t.Errorf("Prepare failed, but it shouldn't: %v", err) | ||
} | ||
} | ||
|
||
// TestConnectionClose, tests that connection close doesn't result an error | ||
// and prepare statement on closed connection is not possible | ||
func TestConnectionClose(t *testing.T) { | ||
emptyClient := Client{} | ||
fireboltConnection := fireboltConnection{&emptyClient, databaseMock, engineUrlMock} | ||
if err := fireboltConnection.Close(); err != nil { | ||
t.Errorf("Close failed with an err: %v", err) | ||
} | ||
|
||
_, err := fireboltConnection.Prepare("SELECT 1") | ||
if err == nil { | ||
t.Errorf("Prepare on closed connection didn't fail, but it should") | ||
} | ||
} |
Oops, something went wrong.