package tool import "testing" type fakeAccessor struct{ s RunState } func (f fakeAccessor) RunState() RunState { return f.s } func TestInvocationRunState_NilSafe(t *testing.T) { var inv Invocation if inv.RunState != nil { t.Fatal("RunState should default nil") } inv.RunState = fakeAccessor{s: RunState{Iteration: 3, MaxIterations: 10}} if got := inv.RunState.RunState(); got.Iteration != 3 || got.MaxIterations != 10 { t.Fatalf("unexpected RunState: %+v", got) } }