github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/client/controllers/main_test.go (about)

     1  package controllers
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/benoitkugler/goACVE/server/core/rawdata"
     8  )
     9  
    10  // ce test nécessite le serveur sur localhost
    11  
    12  func TestPartielDB(t *testing.T) {
    13  	ct := newController(t)
    14  
    15  	// mutate the base on purpose
    16  	p := ct.Base.Personnes[ct.Base.Personnes.Ids()[0]]
    17  	p.Nom = "ds65d4q8sds45c"
    18  	ct.Base.Personnes[p.Id] = p
    19  
    20  	ct.Base.Personnes[-1] = rawdata.Personne{}
    21  	ct.Base.Aides[-1] = rawdata.Aide{}
    22  
    23  	ct.ShowError = func(err error) { fmt.Println(err) }
    24  	ct.ShowStandard = func(msg string, wait bool) { fmt.Println(msg) }
    25  	ct.LoadPartialBaseFromServer(func(i uint8) { fmt.Println(i) })
    26  
    27  	if _, has := ct.Base.Personnes[-1]; has {
    28  		t.Error("should be deleted")
    29  	}
    30  	if _, has := ct.Base.Aides[-1]; has {
    31  		t.Error("should be deleted")
    32  	}
    33  	if ct.Base.Personnes[p.Id].Nom == p.Nom {
    34  		t.Error("should have been corrected")
    35  	}
    36  }