text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func TestNewRegistry(t *testing.T) {
r := NewRegistry(info.NewRuntimeInfo())
compType := "my_component"
compName := "etcd"
r.Register(compType,
NewComponentFactory(compName, func() Component {
return nil
}),
)
_, err := r.Create(compType, compName)
if err != nil {
t.Fatalf("create mock store failed: %v", err)
}
if _, err := r.Create(compType, "not exists"); !strings.Contains(err.Error(), "not regsitered") {
t.Fatalf("create mock store failed: %v", err)
}
} | explode_data.jsonl/17977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
3564,
15603,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
15603,
14208,
7121,
15123,
1731,
2398,
197,
5689,
929,
1669,
330,
2408,
23406,
698,
197,
5689,
675,
1669,
330,
295,
4385,
698,
7000,
19983,
30008,
929,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBytesPump(t *testing.T) {
w := &Websocket{}
w.init()
defer close(w.rxBytesChan)
go w.bytesPump()
payload := []byte("hello world")
refMsg := messageMeta{
service: serviceID(7),
command: commandID(11),
msgID: 15,
payload: payload}
enc, err := encodeMessage(int(refMsg.msgID), int(refMsg.refMsgID), refMsg.service, refMsg.command, payload)
if err != nil {
t.Error(err)
}
w.rxBytesChan <- rxBytes{append(enc, payload...), nil}
msgData := <-w.rxMessageChan
err = verifyMessageMetaEqual(msgData.msg, refMsg)
if err != nil {
t.Error(err)
}
w.Close()
} | explode_data.jsonl/13932 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
7078,
47,
1510,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
609,
5981,
9556,
16094,
6692,
8271,
2822,
16867,
3265,
3622,
45348,
7078,
46019,
340,
30680,
289,
42697,
47,
1510,
2822,
76272,
1669,
3056,
3782,
445,
14990,
1879,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInputService17ProtocolTestXMLAttributeCase1(t *testing.T) {
sess := session.New()
svc := NewInputService17ProtocolTest(sess, &aws.Config{Endpoint: aws.String("https://test")})
input := &InputService17TestShapeInputService17TestCaseOperation1Input{
Grant: &InputService17TestShapeGrant{
Grantee: &InputService17TestShapeGrantee{
EmailAddress: aws.String("foo@example.com"),
Type: aws.String("CanonicalUser"),
},
},
}
req, _ := svc.InputService17TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
restxml.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body := util.SortXML(r.Body)
awstesting.AssertXML(t, `<Grant xmlns:_xmlns="xmlns" _xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:XMLSchema-instance="http://www.w3.org/2001/XMLSchema-instance" XMLSchema-instance:type="CanonicalUser"><Grantee><EmailAddress>foo@example.com</EmailAddress></Grantee></Grant>`, util.Trim(string(body)), InputService17TestShapeInputService17TestCaseOperation1Input{})
// assert URL
awstesting.AssertURL(t, "https://test/", r.URL.String())
// assert headers
} | explode_data.jsonl/46491 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
2505,
1860,
16,
22,
20689,
2271,
10609,
3907,
4207,
16,
1155,
353,
8840,
836,
8,
341,
1903,
433,
1669,
3797,
7121,
741,
1903,
7362,
1669,
1532,
2505,
1860,
16,
22,
20689,
2271,
57223,
11,
609,
8635,
10753,
90,
27380,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValueBinder_BindError(t *testing.T) {
c := createTestContext("/api/user/999?nr=en&id=nope", nil, nil)
b := QueryParamsBinder(c)
id := int64(99)
nr := int64(88)
err := b.Int64("id", &id).
Int64("nr", &nr).
BindError()
assert.EqualError(t, err, "code=400, message=failed to bind field value to int64, internal=strconv.ParseInt: parsing \"nope\": invalid syntax, field=id")
assert.Nil(t, b.errors)
assert.Nil(t, b.BindError())
} | explode_data.jsonl/82533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
1130,
44055,
1668,
484,
1454,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1855,
2271,
1972,
4283,
2068,
11739,
14,
24,
24,
24,
30,
19618,
61757,
42621,
30315,
375,
497,
2092,
11,
2092,
340,
2233,
1669,
11361,
4870,
44055,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestArray_Unique(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
expect := []interface{}{1, 2, 3, 4, 5, 3, 2, 2, 3, 5, 5}
array := garray.NewArrayFrom(expect)
t.Assert(array.Unique().Slice(), []interface{}{1, 2, 3, 4, 5})
})
} | explode_data.jsonl/13890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
1857,
62,
22811,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
24952,
1669,
3056,
4970,
6257,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIsSharedFailure(t *testing.T) {
errorTests := []struct {
name string
content string
}{
{
// the first line is too short
name: "too-short-line",
content: `62 0 253:0 / / rw,relatime
76 62 8:1 / /boot rw,relatime shared:29 - ext4 /dev/sda1 rw,seclabel,data=ordered
78 62 0:41 / /tmp rw,nosuid,nodev shared:30 - tmpfs tmpfs rw,seclabel
80 62 0:42 / /var/lib/nfs/rpc_pipefs rw,relatime shared:31 - rpc_pipefs sunrpc rw
227 62 253:0 /var/lib/docker/devicemapper /var/lib/docker/devicemapper rw,relatime - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered
224 62 253:0 /var/lib/docker/devicemapper/test/shared /var/lib/docker/devicemapper/test/shared rw,relatime master:1 shared:44 - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered
`,
},
{
// there is no root mount
name: "no-root-mount",
content: `76 62 8:1 / /boot rw,relatime shared:29 - ext4 /dev/sda1 rw,seclabel,data=ordered
78 62 0:41 / /tmp rw,nosuid,nodev shared:30 - tmpfs tmpfs rw,seclabel
80 62 0:42 / /var/lib/nfs/rpc_pipefs rw,relatime shared:31 - rpc_pipefs sunrpc rw
227 62 253:0 /var/lib/docker/devicemapper /var/lib/docker/devicemapper rw,relatime - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered
224 62 253:0 /var/lib/docker/devicemapper/test/shared /var/lib/docker/devicemapper/test/shared rw,relatime master:1 shared:44 - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered
`,
},
}
for _, test := range errorTests {
tempDir, filename, err := writeFile(test.content)
if err != nil {
t.Fatalf("cannot create temporary file: %v", err)
}
defer os.RemoveAll(tempDir)
_, err = isShared("/", filename)
if err == nil {
t.Errorf("test %q: expected error, got none", test.name)
}
}
} | explode_data.jsonl/76949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 736
} | [
2830,
3393,
3872,
16997,
17507,
1155,
353,
8840,
836,
8,
341,
18290,
18200,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
27751,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
322,
279,
1156,
1555,
374,
2238,
2805,
198,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNamespaceExtractionRules(t *testing.T) {
c, _ := newTestClientWithRulesAndFilters(t, ExtractionRules{}, Filters{})
namespace := &api_v1.Namespace{
ObjectMeta: meta_v1.ObjectMeta{
Name: "auth-service-namespace-abc12-xyz3",
UID: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
CreationTimestamp: meta_v1.Now(),
Labels: map[string]string{
"label1": "lv1",
},
Annotations: map[string]string{
"annotation1": "av1",
},
},
}
testCases := []struct {
name string
rules ExtractionRules
attributes map[string]string
}{{
name: "no-rules",
rules: ExtractionRules{},
attributes: nil,
}, {
name: "labels",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "a1",
Key: "annotation1",
From: MetadataFromNamespace,
},
},
Labels: []FieldExtractionRule{{
Name: "l1",
Key: "label1",
From: MetadataFromNamespace,
},
},
},
attributes: map[string]string{
"l1": "lv1",
"a1": "av1",
},
},
{
name: "all-labels",
rules: ExtractionRules{
Labels: []FieldExtractionRule{{
KeyRegex: regexp.MustCompile("la*"),
From: MetadataFromNamespace,
},
},
},
attributes: map[string]string{
"k8s.namespace.labels.label1": "lv1",
},
},
{
name: "all-annotations",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
KeyRegex: regexp.MustCompile("an*"),
From: MetadataFromNamespace,
},
},
},
attributes: map[string]string{
"k8s.namespace.annotations.annotation1": "av1",
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c.Rules = tc.rules
c.handleNamespaceAdd(namespace)
p, ok := c.GetNamespace(namespace.Name)
require.True(t, ok)
assert.Equal(t, len(tc.attributes), len(p.Attributes))
for k, v := range tc.attributes {
got, ok := p.Attributes[k]
assert.True(t, ok)
assert.Equal(t, v, got)
}
})
}
} | explode_data.jsonl/56854 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 968
} | [
2830,
3393,
22699,
840,
26425,
26008,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
501,
2271,
2959,
2354,
26008,
3036,
28351,
1155,
11,
94506,
26008,
22655,
45012,
6257,
692,
56623,
1669,
609,
2068,
2273,
16,
46011,
515,
197,
2381... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestWriteThroughHeader(t *testing.T) {
t.Run("Slice", func(t *testing.T) {
s := []byte("Hello, checkptr!")[:5]
var alias []byte
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&alias))
hdr.Data = unsafe.Pointer(&s[0])
hdr.Cap = cap(s)
hdr.Len = len(s)
if !bytes.Equal(alias, s) {
t.Errorf("alias of %T(%q) constructed via Slice = %T(%q)", s, s, alias, alias)
}
if cap(alias) != cap(s) {
t.Errorf("alias of %T with cap %d has cap %d", s, cap(s), cap(alias))
}
})
t.Run("String", func(t *testing.T) {
s := "Hello, checkptr!"
var alias string
hdr := (*unsafeheader.String)(unsafe.Pointer(&alias))
hdr.Data = (*unsafeheader.String)(unsafe.Pointer(&s)).Data
hdr.Len = len(s)
if alias != s {
t.Errorf("alias of %q constructed via String = %q", s, alias)
}
})
} | explode_data.jsonl/68577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 358
} | [
2830,
3393,
7985,
23857,
4047,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
33236,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1903,
1669,
3056,
3782,
445,
9707,
11,
1779,
3505,
88783,
3447,
20,
2533,
197,
2405,
15534,
3056,
3782... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCustomToUnstructured(t *testing.T) {
testcases := []struct {
Data string
Expected interface{}
}{
{Data: `null`, Expected: nil},
{Data: `true`, Expected: true},
{Data: `false`, Expected: false},
{Data: `[]`, Expected: []interface{}{}},
{Data: `[1]`, Expected: []interface{}{int64(1)}},
{Data: `{}`, Expected: map[string]interface{}{}},
{Data: `{"a":1}`, Expected: map[string]interface{}{"a": int64(1)}},
{Data: `0`, Expected: int64(0)},
{Data: `0.0`, Expected: float64(0)},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.Data, func(t *testing.T) {
t.Parallel()
result, err := runtime.NewTestUnstructuredConverter(simpleEquality).ToUnstructured(&G{
CustomValue1: CustomValue{data: []byte(tc.Data)},
CustomValue2: &CustomValue{data: []byte(tc.Data)},
CustomPointer1: CustomPointer{data: []byte(tc.Data)},
CustomPointer2: &CustomPointer{data: []byte(tc.Data)},
})
require.NoError(t, err)
for field, fieldResult := range result {
assert.Equal(t, tc.Expected, fieldResult, field)
}
})
}
} | explode_data.jsonl/77965 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 496
} | [
2830,
3393,
10268,
1249,
1806,
51143,
1155,
353,
8840,
836,
8,
972,
18185,
23910,
1669,
3056,
1235,
972,
197,
40927,
257,
914,
319,
197,
197,
18896,
3749,
90,
1771,
197,
92,
1666,
197,
197,
90,
1043,
25,
1565,
2921,
7808,
31021,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_JoinSelf(t *testing.T) {
en := NewOnSlice("fs", "sf", "ff", "ss")
type args struct {
outer Enumerator[string]
inner Enumerator[string]
outerKeySelector func(string) rune
innerKeySelector func(string) rune
resultSelector func(string, string) string
}
tests := []struct {
name string
args args
want Enumerator[string]
}{
{name: "SameEnumerable",
args: args{
outer: en,
inner: en,
outerKeySelector: func(oel string) rune { return ([]rune(oel))[0] },
innerKeySelector: func(iel string) rune { return ([]rune(iel))[1] },
resultSelector: func(oel, iel string) string { return oel + ":" + iel },
},
want: NewOnSlice("fs:sf", "fs:ff", "sf:fs", "sf:ss", "ff:sf", "ff:ff", "ss:fs", "ss:ss"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, _ := JoinSelf(tt.args.outer, tt.args.inner, tt.args.outerKeySelector, tt.args.innerKeySelector, tt.args.resultSelector)
if !SequenceEqualMust(got, tt.want) {
got.Reset()
tt.want.Reset()
t.Errorf("JoinSelf() = '%v', want '%v'", String(got), String(tt.want))
}
})
}
} | explode_data.jsonl/67377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 540
} | [
2830,
3393,
10598,
1961,
12092,
1155,
353,
8840,
836,
8,
341,
81848,
1669,
1532,
1925,
33236,
445,
3848,
497,
330,
17246,
497,
330,
542,
497,
330,
778,
1138,
13158,
2827,
2036,
341,
197,
197,
2676,
310,
76511,
14032,
921,
197,
197,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGMC2TwoSeriesV2(test *testing.T) {
gmc := NewGroupMemoryChunk2(2)
app, _ := gmc.Appender()
for i := 0; i < 4000; i += 5 {
app.AppendGroup(int64(i), []float64{float64(i), float64(i)})
}
it := gmc.IteratorGroup(2500, 0)
i := 2500
for it.Next() {
t, v := it.At()
testutil.Equals(test, int64(i), t)
testutil.Equals(test, float64(i), v)
i += 5
}
testutil.Equals(test, 4000, i)
} | explode_data.jsonl/36846 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
38,
11604,
17,
11613,
25544,
53,
17,
8623,
353,
8840,
836,
8,
341,
3174,
12887,
1669,
1532,
2808,
10642,
28304,
17,
7,
17,
340,
28236,
11,
716,
1669,
342,
12887,
5105,
1659,
741,
2023,
600,
1669,
220,
15,
26,
600,
366,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBadSecrets(t *testing.T) {
_, err := fixture(t, "invalid/bad-secrets.workflow")
pe := extractParserError(t, err)
assert.Equal(t, "d", pe.Actions[3].Identifier)
assert.Equal(t, []string{"-", "^", "9", "a", "0_o", "o_0"}, pe.Actions[3].Secrets)
assert.Equal(t, "e", pe.Actions[4].Identifier)
assert.Equal(t, map[string]string{"x": "foo"}, pe.Actions[4].Env)
assert.Equal(t, []string{"x"}, pe.Actions[4].Secrets)
assert.Equal(t, "f", pe.Actions[5].Identifier)
assert.Equal(t, []string{"x", "y", "x"}, pe.Actions[5].Secrets)
} | explode_data.jsonl/55680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
17082,
19773,
82,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
12507,
1155,
11,
330,
11808,
3470,
329,
7806,
52710,
72774,
1138,
197,
375,
1669,
8649,
6570,
1454,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
330,
67... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReadASN1OptionalOctetString(t *testing.T) {
for _, test := range optionalOctetStringTestData {
t.Run(test.name, func(t *testing.T) {
in := String(test.in)
var out []byte
var present bool
ok := in.ReadOptionalASN1OctetString(&out, &present, test.tag)
if ok != test.ok || present != test.present || !bytes.Equal(out, test.out.([]byte)) {
t.Errorf("in.ReadOptionalASN1OctetString() = %v, want %v; present = %v want %v; out = %v, want %v", ok, test.ok, present, test.present, out, test.out)
}
})
}
} | explode_data.jsonl/16722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
4418,
68134,
16,
15309,
18053,
295,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
10101,
18053,
295,
703,
83920,
341,
197,
3244,
16708,
8623,
2644,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
17430,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestServerUnreadRequestBodyLittle(t *testing.T) {
defer afterTest(t)
conn := new(testConn)
body := strings.Repeat("x", 100<<10)
conn.readBuf.Write([]byte(fmt.Sprintf(
"POST / HTTP/1.1\r\n"+
"Host: test\r\n"+
"Content-Length: %d\r\n"+
"\r\n", len(body))))
conn.readBuf.Write([]byte(body))
done := make(chan bool)
readBufLen := func() int {
conn.readMu.Lock()
defer conn.readMu.Unlock()
return conn.readBuf.Len()
}
ls := &oneConnListener{conn}
go Serve(ls, HandlerFunc(func(rw ResponseWriter, req *Request) {
defer close(done)
if bufLen := readBufLen(); bufLen < len(body)/2 {
t.Errorf("on request, read buffer length is %d; expected about 100 KB", bufLen)
}
rw.WriteHeader(200)
rw.(Flusher).Flush()
if g, e := readBufLen(), 0; g != e {
t.Errorf("after WriteHeader, read buffer length is %d; want %d", g, e)
}
if c := rw.Header().Get("Connection"); c != "" {
t.Errorf(`Connection header = %q; want ""`, c)
}
}))
<-done
} | explode_data.jsonl/22415 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 423
} | [
2830,
3393,
5475,
1806,
878,
33334,
38103,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
32917,
1669,
501,
8623,
9701,
340,
35402,
1669,
9069,
2817,
10979,
445,
87,
497,
220,
16,
15,
15,
2442,
16,
15,
340,
32917,
4125,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestV13WithStateCouchdb(t *testing.T) {
env := newEnv(t)
defer env.cleanup()
ledgerFSRoot := env.initializer.Config.RootFSPath
// pass false so that 'ledgersData' directory will not be created when unzipped to ledgerFSRoot
require.NoError(t, testutil.Unzip("testdata/v13_statecouchdb/sample_ledgers/ledgersData.zip", ledgerFSRoot, false))
// unzip couchdb data to prepare the mount dir
couchdbDataUnzipDir := filepath.Join(ledgerFSRoot, "couchdbData")
require.NoError(t, os.Mkdir(couchdbDataUnzipDir, os.ModePerm))
require.NoError(t, testutil.Unzip("testdata/v13_statecouchdb/sample_ledgers/couchdbData.zip", couchdbDataUnzipDir, false))
// prepare the local.d mount dir to overwrite the number of shards and nodes so that they match the couchdb data generated from v1.3
localdHostDir := filepath.Join(ledgerFSRoot, "local.d")
require.NoError(t, os.MkdirAll(localdHostDir, os.ModePerm))
testutil.CopyDir("testdata/v13_statecouchdb/couchdb_etc/local.d", localdHostDir, true)
// start couchdb using couchdbDataUnzipDir and localdHostDir as mount dirs
couchAddress, cleanup := couchDBSetup(t, couchdbDataUnzipDir, localdHostDir)
defer cleanup()
// set required config data to use state couchdb
couchdbConfig := &couchdb.Config{
Address: couchAddress,
Username: "",
Password: "",
MaxRetries: 3,
MaxRetriesOnStartup: 3,
RequestTimeout: 10 * time.Second,
RedoLogPath: filepath.Join(ledgerFSRoot, "couchdbRedoLogs"),
}
env.initializer.Config.StateDBConfig.StateDatabase = "CouchDB"
env.initializer.Config.StateDBConfig.CouchDB = couchdbConfig
env.initializer.HealthCheckRegistry = &mock.HealthCheckRegistry{}
env.initializer.ChaincodeLifecycleEventProvider = &mock.ChaincodeLifecycleEventProvider{}
// verify init ledger panic and drop the corresponding db after each panic
checkInitLedgerPanicAndDropDBs(t, env, ledgerFSRoot, couchdbConfig)
t.Logf("All stores are reformatted/dropped, now ledgermgmt initialization should not panic")
env.initLedgerMgmt()
h1, h2 := env.newTestHelperOpenLgr("ledger1", t), env.newTestHelperOpenLgr("ledger2", t)
dataHelper := &v1xSampleDataHelper{sampleDataVersion: "v1.3", t: t}
dataHelper.verify(h1)
dataHelper.verify(h2)
// drop couchDB and other rebuildable dbs to test db rebuild
dropCouchDBs(t, couchdbConfig)
env.closeAllLedgersAndDrop(rebuildableBlockIndex + rebuildableConfigHistory + rebuildableHistoryDB)
h1, h2 = env.newTestHelperOpenLgr("ledger1", t), env.newTestHelperOpenLgr("ledger2", t)
dataHelper.verify(h1)
dataHelper.verify(h2)
} | explode_data.jsonl/40435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 955
} | [
2830,
3393,
53,
16,
18,
2354,
1397,
34,
3026,
1999,
1155,
353,
8840,
836,
8,
341,
57538,
1669,
501,
14359,
1155,
340,
16867,
6105,
87689,
2822,
197,
50704,
8485,
8439,
1669,
6105,
17793,
3135,
10753,
45345,
8485,
1820,
198,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddMemberOk(t *testing.T) {
ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad)
member1 := ctx.NewSoloAgent()
dividendMember(ctx, member1, 100)
require.NoError(t, ctx.Err)
} | explode_data.jsonl/31341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
2212,
9366,
11578,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
572,
1011,
10011,
7121,
89299,
1972,
1155,
11,
45880,
18326,
675,
11,
45880,
8071,
5879,
692,
2109,
1377,
16,
1669,
5635,
7121,
89299,
16810,
741,
63278,
68850,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSetChainConfigs(t *testing.T) {
tests := map[string]struct {
configs map[string]string
upgrades map[string]string
corethConfig string
errMessage string
expected map[string]chains.ChainConfig
}{
"no chain configs": {
configs: map[string]string{},
upgrades: map[string]string{},
expected: map[string]chains.ChainConfig{},
},
"valid chain-id": {
configs: map[string]string{"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp": "hello", "2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm": "world"},
upgrades: map[string]string{"yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp": "helloUpgrades"},
expected: func() map[string]chains.ChainConfig {
m := map[string]chains.ChainConfig{}
id1, err := ids.FromString("yH8D7ThNJkxmtkuv2jgBa4P1Rn3Qpr4pPr7QYNfcdoS6k6HWp")
assert.NoError(t, err)
m[id1.String()] = chains.ChainConfig{Config: []byte("hello"), Upgrade: []byte("helloUpgrades")}
id2, err := ids.FromString("2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm")
assert.NoError(t, err)
m[id2.String()] = chains.ChainConfig{Config: []byte("world"), Upgrade: []byte(nil)}
return m
}(),
},
"valid alias": {
configs: map[string]string{"C": "hello", "X": "world"},
upgrades: map[string]string{"C": "upgradess"},
expected: func() map[string]chains.ChainConfig {
m := map[string]chains.ChainConfig{}
m["C"] = chains.ChainConfig{Config: []byte("hello"), Upgrade: []byte("upgradess")}
m["X"] = chains.ChainConfig{Config: []byte("world"), Upgrade: []byte(nil)}
return m
}(),
},
"coreth config only": {
configs: map[string]string{},
upgrades: map[string]string{},
corethConfig: "hello",
expected: map[string]chains.ChainConfig{"C": {Config: []byte("hello"), Upgrade: []byte(nil)}},
},
"coreth with c alias chain config": {
configs: map[string]string{"C": "hello", "X": "world"},
upgrades: map[string]string{"C": "upgradess"},
corethConfig: "hellocoreth",
errMessage: "is already provided",
expected: nil,
},
"coreth with evm alias chain config": {
configs: map[string]string{"evm": "hello", "X": "world"},
upgrades: map[string]string{"evm": "upgradess"},
corethConfig: "hellocoreth",
errMessage: "is already provided",
expected: nil,
},
"coreth and c chain upgrades in config": {
configs: map[string]string{"X": "world"},
upgrades: map[string]string{"C": "upgradess"},
corethConfig: "hello",
expected: func() map[string]chains.ChainConfig {
m := map[string]chains.ChainConfig{}
m["C"] = chains.ChainConfig{Config: []byte("hello"), Upgrade: []byte("upgradess")}
m["X"] = chains.ChainConfig{Config: []byte("world"), Upgrade: []byte(nil)}
return m
}(),
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
assert := assert.New(t)
root := t.TempDir()
var configJSON string
if len(test.corethConfig) > 0 {
configJSON = fmt.Sprintf(`{%q: %q, %q: %q}`, ChainConfigDirKey, root, CorethConfigKey, test.corethConfig)
} else {
configJSON = fmt.Sprintf(`{%q: %q}`, ChainConfigDirKey, root)
}
configFile := setupConfigJSON(t, root, configJSON)
chainsDir := root
// Create custom configs
for key, value := range test.configs {
chainDir := path.Join(chainsDir, key)
setupFile(t, chainDir, chainConfigFileName+".ex", value)
}
for key, value := range test.upgrades {
chainDir := path.Join(chainsDir, key)
setupFile(t, chainDir, chainUpgradeFileName+".ex", value)
}
v := setupViper(configFile)
// Parse config
assert.Equal(root, v.GetString(ChainConfigDirKey))
chainConfigs, err := getChainConfigs(v)
if len(test.errMessage) > 0 {
assert.Error(err)
if err != nil {
assert.Contains(err.Error(), test.errMessage)
}
} else {
assert.NoError(err)
}
assert.Equal(test.expected, chainConfigs)
})
}
} | explode_data.jsonl/51975 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1733
} | [
2830,
3393,
1649,
18837,
84905,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
25873,
82,
414,
2415,
14032,
30953,
198,
197,
59810,
22340,
257,
2415,
14032,
30953,
198,
197,
71882,
339,
2648,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIndexName(t *testing.T) {
tests := []struct {
name string
index string
nameProvider indexNameProvider
date time.Time
end time.Time
}{
{
name: "index prefix",
nameProvider: newIndexNameProvider("myindex", "production", false, false),
index: "production-myindex-0001-01-01",
},
{
name: "no prefix",
nameProvider: newIndexNameProvider("myindex", "", false, false),
index: "myindex-2020-08-28",
date: time.Date(2020, 8, 28, 0, 0, 0, 0, time.UTC),
},
{
name: "use aliases",
nameProvider: newIndexNameProvider("myindex", "", true, false),
index: "myindex-write",
date: time.Date(2020, 8, 28, 0, 0, 0, 0, time.UTC),
},
{
name: "use archive",
nameProvider: newIndexNameProvider("myindex", "", false, true),
index: "myindex-archive",
date: time.Date(2020, 8, 28, 0, 0, 0, 0, time.UTC),
},
{
name: "use archive alias",
nameProvider: newIndexNameProvider("myindex", "", true, true),
index: "myindex-archive-write",
date: time.Date(2020, 8, 28, 0, 0, 0, 0, time.UTC),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
indices := test.nameProvider.get(test.date)
assert.Equal(t, test.index, indices)
})
}
} | explode_data.jsonl/67915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 651
} | [
2830,
3393,
1552,
675,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
26327,
286,
914,
198,
197,
11609,
5179,
1922,
675,
5179,
198,
197,
44086,
260,
882,
16299,
198,
197,
6246,
688,
882,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShouldConvert(t *testing.T) {
t.Run("should not convert root element", func(t *testing.T) {
mapper := mapify.Mapper{
ShouldConvert: func(path string, value reflect.Value) (bool, error) {
if path == "" {
return false, nil
}
return true, nil
},
}
tests := map[string]interface{}{
"struct": struct{ Field string }{Field: "v"},
"map": map[string]string{"key": "value"},
"slice": []struct{ Field string }{{Field: "v"}},
}
for name, instance := range tests {
t.Run(name, func(t *testing.T) {
// when
mapped, err := mapper.MapAny(instance)
// then
require.NoError(t, err)
assert.Equal(t, instance, mapped)
})
}
})
t.Run("should not convert nested object", func(t *testing.T) {
type nestedStruct struct{ Field string }
nestedStructInstance := nestedStruct{Field: "a"}
nestedMap := map[string]string{"Field": "a"}
tests := map[string]struct {
input, expected interface{}
}{
"struct in a struct field": {
input: struct{ Nested nestedStruct }{Nested: nestedStructInstance},
expected: map[string]interface{}{"Nested": nestedStructInstance},
},
"struct pointer in a struct field": {
input: struct{ Nested *nestedStruct }{Nested: &nestedStructInstance},
expected: map[string]interface{}{"Nested": &nestedStructInstance},
},
"struct in a map key": {
input: map[string]nestedStruct{"Nested": nestedStructInstance},
expected: map[string]interface{}{"Nested": nestedStructInstance},
},
"map in a struct field": {
input: struct{ Nested map[string]string }{Nested: nestedMap},
expected: map[string]interface{}{"Nested": nestedMap},
},
"map in a map key": {
input: map[string]map[string]string{"Nested": nestedMap},
expected: map[string]interface{}{"Nested": nestedMap},
},
"structs slice in a struct field": {
input: struct{ Nested []nestedStruct }{Nested: []nestedStruct{nestedStructInstance}},
expected: map[string]interface{}{"Nested": []nestedStruct{nestedStructInstance}},
},
"structs slice in a map key": {
input: map[string][]nestedStruct{"Nested": {nestedStructInstance}},
expected: map[string]interface{}{"Nested": []nestedStruct{nestedStructInstance}},
},
"map slice in a struct field": {
input: struct{ Nested []map[string]string }{Nested: []map[string]string{nestedMap}},
expected: map[string]interface{}{"Nested": []map[string]string{nestedMap}},
},
"2d structs slice in a map key": {
input: map[string][][]nestedStruct{"Nested": {{nestedStructInstance}}},
expected: map[string]interface{}{"Nested": [][]nestedStruct{{nestedStructInstance}}},
},
}
mapper := mapify.Mapper{
ShouldConvert: func(path string, value reflect.Value) (bool, error) {
if path == ".Nested" {
return false, nil
}
return true, nil
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
// when
mapped, err := mapper.MapAny(test.input)
// then
require.NoError(t, err)
assert.Equal(t, test.expected, mapped)
})
}
})
t.Run("should not run ShouldConvert for inconvertible values", func(t *testing.T) {
mapper := mapify.Mapper{
ShouldConvert: func(path string, value reflect.Value) (bool, error) {
panic("ShouldConvert run but should not")
},
}
tests := []interface{}{nil, 1, "str", map[int]interface{}{}, []int{1}}
for _, test := range tests {
name := fmt.Sprintf("%+v", test)
t.Run(name, func(t *testing.T) {
assert.NotPanics(t, func() {
_, _ = mapper.MapAny(test)
})
})
}
})
t.Run("should run ShouldConvert only once for pointer to struct", func(t *testing.T) {
s := &struct{ Field string }{Field: "v"}
timesRun := 0
mapper := mapify.Mapper{
ShouldConvert: func(path string, value reflect.Value) (bool, error) {
assert.Equal(t, s, value.Interface())
timesRun++
return true, nil
},
}
_, err := mapper.MapAny(s)
require.NoError(t, err)
assert.Equal(t, 1, timesRun, "ShouldConvert must be executed only once")
})
} | explode_data.jsonl/71717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1637
} | [
2830,
3393,
14996,
12012,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5445,
537,
5508,
3704,
2392,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2109,
3106,
1669,
2415,
1437,
71892,
515,
298,
197,
14996,
12012,
25,
2915,
5581,
914... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSLIPluginLoader(t *testing.T) {
tests := map[string]struct {
pluginSrc string
pluginID string
meta map[string]string
labels map[string]string
options map[string]string
expPluginID string
expSLIQuery string
expErrLoad bool
expErr bool
}{
"Plugin without version should fail on load.": {
pluginSrc: `
package testplugin
import "context"
const SLIPluginVersion = "prometheus/v1"
func SLIPlugin(ctx context.Context, meta, labels, options map[string]string) (string, error) {
return "test_query{}", nil
}
`,
expErrLoad: true,
},
"Basic plugin should load and return a correct SLI.": {
pluginSrc: `
package testplugin
import "context"
const (
SLIPluginID = "test_plugin"
SLIPluginVersion = "prometheus/v1"
)
func SLIPlugin(ctx context.Context, meta, labels, options map[string]string) (string, error) {
return "test_query{}", nil
}
`,
expPluginID: "test_plugin",
expSLIQuery: "test_query{}",
},
"Plugin with meta and options should load and return a correct SLI.": {
pluginSrc: `
package testplugin
import "context"
import "fmt"
const (
SLIPluginID = "test_plugin"
SLIPluginVersion = "prometheus/v1"
)
func SLIPlugin(ctx context.Context, meta, labels, options map[string]string) (string, error) {
return fmt.Sprintf("test_query{mk1=\"%s\",lk1=\"%s\",k1=\"%s\",k2=\"%s\"}", meta["mk1"], labels["lk1"], options["k1"], options["k2"]), nil
}
`,
meta: map[string]string{"mk1": "mv1"},
labels: map[string]string{"lk1": "lv1"},
options: map[string]string{"k1": "v1", "k2": "v2"},
expSLIQuery: `test_query{mk1="mv1",lk1="lv1",k1="v1",k2="v2"}`,
expPluginID: "test_plugin",
},
"Plugin with error should return errors.": {
pluginSrc: `
package testplugin
import "context"
import "fmt"
const (
SLIPluginID = "test_plugin"
SLIPluginVersion = "prometheus/v1"
)
func SLIPlugin(ctx context.Context, meta, labels, options map[string]string) (string, error) {
return "", fmt.Errorf("something")
}
`,
meta: map[string]string{"mk1": "mv1"},
labels: map[string]string{"lk1": "lv1"},
options: map[string]string{"k1": "v1", "k2": "v2"},
expPluginID: "test_plugin",
expErr: true,
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
// Mock the plugin files.
mfm := &prometheusmock.FileManager{}
mfm.On("FindFiles", mock.Anything, "./", mock.Anything).Once().Return([]string{"testplugin/test.go"}, nil)
mfm.On("ReadFile", mock.Anything, "testplugin/test.go").Once().Return([]byte(test.pluginSrc), nil)
// Create repository and load plugins.
config := prometheus.FileSLIPluginRepoConfig{
FileManager: mfm,
Paths: []string{"./"},
}
repo, err := prometheus.NewFileSLIPluginRepo(config)
if test.expErrLoad {
assert.Error(err)
return
}
assert.NoError(err)
// Get plugin.
plugin, err := repo.GetSLIPlugin(context.TODO(), test.expPluginID)
require.NoError(err)
// Check.
assert.Equal(test.expPluginID, plugin.ID)
gotSLIQuery, err := plugin.Func(context.TODO(), test.meta, test.labels, test.options)
if test.expErr {
assert.Error(err)
} else if assert.NoError(err) {
assert.Equal(test.expSLIQuery, gotSLIQuery)
}
})
}
} | explode_data.jsonl/35569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1407
} | [
2830,
3393,
7984,
40,
11546,
9181,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
9138,
20360,
256,
914,
198,
197,
197,
9138,
915,
262,
914,
198,
197,
84004,
286,
2415,
14032,
30953,
198,
197,
95143,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestProvider(t *testing.T) {
test.IntegrationTest(t)
var (
kymaVersion = "main"
kymaComponent = "cluster-users"
)
log, err := logger.NewLogger(true)
require.NoError(t, err)
wsFactory, err := workspace.NewFactory("test", log)
require.NoError(t, err)
cleanupFct := func(t *testing.T) {
require.NoError(t, wsFactory.Delete(kymaVersion))
}
//cleanup before test runs (to delete relicts of previous test executions) and after test is finished
cleanupFct(t)
defer cleanupFct(t)
t.Parallel()
prov, err := NewProvider(wsFactory, log)
require.NoError(t, err)
t.Run("Render manifest", func(t *testing.T) {
component := NewComponentBuilder(kymaVersion, kymaComponent).
WithNamespace("kyma-system").
Build()
manifest, err := prov.RenderManifest(component)
require.NoError(t, err)
require.Equal(t, kymaComponent, manifest.Name)
require.Equal(t, HelmChart, manifest.Type)
require.True(t, len(manifest.Manifest) > 1000)
require.NoError(t, yaml.Unmarshal([]byte(manifest.Manifest), make(map[string]interface{})))
})
t.Run("Render CRDs", func(t *testing.T) {
crds, err := prov.RenderCRD(kymaVersion)
require.NoError(t, err)
require.NotEmpty(t, crds)
require.Equal(t, crds[0].Type, CRD)
})
} | explode_data.jsonl/64307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
5179,
1155,
353,
8840,
836,
8,
341,
18185,
7371,
17376,
2271,
1155,
692,
2405,
2399,
197,
16463,
1600,
64,
5637,
256,
284,
330,
3817,
698,
197,
16463,
1600,
64,
2189,
284,
330,
18855,
43380,
698,
197,
692,
6725,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestApiTest_JSONBody(t *testing.T) {
type bodyStruct struct {
A int `json:"a"`
}
tests := map[string]struct {
body interface{}
}{
"string": {
body: `{"a": 12345}`,
},
"[]byte": {
body: []byte(`{"a": 12345}`),
},
"struct": {
body: bodyStruct{A: 12345},
},
"map": {
body: map[string]interface{}{"a": 12345},
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
handler := http.NewServeMux()
handler.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
data, _ := ioutil.ReadAll(r.Body)
assert.JSONEq(t, `{"a": 12345}`, string(data))
if r.Header.Get("Content-Type") != "application/json" {
w.WriteHeader(http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusOK)
})
apitest.New().
Handler(handler).
Post("/hello").
JSON(test.body).
Expect(t).
Status(http.StatusOK).
End()
})
}
} | explode_data.jsonl/54784 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
6563,
2271,
25356,
5444,
1155,
353,
8840,
836,
8,
341,
13158,
2487,
9422,
2036,
341,
197,
22985,
526,
1565,
2236,
2974,
64,
8805,
197,
630,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
35402,
3749,
16094,
197,
59403,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTrie_longestCommonPrefixLenght(t *testing.T) {
trie := NewTrie()
trie.prefix = []byte("1234567890")
switch {
case trie.longestCommonPrefixLength([]byte("")) != 0:
t.Fail()
case trie.longestCommonPrefixLength([]byte("12345")) != 5:
t.Fail()
case trie.longestCommonPrefixLength([]byte("123789")) != 3:
t.Fail()
case trie.longestCommonPrefixLength([]byte("12345678901")) != 10:
t.Fail()
}
} | explode_data.jsonl/2373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
51,
7231,
17799,
477,
10839,
14335,
43,
70078,
1155,
353,
8840,
836,
8,
341,
197,
8927,
1669,
1532,
51,
7231,
741,
197,
8927,
38543,
284,
3056,
3782,
445,
16,
17,
18,
19,
20,
21,
22,
23,
24,
15,
5130,
8961,
341,
2722,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_GetStorageClasses(t *testing.T) {
type checkFn func(*testing.T, *v1.StorageClassList, error)
type connectFn func(*k8s.API) error
type configFn func() (*rest.Config, error)
check := func(fns ...checkFn) []checkFn { return fns }
hasNoError := func(t *testing.T, volumes *v1.StorageClassList, err error) {
if err != nil {
t.Fatalf("expected no error")
}
}
checkExpectedOutput := func(expectedOutput *v1.StorageClassList) func(t *testing.T, volumes *v1.StorageClassList, err error) {
return func(t *testing.T, volumes *v1.StorageClassList, err error) {
assert.Equal(t, expectedOutput, volumes)
}
}
hasError := func(t *testing.T, volumes *v1.StorageClassList, err error) {
if err == nil {
t.Fatalf("expected error")
}
}
tests := map[string]func(t *testing.T) (connectFn, configFn, []checkFn){
"success": func(*testing.T) (connectFn, configFn, []checkFn) {
storageClasses := &v1.StorageClassList{
Items: []v1.StorageClass{
{
ObjectMeta: metav1.ObjectMeta{
Name: "vxflexos",
},
Provisioner: "csi-vxflexos.dellemc.com",
Parameters: map[string]string{
"storagepool": "mypool",
},
},
},
}
connect := func(api *k8s.API) error {
api.Client = fake.NewSimpleClientset(storageClasses)
return nil
}
return connect, nil, check(hasNoError, checkExpectedOutput(storageClasses))
},
"error connecting": func(*testing.T) (connectFn, configFn, []checkFn) {
connect := func(api *k8s.API) error {
return errors.New("error")
}
return connect, nil, check(hasError)
},
"error getting a valid config": func(*testing.T) (connectFn, configFn, []checkFn) {
inClusterConfig := func() (*rest.Config, error) {
return nil, errors.New("error")
}
return nil, inClusterConfig, check(hasError)
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
connectFn, inClusterConfig, checkFns := tc(t)
k8sclient := &k8s.API{}
if connectFn != nil {
oldConnectFn := k8s.ConnectFn
defer func() { k8s.ConnectFn = oldConnectFn }()
k8s.ConnectFn = connectFn
}
if inClusterConfig != nil {
oldInClusterConfig := k8s.InClusterConfigFn
defer func() { k8s.InClusterConfigFn = oldInClusterConfig }()
k8s.InClusterConfigFn = inClusterConfig
}
storageClasses, err := k8sclient.GetStorageClasses()
for _, checkFn := range checkFns {
checkFn(t, storageClasses, err)
}
})
}
} | explode_data.jsonl/29789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1048
} | [
2830,
3393,
13614,
5793,
20077,
1155,
353,
8840,
836,
8,
341,
13158,
1779,
24911,
2915,
4071,
8840,
836,
11,
353,
85,
16,
43771,
1957,
852,
11,
1465,
340,
13158,
4564,
24911,
2915,
4071,
74,
23,
82,
24922,
8,
1465,
198,
13158,
2193,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRedirectURIsFromRoutes(t *testing.T) {
for _, test := range []struct {
name string
namespace string
names sets.String
routes []*routeapi.Route
expected map[string]redirectURIList
}{
{
name: "single route with single ingress",
namespace: "ns01",
names: sets.NewString("routeA"),
routes: []*routeapi.Route{
{
ObjectMeta: metav1.ObjectMeta{
Name: "routeA",
Namespace: "ns01",
},
Spec: routeapi.RouteSpec{
Path: "/pathA",
},
Status: routeapi.RouteStatus{
Ingress: []routeapi.RouteIngress{
{Host: "exampleA.com", Conditions: buildValidRouteIngressCondition()},
},
},
},
},
expected: map[string]redirectURIList{
"routeA": {
{
scheme: "http",
host: "exampleA.com",
port: "",
path: "/pathA",
},
},
},
},
{
name: "multiple routes with multiple ingresses",
namespace: "ns01",
names: sets.NewString("route0", "route1", "route2"),
routes: []*routeapi.Route{
{
ObjectMeta: metav1.ObjectMeta{
Name: "route0",
Namespace: "ns01",
},
Spec: routeapi.RouteSpec{
Path: "/path0",
},
Status: routeapi.RouteStatus{
Ingress: []routeapi.RouteIngress{
{Host: "example0A.com", Conditions: buildValidRouteIngressCondition()},
{Host: "example0B.com", Conditions: buildValidRouteIngressCondition()},
{Host: "example0C.com", Conditions: buildValidRouteIngressCondition()},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "route1",
Namespace: "ns01",
},
Spec: routeapi.RouteSpec{
Path: "/path1",
TLS: &routeapi.TLSConfig{},
},
Status: routeapi.RouteStatus{
Ingress: []routeapi.RouteIngress{
{Host: "redhat.com", Conditions: buildValidRouteIngressCondition()},
{Host: "coreos.com", Conditions: buildValidRouteIngressCondition()},
{Host: "github.com", Conditions: buildValidRouteIngressCondition()},
},
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "route2",
Namespace: "ns01",
},
Spec: routeapi.RouteSpec{
Path: "/path2",
TLS: &routeapi.TLSConfig{},
},
Status: routeapi.RouteStatus{
Ingress: []routeapi.RouteIngress{
{Host: "google.com", Conditions: buildValidRouteIngressCondition()},
{Host: "yahoo.com", Conditions: buildValidRouteIngressCondition()},
{Host: "bing.com", Conditions: buildValidRouteIngressCondition()},
},
},
},
},
expected: map[string]redirectURIList{
"route0": {
{
scheme: "http",
host: "example0A.com",
port: "",
path: "/path0",
},
{
scheme: "http",
host: "example0B.com",
port: "",
path: "/path0",
},
{
scheme: "http",
host: "example0C.com",
port: "",
path: "/path0",
},
},
"route1": {
{
scheme: "https",
host: "redhat.com",
port: "",
path: "/path1",
},
{
scheme: "https",
host: "coreos.com",
port: "",
path: "/path1",
},
{
scheme: "https",
host: "github.com",
port: "",
path: "/path1",
},
},
"route2": {
{
scheme: "https",
host: "google.com",
port: "",
path: "/path2",
},
{
scheme: "https",
host: "yahoo.com",
port: "",
path: "/path2",
},
{
scheme: "https",
host: "bing.com",
port: "",
path: "/path2",
},
},
},
},
} {
a := buildRouteClient(test.routes)
uris, errs := a.redirectURIsFromRoutes(test.namespace, test.names)
if len(errs) > 0 {
t.Errorf("%s: unexpected redirectURIsFromRoutes errors %v", test.name, errs)
}
if !reflect.DeepEqual(test.expected, uris) {
t.Errorf("%s: expected %#v, got %#v", test.name, test.expected, uris)
}
}
} | explode_data.jsonl/54740 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2130
} | [
2830,
3393,
17725,
1511,
3872,
3830,
26653,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
56623,
914,
198,
197,
93940,
257,
7289,
6431,
198,
197,
7000,
5495,
262,
29838,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestArgv_Unquote_ShouldFail(t *testing.T) {
tests := []struct {
Name, Input string
Err error
}{
{
Name: "unterminated string #1",
Input: `"a`,
Err: "e.SyntaxError{
Msg: "unterminated quoted string",
Offset: 2,
},
},
{
Name: "unterminated string #2",
Input: `\`,
Err: "e.SyntaxError{
Msg: `character U+005C '\' outside of quoted string`,
Offset: 1,
},
},
{
Name: "char outside of string",
Input: "a",
Err: "e.SyntaxError{
Msg: "character U+0061 'a' outside of quoted string",
Offset: 1,
},
},
{
Name: "char after string",
Input: `"a"a`,
Err: "e.SyntaxError{
Msg: "character U+0061 'a' outside of quoted string",
Offset: 4,
},
},
}
for _, td := range tests {
t.Run(td.Name, func(t *testing.T) {
_, err := Argv.Unquote(td.Input)
if diff := cmp.Diff(td.Err, err); diff != "" {
t.Errorf("Argv.Unquote() mismatch (-want +got):\n%s", diff)
}
})
}
} | explode_data.jsonl/58697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
2735,
85,
40687,
2949,
36578,
616,
19524,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
21297,
11,
5571,
914,
198,
197,
197,
7747,
260,
1465,
198,
197,
59403,
197,
197,
515,
298,
21297,
25,
220,
330,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFullRADIUSSessiontWithAnalyticsModules(t *testing.T) {
// Arrange
logger, err := zap.NewDevelopment()
require.NoError(t, err, "failed to get logger")
testParam := analyticsModuleTestEnvCreate(t, logger)
// Act & Assert
// step 1: Authorization, to establish the session
testFullRADIUSSessiontWithAnalyticsModulesAuthenticate(t, logger, testParam)
// step 2: Acct-start, no Gigawords defined
testFullRADIUSSessiontWithAnalyticsModulesAccountingStart(t, logger, testParam, false)
// step 3: Acct-update, Gigawords defined as 0
testFullRADIUSSessiontWithAnalyticsModulesAccountingUpdate(t, logger, testParam, false)
// step 4: Acct-update, Gigawords defined as > 0
testFullRADIUSSessiontWithAnalyticsModulesAccountingStop(t, logger, testParam, false)
// Cleanup
analyticsModuleTestEnvDestroy(testParam)
} | explode_data.jsonl/59968 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
9432,
49,
33785,
52,
1220,
1338,
83,
2354,
60539,
28201,
1155,
353,
8840,
836,
8,
341,
197,
322,
40580,
198,
17060,
11,
1848,
1669,
32978,
7121,
39419,
741,
17957,
35699,
1155,
11,
1848,
11,
330,
16091,
311,
633,
5925,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBase64MimeEncoder(t *testing.T) {
dest := bytes.NewBufferString("")
encoder := NewBase64MimeEncoder(dest)
_, err := fmt.Fprint(encoder, "Hello World!")
if err != nil {
t.Log(err)
t.FailNow()
}
err = encoder.Close()
if err != nil {
t.Log(err)
t.FailNow()
}
output := dest.String()
t.Log(output)
if output != "SGVsbG8gV29ybGQh" {
t.Fail()
}
} | explode_data.jsonl/60245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
3978,
21,
19,
44,
545,
19921,
1155,
353,
8840,
836,
8,
341,
49616,
1669,
5820,
7121,
4095,
703,
31764,
197,
27008,
1669,
1532,
3978,
21,
19,
44,
545,
19921,
27010,
692,
197,
6878,
1848,
1669,
8879,
991,
1350,
92277,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestRetrieveEntityNotFound(t *testing.T) {
ts := httptest.NewServer(
http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/v2") {
apiResourcesHandler(w, r)
} else {
if r.Header.Get("Accept") != "application/json" {
t.Fatal("Missing application/json accept header")
}
if r.Header.Get("Content-Type") != "" {
t.Fatal("No Content-Type allowed for GET request")
}
if !strings.HasSuffix(r.URL.Path, "/r1") {
t.Fatal("Expected 'r1' as id")
}
if r.URL.Query().Get("type") != "Room" {
t.Fatalf("Expected 'type' value: 'Room', got '%s'", r.URL.Query().Get("type"))
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
fmt.Fprint(w, `{"description": "The requested entity has not been found. Check type and id", "error": "NotFound"}`)
}
}))
defer ts.Close()
cli, err := client.NewNgsiV2Client(client.SetUrl(ts.URL))
if err != nil {
t.Fatalf("Unexpected error: '%v'", err)
}
if res, err := cli.RetrieveEntity("r1", client.RetrieveEntitySetType("Room")); err == nil {
t.Fatal("Expected error (404), but got none")
} else {
// TODO check 404
if res != nil {
t.Fatalf("Expected a nil response, got: %+v", *res)
}
}
} | explode_data.jsonl/64659 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 574
} | [
2830,
3393,
87665,
3030,
10372,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
1006,
197,
28080,
89164,
1006,
298,
29244,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
571,
743,
9069,
16152,
40177,
2601,
208... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func Test_DefaultIstioPerformer_Uninstall(t *testing.T) {
kc := &mocks.Client{}
kc.On("Kubeconfig").Return("kubeconfig")
kc.On("Clientset").Return(fake.NewSimpleClientset(&corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{Name: "istio-system"},
}), nil)
log := logger.NewLogger(false)
t.Run("should not uninstall when istio version could not be resolved", func(t *testing.T) {
// given
cmdResolver := TestCommanderResolver{err: errors.New("istioctl not found")}
proxy := proxymocks.IstioProxyReset{}
provider := clientsetmocks.Provider{}
var wrapper IstioPerformer = NewDefaultIstioPerformer(cmdResolver, &proxy, &provider)
// when
err := wrapper.Uninstall(kc, "1.2.3", log)
// then
require.Error(t, err)
require.Equal(t, "istioctl not found", err.Error())
})
t.Run("should not uninstall Istio when istioctl returned an error", func(t *testing.T) {
// given
cmder := istioctlmocks.Commander{}
cmder.On("Uninstall", mock.AnythingOfType("string"), mock.AnythingOfType("*zap.SugaredLogger")).Return(errors.New("istioctl error"))
cmdResolver := TestCommanderResolver{cmder: &cmder}
proxy := proxymocks.IstioProxyReset{}
provider := clientsetmocks.Provider{}
var wrapper IstioPerformer = NewDefaultIstioPerformer(cmdResolver, &proxy, &provider)
// when
err := wrapper.Uninstall(kc, "1.2.3", log)
// then
require.Error(t, err)
require.Contains(t, err.Error(), "istioctl error")
cmder.AssertCalled(t, "Uninstall", mock.AnythingOfType("string"), mock.AnythingOfType("*zap.SugaredLogger"))
})
t.Run("should uninstall Istio when istioctl command was successful", func(t *testing.T) {
// given
cmder := istioctlmocks.Commander{}
cmder.On("Uninstall", mock.AnythingOfType("string"), mock.AnythingOfType("*zap.SugaredLogger")).Return(nil)
cmdResolver := TestCommanderResolver{cmder: &cmder}
proxy := proxymocks.IstioProxyReset{}
provider := clientsetmocks.Provider{}
wrapper := NewDefaultIstioPerformer(cmdResolver, &proxy, &provider)
// when
err := wrapper.Uninstall(kc, "1.2.3", log)
// then
require.NoError(t, err)
cmder.AssertCalled(t, "Uninstall", mock.AnythingOfType("string"), mock.AnythingOfType("*zap.SugaredLogger"))
})
} | explode_data.jsonl/67280 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 851
} | [
2830,
3393,
60336,
40,
267,
815,
3889,
34527,
40687,
12248,
1155,
353,
8840,
836,
8,
341,
16463,
66,
1669,
609,
16712,
82,
11716,
16094,
16463,
66,
8071,
445,
42,
3760,
1676,
1827,
5598,
445,
97717,
1676,
1138,
16463,
66,
8071,
445,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestError(t *testing.T) {
baseError := errors.New("test error")
err := &Error{
Err: baseError,
Type: ErrorTypePrivate,
}
assert.Equal(t, err.Error(), baseError.Error())
assert.Equal(t, H{"error": baseError.Error()}, err.JSON())
assert.Equal(t, err.SetType(ErrorTypePublic), err)
assert.Equal(t, ErrorTypePublic, err.Type)
assert.Equal(t, err.SetMeta("some data"), err)
assert.Equal(t, "some data", err.Meta)
assert.Equal(t, H{
"error": baseError.Error(),
"meta": "some data",
}, err.JSON())
jsonBytes, _ := json.Marshal(err)
assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
err.SetMeta(H{ // nolint: errcheck
"status": "200",
"data": "some data",
})
assert.Equal(t, H{
"error": baseError.Error(),
"status": "200",
"data": "some data",
}, err.JSON())
err.SetMeta(H{ // nolint: errcheck
"error": "custom error",
"status": "200",
"data": "some data",
})
assert.Equal(t, H{
"error": "custom error",
"status": "200",
"data": "some data",
}, err.JSON())
type customError struct {
status string
data string
}
err.SetMeta(customError{status: "200", data: "other data"}) // nolint: errcheck
assert.Equal(t, customError{status: "200", data: "other data"}, err.JSON())
} | explode_data.jsonl/65424 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 523
} | [
2830,
3393,
1454,
1155,
353,
8840,
836,
8,
341,
24195,
1454,
1669,
5975,
7121,
445,
1944,
1465,
1138,
9859,
1669,
609,
1454,
515,
197,
197,
7747,
25,
220,
2331,
1454,
345,
197,
27725,
25,
4600,
929,
16787,
345,
197,
532,
6948,
12808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFixerVirtualBoxGAAttach_Fix(t *testing.T) {
cases := []struct {
Input map[string]interface{}
Expected map[string]interface{}
}{
// No attach field
{
Input: map[string]interface{}{
"type": "virtualbox",
},
Expected: map[string]interface{}{
"type": "virtualbox",
},
},
// Attach field == false
{
Input: map[string]interface{}{
"type": "virtualbox",
"guest_additions_attach": false,
},
Expected: map[string]interface{}{
"type": "virtualbox",
"guest_additions_mode": "upload",
},
},
// Attach field == true
{
Input: map[string]interface{}{
"type": "virtualbox",
"guest_additions_attach": true,
},
Expected: map[string]interface{}{
"type": "virtualbox",
"guest_additions_mode": "attach",
},
},
// Attach field is not a bool
{
Input: map[string]interface{}{
"type": "virtualbox",
"guest_additions_attach": "what",
},
Expected: map[string]interface{}{
"type": "virtualbox",
"guest_additions_attach": "what",
},
},
}
for _, tc := range cases {
var f FixerVirtualBoxGAAttach
input := map[string]interface{}{
"builders": []map[string]interface{}{tc.Input},
}
expected := map[string]interface{}{
"builders": []map[string]interface{}{tc.Expected},
}
output, err := f.Fix(input)
if err != nil {
t.Fatalf("err: %s", err)
}
if !reflect.DeepEqual(output, expected) {
t.Fatalf("unexpected: %#v\nexpected: %#v\n", output, expected)
}
}
} | explode_data.jsonl/33586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 691
} | [
2830,
3393,
25958,
261,
33026,
1611,
16128,
30485,
1400,
941,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
66588,
262,
2415,
14032,
31344,
16094,
197,
197,
18896,
2415,
14032,
31344,
16094,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGetDetailHandler_validate(t *testing.T) {
// database is nil
h := GetDetailHandler{}
err := h.validate()
require.EqualError(t, err, "database cannot be nil")
// success
db := dbtest.Open(t)
defer db.Close()
conn := db.Open()
defer conn.Close()
h = GetDetailHandler{DB: conn}
err = h.validate()
require.NoError(t, err)
} | explode_data.jsonl/7622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
1949,
10649,
3050,
42681,
1155,
353,
8840,
836,
8,
341,
197,
322,
4625,
374,
2092,
198,
9598,
1669,
2126,
10649,
3050,
16094,
9859,
1669,
305,
19520,
741,
17957,
12808,
1454,
1155,
11,
1848,
11,
330,
12216,
4157,
387,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteUser(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
user := th.BasicUser
th.LoginBasic()
testUser := th.SystemAdminUser
_, resp := Client.DeleteUser(testUser.Id)
CheckForbiddenStatus(t, resp)
Client.Logout()
_, resp = Client.DeleteUser(user.Id)
CheckUnauthorizedStatus(t, resp)
Client.Login(testUser.Email, testUser.Password)
user.Id = model.NewId()
_, resp = Client.DeleteUser(user.Id)
CheckNotFoundStatus(t, resp)
user.Id = "junk"
_, resp = Client.DeleteUser(user.Id)
CheckBadRequestStatus(t, resp)
_, resp = Client.DeleteUser(testUser.Id)
CheckNoError(t, resp)
} | explode_data.jsonl/21532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
6435,
1474,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
2822,
71724,
1669,
270,
11716,
271,
19060,
1669,
270,
48868,
1474,
198,
70479,
32499,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetPubKey(t *testing.T) {
// For testing purposes, use the aikblob if it exists. Otherwise, just skip
// this test. TODO(tmroeder): implement AIK creation so we can always run
// this test.
rwc := openTPMOrSkip(t)
defer rwc.Close()
// Get the key from aikblob, assuming it exists. Otherwise, skip the test.
blob, err := ioutil.ReadFile("./aikblob")
if err != nil {
t.Skip("No aikblob file; skipping test")
}
// Load the AIK for the quote.
// We're using the well-known authenticator of 20 bytes of zeros.
srkAuth := getAuth(srkAuthEnvVar)
handle, err := LoadKey2(rwc, blob, srkAuth[:])
if err != nil {
t.Fatal("Couldn't load the AIK into the TPM and get a handle for it:", err)
}
defer CloseKey(rwc, handle)
k, err := GetPubKey(rwc, handle, srkAuth[:])
if err != nil {
t.Fatal("Couldn't get the pub key for the AIK")
}
if len(k) == 0 {
t.Fatal("Couldn't get a pubkey blob from an AIK")
}
} | explode_data.jsonl/75351 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
1949,
29162,
1592,
1155,
353,
8840,
836,
8,
341,
197,
322,
1752,
7497,
9895,
11,
990,
279,
264,
1579,
35112,
421,
432,
6724,
13,
18214,
11,
1101,
10706,
198,
197,
322,
419,
1273,
13,
5343,
64190,
299,
7294,
1648,
4211,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestHashMapForeach(t *testing.T) {
hashMap := collections.NewHashMap()
hashMap.Put(0, "0")
hashMap.Put(1, "1")
hashMap.Put(2, "2")
hashMap.Foreach(func(key interface{}, value interface{}) bool {
if key == 0 && value != "0" {
t.Errorf("an error occured: v != 0")
}
if key == 1 && value != "1" {
t.Errorf("an error occured: v != 1")
}
if key == 2 && value != "2" {
t.Errorf("an error occured: v != 2")
}
return true
})
} | explode_data.jsonl/56485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
18497,
37,
8539,
1155,
353,
8840,
836,
8,
220,
341,
50333,
2227,
1669,
15302,
7121,
18497,
741,
50333,
2227,
39825,
7,
15,
11,
330,
15,
1138,
50333,
2227,
39825,
7,
16,
11,
330,
16,
1138,
50333,
2227,
39825,
7,
17,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func Test_gcpSecretUpdater_update(t *testing.T) {
testError := errors.New("test-error")
type fields struct {
connection secretDataCreator
config secretDataCreator
}
tests := map[string]struct {
fields fields
args *corev1.Secret
wantErr error
}{"CreateConnectionFailed": {
fields: fields{
connection: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return testError
},
},
config: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return nil
},
},
},
wantErr: errors.Wrapf(testError, errorFailedToCreateConnectionData),
},
"CreateConfigFailed": {
fields: fields{
connection: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return nil
},
},
config: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return testError
},
},
},
wantErr: errors.Wrapf(testError, errorFailedToCreateConfigData),
},
"Successful": {
fields: fields{
connection: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return nil
},
},
config: &mockSecretDataCreator{
mockCreate: func(secret *corev1.Secret) error {
return nil
},
},
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
u := &gcpSecretUpdater{
connection: tt.fields.connection,
config: tt.fields.config,
}
if diff := cmp.Diff(u.update(tt.args), tt.wantErr, cmpErrors); diff != "" {
t.Errorf("gcpSecretUpdater.update() error %s", diff)
}
})
}
} | explode_data.jsonl/53738 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 726
} | [
2830,
3393,
1889,
4672,
19773,
79854,
8882,
1155,
353,
8840,
836,
8,
341,
18185,
1454,
1669,
5975,
7121,
445,
1944,
18917,
1138,
13158,
5043,
2036,
341,
197,
54590,
6234,
1043,
31865,
198,
197,
25873,
257,
6234,
1043,
31865,
198,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMetdatasString(t *testing.T) {
for _, tt := range []struct {
name string
input Metadatas
want string
}{
{
name: "one meta",
input: Metadatas{
&Metadata{
Key: "foo",
Value: "bar",
},
},
want: "metadata:foo bar;",
},
{
name: "three meta",
input: Metadatas{
&Metadata{
Key: "created_at",
Value: "2019_01_01",
},
&Metadata{
Key: "updated_at",
Value: "2019_01_07",
},
&Metadata{
Key: "target",
Value: "Windows",
},
},
want: "metadata:created_at 2019_01_01, updated_at 2019_01_07, target Windows;",
},
} {
got := tt.input.String()
if got != tt.want {
t.Fatalf("%s: got %v -- expected %v", tt.name, got, tt.want)
}
}
} | explode_data.jsonl/59680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
34673,
27240,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
6212,
329,
19346,
198,
197,
50780,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
1160... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetHostPortConflicts(t *testing.T) {
pods := []*api.Pod{
{Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 80}}}}}},
{Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 81}}}}}},
{Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 82}}}}}},
{Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 83}}}}}},
}
// Pods should not cause any conflict.
if hasHostPortConflicts(pods) {
t.Errorf("expected no conflicts, Got conflicts")
}
expected := &api.Pod{
Spec: api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 81}}}}},
}
// The new pod should cause conflict and be reported.
pods = append(pods, expected)
if !hasHostPortConflicts(pods) {
t.Errorf("expected no conflict, Got no conflicts")
}
} | explode_data.jsonl/43324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
1949,
9296,
7084,
15578,
56445,
1155,
353,
8840,
836,
8,
341,
3223,
29697,
1669,
29838,
2068,
88823,
515,
197,
197,
90,
8327,
25,
6330,
88823,
8327,
90,
74632,
25,
3056,
2068,
33672,
2979,
68273,
25,
3056,
2068,
33672,
7084,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUGetFundingHistory(t *testing.T) {
t.Parallel()
_, err := b.UGetFundingHistory(context.Background(), currency.NewPair(currency.BTC, currency.USDT), 1, time.Time{}, time.Time{})
if err != nil {
t.Error(err)
}
_, err = b.UGetFundingHistory(context.Background(), currency.NewPair(currency.LTC, currency.USDT), 1, time.Unix(1577836800, 0), time.Unix(1580515200, 0))
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
52,
1949,
37,
37189,
13424,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
5255,
1949,
37,
37189,
13424,
5378,
19047,
1507,
11413,
7121,
12443,
90475,
1785,
7749,
11,
11413,
67672,
10599,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestReservedVariables(t *testing.T) {
_, err := fixture(t, "invalid/reserved-variables.workflow")
pe := extractParserError(t, err)
assert.Equal(t, "nope", pe.Actions[0].Env["GITHUB_FOO"])
assert.Equal(t, "yup", pe.Actions[0].Env["GITHUB_TOKEN"])
assert.Equal(t, []string{"GITHUB_BAR", "GITHUB_TOKEN"}, pe.Actions[1].Secrets)
} | explode_data.jsonl/55699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
53003,
22678,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
12507,
1155,
11,
330,
11808,
32426,
2771,
12,
18616,
72774,
1138,
197,
375,
1669,
8649,
6570,
1454,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
330,
2152,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFunction(t *testing.T) {
for _, tc := range []struct{
input []int
expected int
}{
{
[]int{},
5,
},
{
[]int{},
0,
},
}{
actual := 1
if actual != tc.expected {
t.Errorf("expected %v, got %v", tc.expected, actual)
}
}
} | explode_data.jsonl/47477 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
5152,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
515,
197,
22427,
3056,
396,
198,
197,
42400,
526,
198,
197,
59403,
197,
197,
515,
298,
197,
1294,
396,
38837,
298,
197,
20,
345,
197,
197,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSentenceCase(t *testing.T) {
input := inputInfo{}
output := outputInfo{
Tags: map[string]string{
"Capitalized words": "capitalized words",
"Machine": "machine",
"Rise of the machines": "Rise Of The Machines",
"Chanson d'avant": "Chanson D'Avant",
"Names like o'hara, d’arcy": "Names LIKE O'HARA, D’ARCY",
"Names like McDonald and MacNeil": "Names LIKE MCDONALD AND MACNEIL",
"XIV LIV xiv liv. Liv. Xiv.": "XIV LIV xiv liv. liv. xiv.",
"Foo & the bar": "foo & the bar",
},
}
buf, err := ioutil.ReadFile(scriptCase)
if err != nil {
t.Fatal("Script is not readable", err)
}
// Compile scripts.
L := MakeSandbox(nil)
SandboxCompileScript(L, "case", string(buf))
if err != nil {
t.Fatal("Spurious sandbox", err)
}
defer L.Close()
// Set setencecase.
L.PushBoolean(true)
L.SetGlobal("scase")
err = RunScript(L, "case", &input, &output)
if err != nil {
t.Fatalf("script case: %s", err)
}
for want, got := range output.Tags {
if got != want {
t.Errorf(`Got "%v", want "%v"`, got, want)
}
}
} | explode_data.jsonl/68142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
84564,
4207,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
1946,
1731,
16094,
21170,
1669,
2550,
1731,
515,
197,
10261,
2032,
25,
2415,
14032,
30953,
515,
298,
197,
1,
63593,
1506,
4244,
788,
2290,
330,
65063,
1506,
4244,
756,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestE2e(t *testing.T) {
// Run tests through the Ginkgo runner with output to console + JUnit for reporting
var r []ginkgo.Reporter
if framework.TestContext.ReportDir != "" {
klog.Infof("Saving reports to %s", framework.TestContext.ReportDir)
// TODO: we should probably only be trying to create this directory once
// rather than once-per-Ginkgo-node.
if err := os.MkdirAll(framework.TestContext.ReportDir, 0755); err != nil {
klog.Errorf("Failed creating report directory: %v", err)
} else {
r = append(r, reporters.NewJUnitReporter(path.Join(framework.TestContext.ReportDir, fmt.Sprintf("junit_%v%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode))))
}
}
gomega.RegisterFailHandler(framework.Fail)
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "E2e Suite", r)
} | explode_data.jsonl/76534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
36,
17,
68,
1155,
353,
8840,
836,
8,
341,
197,
322,
6452,
7032,
1526,
279,
479,
766,
3346,
22259,
448,
2550,
311,
2339,
488,
619,
4562,
369,
12827,
198,
2405,
435,
3056,
70,
766,
3346,
25702,
261,
198,
743,
12626,
8787,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTLS_Opts(t *testing.T) {
type fields struct {
Enabled bool
Cert string
Key string
CA string
}
type want struct {
want []tls.Option
}
type test struct {
name string
fields fields
want want
checkFunc func(want, []tls.Option) error
beforeFunc func()
afterFunc func()
}
defaultCheckFunc := func(w want, got []tls.Option) error {
if len(w.want) != len(got) {
return errors.Errorf("len(got) = %d, len(want) = %d", len(got), len(w.want))
}
return nil
}
tests := []test{
{
name: "returns []tls.Option",
fields: fields{
Enabled: true,
Cert: "cert",
Key: "key",
CA: "ca",
},
want: want{
want: []tls.Option{
tls.WithCa("ca"),
tls.WithCert("cert"),
tls.WithKey("key"),
tls.WithInsecureSkipVerify(false),
},
},
},
{
name: "returns []tls.Option",
want: want{
want: []tls.Option{
tls.WithCa(""),
tls.WithCert(""),
tls.WithKey(""),
tls.WithInsecureSkipVerify(false),
},
},
},
}
for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
if test.beforeFunc != nil {
test.beforeFunc()
}
if test.afterFunc != nil {
defer test.afterFunc()
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
t := &TLS{
Enabled: test.fields.Enabled,
Cert: test.fields.Cert,
Key: test.fields.Key,
CA: test.fields.CA,
}
got := t.Opts()
if err := test.checkFunc(test.want, got); err != nil {
tt.Errorf("error = %v", err)
}
})
}
} | explode_data.jsonl/49614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 802
} | [
2830,
3393,
45439,
2232,
12754,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
5462,
1807,
198,
197,
6258,
529,
262,
914,
198,
197,
55242,
257,
914,
198,
197,
197,
5049,
414,
914,
198,
197,
532,
13158,
1366,
2036,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestKubectlRender(t *testing.T) {
tests := []struct {
description string
builds []graph.Artifact
input string
expected string
}{
{
description: "normal render",
builds: []graph.Artifact{
{
ImageName: "gcr.io/k8s-skaffold/skaffold",
Tag: "gcr.io/k8s-skaffold/skaffold:test",
},
},
input: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/k8s-skaffold/skaffold
name: skaffold
`,
expected: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/k8s-skaffold/skaffold:test
name: skaffold
`,
},
{
description: "two artifacts",
builds: []graph.Artifact{
{
ImageName: "gcr.io/project/image1",
Tag: "gcr.io/project/image1:tag1",
},
{
ImageName: "gcr.io/project/image2",
Tag: "gcr.io/project/image2:tag2",
},
},
input: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/project/image1
name: image1
- image: gcr.io/project/image2
name: image2
`,
expected: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/project/image1:tag1
name: image1
- image: gcr.io/project/image2:tag2
name: image2
`,
},
{
description: "no artifacts",
builds: nil,
input: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: image1:tag1
name: image1
- image: image2:tag2
name: image2
`,
expected: `apiVersion: v1
kind: Pod
metadata:
namespace: default
spec:
containers:
- image: gcr.io/project/image1:tag1
name: image1
- image: gcr.io/project/image2:tag2
name: image2
`,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
tmpDir := t.NewTempDir().Write("deployment.yaml", test.input)
t.Override(&util.DefaultExecCommand, testutil.
CmdRunOut("kubectl version --client -ojson", KubectlVersion112).
AndRunOut("kubectl --context kubecontext create --dry-run -oyaml -f "+tmpDir.Path("deployment.yaml"), test.input))
deployer, err := NewDeployer(&kubectlConfig{
workingDir: ".",
defaultRepo: "gcr.io/project",
}, &label.DefaultLabeller{}, &latestV1.KubectlDeploy{
Manifests: []string{tmpDir.Path("deployment.yaml")},
})
t.RequireNoError(err)
var b bytes.Buffer
err = deployer.Render(context.Background(), &b, test.builds, true, "")
t.CheckNoError(err)
t.CheckDeepEqual(test.expected, b.String())
})
}
} | explode_data.jsonl/52881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1145
} | [
2830,
3393,
42,
53380,
6750,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
69371,
82,
414,
3056,
4439,
50064,
20754,
198,
197,
22427,
981,
914,
198,
197,
42400,
262,
914,
198,
197,
59403,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRouterGroupMatch(t *testing.T) {
// Create empty handler
h := new(Handler)
// Create empty context
c := new(Context)
c.Params = Params{}
// Create group
g := RouteGroup("/v1")
g.Add("/test/:param", h)
// Matching routes
rs := []string{"/v1/test/test", "/v1/test/:param/"}
// Check
for _, s := range rs {
if !g.Match(s, c) {
t.Errorf("'%s' should match", s)
}
}
} | explode_data.jsonl/35810 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
9523,
2808,
8331,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
4287,
7013,
198,
9598,
1669,
501,
7,
3050,
692,
197,
322,
4230,
4287,
2266,
198,
1444,
1669,
501,
14001,
340,
1444,
58268,
284,
34352,
31483,
197,
322,
4230,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAuthorizeWithLocksForLocalUser(t *testing.T) {
t.Parallel()
ctx := context.Background()
srv, err := NewTestAuthServer(TestAuthServerConfig{
Dir: t.TempDir(),
Clock: clockwork.NewFakeClock(),
})
require.NoError(t, err)
user, _, err := CreateUserAndRole(srv.AuthServer, "test-user", []string{})
require.NoError(t, err)
localUser := LocalUser{
Username: user.GetName(),
Identity: tlsca.Identity{
Username: user.GetName(),
Groups: []string{"test-role-1"},
MFAVerified: "mfa-device-id",
},
}
// Apply an MFA lock.
mfaLock, err := types.NewLock("mfa-lock", types.LockSpecV2{
Target: types.LockTarget{MFADevice: localUser.Identity.MFAVerified},
})
require.NoError(t, err)
require.NoError(t, srv.AuthServer.UpsertLock(ctx, mfaLock))
upsertLockWithPutEvent(ctx, t, srv, mfaLock)
_, err = srv.Authorizer.Authorize(context.WithValue(ctx, ContextUser, localUser))
require.Error(t, err)
require.True(t, trace.IsAccessDenied(err))
// Remove the MFA record from the user value being authorized.
localUser.Identity.MFAVerified = ""
_, err = srv.Authorizer.Authorize(context.WithValue(ctx, ContextUser, localUser))
require.NoError(t, err)
// Create a lock targeting the role written in the user's identity.
roleLock, err := types.NewLock("role-lock", types.LockSpecV2{
Target: types.LockTarget{Role: localUser.Identity.Groups[0]},
})
require.NoError(t, err)
require.NoError(t, srv.AuthServer.UpsertLock(ctx, roleLock))
upsertLockWithPutEvent(ctx, t, srv, roleLock)
_, err = srv.Authorizer.Authorize(context.WithValue(ctx, ContextUser, localUser))
require.Error(t, err)
require.True(t, trace.IsAccessDenied(err))
} | explode_data.jsonl/10803 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 641
} | [
2830,
3393,
37483,
2354,
11989,
82,
2461,
7319,
1474,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
2266,
19047,
2822,
1903,
10553,
11,
1848,
1669,
1532,
2271,
5087,
5475,
31159,
5087,
5475,
2648,
515,
197,
197,
618... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSequenceNoOverflow(t *testing.T) {
// Forcefully set the next sequence number to the maximum
backend := InitForTesting(DEBUG)
sequenceNo = ^uint64(0)
log := NewLogger("test")
log.Debug("test")
if MemoryRecordN(backend, 0).ID != 0 {
t.Errorf("Unexpected sequence no: %v", MemoryRecordN(backend, 0).ID)
}
} | explode_data.jsonl/76183 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
14076,
2753,
42124,
1155,
353,
8840,
836,
8,
341,
197,
322,
11732,
3641,
738,
279,
1790,
8500,
1372,
311,
279,
7192,
198,
197,
20942,
1669,
15690,
2461,
16451,
52792,
340,
197,
15512,
2753,
284,
6306,
2496,
21,
19,
7,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderRTBHouse, config.Adapter{
Endpoint: testsBidderEndpoint})
if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
}
adapterstest.RunJSONBidderTest(t, testsDir, bidder)
} | explode_data.jsonl/7139 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
5014,
39571,
1155,
353,
8840,
836,
8,
341,
2233,
307,
1107,
11,
1936,
7747,
1669,
20626,
30981,
3342,
65,
9927,
1785,
307,
1107,
5350,
33,
28607,
11,
2193,
34190,
515,
197,
197,
27380,
25,
7032,
65452,
1107,
27380,
8824,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_extractFields(t *testing.T) {
r, err := http.NewRequest("GET", "/test?value1=1&value2=2", nil)
assert.NoError(t, err)
f := extractFields(r)
assert.Len(t, f, 2)
assert.Equal(t, "1", f["value1"])
assert.Equal(t, "2", f["value2"])
} | explode_data.jsonl/54951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
39123,
8941,
1155,
353,
8840,
836,
8,
341,
7000,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
3521,
1944,
30,
957,
16,
28,
16,
5,
957,
17,
28,
17,
497,
2092,
340,
6948,
35699,
1155,
11,
1848,
340,
1166,
1669,
8649,
894... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewSessionWithMissingSoftwareName(t *testing.T) {
if testing.Short() {
t.Skip("skip test in short mode")
}
sess, err := oonimkall.NewSession(&oonimkall.SessionConfig{
StateDir: "../testdata/oonimkall/state",
})
if err == nil || err.Error() != "AssetsDir is empty" {
t.Fatal("not the error we expected")
}
if sess != nil {
t.Fatal("expected a nil Session here")
}
} | explode_data.jsonl/78948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
3564,
5283,
2354,
25080,
19250,
675,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
20599,
1273,
304,
2805,
3856,
1138,
197,
532,
1903,
433,
11,
1848,
1669,
297,
263,
318,
74,
541,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestMulNonCommutativeInt64(t *testing.T) {
f := func(x, y *Int64) bool {
// t.Logf("x = %v, y = %v", x, y)
l := new(Int64).Commutator(x, y)
zero := new(Int64)
return !l.Equals(zero)
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)
}
} | explode_data.jsonl/29662 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
59155,
8121,
1092,
6984,
1388,
1072,
21,
19,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
2915,
2075,
11,
379,
353,
1072,
21,
19,
8,
1807,
341,
197,
197,
322,
259,
98954,
445,
87,
284,
1018,
85,
11,
379,
284,
1018,
85,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRepoExpander_ExpandPlatform(t *testing.T) {
tests := []struct {
name string
input string
want string
}{
{
name: "github",
input: "g",
want: "github.com",
},
{
name: "default",
input: "",
want: "github.com",
},
{
name: "bitbucket",
input: "bb",
want: "bitbucket.org",
},
{
name: "fallback",
input: "alkjsdhflkashdflakjhsdf",
want: "alkjsdhflkashdflakjhsdf",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rs := NewRepoExpander()
if got := rs.ExpandPlatform(tt.input); got != tt.want {
t.Errorf("RepoExpander.ExpandPlatform() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/22609 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
25243,
8033,
8199,
62,
38946,
17296,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
914,
198,
197,
50780,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetPendings_NilMsgPayload(t *testing.T) {
t.Parallel()
mc := minimock.NewController(t)
ctx := inslogger.TestContext(t)
meta := payload.Meta{
Polymorph: uint32(payload.TypeMeta),
Payload: nil,
}
handler := handle.NewGetPendings(nil, meta, false)
err := handler.Present(ctx, flow.NewFlowMock(mc))
require.Error(t, err)
} | explode_data.jsonl/68630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
1949,
47,
408,
819,
1604,
321,
6611,
29683,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
97662,
1669,
21187,
1176,
7121,
2051,
1155,
692,
20985,
1669,
1640,
9786,
8787,
1972,
1155,
340,
84004,
1669,
7729,
58806,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestModuleMarkdown_Init(t *testing.T) {
type args struct {
cbs *bfe_module.BfeCallbacks
whs *web_monitor.WebHandlers
cr string
wantErr bool
}
// normal test case
m := NewModuleMarkdown()
case0 := args{
cbs: bfe_module.NewBfeCallbacks(),
whs: web_monitor.NewWebHandlers(),
cr: "./testdata",
wantErr: false,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
// not exist path test case
m = NewModuleMarkdown()
case0 = args{
cbs: bfe_module.NewBfeCallbacks(),
whs: web_monitor.NewWebHandlers(),
cr: "./notexist",
wantErr: true,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
// normal case
m = NewModuleMarkdown()
case0 = args{
cbs: bfe_module.NewBfeCallbacks(),
whs: nil,
cr: "./testdata",
wantErr: true,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
// no register pointer case
m = NewModuleMarkdown()
case0 = args{
cbs: &bfe_module.BfeCallbacks{},
whs: web_monitor.NewWebHandlers(),
cr: "./testdata",
wantErr: true,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
// no data case
m = NewModuleMarkdown()
case0 = args{
cbs: &bfe_module.BfeCallbacks{},
whs: web_monitor.NewWebHandlers(),
cr: "./testdata/case0",
wantErr: true,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
// no data case
m = NewModuleMarkdown()
case0 = args{
cbs: &bfe_module.BfeCallbacks{},
whs: web_monitor.NewWebHandlers(),
cr: "./testdata/case1",
wantErr: true,
}
if err := m.Init(case0.cbs, case0.whs, case0.cr); (err != nil) != case0.wantErr {
t.Errorf("ModuleMarkdown.Init() error = %v, wantErr %v", err, case0.wantErr)
}
} | explode_data.jsonl/3777 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1074
} | [
2830,
3393,
3332,
68005,
15644,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1444,
1279,
257,
353,
65,
1859,
10750,
1785,
1859,
44461,
198,
197,
197,
1312,
82,
257,
353,
2911,
40112,
6473,
39949,
198,
197,
91492,
414,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestNewExifEditorEmpty(t *testing.T) {
tests := []bool{false, true}
for _, flag := range tests {
ee, err := NewExifEditorEmpty(flag)
if err != nil {
t.Errorf("Could not create empty exif editor with flag %v got error: %v", flag, err)
}
if ee.dirty != flag {
t.Errorf("Expected dirty to be %v got %v", flag, ee.dirty)
}
if ee.rootIb == nil {
t.Errorf("Expected rootIb to not be nil")
}
}
} | explode_data.jsonl/79877 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 176
} | [
2830,
3393,
3564,
840,
333,
9410,
3522,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
2641,
90,
3849,
11,
830,
532,
2023,
8358,
5181,
1669,
2088,
7032,
341,
197,
197,
2127,
11,
1848,
1669,
1532,
840,
333,
9410,
3522,
33104,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestEnqueueAfter(t *testing.T) {
impl := NewImplWithStats(&nopReconciler{}, TestLogger(t), "Testing", &FakeStatsReporter{})
t.Cleanup(func() {
impl.WorkQueue().ShutDown()
})
// Enqueue two items with a long delay.
impl.EnqueueAfter(&Resource{
ObjectMeta: metav1.ObjectMeta{
Name: "for",
Namespace: "waiting",
},
}, longDelay)
impl.EnqueueAfter(&Resource{
ObjectMeta: metav1.ObjectMeta{
Name: "waterfall",
Namespace: "the",
},
}, longDelay)
// Enqueue one item with a short delay.
enqueueTime := time.Now()
impl.EnqueueAfter(&Resource{
ObjectMeta: metav1.ObjectMeta{
Name: "fall",
Namespace: "to",
},
}, shortDelay)
// Keep checking the queue length until 'to/fall' gets enqueued, send to channel to indicate success.
queuePopulated := make(chan int)
ctx, cancel := context.WithTimeout(context.Background(), queueCheckTimeout)
t.Cleanup(func() {
close(queuePopulated)
cancel()
})
go wait.PollImmediateUntil(5*time.Millisecond,
pollQ(impl.WorkQueue(), queuePopulated), ctx.Done())
select {
case qlen := <-queuePopulated:
if enqueueDelay := time.Since(enqueueTime); enqueueDelay < shortDelay {
t.Errorf("Item enqueued within %v, expected at least a %v delay", enqueueDelay, shortDelay)
}
if got, want := qlen, 1; got != want {
t.Errorf("|Queue| = %d, want: %d", got, want)
}
case <-ctx.Done():
t.Fatal("Timed out waiting for item to be put onto the workqueue")
}
impl.WorkQueue().ShutDown()
got, want := drainWorkQueue(impl.WorkQueue()), []types.NamespacedName{{Namespace: "to", Name: "fall"}}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Unexpected workqueue state (-:expect, +:got):\n%s", diff)
}
} | explode_data.jsonl/45283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 657
} | [
2830,
3393,
1702,
4584,
6025,
1155,
353,
8840,
836,
8,
341,
197,
6383,
1669,
1532,
9673,
2354,
16635,
2099,
62813,
693,
40446,
5769,
22655,
3393,
7395,
1155,
701,
330,
16451,
497,
609,
52317,
16635,
52766,
37790,
3244,
727,
60639,
18552,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestState_EachUser(t *testing.T) {
t.Parallel()
st := setupNewState()
st.addUser(users[0])
st.addUser(users[1])
i := 0
st.EachUser(func(u User) bool {
has := false
for _, user := range users {
if user == string(u.Host) {
has = true
break
}
}
if got, exp := has, true; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
i++
return false
})
if got, exp := i, 2; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
} | explode_data.jsonl/32084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
1397,
2089,
610,
1474,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18388,
1669,
6505,
3564,
1397,
741,
18388,
1364,
1474,
35438,
58,
15,
2546,
18388,
1364,
1474,
35438,
58,
16,
2546,
8230,
1669,
220,
15,
198,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestInvokeNOKInvokesNotExt(t *testing.T) {
t.Run("1.2Capability", func(t *testing.T) {
l, v, cleanup := setupLedgerAndValidatorWithV12Capabilities(t)
defer cleanup()
testInvokeNOKInvokesNotExt(t, l, v)
})
t.Run("1.3Capability", func(t *testing.T) {
l, v, cleanup := setupLedgerAndValidatorWithV13Capabilities(t)
defer cleanup()
testInvokeNOKInvokesNotExt(t, l, v)
})
} | explode_data.jsonl/47809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
17604,
45,
3925,
15174,
7940,
2623,
6756,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
16,
13,
17,
63746,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
8810,
11,
348,
11,
21290,
1669,
6505,
60850,
1389,
3036,
14256,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParseXML(t *testing.T) {
f, err := os.Open("./examples/xmind/content.xml.ok")
assert.NoError(t, err)
m, err := ParseXML(f)
assert.NoError(t, err)
spew.Dump(m)
} | explode_data.jsonl/30056 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
14463,
10609,
1155,
353,
8840,
836,
8,
341,
1166,
11,
1848,
1669,
2643,
12953,
13988,
51668,
10776,
37724,
27917,
9028,
18165,
1138,
6948,
35699,
1155,
11,
1848,
340,
2109,
11,
1848,
1669,
14775,
10609,
955,
340,
6948,
35699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestLoad(t *testing.T) {
tests := []struct {
name string
composeFile string
expConfig types.Config
expError error
}{
{
name: "invalid YAML",
composeFile: `version: "3"
ignoreme:
foo
bar:`,
expError: errors.NewFriendlyError(
"Failed to parse Compose file (docker-compose.yml)\n" +
"Error: yaml: line 4: mapping values are not allowed in this context\n\n" +
"3 | foo\n" +
"\x1b[33m4 | bar:\x1b[0m"),
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
fs = afero.NewMemMapFs()
assert.NoError(t, afero.WriteFile(fs, "docker-compose.yml", []byte(test.composeFile), 0644))
config, err := Load("docker-compose.yml", nil)
assert.Equal(t, test.expError, err)
assert.Equal(t, test.expConfig, config)
})
}
} | explode_data.jsonl/8480 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
5879,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
32810,
2900,
1703,
914,
198,
197,
48558,
2648,
256,
4494,
10753,
198,
197,
48558,
1454,
262,
1465,
198,
197,
59403,
197,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_scheduler(t *testing.T) {
g := gomega.NewGomegaWithT(t)
t.Run("should schedule resources as wake and send the report", func(t *testing.T) {
config := &SchedulerConfig{
Report: Report{
SendReport: true,
Hour: 9,
},
Period: Period{
Pattern: officeHours,
},
TimeZone: "Europe/Helsinki",
Resources: map[string]Resource{
"i-123": {
Type: elasticComputeCloud,
Identifier: "i-123",
},
"i-456": {
Type: elasticComputeCloud,
Identifier: "i-456",
},
"cluster-name:service-name": {
Type: fargate,
Identifier: "cluster-name:service-name",
},
},
}
client := &SchedulerConfigClient{
Config: config,
now: func() time.Time {
return insideOfficeHourAndDay
},
}
factory := ResourceClientsFactory{}
factory[elasticComputeCloud] = &EC2{client: ec2ClientMock{}}
factory[fargate] = &Fargate{client: fargateClientMock{}}
service := SchedulerService{
Config: config,
SchedulerConfigClient: client,
Factory: factory,
MessageBus: messageBusMock{},
}
got, err := service.Execute()
if err != nil {
t.Error(err)
return
}
report, err := service.sendReport(got)
if err != nil {
t.Error(err)
}
g.Expect(len(got)).To(gomega.Equal(3))
g.Expect(got["i-123"].State).To(gomega.Equal("running"))
g.Expect(got["service-name"].State).To(gomega.Equal("1"))
g.Expect(strings.Contains(report, "EC2 with id i-456 has status: running")).To(gomega.Equal(true))
g.Expect(strings.Contains(report, "EC2 with id i-123 has status: running")).To(gomega.Equal(true))
g.Expect(strings.Contains(report, "Fargate with id service-name has tasks running count of: 1")).To(gomega.Equal(true))
})
t.Run("should schedule resources as sleeping and not print the report", func(t *testing.T) {
config := &SchedulerConfig{
Report: Report{
SendReport: true,
Hour: 9,
},
Period: Period{
Pattern: officeHours,
},
TimeZone: "Europe/Helsinki",
Resources: map[string]Resource{
"i-123": {
Type: elasticComputeCloud,
Identifier: "i-123",
},
"i-456": {
Type: elasticComputeCloud,
Identifier: "i-456",
},
"cluster-name:service-name": {
Type: fargate,
Identifier: "cluster-name:service-name",
},
},
}
client := &SchedulerConfigClient{
Config: config,
now: func() time.Time {
return outsideOfficeHourButNotDay
},
}
factory := ResourceClientsFactory{}
factory[elasticComputeCloud] = &EC2{client: ec2ClientMock{}}
factory[fargate] = &Fargate{client: fargateClientMock{}}
service := SchedulerService{
Config: config,
SchedulerConfigClient: client,
Factory: factory,
MessageBus: messageBusMock{},
}
got, err := service.Execute()
if err != nil {
t.Error(err)
return
}
report, err := service.sendReport(got)
if err != nil {
t.Error(err)
}
g.Expect(len(got)).To(gomega.Equal(3))
g.Expect(got["i-123"].State).To(gomega.Equal("stopped"))
g.Expect(got["service-name"].State).To(gomega.Equal("0"))
g.Expect(report).To(gomega.Equal(""))
})
} | explode_data.jsonl/14910 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1498
} | [
2830,
3393,
53646,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
3244,
16708,
445,
5445,
9700,
4963,
438,
15156,
323,
3624,
279,
1895,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
25873,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_reconcileBEMemLimit(t *testing.T) {
type args struct {
podMeta *statesinformer.PodMeta
podCurMemLimit int64
containerCurMemLimit map[string]int64
wantPodMemLimit int64
wantContainerMemLimit map[string]int64
}
tests := []struct {
name string
args args
}{
{
name: "set-mem-limit",
args: args{
podMeta: &statesinformer.PodMeta{
Pod: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test-ns",
Name: "test-name",
UID: "test-pod-uid",
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "test-container-1",
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
extension.BatchMemory: *resource.NewQuantity(512, resource.BinarySI),
},
Requests: corev1.ResourceList{
extension.BatchMemory: *resource.NewQuantity(512, resource.BinarySI),
},
},
},
{
Name: "test-container-2",
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
extension.BatchMemory: *resource.NewQuantity(1024, resource.BinarySI),
},
Requests: corev1.ResourceList{
extension.BatchMemory: *resource.NewQuantity(1024, resource.BinarySI),
},
},
},
},
},
Status: corev1.PodStatus{
ContainerStatuses: []corev1.ContainerStatus{
{
Name: "test-container-1",
ContainerID: "docker://testcontainer1hashid",
},
{
Name: "test-container-2",
ContainerID: "docker://testcontainer2hashid",
},
},
},
},
CgroupDir: "kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-podtest_pod_uid.slice",
},
podCurMemLimit: defaultMemUnlimit,
containerCurMemLimit: map[string]int64{
"test-container-1": defaultMemUnlimit,
"test-container-2": defaultMemUnlimit,
},
wantPodMemLimit: 1536,
wantContainerMemLimit: map[string]int64{
"test-container-1": 512,
"test-container-2": 1024,
},
},
},
}
for _, tt := range tests {
system.Conf = system.NewDsModeConfig()
system.Conf.CgroupRootDir, _ = ioutil.TempDir("/tmp", "koordlet-test")
err := initTestPodMemLimit(tt.args.podMeta, tt.args.podCurMemLimit, tt.args.containerCurMemLimit)
if err != nil {
t.Errorf("init cpu share failed, error: %v", err)
}
t.Run(tt.name, func(t *testing.T) {
reconcileBEMemLimit(tt.args.podMeta)
podMemLimitResult, err := util.GetPodCurMemLimitBytes(tt.args.podMeta.CgroupDir)
if err != nil {
t.Errorf("get pod mem limit result failed, error %v", err)
}
if podMemLimitResult != tt.args.wantPodMemLimit {
t.Errorf("pod mem limit result not equal, want %v, got %v", tt.args.wantPodMemLimit, podMemLimitResult)
}
for _, containerStat := range tt.args.podMeta.Pod.Status.ContainerStatuses {
containerMemLimitResult, err := util.GetContainerCurMemLimitBytes(tt.args.podMeta.CgroupDir, &containerStat)
if err != nil {
t.Errorf("get container %v mem limit result failed, error %v", containerStat.Name, err)
}
wantContainerMemLimit, exist := tt.args.wantContainerMemLimit[containerStat.Name]
if !exist {
t.Errorf("container %v want mem limit not exist", containerStat.Name)
}
if containerMemLimitResult != wantContainerMemLimit {
t.Errorf("container %v mem limit result not equal, want %v, got %v",
containerStat.Name, wantContainerMemLimit, containerMemLimitResult)
}
}
})
}
} | explode_data.jsonl/38232 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1689
} | [
2830,
3393,
1288,
40446,
457,
33,
2716,
336,
16527,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
3223,
347,
12175,
2290,
353,
32069,
258,
34527,
88823,
12175,
198,
197,
3223,
347,
16704,
18816,
16527,
286,
526,
21,
19,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestNewLogsExporter_NilRequiredFields(t *testing.T) {
_, err := NewLogsProcessor(testCfg, exportertest.NewNopLogsExporter(), nil)
assert.Error(t, err)
_, err = NewLogsProcessor(testCfg, nil, newTestLProcessor(nil))
assert.Equal(t, componenterror.ErrNilNextConsumer, err)
} | explode_data.jsonl/4019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
3564,
51053,
88025,
1604,
321,
8164,
8941,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
1532,
51053,
22946,
8623,
42467,
11,
7485,
83386,
7121,
45,
453,
51053,
88025,
1507,
2092,
340,
6948,
6141,
1155,
11,
1848,
692,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEntropy(t *testing.T) {
_, _, pv := crypto.GenerateTestKeyPair()
signer := crypto.NewSigner(pv)
max := int64(500)
vrf := NewVRF(signer)
vrf.SetMax(max)
entropy := make([]bool, max)
for i := int64(0); i < max; i++ {
h := crypto.GenerateTestHash()
index, _ := vrf.Evaluate(h)
assert.LessOrEqual(t, index, max)
entropy[index] = true
}
hits := int64(0)
for _, b := range entropy {
if b == true {
hits++
}
}
fmt.Printf("Entropy is : %v%% \n", hits*100/max)
assert.Greater(t, hits, int64(50))
} | explode_data.jsonl/2407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
97582,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
33491,
1669,
19028,
57582,
2271,
1592,
12443,
741,
69054,
261,
1669,
19028,
7121,
7264,
261,
1295,
85,
692,
22543,
1669,
526,
21,
19,
7,
20,
15,
15,
340,
5195,
8052,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFeature_String(t *testing.T) {
cases := []struct {
name string
id FeatureID
expected string
}{
{
name: "node",
id: NodeID(1).FeatureID(),
expected: "node/1",
},
{
name: "way",
id: WayID(3).FeatureID(),
expected: "way/3",
},
{
name: "relation",
id: RelationID(1000).FeatureID(),
expected: "relation/1000",
},
{
name: "unknown",
id: 0,
expected: "unknown/0",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if v := tc.id.String(); v != tc.expected {
t.Errorf("incorrect string: %v", v)
}
})
}
} | explode_data.jsonl/54770 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
13859,
31777,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
15710,
981,
19998,
915,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
257,
330,
3509,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTokenizeAlterStatement(t *testing.T) {
parser := NewAlterTableParser()
{
alterStatement := "add column t int"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int"}))
}
{
alterStatement := "add column t int, change column i int"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "change column i int"}))
}
{
alterStatement := "add column t int, change column i int 'some comment'"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "change column i int 'some comment'"}))
}
{
alterStatement := "add column t int, change column i int 'some comment, with comma'"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "change column i int 'some comment, with comma'"}))
}
{
alterStatement := "add column t int, add column d decimal(10,2)"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "add column d decimal(10,2)"}))
}
{
alterStatement := "add column t int, add column e enum('a','b','c')"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "add column e enum('a','b','c')"}))
}
{
alterStatement := "add column t int(11), add column e enum('a','b','c')"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int(11)", "add column e enum('a','b','c')"}))
}
} | explode_data.jsonl/71263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 644
} | [
2830,
3393,
3323,
551,
74290,
8636,
1155,
353,
8840,
836,
8,
341,
55804,
1669,
1532,
74290,
2556,
6570,
741,
197,
515,
197,
197,
37277,
8636,
1669,
330,
718,
3250,
259,
526,
698,
197,
3244,
9713,
11,
716,
1669,
6729,
96790,
74290,
863... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGroupSnapshotWithNoSelector(t *testing.T) {
name := "test-group-snap-no-selector"
expected := "error: PVC label selectors must be provided"
cmdArgs := []string{"create", "groupsnapshots", name}
testCommon(t, cmdArgs, nil, expected, true)
} | explode_data.jsonl/20428 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
2808,
15009,
2354,
2753,
5877,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
330,
1944,
4351,
1331,
6861,
28366,
76127,
698,
42400,
1669,
330,
841,
25,
49866,
2383,
56037,
1969,
387,
3897,
698,
25920,
4117,
1669,
3056,
917,
491... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNoTunnelServerEndpointEds(t *testing.T) {
s := xds.NewFakeDiscoveryServer(t, xds.FakeOptions{})
// Add the test ads clients to list of service instances in order to test the context dependent locality coloring.
addTestClientEndpoints(s.Discovery)
s.Discovery.MemRegistry.AddHTTPService(edsIncSvc, edsIncVip, 8080)
s.Discovery.MemRegistry.SetEndpoints(edsIncSvc, "",
[]*model.IstioEndpoint{
{
Address: "127.0.0.1",
ServicePortName: "http-main",
EndpointPort: 80,
// Labels: map[string]string{"version": version},
ServiceAccount: "hello-sa",
// No Tunnel Support at this endpoint.
TunnelAbility: networking.MakeTunnelAbility(),
},
})
t.Run("TestClientWantsTunnelEndpoints", func(t *testing.T) {
adscConn := s.Connect(&model.Proxy{IPAddresses: []string{"10.10.10.10"}, Metadata: &model.NodeMetadata{
ProxyConfig: &model.NodeMetaProxyConfig{
ProxyMetadata: map[string]string{
"tunnel": networking.H2TunnelTypeName,
},
},
}}, nil, watchAll)
testTunnelEndpoints("127.0.0.1", 80, adscConn, t)
})
t.Run("TestClientWantsNoTunnelEndpoints", func(t *testing.T) {
adscConn := s.Connect(&model.Proxy{IPAddresses: []string{"10.10.10.11"}, Metadata: &model.NodeMetadata{}}, nil, watchAll)
testTunnelEndpoints("127.0.0.1", 80, adscConn, t)
})
} | explode_data.jsonl/7948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
2753,
51,
40292,
5475,
27380,
2715,
82,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
856,
5356,
7121,
52317,
67400,
5475,
1155,
11,
856,
5356,
991,
726,
3798,
6257,
692,
197,
322,
2691,
279,
1273,
13740,
8239,
311,
1140,
315,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIsIncludeMultibyte(t *testing.T) {
tests := []struct {
input string
expected bool
}{
{
"apple",
false,
},
{
"umbrella",
false,
},
{
"----",
false,
},
{
"林檎",
true,
},
{
"かさ",
true,
},
{
"○",
true,
},
{
"Goラング",
true,
},
}
for i, test := range tests {
got := isIncludeMultibyte(test.input)
if got != test.expected {
t.Errorf("tests[%d] got %v, want %v", i, got, test.expected)
}
}
} | explode_data.jsonl/5540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
3872,
22283,
40404,
579,
78361,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
262,
914,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
1,
22377,
756,
298,
36012,
345,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_sort(t *testing.T) {
input := SortableStrings{
"1",
"a",
"10",
"pony",
"11",
"3",
"went",
"2",
"to",
"4",
"market",
"y10",
"y1",
"y20",
"y2",
"z10x10",
"z10x2",
"z10x4",
"z10x3",
"z10x44",
"z10x33",
"z10x1",
}
output := SortableStrings{
"1",
"2",
"3",
"4",
"10",
"11",
"a",
"market",
"pony",
"to",
"went",
"y1",
"y2",
"y10",
"y20",
"z10x1",
"z10x2",
"z10x3",
"z10x4",
"z10x10",
"z10x33",
"z10x44",
}
sort.Sort(input)
if reflect.DeepEqual(input, output) == false {
t.Errorf("Undeisred sorting result: %v\n", strings.Join(input, ", "))
t.Errorf("Wanted : %v\n", strings.Join(output, ", "))
}
} | explode_data.jsonl/40687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 452
} | [
2830,
3393,
18435,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
15967,
480,
20859,
515,
197,
197,
1,
16,
756,
197,
197,
56693,
756,
197,
197,
1,
16,
15,
756,
197,
197,
1,
618,
88,
756,
197,
197,
1,
16,
16,
756,
197,
197,
1,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInjectFilePath(t *testing.T) {
var (
resourceFolder = filepath.Join("inject-filepath", "resources")
expectedFolder = filepath.Join("inject-filepath", "expected")
)
t.Run("read from files", func(t *testing.T) {
testCases := []injectFilePath{
{
resource: "nginx",
resourceFile: filepath.Join(resourceFolder, "nginx.yaml"),
expectedFile: filepath.Join(expectedFolder, "injected_nginx.yaml"),
stdErrFile: filepath.Join(expectedFolder, "injected_nginx.stderr"),
},
{
resource: "redis",
resourceFile: filepath.Join(resourceFolder, "db/redis.yaml"),
expectedFile: filepath.Join(expectedFolder, "injected_redis.yaml"),
stdErrFile: filepath.Join(expectedFolder, "injected_redis.stderr"),
},
}
for i, testCase := range testCases {
testCase := testCase // pin
verbose = true
t.Run(fmt.Sprintf("%d %s", i, testCase.resource), func(t *testing.T) {
testInjectFilePath(t, testCase)
})
verbose = false
t.Run(fmt.Sprintf("%d %s", i, testCase.resource), func(t *testing.T) {
testInjectFilePath(t, testCase)
})
}
})
verbose = true
t.Run("read from folder --verbose", func(t *testing.T) {
testReadFromFolder(t, resourceFolder, expectedFolder)
})
verbose = false
t.Run("read from folder --verbose", func(t *testing.T) {
testReadFromFolder(t, resourceFolder, expectedFolder)
})
} | explode_data.jsonl/22530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
13738,
19090,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
50346,
13682,
284,
26054,
22363,
445,
32133,
14203,
2343,
497,
330,
12745,
1138,
197,
42400,
13682,
284,
26054,
22363,
445,
32133,
14203,
2343,
497,
330,
7325,
1138,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandleNodeSelector(t *testing.T) {
testKubelet := newTestKubelet(t)
kl := testKubelet.kubelet
kl.nodeLister = testNodeLister{nodes: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname, Labels: map[string]string{"key": "B"}}},
}}
kl.nodeInfo = testNodeInfo{nodes: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname, Labels: map[string]string{"key": "B"}}},
}}
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
pods := []*api.Pod{
{
ObjectMeta: api.ObjectMeta{
UID: "123456789",
Name: "podA",
Namespace: "foo",
},
Spec: api.PodSpec{NodeSelector: map[string]string{"key": "A"}},
},
{
ObjectMeta: api.ObjectMeta{
UID: "987654321",
Name: "podB",
Namespace: "foo",
},
Spec: api.PodSpec{NodeSelector: map[string]string{"key": "B"}},
},
}
// The first pod should be rejected.
notfittingPod := pods[0]
kl.HandlePodAdditions(pods)
// Check pod status stored in the status map.
status, found := kl.statusManager.GetPodStatus(notfittingPod.UID)
if !found {
t.Fatalf("status of pod %q is not found in the status map", notfittingPod.UID)
}
if status.Phase != api.PodFailed {
t.Fatalf("expected pod status %q. Got %q.", api.PodFailed, status.Phase)
}
} | explode_data.jsonl/43326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 617
} | [
2830,
3393,
6999,
1955,
5877,
1155,
353,
8840,
836,
8,
341,
18185,
42,
3760,
1149,
1669,
501,
2271,
42,
3760,
1149,
1155,
340,
197,
10561,
1669,
1273,
42,
3760,
1149,
5202,
3760,
1149,
198,
197,
10561,
12097,
852,
261,
284,
1273,
1955... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDeleteSilence(t *testing.T) {
for _, tc := range []struct {
ID string
labelv string
upstream http.Handler
expCode int
expBody []byte
}{
{
// No "namespace" parameter returns an error.
expCode: http.StatusBadRequest,
},
{
// Missing silence ID.
ID: "",
labelv: "default",
expCode: http.StatusBadRequest,
},
{
// The silence doesn't exist upstream.
ID: silID,
labelv: "default",
upstream: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
http.NotFound(w, req)
}),
expCode: http.StatusBadGateway,
},
{
// The silence doesn't contain the expected label.
ID: silID,
labelv: "default",
upstream: getSilenceWithoutLabel(),
expCode: http.StatusForbidden,
},
{
// The silence doesn't have the expected value for the label.
ID: silID,
labelv: "default",
upstream: getSilenceWithLabel("not default"),
expCode: http.StatusForbidden,
},
{
// The silence has the expected value for the label.
ID: silID,
labelv: "default",
upstream: &chainedHandlers{
handlers: []http.Handler{
getSilenceWithLabel("default"),
http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("ok"))
}),
},
},
expCode: http.StatusOK,
expBody: []byte("ok"),
},
{
// The silence has the expected value for the label but upstream returns an error.
ID: silID,
labelv: "default",
upstream: &chainedHandlers{
handlers: []http.Handler{
getSilenceWithLabel("default"),
http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusTeapot)
}),
},
},
expCode: http.StatusTeapot,
},
} {
t.Run("", func(t *testing.T) {
m := newMockUpstream(tc.upstream)
defer m.Close()
r, err := NewRoutes(m.url, proxyLabel)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
u, err := url.Parse(fmt.Sprintf("http://alertmanager.example.com/api/v2/silence/" + tc.ID))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
q := u.Query()
q.Set(proxyLabel, tc.labelv)
u.RawQuery = q.Encode()
w := httptest.NewRecorder()
req := httptest.NewRequest("DELETE", u.String(), nil)
r.ServeHTTP(w, req)
resp := w.Result()
body, _ := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
if resp.StatusCode != tc.expCode {
t.Logf("expected status code %d, got %d", tc.expCode, resp.StatusCode)
t.Logf("%s", string(body))
t.FailNow()
}
if resp.StatusCode != http.StatusOK {
return
}
if string(body) != string(tc.expBody) {
t.Fatalf("expected body %q, got %q", string(tc.expBody), string(body))
}
})
}
} | explode_data.jsonl/75022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1234
} | [
2830,
3393,
6435,
27571,
763,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
29580,
981,
914,
198,
197,
29277,
85,
256,
914,
198,
197,
59810,
4027,
1758,
31010,
271,
197,
48558,
2078,
526,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFillTxMemoryWithMultiBuffer(t *testing.T) {
const bufferSize = 1500
c := newTestContext(t, 20000, bufferSize, localLinkAddr)
defer c.cleanup()
// Prepare to send a packet.
r := stack.Route{
RemoteLinkAddress: remoteLinkAddr,
}
buf := buffer.NewView(100)
// Each packet is uses up one buffer, so write as many as possible
// until there is only one buffer left.
for i := queueDataSize/bufferSize - 1; i > 0; i-- {
hdr := buffer.NewPrependable(int(c.ep.MaxHeaderLength()))
if err := c.ep.WritePacket(&r, &hdr, buf, header.IPv4ProtocolNumber); err != nil {
t.Fatalf("WritePacket failed unexpectedly: %v", err)
}
// Pull the posted buffer.
c.txq.tx.Pull()
c.txq.tx.Flush()
}
// Attempt to write a two-buffer packet. It must fail.
hdr := buffer.NewPrependable(int(c.ep.MaxHeaderLength()))
err := c.ep.WritePacket(&r, &hdr, buffer.NewView(bufferSize), header.IPv4ProtocolNumber)
if want := tcpip.ErrWouldBlock; err != want {
t.Fatalf("WritePacket return unexpected result: got %v, want %v", err, want)
}
// Attempt to write a one-buffer packet. It must succeed.
hdr = buffer.NewPrependable(int(c.ep.MaxHeaderLength()))
if err := c.ep.WritePacket(&r, &hdr, buf, header.IPv4ProtocolNumber); err != nil {
t.Fatalf("WritePacket failed unexpectedly: %v", err)
}
} | explode_data.jsonl/4237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 483
} | [
2830,
3393,
14449,
31584,
10642,
2354,
20358,
4095,
1155,
353,
8840,
836,
8,
341,
4777,
65158,
284,
220,
16,
20,
15,
15,
198,
1444,
1669,
501,
2271,
1972,
1155,
11,
220,
17,
15,
15,
15,
15,
11,
65158,
11,
2205,
3939,
13986,
340,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestK8sPluginConfig_SetFlags(t *testing.T) {
actual := K8sPluginConfig{}
cmdFlags := actual.GetPFlagSet("")
assert.True(t, cmdFlags.HasFlags())
t.Run("Test_inject-finalizer", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("inject-finalizer", testValue)
if vBool, err := cmdFlags.GetBool("inject-finalizer"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vBool), &actual.InjectFinalizer)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_default-cpus", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := defaultK8sConfig.DefaultCPURequest.String()
cmdFlags.Set("default-cpus", testValue)
if vString, err := cmdFlags.GetString("default-cpus"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.DefaultCPURequest)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_default-memory", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := defaultK8sConfig.DefaultMemoryRequest.String()
cmdFlags.Set("default-memory", testValue)
if vString, err := cmdFlags.GetString("default-memory"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.DefaultMemoryRequest)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_scheduler-name", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("scheduler-name", testValue)
if vString, err := cmdFlags.GetString("scheduler-name"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.SchedulerName)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.name", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.name", testValue)
if vString, err := cmdFlags.GetString("co-pilot.name"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.NamePrefix)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.image", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.image", testValue)
if vString, err := cmdFlags.GetString("co-pilot.image"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.Image)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.default-input-path", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.default-input-path", testValue)
if vString, err := cmdFlags.GetString("co-pilot.default-input-path"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.DefaultInputDataPath)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.default-output-path", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.default-output-path", testValue)
if vString, err := cmdFlags.GetString("co-pilot.default-output-path"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.DefaultOutputPath)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.input-vol-name", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.input-vol-name", testValue)
if vString, err := cmdFlags.GetString("co-pilot.input-vol-name"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.InputVolumeName)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.output-vol-name", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.output-vol-name", testValue)
if vString, err := cmdFlags.GetString("co-pilot.output-vol-name"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.OutputVolumeName)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.cpu", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.cpu", testValue)
if vString, err := cmdFlags.GetString("co-pilot.cpu"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.CPU)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.memory", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.memory", testValue)
if vString, err := cmdFlags.GetString("co-pilot.memory"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.Memory)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_co-pilot.storage", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("co-pilot.storage", testValue)
if vString, err := cmdFlags.GetString("co-pilot.storage"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vString), &actual.CoPilot.Storage)
} else {
assert.FailNow(t, err.Error())
}
})
})
t.Run("Test_delete-resource-on-finalize", func(t *testing.T) {
t.Run("Override", func(t *testing.T) {
testValue := "1"
cmdFlags.Set("delete-resource-on-finalize", testValue)
if vBool, err := cmdFlags.GetBool("delete-resource-on-finalize"); err == nil {
testDecodeJson_K8sPluginConfig(t, fmt.Sprintf("%v", vBool), &actual.DeleteResourceOnFinalize)
} else {
assert.FailNow(t, err.Error())
}
})
})
} | explode_data.jsonl/11287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2528
} | [
2830,
3393,
42,
23,
82,
11546,
2648,
14812,
9195,
1155,
353,
8840,
836,
8,
341,
88814,
1669,
730,
23,
82,
11546,
2648,
16094,
25920,
9195,
1669,
5042,
2234,
47,
12135,
1649,
31764,
6948,
32443,
1155,
11,
5439,
9195,
16152,
9195,
12367,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewFormatter(t *testing.T) {
var tests = []struct {
verb string
format string
formatter fabenc.Formatter
errorMsg string
}{
{verb: "color", format: "", formatter: fabenc.ColorFormatter{}},
{verb: "color", format: "bold", formatter: fabenc.ColorFormatter{Bold: true}},
{verb: "color", format: "reset", formatter: fabenc.ColorFormatter{Reset: true}},
{verb: "color", format: "unknown", errorMsg: "invalid color option: unknown"},
{verb: "id", format: "", formatter: fabenc.SequenceFormatter{FormatVerb: "%d"}},
{verb: "id", format: "04x", formatter: fabenc.SequenceFormatter{FormatVerb: "%04x"}},
{verb: "level", format: "", formatter: fabenc.LevelFormatter{FormatVerb: "%s"}},
{verb: "level", format: ".4s", formatter: fabenc.LevelFormatter{FormatVerb: "%.4s"}},
{verb: "message", format: "", formatter: fabenc.MessageFormatter{FormatVerb: "%s"}},
{verb: "message", format: "#30s", formatter: fabenc.MessageFormatter{FormatVerb: "%#30s"}},
{verb: "module", format: "", formatter: fabenc.ModuleFormatter{FormatVerb: "%s"}},
{verb: "module", format: "ok", formatter: fabenc.ModuleFormatter{FormatVerb: "%ok"}},
{verb: "shortfunc", format: "", formatter: fabenc.ShortFuncFormatter{FormatVerb: "%s"}},
{verb: "shortfunc", format: "U", formatter: fabenc.ShortFuncFormatter{FormatVerb: "%U"}},
{verb: "time", format: "", formatter: fabenc.TimeFormatter{Layout: "2006-01-02T15:04:05.999Z07:00"}},
{verb: "time", format: "04:05.999999Z05:00", formatter: fabenc.TimeFormatter{Layout: "04:05.999999Z05:00"}},
{verb: "unknown", format: "", errorMsg: "unknown verb: unknown"},
}
for i, tc := range tests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
f, err := fabenc.NewFormatter(tc.verb, tc.format)
if tc.errorMsg == "" {
assert.NoError(t, err)
assert.Equal(t, tc.formatter, f)
} else {
assert.EqualError(t, err, tc.errorMsg)
}
})
}
} | explode_data.jsonl/10931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 764
} | [
2830,
3393,
3564,
14183,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
197,
22328,
414,
914,
198,
197,
59416,
262,
914,
198,
197,
197,
32941,
9570,
954,
96291,
198,
197,
18290,
6611,
220,
914,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDirMethods(t *testing.T) {
d := Dir2{10, 12}
if d.X() != 10 {
t.Fatalf("expected 10 for x, got %v", d.X())
}
if d.Y() != 12 {
t.Fatalf("expected 12 for y, got %v", d.Y())
}
} | explode_data.jsonl/24002 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
6184,
17856,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
30094,
17,
90,
16,
15,
11,
220,
16,
17,
532,
743,
294,
4338,
368,
961,
220,
16,
15,
341,
197,
3244,
30762,
445,
7325,
220,
16,
15,
369,
856,
11,
2684,
1018,
85,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPutByPattern(t *testing.T) {
mb, _ := mailbox.Create("PATTERN")
accessKey := mailbox.AccessKey{FullAccess: true}
accessKey.Create()
req := api.PutMessageRequest{Pattern: "P*"}
req.Sign(accessKey.Name, accessKey.Secret)
var resp api.PutMessageResponse
code := doRequest(t, req, &resp, "put")
count, err := mb.MessageCount()
if err != nil {
t.Fatal(err)
}
if count == 0 {
t.Fatal("Message not added to mailbox")
}
if code != 200 {
t.Fatal("Server responded with", code)
}
} | explode_data.jsonl/15713 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
19103,
1359,
15760,
1155,
353,
8840,
836,
8,
341,
2109,
65,
11,
716,
1669,
45742,
7251,
445,
47,
34443,
1138,
197,
5211,
1592,
1669,
45742,
35645,
1592,
90,
9432,
6054,
25,
830,
532,
197,
5211,
1592,
7251,
741,
24395,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSpanTags(t *testing.T) {
tracer := mocktracer.New()
for code := firstCode; code <= lastCode; code++ {
// Client error
tracer.Reset()
span := tracer.StartSpan("test-trace-client")
err := status.Error(code, "")
SetSpanTags(span, err, true)
span.Finish()
// Assert added tags
rawSpan := tracer.FinishedSpans()[0]
expectedTags := map[string]interface{}{
"response_code": code,
"response_class": ErrorClass(err),
}
if err != nil {
expectedTags["error"] = true
}
assert.Equal(t, expectedTags, rawSpan.Tags())
// Server error
tracer.Reset()
span = tracer.StartSpan("test-trace-server")
err = status.Error(code, "")
SetSpanTags(span, err, false)
span.Finish()
// Assert added tags
rawSpan = tracer.FinishedSpans()[0]
expectedTags = map[string]interface{}{
"response_code": code,
"response_class": ErrorClass(err),
}
if err != nil && ErrorClass(err) == ServerError {
expectedTags["error"] = true
}
assert.Equal(t, expectedTags, rawSpan.Tags())
}
} | explode_data.jsonl/37854 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 410
} | [
2830,
3393,
12485,
15930,
1155,
353,
8840,
836,
8,
341,
25583,
9584,
1669,
7860,
94941,
7121,
741,
2023,
2038,
1669,
1156,
2078,
26,
2038,
2651,
1537,
2078,
26,
2038,
1027,
341,
197,
197,
322,
8423,
1465,
198,
197,
25583,
9584,
36660,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestNewMCP23017Driver(t *testing.T) {
var bm interface{} = NewMCP23017Driver(newI2cTestAdaptor())
_, ok := bm.(*MCP23017Driver)
if !ok {
t.Errorf("NewMCP23017Driver() should have returned a *MCP23017Driver")
}
b := NewMCP23017Driver(newI2cTestAdaptor())
gobottest.Refute(t, b.Connection(), nil)
} | explode_data.jsonl/42303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
3564,
44,
7123,
17,
18,
15,
16,
22,
11349,
1155,
353,
8840,
836,
8,
341,
2405,
34868,
3749,
6257,
284,
1532,
44,
7123,
17,
18,
15,
16,
22,
11349,
1755,
40,
17,
66,
2271,
2589,
32657,
2398,
197,
6878,
5394,
1669,
34868,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRemoteErrorWhileRequestingProducts(t *testing.T) {
// We setup a fake http server that mocks a registration server.
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "something bad happened", 500)
}))
defer ts.Close()
var cr Credentials
var ip InstalledProduct
data := SUSEConnectData{SccURL: ts.URL, Insecure: true}
_, err := RequestProducts(data, cr, ip)
if err == nil || err.Error() != "Unexpected error while retrieving products with regCode : 500 Internal Server Error" {
t.Fatalf("It should have a proper error: %v", err)
}
} | explode_data.jsonl/43078 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
24703,
1454,
7983,
1900,
287,
17746,
1155,
353,
8840,
836,
8,
341,
197,
322,
1205,
6505,
264,
12418,
1758,
3538,
429,
68909,
264,
12227,
3538,
624,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLogsExporter_WithSpan_ReturnError(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
defer otel.SetTracerProvider(trace.NewNoopTracerProvider())
want := errors.New("my_error")
le, err := NewLogsExporter(&fakeLogsExporterConfig, set, newPushLogsData(want))
require.Nil(t, err)
require.NotNil(t, le)
checkWrapSpanForLogsExporter(t, sr, set.TracerProvider.Tracer("test"), le, want, 1)
} | explode_data.jsonl/59611 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
51053,
88025,
62,
2354,
12485,
53316,
1454,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
3692,
1944,
7121,
45,
453,
88025,
4021,
6086,
741,
1903,
81,
1669,
501,
7624,
580,
57824,
85309,
47023,
340,
8196,
8240,
9584,
5179,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHaltChainProcessing(t *testing.T) {
gossipChannel := func(c chan *proto.GossipMessage) <-chan *proto.GossipMessage {
return c
}
makeBlock := func(seq int) []byte {
b := &pcomm.Block{
Header: &pcomm.BlockHeader{
Number: uint64(seq),
},
Data: &pcomm.BlockData{
Data: [][]byte{},
},
Metadata: &pcomm.BlockMetadata{
Metadata: [][]byte{
{}, {}, {}, {},
},
},
}
data, _ := pb.Marshal(b)
return data
}
newBlockMsg := func(i int) *proto.GossipMessage {
return &proto.GossipMessage{
Channel: []byte("testchainid"),
Content: &proto.GossipMessage_DataMsg{
DataMsg: &proto.DataMessage{
Payload: &proto.Payload{
SeqNum: uint64(i),
Data: makeBlock(i),
},
},
},
}
}
l, recorder := floggingtest.NewTestLogger(t)
logger = l
mc := &mockCommitter{Mock: &mock.Mock{}}
mc.On("CommitWithPvtData", mock.Anything)
mc.On("LedgerHeight", mock.Anything).Return(uint64(1), nil)
g := &mocks.GossipMock{}
gossipMsgs := make(chan *proto.GossipMessage)
g.On("Accept", mock.Anything, false).Return(gossipChannel(gossipMsgs), nil)
g.On("Accept", mock.Anything, true).Return(nil, make(chan proto.ReceivedMessage))
g.On("PeersOfChannel", mock.Anything).Return([]discovery.NetworkMember{})
v := &validator.MockValidator{}
v.On("Validate").Return(&errors2.VSCCExecutionFailureError{
Err: errors.New("foobar"),
}).Once()
peerNode := newPeerNodeWithGossipWithValidator(0, mc, noopPeerIdentityAcceptor, g, v)
defer peerNode.shutdown()
gossipMsgs <- newBlockMsg(1)
assertLogged(t, recorder, "Got error while committing")
assertLogged(t, recorder, "Aborting chain processing")
assertLogged(t, recorder, "foobar")
} | explode_data.jsonl/5639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 719
} | [
2830,
3393,
39,
3145,
18837,
28892,
1155,
353,
8840,
836,
8,
341,
3174,
41473,
9629,
1669,
2915,
1337,
26023,
353,
15110,
1224,
41473,
2052,
8,
9119,
5658,
353,
15110,
1224,
41473,
2052,
341,
197,
853,
272,
198,
197,
532,
77438,
4713,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateExistingVPC(t *testing.T) {
validCases := []struct {
vpc string
subnets []string
}{
{"10.0.0.0/16", []string{"10.0.3.0/24", "10.0.4.0/24"}},
}
invalidCases := []struct {
vpc string
subnets []string
}{
// both subnets conflicts
{"10.0.0.0/16", []string{"10.0.1.0/24", "10.0.2.0/24"}},
// 10.0.1.0/24 conflicts
{"10.0.0.0/16", []string{"10.0.1.0/24", "10.0.3.0/24"}},
// 10.0.2.0/24 conflicts
{"10.0.0.0/16", []string{"10.0.2.0/24", "10.0.3.0/24"}},
// vpc cidr doesn't match
{"10.1.0.0/16", []string{"10.1.1.0/24", "10.1.2.0/24"}},
// vpc cidr is invalid
{"1o.1.o.o/16", []string{"10.1.1.0/24", "10.1.2.0/24"}},
// subnet cidr is invalid
{"10.1.0.0/16", []string{"1o.1.1.o/24", "10.1.2.0/24"}},
}
cluster := api.NewDefaultCluster()
cluster.VPCCIDR = "10.0.0.0/16"
cluster.Subnets = api.Subnets{
api.NewPublicSubnet("ap-northeast-1a", "10.0.1.0/24"),
api.NewPublicSubnet("ap-northeast-1a", "10.0.2.0/24"),
}
for _, testCase := range validCases {
err := cluster.ValidateExistingVPC(testCase.vpc, testCase.subnets)
if err != nil {
t.Errorf("failed to validate existing vpc and subnets: %v", err)
}
}
for _, testCase := range invalidCases {
err := cluster.ValidateExistingVPC(testCase.vpc, testCase.subnets)
if err == nil {
t.Errorf("expected to fail validating existing vpc and subnets: %v", testCase)
}
}
} | explode_data.jsonl/4377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 696
} | [
2830,
3393,
17926,
53067,
53,
4872,
1155,
353,
8840,
836,
8,
341,
56322,
37302,
1669,
3056,
1235,
341,
197,
5195,
3992,
257,
914,
198,
197,
28624,
52861,
3056,
917,
198,
197,
59403,
197,
197,
4913,
16,
15,
13,
15,
13,
15,
13,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCreateDeploymentConfigBadObject(t *testing.T) {
storage := REST{}
channel, err := storage.Create(kapi.NewDefaultContext(), &api.DeploymentList{})
if channel != nil {
t.Errorf("Expected nil, got %v", channel)
}
if strings.Index(err.Error(), "not a deploymentConfig") == -1 {
t.Errorf("Expected 'not a deploymentConfig' error, got '%v'", err.Error())
}
} | explode_data.jsonl/66984 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
4021,
75286,
2648,
17082,
1190,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
25414,
31483,
71550,
11,
1848,
1669,
5819,
7251,
5969,
2068,
7121,
3675,
1972,
1507,
609,
2068,
34848,
39130,
852,
37790,
743,
5496,
961,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSend(t *testing.T) {
is := is.New(t)
transport := newTestTransport()
defer func() {
transport.Stop()
<-transport.Done()
}()
testConsumer := NewNSQTestConsumer(t, "test_send", "test")
defer testConsumer.Stop()
select {
case transport.Send("test_send") <- []byte("hello vice"):
case <-time.After(1 * time.Second):
is.Fail() // timeout: transport.Send
}
select {
case msg := <-testConsumer.messages:
is.Equal(string(msg.Body), "hello vice")
case <-time.After(2 * time.Second):
is.Fail() // timeout: testConsumer <- messages
}
is.Equal(testConsumer.Count(), 1)
// make sure Send with same name returns the same
// channel
is.Equal(transport.Send("test_send"), transport.Send("test_send"))
is.True(transport.Send("test_send") != transport.Send("different"))
} | explode_data.jsonl/55187 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
11505,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
692,
197,
26445,
1669,
501,
2271,
27560,
741,
16867,
2915,
368,
341,
197,
197,
26445,
30213,
741,
197,
197,
45342,
26445,
60422,
741,
197,
66816,
18185,
2996... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBuildFieldSelectorConversions(t *testing.T) {
install := func(scheme *runtime.Scheme) error {
InstallInternalLegacyBuild(scheme)
return nil
}
apitesting.FieldKeyCheck{
SchemeBuilder: []func(*runtime.Scheme) error{install},
Kind: GroupVersion.WithKind("Build"),
// Ensure previously supported labels have conversions. DO NOT REMOVE THINGS FROM THIS LIST
AllowedExternalFieldKeys: []string{"name", "status", "podName"},
FieldKeyEvaluatorFn: internal.BuildFieldSelector,
}.Check(t)
apitesting.FieldKeyCheck{
SchemeBuilder: []func(*runtime.Scheme) error{install},
Kind: GroupVersion.WithKind("BuildConfig"),
// Ensure previously supported labels have conversions. DO NOT REMOVE THINGS FROM THIS LIST
AllowedExternalFieldKeys: []string{"name"},
}.Check(t)
} | explode_data.jsonl/32031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
11066,
1877,
5877,
1109,
28290,
1155,
353,
8840,
836,
8,
341,
197,
12248,
1669,
2915,
1141,
8058,
353,
22255,
92719,
8,
1465,
341,
197,
197,
24690,
11569,
77415,
11066,
1141,
8058,
340,
197,
853,
2092,
198,
197,
630,
69898,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHasDayOfWeek(t *testing.T) {
tests := []struct {
day time.Weekday
exists bool
sched *Schedule
}{
{
day: 0,
exists: false,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{
1: true,
},
},
},
{
day: 1,
exists: true,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{
1: true,
},
},
},
{
day: 0,
exists: true,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{
0: true,
1: true,
},
},
},
{
day: 1,
exists: true,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{
0: true,
1: true,
},
},
},
{
day: 2,
exists: false,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{
0: true,
1: true,
},
},
},
{
day: 2,
exists: false,
sched: &Schedule{
dayOfWeek: map[time.Weekday]bool{},
},
},
}
for i, tst := range tests {
if tst.sched.hasDayOfWeek(tst.day) != tst.exists {
t.Errorf("failed test %d", i)
}
}
} | explode_data.jsonl/5944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 599
} | [
2830,
3393,
10281,
10159,
38353,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
98197,
262,
882,
22404,
1225,
1292,
198,
197,
8122,
1671,
1807,
198,
197,
1903,
2397,
220,
353,
32210,
198,
197,
59403,
197,
197,
515,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSentryMiddleware(t *testing.T) {
logger.ConfigureSentry("test", logger.EnvTest)
a := New(Opts{
Address: ":4999",
})
a.Router.HandleFunc("/error", func(w http.ResponseWriter, r *http.Request) {
if hub := sentry.GetHubFromContext(r.Context()); hub != nil {
hub.Scope().SetExtra("errored", "completely")
}
panic("y tho")
})
a.Start()
_, err := http.Get("http://localhost:4999/error")
require.Error(t, err)
require.NotNil(t, logger.TestSentryTransport.LastEvent)
assert.Equal(t, "y tho", logger.TestSentryTransport.LastEvent.Message)
assert.Equal(t, "completely", logger.TestSentryTransport.LastEvent.Extra["errored"])
assert.NoError(t, a.Shutdown())
} | explode_data.jsonl/72594 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
50,
4085,
24684,
1155,
353,
8840,
836,
8,
341,
17060,
78281,
50,
4085,
445,
1944,
497,
5925,
81214,
2271,
340,
11323,
1669,
1532,
19238,
12754,
515,
197,
98090,
25,
13022,
19,
24,
24,
24,
756,
197,
8824,
11323,
31413,
6362... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMultiplicity(t *testing.T) {
Convey("Given a *String that represents the verbose graph traversal", t, func() {
g := NewGraph()
Convey("When 'Multiplicity' is called with a multiplicity", func() {
result := g.Multiplicity(m.Simple)
Convey("Then result should equal 'graph.multiplicity(SIMPLE)'", func() {
So(result.String(), ShouldEqual, "graph.multiplicity(SIMPLE)")
})
})
})
} | explode_data.jsonl/16187 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
93330,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
353,
703,
429,
10868,
279,
13694,
4771,
56302,
497,
259,
11,
2915,
368,
341,
197,
3174,
1669,
1532,
11212,
741,
197,
93070,
5617,
445,
4498,
364,
93330,
6,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMapProxy_TryPutWithNonSerializableValue(t *testing.T) {
_, err := mp.TryPut("test", student{})
AssertErrorNotNil(t, err, "tryPut did not return an error for nonserializable value")
mp.Clear()
} | explode_data.jsonl/57045 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
2227,
16219,
1139,
884,
19103,
2354,
8121,
29268,
1130,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
10490,
19824,
19103,
445,
1944,
497,
5458,
37790,
18017,
1454,
96144,
1155,
11,
1848,
11,
330,
1539,
19103,
1521,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestJsonUnmarshalURL(t *testing.T) {
testCases := map[string]struct {
b []byte
want *URL
wantErr string
}{
"empty": {
wantErr: "unexpected end of JSON input",
},
"invalid format": {
b: []byte("%"),
wantErr: "invalid character '%' looking for beginning of value",
},
"relative": {
b: []byte(`"/path/to/something"`),
want: &URL{
Path: "/path/to/something",
},
},
"url": {
b: []byte(`"http://path/to/something"`),
want: &URL{
Scheme: "http",
Host: "path",
Path: "/to/something",
},
},
}
for n, tc := range testCases {
t.Run(n, func(t *testing.T) {
got := &URL{}
err := got.UnmarshalJSON(tc.b)
if tc.wantErr != "" || err != nil {
var gotErr string
if err != nil {
gotErr = err.Error()
}
if diff := cmp.Diff(tc.wantErr, gotErr); diff != "" {
t.Errorf("unexpected error (-want, +got) = %v", diff)
}
return
}
if diff := cmp.Diff(tc.want, got); diff != "" {
t.Errorf("unexpected object (-want, +got) = %v", diff)
}
})
}
} | explode_data.jsonl/71955 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 529
} | [
2830,
3393,
5014,
1806,
27121,
3144,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
2233,
981,
3056,
3782,
198,
197,
50780,
262,
353,
3144,
198,
197,
50780,
7747,
914,
198,
197,
59403,
197,
197,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestGetOnly(t *testing.T) {
tt := []struct {
methodType string
expectedStatus string
expectedStatusCode int
}{
{http.MethodGet, "StatusOK", http.StatusOK},
{http.MethodPost, "StatusMethodNotAllowed", http.StatusMethodNotAllowed},
{http.MethodPut, "StatusMethodNotAllowed", http.StatusMethodNotAllowed},
}
for _, tc := range tt {
req, err := http.NewRequest(tc.methodType, "localhost:51234/", nil)
if err != nil {
t.Fatalf("could not created request: %v", err)
}
rec := httptest.NewRecorder()
h := GetOnly(IndexHandler)
h(rec, req)
res := rec.Result()
defer res.Body.Close()
if res.StatusCode != tc.expectedStatusCode {
t.Fatalf("expected %v; got %v", tc.expectedStatus, res.Status)
}
}
} | explode_data.jsonl/75699 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
1949,
7308,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
42257,
929,
260,
914,
198,
197,
42400,
2522,
257,
914,
198,
197,
42400,
15872,
526,
198,
197,
59403,
197,
197,
90,
1254,
20798,
1949,
11,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestEscapeTextIOErrors(t *testing.T) {
expectErr := "unwritable"
err := EscapeText(errWriter{}, []byte{'A'})
if err == nil || err.Error() != expectErr {
t.Errorf("have %v, want %v", err, expectErr)
}
} | explode_data.jsonl/48627 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
48124,
1178,
3810,
13877,
1155,
353,
8840,
836,
8,
341,
24952,
7747,
1669,
330,
359,
86,
22533,
698,
9859,
1669,
45643,
1178,
3964,
6492,
22655,
3056,
3782,
13608,
32,
81645,
743,
1848,
621,
2092,
1369,
1848,
6141,
368,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRequestViaIntermediaryTimeout(t *testing.T) {
r, cfg := setup(t)
s := NewService(cfg)
fr := &IntermediaryFactRequest{
SelfID: "1234567890",
Intermediary: "intermediary",
Expiry: time.Millisecond,
Facts: []Fact{
{
Fact: FactDateOfBirth,
Sources: []string{SourceDrivingLicense, SourcePassport},
Operator: "<=",
ExpectedValue: time.Now().Add(time.Hour * 183960).Format(time.RFC3339),
},
},
}
ipk, isk, err := ed25519.GenerateKey(rand.Reader)
require.Nil(t, err)
r.addpk("intermediary", isk, ipk)
r.path = "/v1/apps/intermediary/devices"
r.payload = []byte(`["1", "2"]`)
r.secondaryPaths["/v1/apps/test"] = []byte(`{"paid_actions":true}`)
var called bool
r.responder = func(recipients []string, req []byte) (string, []byte, error) {
called = true
return fr.Intermediary + ":1", nil, ErrRequestTimeout
}
_, err = s.RequestViaIntermediary(fr)
require.NotNil(t, err)
assert.True(t, called)
} | explode_data.jsonl/25980 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 434
} | [
2830,
3393,
1900,
54428,
3306,
4404,
658,
7636,
1155,
353,
8840,
836,
8,
341,
7000,
11,
13286,
1669,
6505,
1155,
692,
1903,
1669,
1532,
1860,
28272,
692,
97714,
1669,
609,
3306,
4404,
658,
17417,
1900,
515,
197,
7568,
490,
915,
25,
98... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFilter8(t *testing.T) {
t.Run("Add()", func(t *testing.T) {
t.Run("increments and returns the count for the value", func(t *testing.T) {
f := New8Bit(16, 0.1)
if expected, actual := uint(0), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
count := f.Add("hello")
if expected, actual := uint(1), count; expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(1), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
count = f.Add("hello")
if expected, actual := uint(2), count; expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(2), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
})
t.Run("stops incrementing at 255", func(t *testing.T) {
f := New8Bit(16, 0.1).(*filter8)
for i := 0; i < len(f.counters); i++ {
f.counters[i] = 255
}
f.Add("hello")
if expected, actual := uint(255), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
})
t.Run("is thread safe", func(t *testing.T) {
f := New8Bit(16, 0.1)
start := sync.WaitGroup{}
start.Add(1)
wait := sync.WaitGroup{}
for i := 0; i < 250; i++ {
wait.Add(1)
go func() {
start.Wait()
f.Add("hello")
wait.Done()
}()
}
start.Done()
wait.Wait()
if expected, actual := uint(250), f.Count("hello"); expected != actual {
t.Errorf("Expected a total count of %d but got %d; possible concurrency error", expected, actual)
}
})
})
t.Run("Clear()", func(t *testing.T) {
t.Run("zeros out all counters", func(t *testing.T) {
f := New8Bit(16, 0.1).(*filter8)
for i := 0; i < len(f.counters); i++ {
f.counters[i] = 255
}
f.Clear()
for i := 0; i < len(f.counters); i++ {
if expected, actual := uint8(0), f.counters[i]; expected != actual {
t.Errorf("Expected counter %d to be %d but got %d", i, expected, actual)
}
}
})
})
t.Run("Remove()", func(t *testing.T) {
t.Run("decrements and returns the count for the value", func(t *testing.T) {
f := New8Bit(16, 0.1)
f.Add("hello")
f.Add("hello")
f.Add("hello")
if expected, actual := uint(3), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
count := f.Remove("hello")
if expected, actual := uint(2), count; expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(2), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
count = f.Remove("hello")
if expected, actual := uint(1), count; expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(1), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if expected, actual := uint(0), f.Count("hello 2"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
})
t.Run("stops decrementing at zero", func(t *testing.T) {
f := New8Bit(16, 0.1)
f.Remove("hello")
if expected, actual := uint(0), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
})
t.Run("is thread safe", func(t *testing.T) {
f := New8Bit(16, 0.1).(*filter8)
for i := 0; i < len(f.counters); i++ {
f.counters[i] = 255
}
start := sync.WaitGroup{}
start.Add(1)
wait := sync.WaitGroup{}
for i := 0; i < 250; i++ {
wait.Add(1)
go func() {
start.Wait()
f.Remove("hello")
wait.Done()
}()
}
start.Done()
wait.Wait()
if expected, actual := uint(5), f.Count("hello"); expected != actual {
t.Errorf("Expected a total count of %d but got %d; possible concurrency error", expected, actual)
}
})
})
t.Run("Reset()", func(t *testing.T) {
t.Run("zeros out counters for one value", func(t *testing.T) {
f := New8Bit(16, 0.1)
f.Add("hello")
f.Add("hello")
f.Add("hello 2")
f.Reset("hello")
if expected, actual := uint(0), f.Count("hello"); expected != actual {
t.Errorf("Expected count of %d but got %d", expected, actual)
}
if actual := f.Count("hello 2"); actual == 0 {
t.Errorf("Expected non-zero count but got %d", actual)
}
})
})
t.Run("New8Bit()", func(t *testing.T) {
t.Run("initialises the number of hashes and the counters", func(t *testing.T) {
f := New8Bit(32, 0.5).(*filter8)
if expected, actual := uint(1), f.hashCount; expected != actual {
t.Errorf("Expected %d hashes but got %d", expected, actual)
}
if expected, actual := 46, len(f.counters); expected != actual {
t.Errorf("Expected %d counters but got %d", expected, actual)
}
f = New8Bit(16, 0.2).(*filter8)
if expected, actual := uint(2), f.hashCount; expected != actual {
t.Errorf("Expected %d hashes but got %d", expected, actual)
}
if expected, actual := 53, len(f.counters); expected != actual {
t.Errorf("Expected %d counters but got %d", expected, actual)
}
f = New8Bit(8, 0.01).(*filter8)
if expected, actual := uint(6), f.hashCount; expected != actual {
t.Errorf("Expected %d hashes but got %d", expected, actual)
}
if expected, actual := 76, len(f.counters); expected != actual {
t.Errorf("Expected %d counters but got %d", expected, actual)
}
})
})
} | explode_data.jsonl/63808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2656
} | [
2830,
3393,
5632,
23,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
2212,
50514,
2915,
1155,
353,
8840,
836,
8,
1476,
197,
3244,
16708,
445,
56437,
323,
4675,
279,
1760,
369,
279,
897,
497,
2915,
1155,
353,
8840,
836,
8,
341,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestArray_PopRights(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.NewFrom(g.Slice{1, 2, 3})
t.Assert(array.PopRights(2), g.Slice{2, 3})
t.Assert(array.Len(), 1)
t.Assert(array.PopLefts(2), g.Slice{1})
t.Assert(array.Len(), 0)
})
} | explode_data.jsonl/13896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
1857,
1088,
453,
81875,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11923,
1669,
342,
1653,
7121,
3830,
3268,
95495,
90,
16,
11,
220,
17,
11,
220,
18,
3518,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMetricGroupData_toNumberDataPointEquivalence(t *testing.T) {
type scrape struct {
at int64
value float64
metric string
}
tests := []struct {
name string
labels labels.Labels
scrapes []*scrape
}{
{
name: "counter",
labels: labels.Labels{{Name: "a", Value: "A"}, {Name: "b", Value: "B"}},
scrapes: []*scrape{
{at: 13, value: 33.7, metric: "value"},
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
mf := newMetricFamily(tt.name, mc, zap.NewNop()).(*metricFamily)
mp := newMetricFamilyPdata(tt.name, mc).(*metricFamilyPdata)
for _, tv := range tt.scrapes {
require.NoError(t, mp.Add(tv.metric, tt.labels.Copy(), tv.at, tv.value))
require.NoError(t, mf.Add(tv.metric, tt.labels.Copy(), tv.at, tv.value))
}
groupKey := mf.getGroupKey(tt.labels.Copy())
ocTimeseries := mf.groups[groupKey].toDoubleValueTimeSeries(mf.labelKeysOrdered)
ddpL := pdata.NewNumberDataPointSlice()
require.True(t, mp.groups[groupKey].toNumberDataPoint(mp.labelKeysOrdered, &ddpL))
require.Equal(t, len(ocTimeseries.Points), ddpL.Len(), "They should have the exact same number of points")
require.Equal(t, 1, ddpL.Len(), "Exactly one point expected")
ocPoint := ocTimeseries.Points[0]
pdataPoint := ddpL.At(0)
// 1. Ensure that the startTimestamps are equal.
require.Equal(t, ocTimeseries.GetStartTimestamp().AsTime(), pdataPoint.Timestamp().AsTime(), "The timestamp must be equal")
// 2. Ensure that the value is equal.
require.Equal(t, ocPoint.GetDoubleValue(), pdataPoint.DoubleVal(), "Count must be equal")
// 4. Ensure that the point's timestamp is equal to that from the OpenCensusProto data point.
require.Equal(t, ocPoint.GetTimestamp().AsTime(), pdataPoint.Timestamp().AsTime(), "Point timestamps must be equal")
// 5. Ensure that the labels all match up.
ocStringMap := pdata.NewStringMap()
for i, labelValue := range ocTimeseries.LabelValues {
ocStringMap.Insert(mf.labelKeysOrdered[i], labelValue.Value)
}
require.Equal(t, ocStringMap.Sort(), pdataPoint.LabelsMap().Sort())
})
}
} | explode_data.jsonl/19398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 864
} | [
2830,
3393,
54310,
2808,
1043,
2346,
2833,
1043,
2609,
24509,
88790,
1155,
353,
8840,
836,
8,
341,
13158,
57128,
2036,
341,
197,
35447,
257,
526,
21,
19,
198,
197,
16309,
220,
2224,
21,
19,
198,
197,
2109,
16340,
914,
198,
197,
532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.