2022-01-19 13:05:48 +01:00
|
|
|
package db
|
|
|
|
|
2024-11-23 12:25:32 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
2022-01-19 13:05:48 +01:00
|
|
|
|
|
|
|
func TestObjectToJSON(t *testing.T) {
|
|
|
|
v := &SurveyVar{
|
|
|
|
Name: "test",
|
|
|
|
Title: "Test",
|
|
|
|
}
|
|
|
|
s := ObjectToJSON(v)
|
2024-11-23 12:25:32 +01:00
|
|
|
assert.NotNil(t, s)
|
|
|
|
assert.Equal(t, "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}", *s)
|
2022-01-19 13:05:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestObjectToJSON2(t *testing.T) {
|
2022-01-19 13:48:16 +01:00
|
|
|
var v *SurveyVar = nil
|
2022-01-19 13:05:48 +01:00
|
|
|
s := ObjectToJSON(v)
|
2024-11-23 12:25:32 +01:00
|
|
|
assert.Nil(t, s)
|
2022-01-19 13:05:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestObjectToJSON3(t *testing.T) {
|
|
|
|
v := SurveyVar{
|
|
|
|
Name: "test",
|
|
|
|
Title: "Test",
|
|
|
|
}
|
|
|
|
s := ObjectToJSON(v)
|
2024-11-23 12:25:32 +01:00
|
|
|
assert.NotNil(t, s)
|
|
|
|
assert.Equal(t, "{\"name\":\"test\",\"title\":\"Test\",\"required\":false,\"type\":\"\",\"description\":\"\",\"values\":null}", *s)
|
2022-01-19 13:05:48 +01:00
|
|
|
}
|