草庐IT

DeviceRepo

全部标签

unit-testing - Golang 模拟函数被调用两次

我正在编写用于测试main.go的单元测试,并在函数内部调用Get函数(DeviceRepo.Get())两次,然后我想模拟返回不同的Get函数,但我可以在第一次模拟时模拟它调用了,所以我不知道如何在第二次模拟Get函数?main.go:typeDeviceInterfaceinterface{}typeDeviceStructstruct{}varDeviceReporepositories.DeviceRepoInterface=&repositories.DeviceRepoStruct{}func(d*DeviceStruct)CheckDevice(familynamestr

unit-testing - Golang 模拟函数被调用两次

我正在编写用于测试main.go的单元测试,并在函数内部调用Get函数(DeviceRepo.Get())两次,然后我想模拟返回不同的Get函数,但我可以在第一次模拟时模拟它调用了,所以我不知道如何在第二次模拟Get函数?main.go:typeDeviceInterfaceinterface{}typeDeviceStructstruct{}varDeviceReporepositories.DeviceRepoInterface=&repositories.DeviceRepoStruct{}func(d*DeviceStruct)CheckDevice(familynamestr