huaweicloud-iot-device-sdk-go/info_test.go

49 lines
867 B
Go
Raw Normal View History

2020-12-22 23:35:42 +08:00
package iot
import (
"bufio"
"fmt"
"io"
"os"
"strings"
"testing"
)
// 该测试用力仅能在Windows系统运行
func TestOsName(t *testing.T) {
if !strings.Contains(OsName(), "windows") {
t.Errorf(`OsName must be windwos`)
}
}
func TestVersion(t *testing.T) {
2020-12-23 23:08:35 +08:00
if SdkInfo()["sdk-version"] != "v0.0.2-alpha" {
t.Errorf("sdk version must be v0.0.2-alpha")
2020-12-22 23:35:42 +08:00
}
if SdkInfo()["author"] != "chen tong" {
t.Errorf("sdk author must be chen tong")
}
}
func TestCreateFileUploadResultResponse(t *testing.T) {
f, err := os.Open("sdk_info")
if err != nil {
fmt.Println(err.Error())
}
//建立缓冲区,把文件内容放到缓冲区中
buf := bufio.NewReader(f)
for {
//遇到\n结束读取
b, errR := buf.ReadBytes('\n')
if errR != nil {
if errR == io.EOF {
break
}
fmt.Println(errR.Error())
}
fmt.Println(string(b))
}
}