genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
hs_monolith/runtime/good_fouled_test.go

53 lines
989 B
Go

// Package with supporting functionality to run the microservice
package runtime
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/genofire/hs_master-kss-monolith/lib/database"
"github.com/genofire/hs_master-kss-monolith/models"
)
// Function to test the unlocking of goods
func TestFouledDelete(t *testing.T) {
assert := assert.New(t)
database.Open(database.Config{
Type: "sqlite3",
Logging: true,
Connection: ":memory:",
})
now := time.Now().Add(-time.Hour * 48)
good := models.Good{
FouledAt: &now,
}
database.Write.Create(&good)
good = models.Good{
FouledAt: &now,
}
database.Write.Create(&good)
count := GoodFouled()
assert.Equal(2, count, "not fouled")
good = models.Good{
FouledAt: &now,
}
database.Write.Create(&good)
now = time.Now().Add(time.Hour * 48)
good = models.Good{
FouledAt: &now,
}
database.Write.Create(&good)
count = GoodFouled()
assert.Equal(1, count, "fouled")
database.Close()
}