podhmo / go-webtest

Sometimes, easy is better than simple
MIT License
1 stars 0 forks source link

snapshot.Take() with snapshot.WithReplaceMap() #20

Closed podhmo closed 5 years ago

podhmo commented 5 years ago

for #18

func TestItWithReplaceMap(t *testing.T) {
    got := map[string]string{
        "name": "foo",
        "now":  rfc3339.Format(time.Now()),
    }
    repMap := map[string]interface{}{
        "#/now": got["now"],
    }
    want := snapshot.Take(t, got, snapshot.WithReplaceMap(repMap))

    if err := jsonequal.ShouldBeSame(jsonequal.From(got), jsonequal.From(want)); err != nil {
        t.Errorf("%+v", err)
    }
}