| 1 |
package tests |
| 2 |
|
| 3 |
import ( |
| 4 |
. "github.com/onsi/ginkgo" |
| 5 |
|
| 6 |
"encoding/json" |
| 7 |
"io/ioutil" |
| 8 |
) |
| 9 |
|
| 10 |
func LoadFixture(file string) map[string]interface{} { |
| 11 |
content, err := ioutil.ReadFile(file) |
| 12 |
if err != nil { |
| 13 |
Fail("Fixture file '" + file + "' not found.") |
| 14 |
} |
| 15 |
var result map[string]interface{} |
| 16 |
err = json.Unmarshal(content, &result) |
| 17 |
if err != nil { |
| 18 |
Fail("Unmarshaling JSON of '" + file + "' failed: " + err.Error()) |
| 19 |
} |
| 20 |
return result |
| 21 |
} |
| 22 |
|
| 23 |
func LoadFixtureAsArray(file string) []interface{} { |
| 24 |
content, err := ioutil.ReadFile(file) |
| 25 |
if err != nil { |
| 26 |
Fail("Fixture file '" + file + "' not found.") |
| 27 |
} |
| 28 |
var result []interface{} |
| 29 |
err = json.Unmarshal(content, &result) |
| 30 |
if err != nil { |
| 31 |
Fail("Unmarshaling JSON of '" + file + "' failed: " + err.Error()) |
| 32 |
} |
| 33 |
return result |
| 34 |
} |