Exemple #1
0
func TestUpdate(t *testing.T) {
	s, e := site.New(DB)
	if e != nil {
		t.Error(e)
	}
	s.Id = 0
	s1, e := s.Read(1)
	if e != nil {
		t.Error(e)
	}
	//assert.Equal(t, s.Id, int64(1), "s id must be 1")
	assert.Equal(t, s1.Id, int64(1), "s1 id must be 1")
	assert.NotNil(t, s1.DB, "Db must be defined")
	assert.NotNil(t, s1.Object.SelfPointer, "SelfPointer must be defined")
	s1.Host = "google.com"
	t.Log(s1)
	e = s1.Save()
	if e != nil {
		t.Error(e)
	}

	s2, e := s1.Read(1)
	if e != nil {
		t.Error(e)
	}
	t.Log(s2)
}
Exemple #2
0
func TestRead(t *testing.T) {
	s, e := site.New(DB)
	if e != nil {
		t.Error(e)
	}
	s1, e := s.Read(1)
	if e != nil {
		t.Error(e)
	}
	assert.Equal(t, s1.Id, int64(1), "Id must be 1")
}
Exemple #3
0
func TestInsert(t *testing.T) {
	s, e := site.New(DB)
	if e != nil {
		t.Error(e)
	}
	s.Ipv4 = "1.1.1.1"
	e = s.Save()
	if e != nil {
		t.Error(e)
	}
	if s.Id == 0 {
		t.Error("auto incremet not working")
	}
}