2024-08-31 15:23:21 +02:00
|
|
|
package updater
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type updaterTestCase struct {
|
2025-08-23 22:14:34 +02:00
|
|
|
name string
|
|
|
|
|
content string
|
|
|
|
|
info ReleaseInfo
|
|
|
|
|
want string
|
|
|
|
|
wantErr assert.ErrorAssertionFunc
|
2024-08-31 15:23:21 +02:00
|
|
|
}
|
|
|
|
|
|
2025-08-23 22:14:34 +02:00
|
|
|
func runUpdaterTest(t *testing.T, u Updater, tt updaterTestCase) {
|
2024-08-31 15:23:21 +02:00
|
|
|
t.Helper()
|
|
|
|
|
|
2025-08-23 22:14:34 +02:00
|
|
|
got, err := u.Update(tt.info)(tt.content)
|
|
|
|
|
if !tt.wantErr(t, err, fmt.Sprintf("Updater(%v, %v)", tt.content, tt.info)) {
|
2024-08-31 15:23:21 +02:00
|
|
|
return
|
|
|
|
|
}
|
2025-08-23 22:14:34 +02:00
|
|
|
assert.Equalf(t, tt.want, got, "Updater(%v, %v)", tt.content, tt.info)
|
2024-08-31 15:23:21 +02:00
|
|
|
}
|