mirror of
https://github.com/MedzikUser/go-utils.git
synced 2024-08-15 03:26:56 +00:00
chore: new tests
* Create bytes_test.go * Create cpu_test.go * Create memory_test.go * Create uptime_test.go
This commit is contained in:
parent
df1b532e2a
commit
1cb931d9ef
4 changed files with 46 additions and 0 deletions
12
common/uptime_test.go
Normal file
12
common/uptime_test.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCheckUptime(T *testing.T) {
|
||||||
|
uptime := Uptime(time.Date(2016, 6, 2, 1, 1, 1, 1, time.UTC))
|
||||||
|
fmt.Println(uptime)
|
||||||
|
}
|
10
stats/cpu_test.go
Normal file
10
stats/cpu_test.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package stats
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestCPU(t *testing.T) {
|
||||||
|
_, err := CPU()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
7
stats/memory_test.go
Normal file
7
stats/memory_test.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package stats
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestMemory(t *testing.T) {
|
||||||
|
Memory()
|
||||||
|
}
|
17
utils/bytes_test.go
Normal file
17
utils/bytes_test.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestBytes(t *testing.T) {
|
||||||
|
// 1
|
||||||
|
r := Bytes(53)
|
||||||
|
if r != "53 B" {
|
||||||
|
t.Fatal(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2
|
||||||
|
r = Bytes(1522)
|
||||||
|
if r != "1.5 kB" {
|
||||||
|
t.Fatal(r)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue