mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
add test case
This commit is contained in:
parent
d48d204af6
commit
f8dac9d4e9
@ -1,6 +1,8 @@
|
|||||||
package godns
|
package godns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,3 +49,28 @@ func TestCheckSettings(t *testing.T) {
|
|||||||
t.Error("HE setting without password, should be faild")
|
t.Error("HE setting without password, should be faild")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSaveCurrentIP(t *testing.T) {
|
||||||
|
SaveCurrentIP("1.2.3.4")
|
||||||
|
|
||||||
|
if _, err := os.Stat("./.current_ip"); os.IsNotExist(err) {
|
||||||
|
t.Error(".current_ip file should exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
savedIP := LoadCurrentIP()
|
||||||
|
|
||||||
|
if strings.TrimRight(savedIP, "\n") != "1.2.3.4" {
|
||||||
|
t.Error("saved IP should be equal to 1.2.3.4")
|
||||||
|
}
|
||||||
|
|
||||||
|
//Cleanup
|
||||||
|
os.Remove("./.current_ip")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLoadCurrentIP(t *testing.T) {
|
||||||
|
ip := LoadCurrentIP()
|
||||||
|
|
||||||
|
if ip != "" {
|
||||||
|
t.Error("current ip file should be empth")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user