You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-23 21:44:44 +02:00
Cleanup state reporting (#3850)
This commit is contained in:
@@ -41,7 +41,7 @@ func TestUpdateStepStatusNotExited(t *testing.T) {
|
||||
step := &model.Step{}
|
||||
|
||||
// advertised step status
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Started: int64(42),
|
||||
Exited: false,
|
||||
// Dummy data
|
||||
@@ -54,7 +54,7 @@ func TestUpdateStepStatusNotExited(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, model.StatusRunning, step.State)
|
||||
assert.EqualValues(t, 42, step.Started)
|
||||
assert.EqualValues(t, 0, step.Stopped)
|
||||
assert.EqualValues(t, 0, step.Finished)
|
||||
assert.EqualValues(t, 0, step.ExitCode)
|
||||
assert.EqualValues(t, "", step.Error)
|
||||
}
|
||||
@@ -63,10 +63,10 @@ func TestUpdateStepStatusNotExitedButStopped(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// step in db before update
|
||||
step := &model.Step{Started: 42, Stopped: 64, State: model.StatusKilled}
|
||||
step := &model.Step{Started: 42, Finished: 64, State: model.StatusKilled}
|
||||
|
||||
// advertised step status
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Exited: false,
|
||||
// Dummy data
|
||||
Finished: int64(1),
|
||||
@@ -78,7 +78,7 @@ func TestUpdateStepStatusNotExitedButStopped(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, model.StatusKilled, step.State)
|
||||
assert.EqualValues(t, 42, step.Started)
|
||||
assert.EqualValues(t, 64, step.Stopped)
|
||||
assert.EqualValues(t, 64, step.Finished)
|
||||
assert.EqualValues(t, 0, step.ExitCode)
|
||||
assert.EqualValues(t, "", step.Error)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func TestUpdateStepStatusExited(t *testing.T) {
|
||||
step := &model.Step{Started: 42}
|
||||
|
||||
// advertised step status
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Started: int64(42),
|
||||
Exited: true,
|
||||
Finished: int64(34),
|
||||
@@ -102,7 +102,7 @@ func TestUpdateStepStatusExited(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, model.StatusKilled, step.State)
|
||||
assert.EqualValues(t, 42, step.Started)
|
||||
assert.EqualValues(t, 34, step.Stopped)
|
||||
assert.EqualValues(t, 34, step.Finished)
|
||||
assert.EqualValues(t, pipeline.ExitCodeKilled, step.ExitCode)
|
||||
assert.EqualValues(t, "an error", step.Error)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func TestUpdateStepStatusExitedButNot137(t *testing.T) {
|
||||
step := &model.Step{Started: 42}
|
||||
|
||||
// advertised step status
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Started: int64(42),
|
||||
Exited: true,
|
||||
Finished: int64(34),
|
||||
@@ -125,7 +125,7 @@ func TestUpdateStepStatusExitedButNot137(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, model.StatusFailure, step.State)
|
||||
assert.EqualValues(t, 42, step.Started)
|
||||
assert.EqualValues(t, 34, step.Stopped)
|
||||
assert.EqualValues(t, 34, step.Finished)
|
||||
assert.EqualValues(t, 0, step.ExitCode)
|
||||
assert.EqualValues(t, "an error", step.Error)
|
||||
}
|
||||
@@ -134,7 +134,7 @@ func TestUpdateStepStatusExitedWithCode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// advertised step status
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Started: int64(42),
|
||||
Exited: true,
|
||||
Finished: int64(34),
|
||||
@@ -149,10 +149,10 @@ func TestUpdateStepStatusExitedWithCode(t *testing.T) {
|
||||
assert.Equal(t, 1, step.ExitCode)
|
||||
}
|
||||
|
||||
func TestUpdateStepPToStatusStarted(t *testing.T) {
|
||||
func TestUpdateStepToStatusStarted(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
state := rpc.State{Started: int64(42)}
|
||||
state := rpc.StepState{Started: int64(42)}
|
||||
step, _ := UpdateStepToStatusStarted(mockStoreStep(t), model.Step{}, state)
|
||||
|
||||
assert.Equal(t, model.StatusRunning, step.State)
|
||||
@@ -165,7 +165,7 @@ func TestUpdateStepToStatusSkipped(t *testing.T) {
|
||||
step, _ := UpdateStepToStatusSkipped(mockStoreStep(t), model.Step{}, int64(1))
|
||||
|
||||
assert.Equal(t, model.StatusSkipped, step.State)
|
||||
assert.EqualValues(t, 0, step.Stopped)
|
||||
assert.EqualValues(t, 0, step.Finished)
|
||||
}
|
||||
|
||||
func TestUpdateStepToStatusSkippedButStarted(t *testing.T) {
|
||||
@@ -178,20 +178,20 @@ func TestUpdateStepToStatusSkippedButStarted(t *testing.T) {
|
||||
step, _ = UpdateStepToStatusSkipped(mockStoreStep(t), *step, int64(1))
|
||||
|
||||
assert.Equal(t, model.StatusSuccess, step.State)
|
||||
assert.EqualValues(t, 1, step.Stopped)
|
||||
assert.EqualValues(t, 1, step.Finished)
|
||||
}
|
||||
|
||||
func TestUpdateStepStatusToDoneSkipped(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Finished: int64(34),
|
||||
}
|
||||
|
||||
step, _ := UpdateStepStatusToDone(mockStoreStep(t), model.Step{}, state)
|
||||
|
||||
assert.Equal(t, model.StatusSkipped, step.State)
|
||||
assert.EqualValues(t, 34, step.Stopped)
|
||||
assert.EqualValues(t, 34, step.Finished)
|
||||
assert.Empty(t, step.Error)
|
||||
assert.Equal(t, 0, step.ExitCode)
|
||||
}
|
||||
@@ -199,7 +199,7 @@ func TestUpdateStepStatusToDoneSkipped(t *testing.T) {
|
||||
func TestUpdateStepStatusToDoneSuccess(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
state := rpc.State{
|
||||
state := rpc.StepState{
|
||||
Started: int64(42),
|
||||
Finished: int64(34),
|
||||
}
|
||||
@@ -207,7 +207,7 @@ func TestUpdateStepStatusToDoneSuccess(t *testing.T) {
|
||||
step, _ := UpdateStepStatusToDone(mockStoreStep(t), model.Step{}, state)
|
||||
|
||||
assert.Equal(t, model.StatusSuccess, step.State)
|
||||
assert.EqualValues(t, 34, step.Stopped)
|
||||
assert.EqualValues(t, 34, step.Finished)
|
||||
assert.Empty(t, step.Error)
|
||||
assert.Equal(t, 0, step.ExitCode)
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func TestUpdateStepStatusToDoneSuccess(t *testing.T) {
|
||||
func TestUpdateStepStatusToDoneFailureWithError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
state := rpc.State{Error: "an error"}
|
||||
state := rpc.StepState{Error: "an error"}
|
||||
|
||||
step, _ := UpdateStepStatusToDone(mockStoreStep(t), model.Step{}, state)
|
||||
|
||||
@@ -225,7 +225,7 @@ func TestUpdateStepStatusToDoneFailureWithError(t *testing.T) {
|
||||
func TestUpdateStepStatusToDoneFailureWithExitCode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
state := rpc.State{ExitCode: 43}
|
||||
state := rpc.StepState{ExitCode: 43}
|
||||
|
||||
step, _ := UpdateStepStatusToDone(mockStoreStep(t), model.Step{}, state)
|
||||
|
||||
@@ -240,8 +240,8 @@ func TestUpdateStepToStatusKilledStarted(t *testing.T) {
|
||||
step, _ := UpdateStepToStatusKilled(mockStoreStep(t), model.Step{})
|
||||
|
||||
assert.Equal(t, model.StatusKilled, step.State)
|
||||
assert.LessOrEqual(t, now, step.Stopped)
|
||||
assert.Equal(t, step.Stopped, step.Started)
|
||||
assert.LessOrEqual(t, now, step.Finished)
|
||||
assert.Equal(t, step.Finished, step.Started)
|
||||
assert.Equal(t, 137, step.ExitCode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user