chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package renewchange
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNormalizePriceOverrideResultTreatsNoRowsAsMissing(t *testing.T) {
|
||||
got, err := normalizePriceOverrideResult(&FlowPackagePrice{}, sql.ErrNoRows)
|
||||
if err != nil {
|
||||
t.Fatalf("normalizePriceOverrideResult returned error: %v", err)
|
||||
}
|
||||
if got != nil {
|
||||
t.Fatalf("normalizePriceOverrideResult returned %+v, want nil", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePriceOverrideResultReturnsOtherErrors(t *testing.T) {
|
||||
wantErr := errors.New("database unavailable")
|
||||
got, err := normalizePriceOverrideResult(nil, wantErr)
|
||||
if got != nil {
|
||||
t.Fatalf("normalizePriceOverrideResult returned %+v on error", got)
|
||||
}
|
||||
if !errors.Is(err, wantErr) {
|
||||
t.Fatalf("error = %v, want wrapped %v", err, wantErr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePriceOverrideResultKeepsPriceRow(t *testing.T) {
|
||||
want := &FlowPackagePrice{Id: 7, AgentCostProfit: 1.25}
|
||||
got, err := normalizePriceOverrideResult(want, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("normalizePriceOverrideResult returned error: %v", err)
|
||||
}
|
||||
if got != want {
|
||||
t.Fatalf("row pointer = %p, want %p", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user