test: use testify
Some checks are pending
Dev / build-local (push) Waiting to run
Dev / migrate-boltdb (push) Blocked by required conditions
Dev / migrate-mysql (push) Blocked by required conditions
Dev / migrate-mariadb (push) Blocked by required conditions
Dev / migrate-postgres (push) Blocked by required conditions
Dev / integrate-boltdb (push) Blocked by required conditions
Dev / integrate-mysql (push) Blocked by required conditions
Dev / integrate-mariadb (push) Blocked by required conditions
Dev / integrate-postgres (push) Blocked by required conditions
Dev / deploy-server (push) Blocked by required conditions
Dev / deploy-runner (push) Blocked by required conditions

This commit is contained in:
Denis Gukov 2024-11-23 11:25:32 +00:00
parent 74ba01d8f4
commit 98d12ac489

View File

@ -1,6 +1,10 @@
package db
import "testing"
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestObjectToJSON(t *testing.T) {
v := &SurveyVar{
@ -8,17 +12,14 @@ func TestObjectToJSON(t *testing.T) {
Title: "Test",
}
s := ObjectToJSON(v)
if s == nil || *s != "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}" {
t.Fail()
}
assert.NotNil(t, s)
assert.Equal(t, "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}", *s)
}
func TestObjectToJSON2(t *testing.T) {
var v *SurveyVar = nil
s := ObjectToJSON(v)
if s != nil {
t.Fail()
}
assert.Nil(t, s)
}
func TestObjectToJSON3(t *testing.T) {
@ -27,7 +28,6 @@ func TestObjectToJSON3(t *testing.T) {
Title: "Test",
}
s := ObjectToJSON(v)
if s == nil || *s != "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}" {
t.Fail()
}
assert.NotNil(t, s)
assert.Equal(t, "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}", *s)
}