-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdb_test.go
More file actions
54 lines (52 loc) · 1015 Bytes
/
Copy pathdb_test.go
File metadata and controls
54 lines (52 loc) · 1015 Bytes
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
/*
* @Author: shgopher shgopher@gmail.com
* @Date: 2023-05-26 04:15:12
* @LastEditors: shgopher shgopher@gmail.com
* @LastEditTime: 2023-05-26 04:20:48
* @FilePath: /short/db_test.go
* @Description:
*
* Copyright (c) 2023 by shgopher, All Rights Reserved.
*/
package short
import "testing"
func TestMapDB(t *testing.T) {
n := &Node{
LongValue: "https://github.com/googege/12",
ShortValue: "short",
}
//
db := NewMapDB()
//ad
_, err := db.Add(n)
if err != nil {
t.Error(err)
}
// find
shortURL, err := db.Find("https://github.com/googege/12")
if err != nil {
t.Error(err)
}
t.Log(shortURL)
// change
err = db.Change(n, "short1")
if err != nil {
t.Error(err)
}
// find
shortURL, err = db.Find("https://github.com/googege/12")
if err != nil {
t.Error(err)
} else {
t.Log(shortURL)
}
// delete
db.Delete("https://github.com/googege/12")
// find
shortURL, err = db.Find("https://github.com/googege/12")
if err != nil {
t.Error(err)
} else {
t.Log(shortURL)
}
}