-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ovirt password is mandatory for live test helper * made tests runnable with either mock or live client * added nolint to pass new golangci-lint v1.46.0
- Loading branch information
Showing
13 changed files
with
139 additions
and
103 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
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
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
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,67 @@ | ||
package ovirtclient_test | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
ovirtclient "github.com/ovirt/go-ovirt-client" | ||
ovirtclientlog "github.com/ovirt/go-ovirt-client-log/v3" | ||
) | ||
|
||
var getHelper func(t *testing.T) ovirtclient.TestHelper | ||
|
||
func getHelperLive(t *testing.T) ovirtclient.TestHelper { | ||
helper, err := ovirtclient.NewLiveTestHelperFromEnv(ovirtclientlog.NewTestLogger(t)) | ||
if err != nil { | ||
t.Fatal(fmt.Errorf("failed to create live test helper (%w)", err)) | ||
} | ||
return helper | ||
} | ||
|
||
func getHelperMock(t *testing.T) ovirtclient.TestHelper { | ||
helper, err := ovirtclient.NewMockTestHelper(ovirtclientlog.NewTestLogger(t)) | ||
if err != nil { | ||
t.Fatal(fmt.Errorf("failed to create mock test helper (%w)", err)) | ||
} | ||
return helper | ||
} | ||
|
||
func TestMain(m *testing.M) { | ||
|
||
flagValueClientMock := "mock" | ||
flagValueClientLive := "live" | ||
flagValueClientAll := "all" | ||
|
||
clientFlag := flag.String("client", flagValueClientAll, | ||
"Client to use for running the tests. \n"+ | ||
"Supported values: \n"+ | ||
fmt.Sprintf("\t%s\t: Run tests with mock client \n", flagValueClientMock)+ | ||
fmt.Sprintf("\t%s\t: Run tests with live client \n", flagValueClientLive)+ | ||
fmt.Sprintf("\t%s\t: Run tests with mock and live client \n", flagValueClientAll), | ||
) | ||
flag.Parse() | ||
|
||
switch *clientFlag { | ||
case flagValueClientLive: | ||
getHelper = getHelperLive | ||
exitVal := m.Run() | ||
os.Exit(exitVal) | ||
case flagValueClientMock: | ||
getHelper = getHelperMock | ||
exitVal := m.Run() | ||
os.Exit(exitVal) | ||
case flagValueClientAll: | ||
getHelper = getHelperMock | ||
exitVal := m.Run() | ||
if exitVal != 0 { | ||
os.Exit(exitVal) | ||
} | ||
getHelper = getHelperLive | ||
exitVal = m.Run() | ||
os.Exit(exitVal) | ||
default: | ||
panic(fmt.Errorf("Unsupported client '%s'", *clientFlag)) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.