blob: 138949df030d3ea17fb30c77888d70e033842c30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package model
import "testing"
func TestMergeFeedTitle(t *testing.T) {
feed1 := &Feed{Title: "Feed 1"}
feed2 := &Feed{Title: "Feed 2"}
feed1.Merge(feed2)
if feed1.Title != "Feed 2" {
t.Fatal(`The title of feed1 should be merged`)
}
feed1 = &Feed{Title: "Feed 1"}
feed2 = &Feed{}
feed1.Merge(feed2)
if feed1.Title != "Feed 1" {
t.Fatal(`The title of feed1 should not be merged`)
}
feed1 = &Feed{Title: "Feed 1"}
feed2 = &Feed{Title: "Feed 1"}
feed1.Merge(feed2)
if feed1.Title != "Feed 1" {
t.Fatal(`The title of feed1 should not be changed`)
}
}
func TestMergeFeedCategory(t *testing.T) {
feed1 := &Feed{Category: &Category{ID: 222}}
feed2 := &Feed{Category: &Category{ID: 333}}
feed1.Merge(feed2)
if feed1.Category.ID != 333 {
t.Fatal(`The category of feed1 should be merged`)
}
feed1 = &Feed{Category: &Category{ID: 222}}
feed2 = &Feed{}
feed1.Merge(feed2)
if feed1.Category.ID != 222 {
t.Fatal(`The category of feed1 should not be merged`)
}
feed1 = &Feed{Category: &Category{ID: 222}}
feed2 = &Feed{Category: &Category{ID: 0}}
feed1.Merge(feed2)
if feed1.Category.ID != 222 {
t.Fatal(`The category of feed1 should not be merged`)
}
}
|