aboutsummaryrefslogtreecommitdiffstats
path: root/skate/cluster_test.go
blob: 1c8819ea83232dd60ee053d83b0aea1a2a18859f (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
package skate

import "testing"

func TestKeyTitleSandcrawler(t *testing.T) {
	var cases = []struct {
		b     []byte
		ident string
		key   string
		err   error
	}{
		{
			[]byte(`{"ident": "123", "title": "abc"}`),
			"123",
			"abc",
			nil,
		},
		{
			[]byte(`{"ident": "123", "title": "abc++***##???ßßß"}`),
			"123",
			"abcsss",
			nil,
		},
		{
			[]byte(`{"ident": "123", "title": "A k"}`),
			"123",
			"ak",
			nil,
		},
	}
	for _, c := range cases {
		ident, key, err := KeyTitleSandcrawler(c.b)
		if key != c.key {
			t.Errorf("[key] got %v, want %v", key, c.key)
		}
		if ident != c.ident {
			t.Errorf("[ident] got %v, want %v", ident, c.ident)
		}
		if err != c.err {
			t.Errorf("[err] got %v, want %v", err, c.err)
		}
	}
}