-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ut: add unit test for ovn.go and ovs/util.go (#4440)
* add unit test for ovn Signed-off-by: zcq98 <[email protected]> * add unit test for ovs/util.go Signed-off-by: zcq98 <[email protected]> * fix: golangci-lint Signed-off-by: zcq98 <[email protected]> --------- Signed-off-by: zcq98 <[email protected]>
- Loading branch information
Showing
2 changed files
with
232 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package ovs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/ovn-org/libovsdb/ovsdb" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewLegacyClient(t *testing.T) { | ||
timeout := 30 | ||
client := NewLegacyClient(timeout) | ||
require.NotNil(t, client) | ||
require.Equal(t, timeout, client.OvnTimeout) | ||
} | ||
|
||
func TestConstructWaitForNameNotExistsOperation(t *testing.T) { | ||
name := "test-name" | ||
table := "test-table" | ||
op := ConstructWaitForNameNotExistsOperation(name, table) | ||
|
||
require.Equal(t, ovsdb.OperationWait, op.Op) | ||
require.Equal(t, table, op.Table) | ||
require.Equal(t, OVSDBWaitTimeout, *op.Timeout) | ||
require.Equal(t, []ovsdb.Condition{{Column: "name", Function: ovsdb.ConditionEqual, Value: name}}, op.Where) | ||
require.Equal(t, []string{"name"}, op.Columns) | ||
require.Equal(t, string(ovsdb.WaitConditionNotEqual), op.Until) | ||
require.Equal(t, []ovsdb.Row{{"name": name}}, op.Rows) | ||
} | ||
|
||
func TestConstructWaitForUniqueOperation(t *testing.T) { | ||
table := "test-table" | ||
column := "test-column" | ||
value := "test-value" | ||
op := ConstructWaitForUniqueOperation(table, column, value) | ||
|
||
require.Equal(t, ovsdb.OperationWait, op.Op) | ||
require.Equal(t, table, op.Table) | ||
require.Equal(t, OVSDBWaitTimeout, *op.Timeout) | ||
require.Equal(t, []ovsdb.Condition{{Column: column, Function: ovsdb.ConditionEqual, Value: value}}, op.Where) | ||
require.Equal(t, []string{column}, op.Columns) | ||
require.Equal(t, string(ovsdb.WaitConditionNotEqual), op.Until) | ||
require.Equal(t, []ovsdb.Row{{column: value}}, op.Rows) | ||
} |
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