MCPcopy Create free account
hub / github.com/davecheney/pub / TestInstances

Function TestInstances

models/instance_test.go:9–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestInstances(t *testing.T) {
10 db := setupTestDB(t)
11
12 t.Run("create", func(t *testing.T) {
13 require := require.New(t)
14 tx := db.Begin()
15 defer tx.Rollback()
16
17 instance := MockInstance(t, tx, "example.com")
18
19 var i Instance
20 err := tx.First(&i, "domain = ?", instance.Domain).Error
21 require.NoError(err)
22 require.Equal(instance.Domain, i.Domain)
23 })
24
25 t.Run("delete", func(t *testing.T) {
26 require := require.New(t)
27 tx := db.Begin()
28 defer tx.Rollback()
29
30 instance := MockInstance(t, tx, "example.com")
31 err := tx.Delete(&instance).Error
32 require.NoError(err)
33
34 var i Instance
35 err = tx.First(&i, "domain = ?", instance.Domain).Error
36 require.Error(err)
37 require.Equal("record not found", err.Error())
38 })
39}

Callers

nothing calls this directly

Calls 6

MockInstanceFunction · 0.85
NewInstancesFunction · 0.85
FindByDomainMethod · 0.80
setupTestDBFunction · 0.70
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected