This commit is contained in:
Martino Ferrari
2026-06-24 01:39:15 +02:00
parent 11120bedca
commit c0f7e662be
76 changed files with 4368 additions and 210 deletions
+47
View File
@@ -0,0 +1,47 @@
package ca_test
import (
"context"
"testing"
"time"
)
// TestGetCtrlNotFound covers the resolve-failure branch of GetCtrl.
func TestGetCtrlNotFound(t *testing.T) {
srv := newTestServer(t)
cli := newTestClient(t, srv)
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
if _, err := cli.GetCtrl(ctx, "NO:SUCH:PV"); err == nil {
t.Fatal("GetCtrl on missing PV: want error")
}
}
// TestPutNotFound covers the resolve-failure branch of Put.
func TestPutNotFound(t *testing.T) {
srv := newTestServer(t)
cli := newTestClient(t, srv)
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
if err := cli.Put(ctx, "NO:SUCH:PV", 1.0); err == nil {
t.Fatal("Put on missing PV: want error")
}
}
// TestPutUncoercibleValue covers the encodePut-failure branch of Put: the PV
// resolves but the supplied value cannot be coerced to the native type.
func TestPutUncoercibleValue(t *testing.T) {
srv := newTestServer(t)
cli := newTestClient(t, srv)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := cli.Put(ctx, "TEST:DOUBLE", []int{1, 2, 3}); err == nil {
t.Fatal("Put with uncoercible value: want error")
}
}