github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/shared/document_temporaires_test.go (about) 1 package shared 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "github.com/benoitkugler/goACVE/logs" 9 rd "github.com/benoitkugler/goACVE/server/core/rawdata" 10 ) 11 12 func TestPerime(t *testing.T) { 13 ti := time.Date(2020, 1, 10, 0, 0, 0, 0, time.UTC) 14 ti2 := time.Date(2020, 7, 10, 0, 0, 0, 0, time.UTC) 15 validJour := 40 16 shouldTrue := isDocumentPerime(rd.Document{DateHeureModif: rd.Time(ti)}, rd.Contrainte{JoursValide: validJour}, time.Now()) 17 shouldFalse := isDocumentPerime(rd.Document{DateHeureModif: rd.Time(ti2)}, rd.Contrainte{JoursValide: validJour}, time.Now()) 18 if !shouldTrue { 19 t.Error("expected document perime") 20 } 21 if shouldFalse { 22 t.Error("expected document valide") 23 } 24 } 25 26 func TestCleanup(t *testing.T) { 27 db, err := rd.ConnectDB(logs.DBDev) 28 if err != nil { 29 t.Fatal(err) 30 } 31 status, err := cleanupTmpDocuments(db) 32 if err != nil { 33 t.Fatal(err) 34 } 35 fmt.Println(status) 36 }