• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang config.Reset函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中config.Reset函数的典型用法代码示例。如果您正苦于以下问题:Golang Reset函数的具体用法?Golang Reset怎么用?Golang Reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Reset函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestCreateDeleteDomain

func TestCreateDeleteDomain(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Properties.Size = utils.Int64p(10000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))

	if err := m.CreateDomain(info); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 4 {
		t.Error("Expected 1 sketches, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "card" {
		t.Error("Expected [[marvel card]], got", sketches)
	}

	// Create a second Sketch
	info2 := datamodel.NewEmptyInfo()
	info2.Properties.MaxUniqueItems = utils.Int64p(10000)
	info2.Name = utils.Stringp("dc")
	if err := m.CreateDomain(info2); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 8 {
		t.Error("Expected 8 sketches, got", len(sketches))
	} else if sketches[0][0] != "dc" || sketches[0][1] != "card" {
		t.Error("Expected [[dc card]], got", sketches[0][0], sketches[0][1])
	} else if sketches[1][0] != "dc" || sketches[1][1] != "freq" {
		t.Error("Expected [[dc freq]], got", sketches[1][0], sketches[1][1])
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:35,代码来源:manager_test.go


示例2: TestDeleteSketch

func TestDeleteSketch(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_CARD
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.CreateSketch(info); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 1 {
		t.Error("Expected 1 sketches, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "card" {
		t.Error("Expected [[marvel card]], got", sketches)
	}
	if err := m.DeleteSketch(info.ID()); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 0 {
		t.Error("Expected 0 sketches, got", len(sketches))
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:27,代码来源:manager_test.go


示例3: TestCreateAddDeleteAddSketch

func TestCreateAddDeleteAddSketch(t *testing.T) {
	config.Reset()
	testutils.SetupTests()
	defer testutils.TearDownTests()

	client, conn := setupClient()
	defer tearDownClient(conn)

	typ := pb.SketchType_CARD
	name := "yoyo"

	in := &pb.Sketch{
		Name: proto.String(name),
		Type: &typ,
		Properties: &pb.SketchProperties{
			MaxUniqueItems: proto.Int64(1337), // FIXME: Allow default as -1
			Size:           proto.Int64(7),
		},
	}

	addReq := &pb.AddRequest{
		Sketch: in,
		Values: []string{"a", "b", "c", "d", "a", "b"},
	}

	if _, err := client.CreateSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	}

	typ = pb.SketchType_RANK
	if _, err := client.CreateSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	}

	if _, err := client.Add(context.Background(), addReq); err != nil {
		t.Error("Did not expect error, got", err)
	}

	if res, err := client.ListAll(context.Background(), &pb.Empty{}); err != nil {
		t.Error("Did not expect error, got", err)
	} else if len(res.GetSketches()) != 2 {
		t.Error("Expected len(res) == 2, got ", len(res.GetSketches()))
	}

	if _, err := client.DeleteSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	}

	if _, err := client.Add(context.Background(), addReq); err == nil {
		t.Error("Expected error, got", err)
	}

	if res, err := client.ListAll(context.Background(), &pb.Empty{}); err != nil {
		t.Error("Did not expect error, got", err)
	} else if len(res.GetSketches()) != 1 {
		t.Error("Expected len(res) == 1, got ", len(res.GetSketches()))
	}

}
开发者ID:seiflotfy,项目名称:skizze,代码行数:59,代码来源:sketch_test.go


示例4: TestNoSketches

func TestNoSketches(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()
	m := NewManager()
	if sketches := m.GetSketches(); len(sketches) != 0 {
		t.Error("Expected 0 sketches, got", len(sketches))
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:9,代码来源:manager_test.go


示例5: TestAddGetFreqSketch

func TestAddGetFreqSketch(t *testing.T) {
	config.Reset()
	testutils.SetupTests()
	defer testutils.TearDownTests()

	client, conn := setupClient()
	defer tearDownClient(conn)

	typ := pb.SketchType_FREQ
	name := "yoyo"

	in := &pb.Sketch{
		Name: proto.String(name),
		Type: &typ,
		Properties: &pb.SketchProperties{
			MaxUniqueItems: proto.Int64(1337), // FIXME: Allow default as -1
			Size:           proto.Int64(7),
		},
	}

	if res, err := client.CreateSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	} else if res.GetName() != in.GetName() {
		t.Errorf("Expected name == %s, got %s", in.GetName(), res.GetName())
	} else if res.GetType() != in.GetType() {
		t.Errorf("Expected name == %q, got %q", in.GetType(), res.GetType())
	}

	addReq := &pb.AddRequest{
		Sketch: in,
		Values: []string{"a", "a", "b", "c", "d"},
	}

	expected := map[string]int64{
		"a": 2, "b": 1, "c": 1, "d": 1, "e": 0,
	}

	if _, err := client.Add(context.Background(), addReq); err != nil {
		t.Error("Did not expect error, got", err)
	}

	getReq := &pb.GetRequest{
		Sketches: []*pb.Sketch{in},
		Values:   []string{"a", "b", "c", "d", "e", "b"},
	}

	if res, err := client.GetFrequency(context.Background(), getReq); err != nil {
		t.Error("Did not expect error, got", err)
	} else {
		for _, v := range res.GetResults()[0].GetFrequencies() {
			if expected[v.GetValue()] != v.GetCount() {
				t.Errorf("Expected %s == %d, got", v.GetValue(), v.GetCount())
			}
		}
	}
}
开发者ID:seiflotfy,项目名称:skizze,代码行数:56,代码来源:sketch_test.go


示例6: TestAddGetCardSketch

func TestAddGetCardSketch(t *testing.T) {
	config.Reset()
	testutils.SetupTests()
	defer testutils.TearDownTests()

	client, conn := setupClient()
	defer tearDownClient(conn)

	typ := pb.SketchType_CARD
	name := "yoyo"

	in := &pb.Sketch{
		Name: proto.String(name),
		Type: &typ,
		Properties: &pb.SketchProperties{
			MaxUniqueItems: proto.Int64(1337), // FIXME: Allow default as -1
			Size:           proto.Int64(7),
		},
	}

	if res, err := client.CreateSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	} else if res.GetName() != in.GetName() {
		t.Errorf("Expected name == %s, got %s", in.GetName(), res.GetName())
	} else if res.GetType() != in.GetType() {
		t.Errorf("Expected name == %q, got %q", in.GetType(), res.GetType())
	}

	addReq := &pb.AddRequest{
		Sketch: in,
		Values: []string{"a", "b", "c", "d", "a", "b"},
	}

	if _, err := client.Add(context.Background(), addReq); err != nil {
		t.Error("Did not expect error, got", err)
	}

	getReq := &pb.GetRequest{
		Sketches: []*pb.Sketch{in},
		Values:   []string{},
	}

	if res, err := client.GetCardinality(context.Background(), getReq); err != nil {
		t.Error("Did not expect error, got", err)

	} else if res.GetResults()[0].GetCardinality() != 4 {
		t.Error("Expected cardinality 4, got", res.GetResults()[0].GetCardinality())
	}
}
开发者ID:seiflotfy,项目名称:skizze,代码行数:49,代码来源:sketch_test.go


示例7: TestCreateInvalidSketch

func TestCreateInvalidSketch(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Name = utils.Stringp("avengers")
	info.Type = nil
	if err := m.CreateSketch(info); err == nil {
		t.Error("Expected error invalid sketch, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 0 {
		t.Error("Expected 0 sketches, got", len(sketches))
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:17,代码来源:manager_test.go


示例8: TestDeleteNonExistingSketch

func TestDeleteNonExistingSketch(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_CARD
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.DeleteSketch(info.ID()); err == nil {
		t.Error("Expected errors deleting non-existing sketch, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 0 {
		t.Error("Expected 0 sketches, got", len(sketches))
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:19,代码来源:manager_test.go


示例9: TestMembershipSaveLoad

func TestMembershipSaveLoad(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_MEMB
	info.Properties.MaxUniqueItems = utils.Int64p(1000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.CreateSketch(info); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if sketches := m.GetSketches(); len(sketches) != 1 {
		t.Error("Expected 1 sketch, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "memb" {
		t.Error("Expected [[marvel memb]], got", sketches)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "hulk", "thor", "iron man", "hawk-eye"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "black widow", "black widow", "black widow", "black widow"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if res, err := m.GetFromSketch(info.ID(), []string{"hulk", "captian america", "black widow"}); err != nil {
		t.Error("Expected no errors, got", err)
	} else if len(res.(*pb.MembershipResult).GetMemberships()) != 3 {
		t.Error("Expected len(res) = 3, got", len(res.(*pb.MembershipResult).GetMemberships()))
	} else if v := res.(*pb.MembershipResult).GetMemberships()[0].GetIsMember(); !v {
		t.Error("Expected 'hulk' == true , got", v)
	} else if v := res.(*pb.MembershipResult).GetMemberships()[1].GetIsMember(); v {
		t.Error("Expected 'captian america' == false , got", v)
	} else if v := res.(*pb.MembershipResult).GetMemberships()[2].GetIsMember(); !v {
		t.Error("Expected 'captian america' == true , got", v)
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:42,代码来源:manager_test.go


示例10: TestCreateAndSaveSketch

func TestCreateAndSaveSketch(t *testing.T) {
	config.Reset()
	testutils.SetupTests()
	defer testutils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_CARD
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.CreateSketch(info); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 1 {
		t.Error("Expected 1 sketches, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "card" {
		t.Error("Expected [[marvel card]], got", sketches)
	}

	// Create a second Sketch
	info2 := datamodel.NewEmptyInfo()
	typ2 := pb.SketchType_RANK
	info2.Properties.MaxUniqueItems = utils.Int64p(10000)
	info2.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info2.Type = &typ2

	if err := m.CreateSketch(info2); err != nil {
		t.Error("Expected no errors, got", err)
	}
	if sketches := m.GetSketches(); len(sketches) != 2 {
		t.Error("Expected 2 sketches, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "card" {
		t.Error("Expected [[marvel card]], got", sketches[0][0], sketches[0][1])
	} else if sketches[1][0] != "marvel" || sketches[1][1] != "rank" {
		t.Error("Expected [[marvel rank]], got", sketches[1][0], sketches[1][1])
	}

}
开发者ID:seiflotfy,项目名称:skizze,代码行数:40,代码来源:manager_test.go


示例11: TestRankSaveLoad

func TestRankSaveLoad(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_RANK
	info.Properties.Size = utils.Int64p(10)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.CreateSketch(info); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if sketches := m.GetSketches(); len(sketches) != 1 {
		t.Error("Expected 1 sketch, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "rank" {
		t.Error("Expected [[marvel rank]], got", sketches)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "hulk", "thor", "iron man", "hawk-eye"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "black widow", "black widow", "black widow", "black widow"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if res, err := m.GetFromSketch(info.ID(), nil); err != nil {
		t.Error("Expected no errors, got", err)
	} else if len(res.(*pb.RankingsResult).GetRankings()) != 5 {
		t.Error("Expected len(res) = 5, got", len(res.(*pb.RankingsResult).GetRankings()))
	} else if res.(*pb.RankingsResult).GetRankings()[0].GetValue() != "black widow" {
		t.Error("Expected 'black widow', got", res.(*pb.RankingsResult).GetRankings()[0].GetValue())
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:38,代码来源:manager_test.go


示例12: TestFreqSaveLoad

func TestFreqSaveLoad(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	m := NewManager()
	info := datamodel.NewEmptyInfo()
	typ := pb.SketchType_FREQ
	info.Properties.MaxUniqueItems = utils.Int64p(10000)
	info.Name = utils.Stringp(fmt.Sprintf("marvel"))
	info.Type = &typ

	if err := m.CreateSketch(info); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if sketches := m.GetSketches(); len(sketches) != 1 {
		t.Error("Expected 1 sketch, got", len(sketches))
	} else if sketches[0][0] != "marvel" || sketches[0][1] != "freq" {
		t.Error("Expected [[marvel freq]], got", sketches)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "thor", "iron man", "hawk-eye"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if err := m.AddToSketch(info.ID(), []string{"hulk", "black widow"}); err != nil {
		t.Error("Expected no errors, got", err)
	}

	if res, err := m.GetFromSketch(info.ID(), []string{"hulk", "thor", "iron man", "hawk-eye"}); err != nil {
		t.Error("Expected no errors, got", err)
	} else if res.(*pb.FrequencyResult).GetFrequencies()[0].GetCount() != 2 {
		t.Error("Expected res = 2, got", res.(*pb.FrequencyResult).GetFrequencies()[0].GetCount())
	}
}
开发者ID:njpatel,项目名称:skizze,代码行数:36,代码来源:manager_test.go


示例13: TestCreateSketch

func TestCreateSketch(t *testing.T) {
	config.Reset()
	testutils.SetupTests()
	defer testutils.TearDownTests()

	client, conn := setupClient()
	defer tearDownClient(conn)

	typ := pb.SketchType_CARD
	name := "yoyo"

	in := &pb.Sketch{
		Name: proto.String(name),
		Type: &typ,
	}

	if res, err := client.CreateSketch(context.Background(), in); err != nil {
		t.Error("Did not expect error, got", err)
	} else if res.GetName() != in.GetName() {
		t.Errorf("Expected name == %s, got %s", in.GetName(), res.GetName())
	} else if res.GetType() != in.GetType() {
		t.Errorf("Expected name == %q, got %q", in.GetType(), res.GetType())
	}
}
开发者ID:seiflotfy,项目名称:skizze,代码行数:24,代码来源:sketch_test.go


示例14: TestCreateDeleteSketch

func TestCreateDeleteSketch(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	_ = os.Remove("test.log")

	aof := NewAOF("test.log")

	sketch := createSketch("skz1", pb.SketchType_CARD)
	err := aof.AppendDomOp(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	sketch = createSketch("skz2", pb.SketchType_FREQ)
	err = aof.AppendDomOp(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	// Create new AOF
	aof = NewAOF("test.log")
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	for {
		e, err2 := aof.Read()
		if err2 != nil {
			if err2.Error() != "EOF" {
				t.Error("Expected no error, got", err2)
			}
			break
		}
		sketch := &pb.Sketch{}
		err = proto.Unmarshal(e.args, sketch)
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}

	sketch = createSketch("skz3", pb.SketchType_RANK)
	err = aof.AppendDomOp(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	sketch = createSketch("skz1", pb.SketchType_RANK)
	if err = aof.AppendDomOp(DeleteDom, sketch); err != nil {
		t.Error("Expected no error, got", err)
	}

	addReq := &pb.AddRequest{
		Sketch: sketch,
		Values: []string{"foo", "bar", "hello", "world"},
	}
	if err = aof.AppendAddOp(addReq); err != nil {
		t.Error("Expected no error, got", err)
	}

	aof = NewAOF("test.log")
	for {
		e, err := aof.Read()
		if err != nil {
			if err.Error() != "EOF" {
				t.Error("Expected no error, got", err)
			}
			break
		}
		if e.op == Add {
			req := &pb.AddRequest{}
			err = proto.Unmarshal(e.args, req)
		} else {
			sketch := &pb.Sketch{}
			err = proto.Unmarshal(e.args, sketch)
		}
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}
}
开发者ID:silky,项目名称:skizze,代码行数:82,代码来源:aof_test.go


示例15: TestCreateDeleteDom

func TestCreateDeleteDom(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	_ = os.Remove("test.log")

	aof := NewAOF("test.log")

	dom := createDom("test1")
	err := aof.AppendDomOp(CreateDom, dom)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	dom = createDom("test2")
	err = aof.AppendDomOp(CreateDom, dom)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	// Create new AOF
	aof = NewAOF("test.log")
	for {
		e, err2 := aof.Read()
		if err2 != nil {
			if err2.Error() != "EOF" {
				t.Error("Expected no error, got", err2)
			}
			break
		}
		dom := &pb.Domain{}
		err = proto.Unmarshal(e.args, dom)
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}

	dom = createDom("test3")

	if err = aof.AppendDomOp(CreateDom, dom); err != nil {
		t.Error("Expected no error, got", err)
	}

	dom = new(pb.Domain)
	dom.Name = utils.Stringp("test1")

	if err = aof.AppendDomOp(DeleteDom, dom); err != nil {
		t.Error("Expected no error, got", err)
	}

	aof = NewAOF("test.log")
	for {
		e, err := aof.Read()
		if err != nil {
			if err.Error() != "EOF" {
				t.Error("Expected no error, got", err)
			}
			break
		}
		dom := &pb.Domain{}
		err = proto.Unmarshal(e.args, dom)
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}
}
开发者ID:silky,项目名称:skizze,代码行数:67,代码来源:aof_test.go


示例16: TestCreateDeleteSketch

func TestCreateDeleteSketch(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	path := filepath.Join(config.GetConfig().DataDir, "skizze.aof")
	aof := NewAOF(path)
	aof.Run()

	sketch := createSketch("skz1", pb.SketchType_CARD)
	err := aof.Append(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	sketch = createSketch("skz2", pb.SketchType_FREQ)
	err = aof.Append(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	// Create new AOF
	aof = NewAOF(path)
	for {
		e, err2 := aof.Read()
		if err2 != nil {
			if err2.Error() != "EOF" {
				t.Error("Expected no error, got", err2)
			}
			break
		}
		sketch := &pb.Sketch{}
		err = proto.Unmarshal(e.raw, sketch)
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}
	aof.Run()

	sketch = createSketch("skz3", pb.SketchType_RANK)
	err = aof.Append(CreateDom, sketch)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	sketch = createSketch("skz1", pb.SketchType_RANK)
	if err = aof.Append(DeleteDom, sketch); err != nil {
		t.Error("Expected no error, got", err)
	}

	addReq := &pb.AddRequest{
		Sketch: sketch,
		Values: []string{"foo", "bar", "hello", "world"},
	}
	if err = aof.Append(4, addReq); err != nil {
		t.Error("Expected no error, got", err)
	}

	aof = NewAOF(path)
	for {
		e, err := aof.Read()
		if err != nil {
			if err.Error() != "EOF" {
				t.Error("Expected no error, got", err)
			}
			break
		}
		if e.op == Add {
			req := &pb.AddRequest{}
			err = proto.Unmarshal(e.raw, req)
		} else {
			sketch := &pb.Sketch{}
			err = proto.Unmarshal(e.raw, sketch)
		}
		if err != nil {
			t.Error("Expected no error, got", err)
		}
	}
}
开发者ID:liuzl,项目名称:skizze,代码行数:79,代码来源:aof_test.go


示例17: TestCreateDeleteDom

func TestCreateDeleteDom(t *testing.T) {
	config.Reset()
	utils.SetupTests()
	defer utils.TearDownTests()

	path := filepath.Join(config.GetConfig().DataDir, "skizze.aof")
	aof := NewAOF(path)
	aof.Run()

	dom := createDom("test1")
	err := aof.Append(CreateDom, dom)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	dom = createDom("test2")
	err = aof.Append(CreateDom, dom)
	if err != nil {
		t.Error("Expected no error, got", err)
	}

	// Create new AOF
	aof = NewAOF(path)

	for {
		e, err2 := aof.Read()
		if err2 != nil {
			if err2.Error() != "EOF" {
				t.Error("Expected no error, got", err2)
			}
			break
		}
		dom := &pb.Domain{}
		err = proto.Unmarshal(e.raw, dom)
		if err != nil {
			t.Error("Expected no error, got", err)
			break
		}
	}
	aof.Run()

	dom = createDom("test3")

	if err = aof.Append(CreateDom, dom); err != nil {
		t.Error("Expected no error, got", err)
	}

	dom = new(pb.Domain)
	dom.Name = utils.Stringp("test1")

	if err = aof.Append(DeleteDom, dom); err != nil {
		t.Error("Expected no error, got", err)
	}

	aof = NewAOF(path)
	for {
		e, err := aof.Read()
		if err != nil {
			if err.Error() != "EOF" {
				t.Error("Expected no error, got", err)
			}
			break
		}
		dom := &pb.Domain{}
		err = proto.Unmarshal(e.raw, dom)
		if err != nil {
			t.Error("Expected no error, got", err)
			break
		}
	}
}
开发者ID:liuzl,项目名称:skizze,代码行数:71,代码来源:aof_test.go


示例18: TearDownTests

// TearDownTests ...
func TearDownTests() {
	utils.PanicOnError(os.RemoveAll(os.Getenv("SKIZZE_DATA_DIR")))
	utils.PanicOnError(os.RemoveAll(os.Getenv("SKIZZE_INFO_DIR")))
	time.Sleep(50 * time.Millisecond)
	config.Reset()
}
开发者ID:seiflotfy,项目名称:skizze,代码行数:7,代码来源:testutils.go



注:本文中的config.Reset函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang configuration.Configuration类代码示例发布时间:2022-05-24
下一篇:
Golang confab.Controller类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap