mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
fix logf, add unit test as an example
This commit is contained in:
parent
acb020fb7a
commit
e902d2e5d2
16
helper_test.go
Normal file
16
helper_test.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// test this file: go test helper_test.go helper.go -v
|
||||||
|
// test one function: go test -run TestGetFileContentType helper_test.go helper.go -v
|
||||||
|
func TestGetFileContentType(t *testing.T) {
|
||||||
|
var zero = []byte("hello")
|
||||||
|
r := GetFileContentType(zero)
|
||||||
|
if r != "text/plain; charset=utf-8" {
|
||||||
|
t.Errorf("Test error for %s", t.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,7 +15,7 @@ import (
|
|||||||
func autoUpdate() {
|
func autoUpdate() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
log.Errorf("Download error.", err)
|
log.Errorf("Download error: %s", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func autoUpdate() {
|
|||||||
log.Info("Downloading binary to update...")
|
log.Info("Downloading binary to update...")
|
||||||
resp, _ := http.Get(releaseUrl)
|
resp, _ := http.Get(releaseUrl)
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
log.Debug("%s-%s not found on release.", runtime.GOOS, runtime.GOARCH)
|
log.Debugf("%s-%s not found on release.", runtime.GOOS, runtime.GOARCH)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user