panel/shared/json_test.go

24 lines
462 B
Go
Raw Normal View History

2024-11-03 21:33:08 +01:00
package shared
import (
"github.com/stretchr/testify/assert"
"os"
"testing"
)
func TestLoadJsonFile(t *testing.T) {
err := os.WriteFile("test_out/test.json", []byte(`{"name": "test", "test": 1}`), os.ModePerm)
assert.NoError(t, err)
var value struct {
Name string `json:"name"`
Test int `json:"test"`
}
err = LoadJSONFile("test_out/test.json", &value)
assert.NoError(t, err)
assert.NotEmpty(t, value.Test)
assert.NotEmpty(t, value.Name)
}