|
@@ -33,3 +33,47 @@ func TestXph_GetAllDevices(t *testing.T) {
|
|
str, err := json.Marshal(gotData)
|
|
str, err := json.Marshal(gotData)
|
|
t.Log(string(str), err)
|
|
t.Log(string(str), err)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func TestXph_PostControlBallValve(t *testing.T) {
|
|
|
|
+ type fields struct {
|
|
|
|
+ baseUrl string
|
|
|
|
+ back map[int][]Entity
|
|
|
|
+ }
|
|
|
|
+ type args struct {
|
|
|
|
+ id int
|
|
|
|
+ index int
|
|
|
|
+ percent int
|
|
|
|
+ token string
|
|
|
|
+ }
|
|
|
|
+ tests := []struct {
|
|
|
|
+ name string
|
|
|
|
+ fields fields
|
|
|
|
+ args args
|
|
|
|
+ want bool
|
|
|
|
+ wantErr bool
|
|
|
|
+ }{
|
|
|
|
+ // TODO: Add test cases.
|
|
|
|
+ {name: "20000906", fields: fields{baseUrl: "http://115.28.187.9:8005", back: nil}, args: args{
|
|
|
|
+ id: 20000906,
|
|
|
|
+ index: 0,
|
|
|
|
+ percent: 100,
|
|
|
|
+ token: "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJGWkYiLCJhdWQiOiJjb25zdW1lciIsImV4cCI6MTc1NDcwMjQwN30.ERiNMOnnIZQ5d6DU9fkV0Q9HAB9yE2M4pOhvbg9SLcUEDpvqFuCKt2j2nZ5BsjpbMYyS-gSBpk0AgYF-QWyF0g",
|
|
|
|
+ }, want: true, wantErr: false},
|
|
|
|
+ }
|
|
|
|
+ for _, tt := range tests {
|
|
|
|
+ t.Run(tt.name, func(t *testing.T) {
|
|
|
|
+ x := &Xph{
|
|
|
|
+ baseUrl: tt.fields.baseUrl,
|
|
|
|
+ back: tt.fields.back,
|
|
|
|
+ }
|
|
|
|
+ got, err := x.PostControlBallValve(tt.args.id, tt.args.index, tt.args.percent, tt.args.token)
|
|
|
|
+ if (err != nil) != tt.wantErr {
|
|
|
|
+ t.Errorf("PostControlBallValve() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if got != tt.want {
|
|
|
|
+ t.Errorf("PostControlBallValve() got = %v, want %v", got, tt.want)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+}
|