23 lines
462 B
Go
23 lines
462 B
Go
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)
|
|
}
|