func TestExtend(t *testing.T) { fp, err := fieldpath.NewFloat64Path("test", "MyExtendable", test.ThetestDescription(), "FieldA") if err != nil { panic(err) } m := &test.MyExtendable{} err = proto.SetExtension(m, test.E_FieldA, proto.Float64(10.0)) if err != nil { panic(err) } buf, err := proto.Marshal(m) if err != nil { panic(err) } var unmarshalled float64 f := FuncHandler{ Float64Func: func(v float64) { t.Logf("unmarshalled %v", v) unmarshalled = v }, } unmarshaler := fieldpath.NewFloat64Unmarshaler(fp, f) err = unmarshaler.Unmarshal(buf) if err != nil { panic(err) } if unmarshalled != float64(10.0) { panic(fmt.Errorf("wtf %v", unmarshalled)) } }
func TestNoMergeMerge(t *testing.T) { r := rand.New(rand.NewSource(time.Now().UnixNano())) m := test.NewPopulatedNinOptNative(r, true) if m.Field1 == nil { m.Field1 = proto.Float64(1.1) } data, err := proto.Marshal(m) if err != nil { panic(err) } key := byte(uint32(1)<<3 | uint32(1)) data = append(data, key, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) err = fieldpath.NoMerge(data, test.ThetestDescription(), "test", "NinOptNative") if err == nil || !strings.Contains(err.Error(), "NinOptNative.Field1 requires merging") { t.Fatalf("Field1 should require merging") } }
} return names } It("periodically emits events", func() { perform() Eventually(func() int { return len(fakeEventEmitter.GetMessages()) }).Should(BeNumerically(">=", 2)) }) It("emits a NumCpu metric", func() { perform() Eventually(fakeEventEmitter.GetEvents).Should(ContainElement(&events.ValueMetric{ Name: proto.String("numCPUS"), Value: proto.Float64(float64(runtime.NumCPU())), Unit: proto.String("count"), })) }) It("emits a NumGoRoutines metric", func() { perform() Eventually(getMetricNames).Should(ContainElement("numGoRoutines")) }) It("emits all memoryStats metrics", func() { perform() Eventually(getMetricNames).Should(ContainElement("memoryStats.numBytesAllocatedHeap")) Eventually(getMetricNames).Should(ContainElement("memoryStats.numBytesAllocatedStack"))