2023-07-26 16:52:07 +08:00
|
|
|
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
package structs
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
2025-01-09 02:21:47 +01:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2023-07-26 16:52:07 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestNoBetterThan(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
2025-05-28 18:36:21 +03:00
|
|
|
s1, s2 CommitStatusState
|
|
|
|
|
higher bool
|
2023-07-26 16:52:07 +08:00
|
|
|
}{
|
2025-05-28 18:36:21 +03:00
|
|
|
{CommitStatusError, CommitStatusFailure, true},
|
|
|
|
|
{CommitStatusFailure, CommitStatusWarning, true},
|
|
|
|
|
{CommitStatusWarning, CommitStatusPending, true},
|
|
|
|
|
{CommitStatusPending, CommitStatusSuccess, true},
|
|
|
|
|
{CommitStatusSuccess, CommitStatusSkipped, true},
|
|
|
|
|
|
|
|
|
|
{CommitStatusError, "unknown-xxx", false},
|
|
|
|
|
{"unknown-xxx", CommitStatusFailure, true},
|
2023-07-26 16:52:07 +08:00
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
2025-05-28 18:36:21 +03:00
|
|
|
assert.Equal(t, tt.higher, tt.s1.HasHigherPriorityThan(tt.s2), "s1=%s, s2=%s, expected=%v", tt.s1, tt.s2, tt.higher)
|
2023-07-26 16:52:07 +08:00
|
|
|
}
|
2025-05-28 18:36:21 +03:00
|
|
|
assert.False(t, CommitStatusError.HasHigherPriorityThan(CommitStatusError))
|
2023-07-26 16:52:07 +08:00
|
|
|
}
|