history_test.go 753 B

12345678910111213141516171819202122232425262728
  1. package archive
  2. import (
  3. "github.com/smartystreets/goconvey/convey"
  4. "testing"
  5. )
  6. func Test_diff(t *testing.T) {
  7. e1 := &EditHistory{
  8. ArcHistory: &ArcHistory{Title: "haha"},
  9. VHistory: []*VideoHistory{&VideoHistory{Filename: "hahah1"}, &VideoHistory{Filename: "hahah2"}},
  10. }
  11. var e2 *EditHistory
  12. convey.Convey("diff between one and nil", t, func() {
  13. diff, _ := e1.Diff(e2)
  14. convey.So(diff, convey.ShouldEqual, e1)
  15. })
  16. e2 = &EditHistory{
  17. ArcHistory: nil,
  18. VHistory: []*VideoHistory{&VideoHistory{Filename: "hahah1"}},
  19. }
  20. convey.Convey("diff between 2 history", t, func() {
  21. diff, _ := e1.Diff(e2)
  22. convey.So(diff.ArcHistory.Title, convey.ShouldEqual, e1.ArcHistory.Title)
  23. convey.So(len(diff.VHistory), convey.ShouldEqual, 1)
  24. })
  25. }