package system

import (
	"context"
	"testing"
)

func TestFindUserRejectsCorruptOriginSetting(t *testing.T) {
	data := newTransactionTestData(t)
	if err := data.gormDB.WithContext(context.Background()).Create(&userPO{Username: "broken-setting", Password: "hash", AuthorityID: 888, OriginSetting: "{"}).Error; err != nil {
		t.Fatal(err)
	}
	if _, err := (&userRepo{data: data}).FindUserByID(context.Background(), 1); err == nil {
		t.Fatal("FindUserByID accepted corrupt OriginSetting")
	}
}
