|
|
|
@ -42,6 +42,11 @@ func TestStorage_Short(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
assert.Equal(t, expected, s.Token[token])
|
|
|
|
|
|
|
|
|
|
// If already exist the same Token will be return
|
|
|
|
|
err = s.Short("http://bit.ly/2scBYES", &token)
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
assert.Equal(t, expected, s.Token[token])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Whats wrong with this Test?
|
|
|
|
@ -88,10 +93,10 @@ func TestStorage_Get(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestStore_Exist(t *testing.T) {
|
|
|
|
|
s, err := Open("test.db")
|
|
|
|
|
s, err := Open(path)
|
|
|
|
|
defer os.Remove(path)
|
|
|
|
|
|
|
|
|
|
d := &Data{
|
|
|
|
|
d := Data{
|
|
|
|
|
URL:"http://bit.ly/2scBYES",
|
|
|
|
|
URLFetched:"https://www.youtube.com/watch?v=bouIpFd9VGM",
|
|
|
|
|
CanonicalURL:"",
|
|
|
|
@ -111,7 +116,7 @@ func TestStore_Exist(t *testing.T) {
|
|
|
|
|
Clicks:0,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notexist := s.Exist(d)
|
|
|
|
|
notexist := s.Exist(&d)
|
|
|
|
|
assert.Equal(t, false, notexist)
|
|
|
|
|
|
|
|
|
|
var token string
|
|
|
|
@ -119,7 +124,7 @@ func TestStore_Exist(t *testing.T) {
|
|
|
|
|
err = s.Short(d.URL, &token)
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
|
|
exist := s.Exist(d)
|
|
|
|
|
exist := s.Exist(&d)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, true, exist)
|
|
|
|
|
}
|
|
|
|
|