Created
September 12, 2017 10:37
-
-
Save krak3n/ac94d2519650710946559a8d837c544d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"bytes" | |
"io/ioutil" | |
"path/filepath" | |
"testing" | |
) | |
func TestToJSON(t *testing.T) { | |
var b bytes.Buffer | |
w := bufio.NewWriter(&b) | |
err := ToJSON(w) | |
if err != nil { | |
t.Fatalf("failed writing json: %s", err) | |
} | |
w.Flush() | |
g, err := ioutil.ReadFile(filepath.Join("testdata", t.Name()+".golden")) | |
if err != nil { | |
t.Fatalf("failed reading .golden: %s", err) | |
} | |
if !bytes.Equal(b.Bytes(), g) { | |
t.Errorf("written json does not match .golden file") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment