我有一个Entity
定义如下的数据类:
data Entity = Entity { id :: String, name :: String }
和一个返回的函数IO Entity
:
newPersistentEntity :: String -> IO Entity
我想为此编写一个HSpec测试:
spec :: Spec
spec = describe "newPersistentEntity function" $
it "returns a new Entity with a generated id and the specified name" $
newPersistentEntity "myName" `shouldReturn` Entity {id = <any string>, name = "myName"}
问题是 id 是数据库生成的 UUID。我想断言这id
是一个使测试通过的字符串。
我怎样才能做到这一点?