123456789101112131415161718192021222324252627282930 |
- package eliza
- import (
- "encoding/json"
- "io/ioutil"
- "os"
- "testing"
- )
- func TestParsePersonality(t *testing.T) {
- t.Log("Reading Personality test\n")
- jsonFile, err := os.Open("../bots/eliza.json")
- // if we os.Open returns an error then handle it
- if err != nil {
- t.Errorf(err.Error())
- }
- t.Log("Successfully Opened eliza.json")
- byteValue, _ := ioutil.ReadAll(jsonFile)
- // we initialize our Users array
- var personality Personality
- // we unmarshal our byteArray which contains our
- // jsonFile's content into 'users' which we defined above
- json.Unmarshal(byteValue, &personality)
- t.Log("Successfully Parsed eliza.json - name field is "+personality.Name)
- // defer the closing of our jsonFile so that we can parse it later on
- defer jsonFile.Close()
- }
|