예제 #1
0
// test scribble cache updateRecord
func TestScribbleUpdateRecord(t *testing.T) {
	scribbleReset()
	err := cache.UpdateRecord("nanobox.io", &nanopack)
	err2 := cache.UpdateRecord("nanopack.io", &nanopack)
	if err != nil || err2 != nil {
		t.Errorf("Failed to update record in scribble cacher - %v%v", err, err2)
	}
}
예제 #2
0
파일: shaman.go 프로젝트: nanopack/shaman
// UpdateRecord updates a record to a resource(domain)
func UpdateRecord(domain string, resource *sham.Resource) error {
	resource.Validate()
	sham.SanitizeDomain(&domain)

	// in case of some update to domain name...
	if domain != resource.Domain {
		// delete old domain
		err := DeleteRecord(domain)
		if err != nil {
			return fmt.Errorf("Failed to clean up old domain - %v", err)
		}
	}

	// store in cache
	config.Log.Trace("Updating record in persistent cache...")
	err := cache.UpdateRecord(domain, resource)
	if err != nil {
		return err
	}

	// set new resource to domain
	// todo: atomic
	Answers[resource.Domain] = *resource

	return nil
}
예제 #3
0
// test nil cache updateRecord
func TestNoneUpdateRecord(t *testing.T) {
	noneReset()
	err := cache.UpdateRecord("nanopack.io", &shaman.Resource{})
	if err != nil {
		t.Errorf("Failed to update record in none cacher - %v", err)
	}
}