github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/directeurs/inscrits_test.go (about) 1 package directeurs 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 rd "github.com/benoitkugler/goACVE/server/core/rawdata" 9 ) 10 11 func TestInscrits(t *testing.T) { 12 req := newDummyRequest(t, noForce) 13 rc, err := ct.setupRequest(req, loadInscrits) 14 if err != nil { 15 t.Fatal(err) 16 } 17 18 ti := time.Now() 19 l, err := rc.getInscrits("localhost:1323") 20 if err != nil { 21 t.Fatal(err) 22 } 23 fmt.Println("resolving inscrits :", time.Since(ti)) 24 fmt.Println("nb inscrits :", len(l)) 25 } 26 27 func TestLienFS(t *testing.T) { 28 fac := rd.Facture{Key: "1234"} 29 l := getLienFicheSanitaire("localhost:1323", fac, "Benoit KUGLER") 30 if l != "http://localhost:1323/espace_perso/1234/fiches_sanitaires?directeur=ok&nom_prenom=Benoit+KUGLER" { 31 t.Errorf("unexpected lien for fiche sanitaire : %s", l) 32 } 33 } 34 35 func TestFicheSanitaire(t *testing.T) { 36 req := newDummyRequest(t, forceComplet) 37 rc, err := ct.setupRequestComplet(req, loadInscrits) 38 if err != nil { 39 t.Fatal(err) 40 } 41 42 parts := rc.Camp().GetInscrits(nil) 43 if len(parts) == 0 { 44 t.Fatal("aucun inscrit.") 45 } 46 b, n, err := rc.downloadFicheSanitaire(parts[0].Id) 47 if err != nil { 48 t.Fatal(err) 49 } 50 fmt.Println(len(b.Bytes())) 51 fmt.Println(n) 52 53 b, err = rc.downloadFichesSanitaires(false) 54 if err != nil { 55 t.Fatal(err) 56 } 57 fmt.Println(len(b.Bytes())) 58 59 b, err = rc.downloadFichesSanitairesOneDocument(false, true) 60 if err != nil { 61 t.Fatal(err) 62 } 63 fmt.Println(len(b.Bytes())) 64 } 65 66 func TestModifieInscrit(t *testing.T) { 67 req := newDummyRequest(t, noForce) 68 rc, err := ct.setupRequest(req, loadInscrits) 69 if err != nil { 70 t.Fatal(err) 71 } 72 inscrits := rc.Camp().GetInscrits(nil) 73 if len(inscrits) == 0 { 74 t.Fatal("aucun inscrit") 75 } 76 if len(rc.Camp().GetGroupes()) == 0 { 77 t.Fatal("aucun groupes") 78 } 79 groupe := rc.Camp().GetGroupes()[0] 80 var modif InscritWritable 81 modif.IdGroupe = rd.NewOptionnalId(groupe.Id) 82 modif.Mail = "bench26@gmail.com" 83 modif.Options.Bus = rd.BAller 84 err = rc.modifieInscrit(modif, inscrits[0].Id) 85 if err != nil { 86 t.Fatal(err) 87 } 88 } 89 90 func TestExportInscrits(t *testing.T) { 91 req := newDummyRequest(t, forceComplet) 92 rc, err := ct.setupRequest(req, loadInscrits) 93 if err != nil { 94 t.Fatal(err) 95 } 96 97 buf, err := rc.exportListeInscrits(optionsExportExcel{}) 98 if err != nil { 99 t.Fatal(err) 100 } 101 fmt.Println("bytes inscrits :", len(buf.Bytes())) 102 } 103 104 func TestExportFinance(t *testing.T) { 105 req := newDummyRequest(t, forceComplet) 106 rc, err := ct.setupRequestComplet(req, loadInscrits) 107 if err != nil { 108 t.Fatal(err) 109 } 110 111 buf, err := rc.exportListeFinances() 112 if err != nil { 113 t.Fatal(err) 114 } 115 fmt.Println("bytes finances :", len(buf.Bytes())) 116 }