(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func TestEventOccupy(t *testing.T) { |
| 28 | rtMap := initRuntimeList(1) |
| 29 | list := rtMap.RuntimeList() |
| 30 | rt := list[0] |
| 31 | rt.SetState(RuntimeStateClosed) |
| 32 | err := rt.CAS(OpOccupy, &OccupyInput{CommitID: "xxx", WithStreamMode: false}) |
| 33 | expectedErr := &RuntimeStateUnmatched{RuntimeID: rt.RuntimeID, CurrentState: RuntimeStateClosed, ExpectedState: []string{RuntimeStateCold}} |
| 34 | if err.Error() != expectedErr.Error() { |
| 35 | t.Errorf("occupy runtime expected %s, but got %s", expectedErr, err) |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | rt.SetState(RuntimeStateCold) |
| 40 | rt.Invalidate() |
| 41 | err1 := rt.CAS(OpOccupy, &OccupyInput{ |
| 42 | CommitID: "xxx", |
| 43 | WithStreamMode: false, |
| 44 | MemorySize: uint64(128 * bytefmt.Megabyte), |
| 45 | }) |
| 46 | expectedErr1 := &RuntimeMatchError{ |
| 47 | Reason: "runner is not available", |
| 48 | } |
| 49 | if err1.Error() != expectedErr1.Error() { |
| 50 | t.Errorf("occupy runtime expected %s, but got %s", expectedErr, err) |
| 51 | return |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestEventMerged(t *testing.T) { |
| 56 | rtMap := initRuntimeList(1) |
nothing calls this directly
no test coverage detected