65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package handlers
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/storage"
|
|
)
|
|
|
|
type mockRepo struct {
|
|
storage.Repository
|
|
baleTypes []storage.BaleType
|
|
bales []storage.Bale
|
|
}
|
|
|
|
func (r *mockRepo) GetBaleTypes(ctx context.Context) ([]storage.BaleType, error) {
|
|
return r.baleTypes, nil
|
|
}
|
|
|
|
func (r *mockRepo) GetBales(ctx context.Context) ([]storage.Bale, error) {
|
|
return r.bales, nil
|
|
}
|
|
|
|
func TestBaleTypeHandlers_HasRoutes(t *testing.T) {
|
|
h := &BaleTypeHandlers{}
|
|
if h == nil {
|
|
t.Error("BaleTypeHandler is nil")
|
|
}
|
|
}
|
|
|
|
func TestBaleHandlers_HasRoutes(t *testing.T) {
|
|
h := &BaleHandlers{}
|
|
if h == nil {
|
|
t.Error("BaleHandler is nil")
|
|
}
|
|
}
|
|
|
|
func TestTypesFieldMappings(t *testing.T) {
|
|
bt := storage.BaleType{
|
|
ID: 1,
|
|
Type: "test",
|
|
Weight: 10.0,
|
|
}
|
|
if bt.Type != "test" {
|
|
t.Errorf("expected type 'test', got %s", bt.Type)
|
|
}
|
|
if bt.Weight != 10.0 {
|
|
t.Errorf("expected weight 10.0, got %f", bt.Weight)
|
|
}
|
|
}
|
|
|
|
func TestBaleFieldMappings(t *testing.T) {
|
|
b := storage.Bale{
|
|
ID: 1,
|
|
TypeID: 1,
|
|
Type: "standard",
|
|
}
|
|
if b.TypeID != 1 {
|
|
t.Errorf("expected typeId 1, got %d", b.TypeID)
|
|
}
|
|
if b.Type != "standard" {
|
|
t.Errorf("expected type 'standard', got %s", b.Type)
|
|
}
|
|
}
|