-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock_test.go
91 lines (76 loc) · 1.96 KB
/
mock_test.go
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package gitstorage
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
const (
hashValue = "hash_value"
textInFile = "text_in_file"
testFile = "test_file.txt"
)
func TestNewMock(t *testing.T) {
m := NewMock("", nil)
var h Abstractor = (m)
assert.Equal(t, "*gitstorage.Mock", reflect.TypeOf(h).String())
}
func TestMockCreate(t *testing.T) {
m := Mock{ReturnError: nil}
err := m.Create(testFile, textInFile)
assert.NoError(t, err)
}
func TestMockRead(t *testing.T) {
m := Mock{ReturnString: "hello", ReturnError: nil}
str, err := m.Read(testFile)
assert.NoError(t, err)
assert.Equal(t, "hello", str)
}
func TestMockUpdate(t *testing.T) {
m := Mock{ReturnError: nil}
err := m.Update(testFile, textInFile)
assert.NoError(t, err)
}
func TestMockDelete(t *testing.T) {
m := Mock{ReturnError: nil}
err := m.Delete(testFile)
assert.NoError(t, err)
}
func TestMockgetHead(t *testing.T) {
m := Mock{ReturnError: nil, ReturnString: hashValue}
str, err := m.getHead()
assert.NoError(t, err)
assert.Equal(t, hashValue, str)
}
func TestMockpush(t *testing.T) {
m := Mock{ReturnError: nil, ReturnString: hashValue}
err := m.push(testFile)
assert.NoError(t, err)
}
func TestMockcreateFile(t *testing.T) {
m := Mock{ReturnError: nil}
err := m.createFile(testFile, textInFile)
assert.NoError(t, err)
}
func TestMockadd(t *testing.T) {
m := Mock{ReturnError: nil, ReturnString: hashValue}
str, err := m.add(testFile)
assert.NoError(t, err)
assert.Equal(t, hashValue, str)
}
func TestMockget(t *testing.T) {
m := Mock{ReturnError: nil, ReturnString: textInFile}
str, err := m.get(testFile)
assert.NoError(t, err)
assert.Equal(t, textInFile, str)
}
func TestMockcommit(t *testing.T) {
m := Mock{ReturnError: nil, ReturnString: hashValue}
str, err := m.commit()
assert.NoError(t, err)
assert.Equal(t, hashValue, str)
}
func TestMockdeleteFile(t *testing.T) {
m := Mock{ReturnError: nil}
err := m.deleteFile(fileName)
assert.NoError(t, err)
}