28 lines
838 B
Go
28 lines
838 B
Go
//go:build integration
|
|
|
|
package inventory
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// A pending assignment goes with its machine (novox/hq issue 325, review of mesh-controller#150 point 7).
|
|
func TestAPendingAssignmentGoesWithItsMachine(t *testing.T) {
|
|
inv := ForTest(t)
|
|
ctx := t.Context()
|
|
if _, err := inv.AddNode(ctx, "leaving"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := inv.RecordPending(ctx, PendingAssignment{Node: "leaving", Module: "sensors", Build: "b-1"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := inv.store.Pool().Exec(ctx, `delete from node where name = 'leaving'`); err != nil {
|
|
t.Fatalf("a machine with a pending assignment could not be removed: %v", err)
|
|
}
|
|
rows, err := inv.Pending(ctx, time.Unix(0, 0))
|
|
if err != nil || len(rows) != 0 {
|
|
t.Fatalf("a pending assignment outlived its machine: %+v %v", rows, err)
|
|
}
|
|
}
|