File: updates_test.go

package info (click to toggle)
golang-github-ovn-org-libovsdb 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 1,440 kB
  • sloc: makefile: 52; sh: 14
file content (37 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ovsdb

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestRowUpdateInsert(t *testing.T) {
	u1 := RowUpdate{Old: nil, New: &Row{}}
	u2 := RowUpdate{Old: &Row{}, New: &Row{}}
	u3 := RowUpdate{Old: &Row{}, New: nil}

	assert.True(t, u1.Insert())
	assert.False(t, u2.Insert())
	assert.False(t, u3.Insert())
}

func TestRowUpdateModify(t *testing.T) {
	u1 := RowUpdate{Old: nil, New: &Row{}}
	u2 := RowUpdate{Old: &Row{}, New: &Row{}}
	u3 := RowUpdate{Old: &Row{}, New: nil}

	assert.False(t, u1.Modify())
	assert.True(t, u2.Modify())
	assert.False(t, u3.Modify())
}

func TestRowUpdateDelete(t *testing.T) {
	u1 := RowUpdate{Old: nil, New: &Row{}}
	u2 := RowUpdate{Old: &Row{}, New: &Row{}}
	u3 := RowUpdate{Old: &Row{}, New: nil}

	assert.False(t, u1.Delete())
	assert.False(t, u2.Delete())
	assert.True(t, u3.Delete())
}