Skip to content

Commit

Permalink
Merge pull request #287 from trozet/fix_wait_timeout
Browse files Browse the repository at this point in the history
Fix json encoding of wait method timeout
  • Loading branch information
dcbw authored Jan 26, 2022
2 parents 71bfee8 + b8c1ba8 commit c5d9765
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ovsdb/notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Operation struct {
Rows []Row `json:"rows,omitempty"`
Columns []string `json:"columns,omitempty"`
Mutations []Mutation `json:"mutations,omitempty"`
Timeout int `json:"timeout,omitempty"`
Timeout *int `json:"timeout,omitempty"`
Where []Condition `json:"where,omitempty"`
Until string `json:"until,omitempty"`
Durable *bool `json:"durable,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions ovsdb/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ func TestNewGetSchemaArgs(t *testing.T) {
}
}

func TestNewWaitTransactArgs(t *testing.T) {
database := "Open_vSwitch"
i := 0
operation := Operation{Op: "wait", Table: "Bridge", Timeout: &i}
args := NewTransactArgs(database, operation)
argString, _ := json.Marshal(args)
expected := `["Open_vSwitch",{"op":"wait","table":"Bridge","timeout":0}]`
if string(argString) != expected {
t.Error("Expected: ", expected, " Got: ", string(argString))
}
}

func TestNewTransactArgs(t *testing.T) {
database := "Open_vSwitch"
operation := Operation{Op: "insert", Table: "Bridge"}
Expand Down
2 changes: 1 addition & 1 deletion server/transact.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (t *Transaction) Delete(database, table string, where []ovsdb.Condition) (o
}
}

func (t *Transaction) Wait(database, table string, timeout int, conditions []ovsdb.Condition, columns []string, until string, rows []ovsdb.Row) ovsdb.OperationResult {
func (t *Transaction) Wait(database, table string, timeout *int, conditions []ovsdb.Condition, columns []string, until string, rows []ovsdb.Row) ovsdb.OperationResult {
e := ovsdb.NotSupported{}
return ovsdb.OperationResult{Error: e.Error()}
}
Expand Down

0 comments on commit c5d9765

Please sign in to comment.