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 TestMatchBody(t *testing.T) {
hreq := &definition.Request{}
hreq.Body = "HelloWorld"
mreq := &definition.Request{}
mreq.Body = "HelloWorld"
m := MockMatch{}
if m, err := m.Match(hreq, mreq); !m {
t.Error(err)
}
mreq.Body = "ByeWorld"
if m, _ := m.Match(hreq, mreq); m {
t.Error("Not expected match")
}
} | explode_data.jsonl/1094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
8331,
5444,
1155,
353,
8840,
836,
8,
341,
9598,
2958,
1669,
609,
18375,
9659,
16094,
9598,
2958,
20934,
284,
330,
9707,
10134,
698,
2109,
2958,
1669,
609,
18375,
9659,
16094,
2109,
2958,
20934,
284,
330,
9707,
10134,
698,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidSign(t *testing.T) {
if _, err := Sign(make([]byte, 1), nil); err == nil {
t.Errorf("expected sign with hash 1 byte to error")
}
if _, err := Sign(make([]byte, 33), nil); err == nil {
t.Errorf("expected sign with hash 33 byte to error")
}
} | explode_data.jsonl/3759 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
7928,
7264,
1155,
353,
8840,
836,
8,
341,
743,
8358,
1848,
1669,
7075,
36944,
10556,
3782,
11,
220,
16,
701,
2092,
1215,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
7325,
1841,
448,
5175,
220,
16,
4922,
311,
1465,
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... | 3 |
func TestContextHeaders(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Header("Content-Type", "text/plain")
c.Header("X-Custom", "value")
assert.Equal(t, "text/plain", c.Writer.Header().Get("Content-Type"))
assert.Equal(t, "value", c.Writer.Header().Get("X-Custom"))
c.Header("Content-Type", "text/html")
c.Header("X-Custom", "")
assert.Equal(t, "text/html", c.Writer.Header().Get("Content-Type"))
_, exist := c.Writer.Header()["X-Custom"]
assert.False(t, exist)
} | explode_data.jsonl/26797 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
1972,
10574,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
4230,
2271,
1972,
73392,
83,
70334,
7121,
47023,
2398,
1444,
15753,
445,
2762,
10804,
497,
330,
1318,
36971,
1138,
1444,
15753,
445,
55,
7658,
1450,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCksum(t *testing.T) {
testMatrix := []struct {
data []byte
cksum string
}{
{[]byte("abcdef\n"), "5ab557c937e38f15291c04b7e99544ad"},
{[]byte("pqra\n"), "721d6b135656aa83baca6ebdbd2f6c86"},
}
for _, testData := range testMatrix {
if testData.cksum != calculateMd5Sum("", testData.data) {
t.Errorf("md5sum verification failed. (Expected: %s, Received: %s)", testData.cksum, calculateMd5Sum("", testData.data))
}
}
} | explode_data.jsonl/61150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
34,
74,
1242,
1155,
353,
8840,
836,
8,
341,
18185,
6689,
1669,
3056,
1235,
341,
197,
8924,
220,
3056,
3782,
198,
197,
197,
377,
1242,
914,
198,
197,
59403,
197,
197,
90,
1294,
3782,
445,
41202,
1699,
3975,
330,
20,
370,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDoubleDataPointSlice_CopyTo(t *testing.T) {
dest := NewDoubleDataPointSlice()
// Test CopyTo to empty
NewDoubleDataPointSlice().CopyTo(dest)
assert.EqualValues(t, NewDoubleDataPointSlice(), dest)
// Test CopyTo larger slice
generateTestDoubleDataPointSlice().CopyTo(dest)
assert.EqualValues(t, generateTestDoubleDataPointSlice(), dest)
// Test CopyTo same size slice
generateTestDoubleDataPointSlice().CopyTo(dest)
assert.EqualValues(t, generateTestDoubleDataPointSlice(), dest)
} | explode_data.jsonl/19535 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
7378,
1043,
2609,
33236,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
49616,
1669,
1532,
7378,
1043,
2609,
33236,
741,
197,
322,
3393,
14540,
1249,
311,
4287,
198,
197,
3564,
7378,
1043,
2609,
33236,
1005,
12106,
1249,
27010,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMinHeap(t *testing.T) {
for _, tt := range heapTests {
t.Run(tt.name, func(t *testing.T) {
capacity := tt.capacity
h := NewFloatHeap(false, capacity)
assert.Equal(t, capacity, h.Cap())
_, seen := h.Peek()
assert.False(t, seen)
for i, v := range tt.values {
h.Push(v, i)
}
peek, seen := h.Peek()
assert.True(t, seen)
assert.Equal(t, peek, tt.expectedMin[0])
// Flush and sort results (Flush does not care about order)
actual := h.Flush()
sort.Sort(minSlice(actual))
assert.Equal(t, tt.expectedMin, actual)
// Assert Flush flushes the heap
assert.Equal(t, 0, h.floatHeap.Len())
_, seen = h.Peek()
assert.False(t, seen)
})
}
} | explode_data.jsonl/68387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
6217,
27909,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
17364,
18200,
341,
197,
3244,
16708,
47152,
2644,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
1444,
391,
4018,
1669,
17853,
59168,
198,
298,
9598,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddRouteAddsToRoutesMap(t *testing.T) {
r := NewRouter()
r.AddRoute("test", &Route{})
assert.Contains(t, r.Routes, "test", "Expected test in routes")
} | explode_data.jsonl/4484 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
2212,
4899,
72111,
1249,
26653,
2227,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
741,
7000,
1904,
4899,
445,
1944,
497,
609,
4899,
6257,
692,
6948,
11545,
1155,
11,
435,
2013,
5495,
11,
330,
1944,
497,
330,
1889... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAzureFindValidAccessTokenForTenant_DifferentTenant(t *testing.T) {
expirationDate := time.Now().Add(1 * time.Hour)
expectedToken := cli.Token{
ExpiresOn: expirationDate.Format("2006-01-02 15:04:05.999999"),
AccessToken: "7cabcf30-8dca-43f9-91e6-fd56dfb8632f",
TokenType: "9b10b986-7a61-4542-8d5a-9fcd96112585",
Resource: "https://management.core.windows.net/",
Authority: "9b5095de-5496-4b5e-9bc6-ef2c017b9d35",
}
tokens := []cli.Token{expectedToken}
token, err := findValidAccessTokenForTenant(tokens, "c056adac-c6a6-4ddf-ab20-0f26d47f7eea")
if err == nil {
t.Fatalf("Expected an error but didn't get one")
}
if token != nil {
t.Fatalf("Expected Token to be nil but got: %+v", token)
}
} | explode_data.jsonl/60954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
78107,
9885,
4088,
37649,
2461,
71252,
1557,
18277,
71252,
1155,
353,
8840,
836,
8,
341,
48558,
19629,
1916,
1669,
882,
13244,
1005,
2212,
7,
16,
353,
882,
73550,
340,
42400,
3323,
1669,
21348,
32277,
515,
197,
197,
65331,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCrawlGoodVersion(t *testing.T) {
buf := &bytes.Buffer{}
numIssues, err := Crawl(context.Background(), Config{
Root: "../../examples/good_version",
OutputJSON: true,
}, buf, io.Discard)
require.NoError(t, err)
assert.Equal(t, int64(0), numIssues)
assert.Equal(t, "", buf.String())
} | explode_data.jsonl/7796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
34,
33683,
15216,
5637,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
609,
9651,
22622,
16094,
22431,
85828,
11,
1848,
1669,
356,
33683,
5378,
19047,
1507,
5532,
515,
197,
197,
8439,
25,
981,
10208,
51668,
4846,
1386,
9438,
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... | 1 |
func TestOKExFuture_GetFutureOrder(t *testing.T) {
t.Log(okex.OKExFuture.GetFutureOrder("3145664744431616", goex.EOS_USD, goex.QUARTER_CONTRACT))
} | explode_data.jsonl/3931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
3925,
840,
24206,
13614,
24206,
4431,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
60207,
327,
15480,
840,
24206,
2234,
24206,
4431,
445,
18,
16,
19,
20,
21,
21,
19,
22,
19,
19,
19,
18,
16,
21,
16,
21,
497,
728,
327,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCandlesticksGetLast(t *testing.T) {
c1, _ := NewCandlestick(45.5, 46, 46.5, 42.2, time.Now(), 2302)
c2, _ := NewCandlestick(47, 46, 46.5, 42.2, time.Now().Add(time.Minute*1), 3000)
max := 3
testCases := []struct {
candles []*Candlestick
expected *Candlestick
}{
{
candles: []*Candlestick{},
expected: nil,
},
{
candles: []*Candlestick{c1},
expected: c1,
},
{
candles: []*Candlestick{c1, c2},
expected: c2,
},
}
for _, tc := range testCases {
cs, err := NewCandlesticks(IntervalOneDay, max)
if err != nil {
t.Fatalf("Error creating new candlesticks %+v", err)
}
for _, c := range tc.candles {
cs.AppendCandlestick(c)
}
c := cs.GetLastItem()
if c != tc.expected {
t.Errorf("Expected %+v but got %+v", tc.expected, c)
}
}
} | explode_data.jsonl/47325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
34,
3316,
68945,
1949,
5842,
1155,
353,
8840,
836,
8,
341,
1444,
16,
11,
716,
1669,
1532,
34,
3316,
29033,
7,
19,
20,
13,
20,
11,
220,
19,
21,
11,
220,
19,
21,
13,
20,
11,
220,
19,
17,
13,
17,
11,
882,
13244,
150... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestByteSafety(t *testing.T) {
jsonb := []byte(`{"name":"Janet","age":38}`)
mtok := GetBytes(jsonb, "name")
if mtok.String() != "Janet" {
t.Fatalf("expected %v, got %v", "Jason", mtok.String())
}
mtok2 := GetBytes(jsonb, "age")
if mtok2.Raw != "38" {
t.Fatalf("expected %v, got %v", "Jason", mtok2.Raw)
}
jsonb[9] = 'T'
jsonb[12] = 'd'
jsonb[13] = 'y'
if mtok.String() != "Janet" {
t.Fatalf("expected %v, got %v", "Jason", mtok.String())
}
} | explode_data.jsonl/43420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
7153,
73037,
1155,
353,
8840,
836,
8,
341,
30847,
65,
1669,
3056,
3782,
5809,
4913,
606,
3252,
18315,
295,
2198,
424,
788,
18,
23,
27085,
2109,
29594,
1669,
2126,
7078,
9304,
65,
11,
330,
606,
1138,
743,
11965,
562,
6431,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAssignsDefaultServiceAccountAndToleratesMissingAPIToken(t *testing.T) {
ns := "myns"
admit := NewServiceAccount()
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
admit.SetExternalKubeInformerFactory(informerFactory)
admit.MountServiceAccountToken = true
admit.RequireAPIToken = false
// Add the default service account for the ns into the cache
informerFactory.Core().V1().ServiceAccounts().Informer().GetStore().Add(&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: DefaultServiceAccountName,
Namespace: ns,
},
})
pod := &api.Pod{}
attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), ns, "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
err := admit.Admit(attrs)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if pod.Spec.ServiceAccountName != DefaultServiceAccountName {
t.Errorf("Expected service account %s assigned, got %s", DefaultServiceAccountName, pod.Spec.ServiceAccountName)
}
} | explode_data.jsonl/61343 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
28933,
82,
3675,
1860,
7365,
3036,
51,
22072,
973,
25080,
2537,
952,
1679,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
330,
76,
1872,
82,
1837,
98780,
1763,
1669,
1532,
1860,
7365,
741,
17430,
34527,
4153,
1669,
6051,
388,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServer_NewContext(t *testing.T) {
a := assert.New(t, false)
lw := &bytes.Buffer{}
srv := newServer(a, &Options{Tag: language.SimplifiedChinese})
a.NotError(srv.Logs().SetOutput(logs.LevelDebug, lw))
// 错误的 accept
w := httptest.NewRecorder()
r, err := http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("Accept", "not")
srv.NewContext(w, r)
a.Equal(w.Code, http.StatusNotAcceptable)
a.Contains(lw.String(), localeutil.Error("not found serialization for %s", "not").Error())
// 错误的 accept-charset
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("Accept", text.Mimetype)
r.Header.Set("Accept-Charset", "unknown")
srv.NewContext(w, r)
a.Equal(w.Code, http.StatusNotAcceptable)
a.Contains(lw.String(), localeutil.Error("not found charset for %s", "unknown").Error())
// 错误的 content-type,无输入内容
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("Content-Type", ";charset=utf-8")
srv.NewContext(w, r)
a.Equal(w.Code, http.StatusUnsupportedMediaType)
a.NotEmpty(lw.String())
// 错误的 content-type,有输入内容
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodPost, "/path", bytes.NewBufferString("[]"))
a.NotError(err).NotNil(r)
r.Header.Set("Content-Type", ";charset=utf-8")
srv.NewContext(w, r)
a.Equal(w.Code, http.StatusUnsupportedMediaType)
a.NotEmpty(lw.String())
// 错误的 content-type,且有输入内容
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", bytes.NewBufferString("123"))
a.NotError(err).NotNil(r)
r.Header.Set("content-type", buildContentType(text.Mimetype, "utf-"))
srv.NewContext(w, r)
a.Equal(w.Code, http.StatusUnsupportedMediaType)
a.NotEmpty(lw.String())
// 部分错误的 Accept-Language
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("Accept-Language", "zh-hans;q=0.9,zh-Hant;q=xxx")
r.Header.Set("content-type", buildContentType(text.Mimetype, DefaultCharset))
ctx := srv.NewContext(w, r)
a.NotNil(ctx)
a.Equal(ctx.OutputTag, language.MustParse("zh-hans"))
a.Empty(lw.String())
// 正常,指定 Accept-Language,采用默认的 accept
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("Accept-Language", "zh-hans;q=0.9,zh-Hant;q=0.7")
r.Header.Set("content-type", buildContentType(text.Mimetype, DefaultCharset))
ctx = srv.NewContext(w, r)
a.NotNil(ctx)
a.Empty(lw.String())
a.True(charsetIsNop(ctx.InputCharset)).
Equal(ctx.OutputMimetypeName, "application/json").
Equal(ctx.InputMimetype, serialization.UnmarshalFunc(text.Unmarshal)).
Equal(ctx.OutputTag, language.SimplifiedChinese).
NotNil(ctx.LocalePrinter)
// 正常,未指定 Accept-Language 和 Accept-Charset 等不是必须的报头
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("content-type", buildContentType(text.Mimetype, DefaultCharset))
r.Header.Set("accept", "application/json;q=0.2,text/plain;q=0.9")
ctx = srv.NewContext(w, r)
a.Empty(lw.String())
a.NotNil(ctx).
True(charsetIsNop(ctx.InputCharset)).
Equal(ctx.OutputMimetypeName, text.Mimetype)
// 正常,未指定 Accept-Language 和 Accept-Charset 等不是必须的报头,且有输入内容
lw.Reset()
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", bytes.NewBufferString("123"))
a.NotError(err).NotNil(r)
r.Header.Set("content-type", buildContentType(text.Mimetype, DefaultCharset))
r.Header.Set("accept", "application/json;q=0.2,text/*;q=0.9")
ctx = srv.NewContext(w, r)
a.Empty(lw.String())
a.NotNil(ctx).
True(charsetIsNop(ctx.InputCharset)).
Equal(ctx.OutputMimetypeName, text.Mimetype)
} | explode_data.jsonl/34197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1813
} | [
2830,
3393,
5475,
39582,
1972,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
11,
895,
340,
8810,
86,
1669,
609,
9651,
22622,
16094,
1903,
10553,
1669,
501,
5475,
2877,
11,
609,
3798,
90,
5668,
25,
4128,
808,
73837,
4492... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEditFileCmdStr(t *testing.T) {
gitCmd := NewDummyGitCommand()
type scenario struct {
filename string
configEditCommand string
configEditCommandTemplate string
command func(string, ...string) *exec.Cmd
getenv func(string) string
gitConfigMockResponses map[string]string
test func(string, error)
}
scenarios := []scenario{
{
"test",
"",
"{{editor}} {{filename}}",
func(name string, arg ...string) *exec.Cmd {
return secureexec.Command("exit", "1")
},
func(env string) string {
return ""
},
nil,
func(cmdStr string, err error) {
assert.EqualError(t, err, "No editor defined in config file, $GIT_EDITOR, $VISUAL, $EDITOR, or git config")
},
},
{
"test",
"nano",
"{{editor}} {{filename}}",
func(name string, args ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("echo")
},
func(env string) string {
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
"test",
"",
"{{editor}} {{filename}}",
func(name string, arg ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("exit", "1")
},
func(env string) string {
return ""
},
map[string]string{"core.editor": "nano"},
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
"test",
"",
"{{editor}} {{filename}}",
func(name string, arg ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("exit", "1")
},
func(env string) string {
if env == "VISUAL" {
return "nano"
}
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
},
},
{
"test",
"",
"{{editor}} {{filename}}",
func(name string, arg ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("exit", "1")
},
func(env string) string {
if env == "EDITOR" {
return "emacs"
}
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "emacs "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
"test",
"",
"{{editor}} {{filename}}",
func(name string, arg ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("echo")
},
func(env string) string {
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
"file/with space",
"",
"{{editor}} {{filename}}",
func(name string, args ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("echo")
},
func(env string) string {
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("file/with space"), cmdStr)
},
},
{
"open file/at line",
"vim",
"{{editor}} +{{line}} {{filename}}",
func(name string, args ...string) *exec.Cmd {
assert.Equal(t, "which", name)
return secureexec.Command("echo")
},
func(env string) string {
return ""
},
nil,
func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, "vim +1 "+gitCmd.OSCommand.Quote("open file/at line"), cmdStr)
},
},
}
for _, s := range scenarios {
gitCmd.Config.GetUserConfig().OS.EditCommand = s.configEditCommand
gitCmd.Config.GetUserConfig().OS.EditCommandTemplate = s.configEditCommandTemplate
gitCmd.OSCommand.Command = s.command
gitCmd.OSCommand.Getenv = s.getenv
gitCmd.GitConfig = git_config.NewFakeGitConfig(s.gitConfigMockResponses)
s.test(gitCmd.EditFileCmdStr(s.filename, 1))
}
} | explode_data.jsonl/6326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1819
} | [
2830,
3393,
4036,
1703,
15613,
2580,
1155,
353,
8840,
836,
8,
341,
90731,
15613,
1669,
1532,
43344,
46562,
4062,
2822,
13158,
15048,
2036,
341,
197,
66434,
1698,
914,
198,
197,
25873,
4036,
4062,
260,
914,
198,
197,
25873,
4036,
4062,
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... | 1 |
func TestGetOpenEBSImagePullSecrets(t *testing.T) {
testCases := map[string]struct {
value string
expectedValue string
}{
"Missing env variable": {
value: "",
expectedValue: "",
},
"Present env variable with value": {
value: "image-pull-secret",
expectedValue: "image-pull-secret",
},
"Present env variable with multiple value": {
value: "image-pull-secret,secret-1",
expectedValue: "image-pull-secret,secret-1",
},
"Present env variable with whitespaces": {
value: " ",
expectedValue: "",
},
}
for k, v := range testCases {
v := v
t.Run(k, func(t *testing.T) {
if len(v.value) != 0 {
os.Setenv(string(ProvisionerImagePullSecrets), v.value)
}
actualValue := getOpenEBSImagePullSecrets()
if !reflect.DeepEqual(actualValue, v.expectedValue) {
t.Errorf("expected %s got %s", v.expectedValue, actualValue)
}
os.Unsetenv(string(ProvisionerImagePullSecrets))
})
}
} | explode_data.jsonl/30414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
1949,
5002,
36,
7347,
1906,
36068,
19773,
82,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
16309,
260,
914,
198,
197,
42400,
1130,
914,
198,
197,
59403,
197,
197,
1,
25080,
6105,
3890,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigurationErrors(t *testing.T) {
templateErrorFile, err := ioutil.TempFile("", "provider-configuration-error")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(templateErrorFile.Name())
data := []byte("Not a valid template {{ Bar }}")
err = ioutil.WriteFile(templateErrorFile.Name(), data, 0700)
if err != nil {
t.Fatal(err)
}
templateInvalidTOMLFile, err := ioutil.TempFile("", "provider-configuration-error")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(templateInvalidTOMLFile.Name())
data = []byte(`Hello {{ .Name }}
{{ Foo }}`)
err = ioutil.WriteFile(templateInvalidTOMLFile.Name(), data, 0700)
if err != nil {
t.Fatal(err)
}
invalids := []struct {
provider *myProvider
defaultTemplate string
expectedError string
funcMap template.FuncMap
templateObjects interface{}
}{
{
provider: &myProvider{
BaseProvider{
Filename: "/non/existent/template.tmpl",
},
nil,
},
expectedError: "open /non/existent/template.tmpl: no such file or directory",
},
{
provider: &myProvider{},
defaultTemplate: "non/existent/template.tmpl",
expectedError: "Asset non/existent/template.tmpl not found",
},
{
provider: &myProvider{
BaseProvider{
Filename: templateErrorFile.Name(),
},
nil,
},
expectedError: `function "Bar" not defined`,
},
{
provider: &myProvider{
BaseProvider{
Filename: templateInvalidTOMLFile.Name(),
},
nil,
},
expectedError: "Near line 1 (last key parsed 'Hello'): expected key separator '=', but got '<' instead",
funcMap: template.FuncMap{
"Foo": func() string {
return "bar"
},
},
templateObjects: struct{ Name string }{Name: "bar"},
},
}
for _, invalid := range invalids {
configuration, err := invalid.provider.getConfiguration(invalid.defaultTemplate, invalid.funcMap, nil)
if err == nil || !strings.Contains(err.Error(), invalid.expectedError) {
t.Fatalf("should have generate an error with %q, got %v", invalid.expectedError, err)
}
if configuration != nil {
t.Fatalf("shouldn't have return a configuration object : %v", configuration)
}
}
} | explode_data.jsonl/64887 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 857
} | [
2830,
3393,
7688,
13877,
1155,
353,
8840,
836,
8,
341,
22832,
1454,
1703,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
19979,
12,
21138,
18917,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
2643,
8442... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQueryChannelsStatsView(t *testing.T) {
if !base.TestsDisableGSI() {
t.Skip("This test is view only, but GSI is enabled")
}
db := setupTestDB(t)
defer db.Close()
// docID -> Sequence
docSeqMap := make(map[string]uint64, 3)
_, doc, err := db.Put("queryTestDoc1", Body{"channels": []string{"ABC"}})
require.NoError(t, err, "Put queryDoc1")
docSeqMap["queryTestDoc1"] = doc.Sequence
_, doc, err = db.Put("queryTestDoc2", Body{"channels": []string{"ABC"}})
require.NoError(t, err, "Put queryDoc2")
docSeqMap["queryTestDoc2"] = doc.Sequence
_, doc, err = db.Put("queryTestDoc3", Body{"channels": []string{"ABC"}})
require.NoError(t, err, "Put queryDoc3")
docSeqMap["queryTestDoc3"] = doc.Sequence
// Check expvar prior to test
queryExpvar := fmt.Sprintf(base.StatViewFormat, DesignDocSyncGateway(), ViewChannels)
channelQueryCountBefore := db.DbStats.Query(queryExpvar).QueryCount.Value()
channelQueryTimeBefore := db.DbStats.Query(queryExpvar).QueryTime.Value()
channelQueryErrorCountBefore := db.DbStats.Query(queryExpvar).QueryErrorCount.Value()
// Issue channels query
results, queryErr := db.QueryChannels("ABC", docSeqMap["queryTestDoc1"], docSeqMap["queryTestDoc3"], 100, false)
assert.NoError(t, queryErr, "Query error")
assert.Equal(t, 3, countQueryResults(results))
closeErr := results.Close()
assert.NoError(t, closeErr, "Close error")
channelQueryCountAfter := db.DbStats.Query(queryExpvar).QueryCount.Value()
channelQueryTimeAfter := db.DbStats.Query(queryExpvar).QueryTime.Value()
channelQueryErrorCountAfter := db.DbStats.Query(queryExpvar).QueryErrorCount.Value()
assert.Equal(t, channelQueryCountBefore+1, channelQueryCountAfter)
assert.True(t, channelQueryTimeAfter > channelQueryTimeBefore, "Channel query time stat didn't change")
assert.Equal(t, channelQueryErrorCountBefore, channelQueryErrorCountAfter)
} | explode_data.jsonl/2703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 639
} | [
2830,
3393,
2859,
35925,
16635,
851,
1155,
353,
8840,
836,
8,
1476,
743,
753,
3152,
37133,
25479,
38,
13817,
368,
341,
197,
3244,
57776,
445,
1986,
1273,
374,
1651,
1172,
11,
714,
479,
13817,
374,
8970,
1138,
197,
630,
20939,
1669,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRetryable(t *testing.T) {
{
err := errors.New("foo")
err2 := Retryable(err)
if err.Error() != err2.Error() {
t.Error("Retryable should not change the error text")
}
if !IsRetryable(err2) {
t.Error("Retryable should generate a retryable error")
}
}
{
err := httpError(http.StatusBadRequest)
err2 := Retryable(err)
if !IsRetryable(err2) {
t.Error("Retryable should transform a non retryable error into a retryable error")
}
}
} | explode_data.jsonl/4871 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
51560,
480,
1155,
353,
8840,
836,
8,
341,
197,
515,
197,
9859,
1669,
5975,
7121,
445,
7975,
1138,
197,
9859,
17,
1669,
78870,
480,
3964,
340,
197,
743,
1848,
6141,
368,
961,
1848,
17,
6141,
368,
341,
298,
3244,
6141,
445... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoundtripWrap(t *testing.T) {
codec := RandMux()
codec.Wrap = true
f := func(o1 TestType) bool {
var o2 TestType
return mctest.RoundTripTest(t, codec, &o1, &o2)
}
if err := quick.Check(f, nil); err != nil {
t.Error(err)
}
} | explode_data.jsonl/52650 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
27497,
32981,
26787,
1155,
353,
8840,
836,
8,
341,
43343,
66,
1669,
23963,
44,
2200,
741,
43343,
66,
38968,
284,
830,
198,
1166,
1669,
2915,
10108,
16,
3393,
929,
8,
1807,
341,
197,
2405,
297,
17,
3393,
929,
198,
197,
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 TestNewRetrieveWithFileGeneratedStageName(t *testing.T) {
expected := map[string]string{"a.txt": "", "b.txt": "", "c.txt": ""}
client := &fakeRetrievalService{
artifacts: expected,
}
dest := makeTempDir(t)
defer os.RemoveAll(dest)
ctx := grpcx.WriteWorkerID(context.Background(), "worker")
mds, err := newMaterializeWithClient(ctx, client, client.fileArtifactsWithoutStagingTo(), dest)
if err != nil {
t.Fatalf("materialize failed: %v", err)
}
generated := make(map[string]string)
for _, md := range mds {
name, _ := MustExtractFilePayload(md)
payload, _ := proto.Marshal(&pipepb.ArtifactStagingToRolePayload{
StagedName: name})
generated[name] = string(payload)
}
checkStagedFiles(mds, dest, generated, t)
} | explode_data.jsonl/55337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
3564,
87665,
2354,
1703,
15741,
19398,
675,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
2415,
14032,
30953,
4913,
64,
3909,
788,
7342,
330,
65,
3909,
788,
7342,
330,
66,
3909,
788,
1591,
630,
25291,
1669,
609,
30570,
12020,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWaitForResourceTransition(t *testing.T) {
task := &managedTask{
Task: &apitask.Task{
ResourcesMapUnsafe: make(map[string][]taskresource.TaskResource),
},
}
transition := make(chan struct{}, 1)
transitionChangeResource := make(chan string, 1)
resName := "cgroup"
// populate the transitions map with transition for the
// resource. We expect the event to be consumed
// by `waitForTransition`
transitions := make(map[string]string)
transitions[resName] = "ResourceCreated"
go func() {
// Send "transition complete" message
transition <- struct{}{}
transitionChangeResource <- resName
}()
// waitForTransition will block until it receives the event
// sent by the go routine defined above
task.waitForTransition(transitions, transition, transitionChangeResource)
} | explode_data.jsonl/24590 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
14190,
90100,
21768,
1155,
353,
8840,
836,
8,
341,
49115,
1669,
609,
25270,
6262,
515,
197,
81153,
25,
609,
391,
275,
1073,
28258,
515,
298,
197,
11277,
2227,
78770,
25,
1281,
9147,
14032,
45725,
8202,
9233,
28258,
4783,
132... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExpectedBuildFailures(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
if ShouldRunGCPOnlyTests() {
t.Skip("skipping test that is not gcp only")
}
tests := []struct {
description string
dir string
args []string
expected string
}{
{
description: "jib is too old",
dir: "testdata/jib",
args: []string{"-p", "old-jib"},
expected: "Could not find goal '_skaffold-fail-if-jib-out-of-date' in plugin com.google.cloud.tools:jib-maven-plugin:1.3.0",
// test string will need to be updated for the jib.requiredVersion error text when moving to Jib > 1.4.0
},
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
if out, err := skaffold.Build(test.args...).InDir(test.dir).RunWithCombinedOutput(t); err == nil {
t.Fatal("expected build to fail")
} else if !strings.Contains(string(out), test.expected) {
logrus.Info("build output: ", string(out))
t.Fatalf("build failed but for wrong reason")
}
})
}
} | explode_data.jsonl/82303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 433
} | [
2830,
3393,
18896,
11066,
19524,
1413,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
17590,
1273,
1138,
197,
532,
743,
12260,
6727,
38,
7123,
7308,
18200,
368,
341,
197,
3244,
57776,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBot_UnbanChatMember(t *testing.T) {
type fields struct {
apiClient apiClient
}
tests := []struct {
name string
fields fields
wantResult bool
wantErr bool
}{
{
name: "test1",
fields: fields{
apiClient: &mockAPIClient{
method: "unbanChatMember",
interfaceMethod: func() interface{} {
return true
},
bytesMethod: func() []byte {
return []byte("true")
},
},
},
wantResult: true,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Bot{
apiClient: tt.fields.apiClient,
}
gotResult, err := b.UnbanChatMember(axon.O{})
if (err != nil) != tt.wantErr {
t.Errorf("Bot.UnbanChatMember() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotResult, tt.wantResult) {
t.Errorf("Bot.UnbanChatMember() = %v, want %v", gotResult, tt.wantResult)
}
})
}
} | explode_data.jsonl/46108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 454
} | [
2830,
3393,
23502,
40687,
6850,
15672,
9366,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
54299,
2959,
6330,
2959,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
55276,
257,
5043,
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 TestProperReconnectDelay(t *testing.T) {
s1 := RunServerOnPort(1222)
defer s1.Shutdown()
var srvs string
opts := nats.DefaultOptions
if runtime.GOOS == "windows" {
srvs = strings.Join(testServers[:2], ",")
} else {
srvs = strings.Join(testServers, ",")
}
opts.NoRandomize = true
dcbCalled := false
closedCbCalled := false
dch := make(chan bool)
dcb := func(nc *nats.Conn) {
// Suppress any additional calls
if dcbCalled {
return
}
dcbCalled = true
dch <- true
}
ccb := func(_ *nats.Conn) {
closedCbCalled = true
}
nc, err := nats.Connect(srvs, nats.DontRandomize(), nats.DisconnectHandler(dcb), nats.ClosedHandler(ccb))
if err != nil {
t.Fatalf("Expected to connect, got err: %v\n", err)
}
defer nc.Close()
s1.Shutdown()
// wait for disconnect
if e := WaitTime(dch, 2*time.Second); e != nil {
t.Fatal("Did not receive a disconnect callback message")
}
// Wait, want to make sure we don't spin on reconnect to non-existent servers.
time.Sleep(1 * time.Second)
// Make sure we are still reconnecting..
if closedCbCalled {
t.Fatal("Closed CB was triggered, should not have been.")
}
if status := nc.Status(); status != nats.RECONNECTING {
t.Fatalf("Wrong status: %d\n", status)
}
} | explode_data.jsonl/1554 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
1336,
712,
693,
6459,
20039,
1155,
353,
8840,
836,
8,
341,
1903,
16,
1669,
6452,
5475,
1925,
7084,
7,
16,
17,
17,
17,
340,
16867,
274,
16,
10849,
18452,
2822,
2405,
43578,
82,
914,
198,
64734,
1669,
308,
1862,
13275,
379... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFxVerifyMintOperation(t *testing.T) {
vm := secp256k1fx.TestVM{
Codec: linearcodec.NewDefault(),
Log: logging.NoLog{},
}
date := time.Date(2019, time.January, 19, 16, 25, 17, 3, time.UTC)
vm.CLK.Set(date)
fx := Fx{}
if err := fx.Initialize(&vm); err != nil {
t.Fatal(err)
}
tx := &secp256k1fx.TestTx{
Bytes: txBytes,
}
cred := &Credential{Credential: secp256k1fx.Credential{
Sigs: [][crypto.SECP256K1RSigLen]byte{
sigBytes,
},
}}
utxo := &MintOutput{OutputOwners: secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{
addr,
},
}}
op := &MintOperation{
MintInput: secp256k1fx.Input{
SigIndices: []uint32{0},
},
}
utxos := []interface{}{utxo}
if err := fx.VerifyOperation(tx, op, cred, utxos); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/56450 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
81856,
32627,
44,
396,
8432,
1155,
353,
8840,
836,
8,
341,
54879,
1669,
511,
4672,
17,
20,
21,
74,
16,
8298,
8787,
11187,
515,
197,
197,
36913,
25,
13482,
34607,
7121,
3675,
3148,
197,
24201,
25,
256,
8392,
16766,
2201,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestByteMatchString(t *testing.T) {
for _, tt := range []struct {
name string
input ByteMatch
want string
}{
{
name: "byte_test basic",
input: ByteMatch{
Kind: bTest,
NumBytes: "3",
Operator: ">",
Value: "300",
Offset: 42,
},
want: `byte_test:3,>,300,42;`,
},
{
name: "byte_jump basic",
input: ByteMatch{
Kind: bJump,
NumBytes: "3",
Offset: 42,
},
want: `byte_jump:3,42;`,
},
{
name: "byte_extract basic",
input: ByteMatch{
Kind: bExtract,
NumBytes: "3",
Offset: 42,
Variable: "foobar",
},
want: `byte_extract:3,42,foobar;`,
},
{
name: "byte_test options",
input: ByteMatch{
Kind: bTest,
NumBytes: "3",
Operator: ">",
Value: "300",
Offset: 42,
Options: []string{"string", "dec"},
},
want: `byte_test:3,>,300,42,string,dec;`,
},
{
name: "byte_jump options",
input: ByteMatch{
Kind: bJump,
NumBytes: "3",
Offset: 42,
Options: []string{"relative", "post_offset 2", "bitmask 0x03f0"},
},
want: `byte_jump:3,42,relative,post_offset 2,bitmask 0x03f0;`,
},
{
name: "byte_extract options",
input: ByteMatch{
Kind: bExtract,
NumBytes: "3",
Offset: 42,
Variable: "foobar",
Options: []string{"relative", "bitmask 0x03ff"},
},
want: `byte_extract:3,42,foobar,relative,bitmask 0x03ff;`,
},
} {
got := tt.input.String()
if got != tt.want {
t.Fatalf("%s: got %v -- expected %v", tt.name, got, tt.want)
}
}
} | explode_data.jsonl/59683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 811
} | [
2830,
3393,
7153,
8331,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
10906,
8331,
198,
197,
50780,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
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... | 3 |
func TestGetArchiveSuccess(t *testing.T) {
locator := config.NewLocator(config.Config)
serverSocketPath, stop := runRepoServer(t, locator)
defer stop()
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
testRepo, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
formats := []gitalypb.GetArchiveRequest_Format{
gitalypb.GetArchiveRequest_ZIP,
gitalypb.GetArchiveRequest_TAR,
gitalypb.GetArchiveRequest_TAR_GZ,
gitalypb.GetArchiveRequest_TAR_BZ2,
}
testCases := []struct {
desc string
prefix string
commitID string
path []byte
exclude [][]byte
elidePath bool
contents []string
excluded []string
}{
{
desc: "without-prefix",
commitID: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
prefix: "",
contents: []string{"/.gitignore", "/LICENSE", "/README.md"},
},
{
desc: "with-prefix",
commitID: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
prefix: "my-prefix",
contents: []string{"/.gitignore", "/LICENSE", "/README.md"},
},
{
desc: "with path as blank string",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "",
path: []byte(""),
contents: []string{"/.gitignore", "/LICENSE", "/README.md"},
},
{
desc: "with path as nil",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "",
path: nil,
contents: []string{"/.gitignore", "/LICENSE", "/README.md"},
},
{
desc: "with path",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "",
path: []byte("files"),
contents: []string{"/whitespace", "/html/500.html"},
},
{
desc: "with path and trailing slash",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "",
path: []byte("files/"),
contents: []string{"/whitespace", "/html/500.html"},
},
{
desc: "with exclusion",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "",
exclude: [][]byte{[]byte("files")},
contents: []string{"/.gitignore", "/LICENSE", "/README.md"},
excluded: []string{"/files/whitespace", "/files/html/500.html"},
},
{
desc: "with path elision",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "my-prefix",
elidePath: true,
path: []byte("files/"),
contents: []string{"/whitespace", "/html/500.html"},
},
{
desc: "with path elision and exclusion",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "my-prefix",
elidePath: true,
path: []byte("files/"),
exclude: [][]byte{[]byte("files/images")},
contents: []string{"/whitespace", "/html/500.html"},
excluded: []string{"/images/emoji.png"},
},
{
desc: "with path elision at root",
commitID: "1e292f8fedd741b75372e19097c76d327140c312",
prefix: "my-prefix",
elidePath: true,
contents: []string{"/files/whitespace", "/files/html/500.html"},
},
}
for _, tc := range testCases {
// Run test case with each format
for _, format := range formats {
testCaseName := fmt.Sprintf("%s-%s", tc.desc, format.String())
t.Run(testCaseName, func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
req := &gitalypb.GetArchiveRequest{
Repository: testRepo,
CommitId: tc.commitID,
Prefix: tc.prefix,
Format: format,
Path: tc.path,
Exclude: tc.exclude,
ElidePath: tc.elidePath,
}
stream, err := client.GetArchive(ctx, req)
require.NoError(t, err)
data, err := consumeArchive(stream)
require.NoError(t, err)
archiveFile, err := ioutil.TempFile("", "")
require.NoError(t, err)
defer os.Remove(archiveFile.Name())
_, err = archiveFile.Write(data)
require.NoError(t, err)
contents := string(compressedFileContents(t, format, archiveFile.Name()))
for _, content := range tc.contents {
require.Contains(t, contents, tc.prefix+content)
}
for _, excluded := range tc.excluded {
require.NotContains(t, contents, tc.prefix+excluded)
}
})
}
}
} | explode_data.jsonl/60642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1935
} | [
2830,
3393,
1949,
42502,
7188,
1155,
353,
8840,
836,
8,
341,
197,
68033,
1669,
2193,
7121,
33831,
8754,
10753,
340,
41057,
10286,
1820,
11,
2936,
1669,
1598,
25243,
5475,
1155,
11,
47117,
340,
16867,
2936,
2822,
25291,
11,
4534,
1669,
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... | 3 |
func TestMinMaxTimes(t *testing.T) {
// It fails if there are less calls than specified
reporter, ctrl := createFixtures(t)
subject := new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(2).MaxTimes(2)
ctrl.Call(subject, "FooMethod", "argument")
reporter.assertFatal(func() {
ctrl.Finish()
})
// It fails if there are more calls than specified
reporter, ctrl = createFixtures(t)
subject = new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(2).MaxTimes(2)
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
reporter.assertFatal(func() {
ctrl.Call(subject, "FooMethod", "argument")
})
// It succeeds if there is just the right number of calls
reporter, ctrl = createFixtures(t)
subject = new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(2).MinTimes(2)
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Finish()
// If MaxTimes is called after MinTimes is called with 1, MaxTimes takes precedence.
reporter, ctrl = createFixtures(t)
subject = new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(1).MaxTimes(2)
ctrl.Call(subject, "FooMethod", "argument")
ctrl.Call(subject, "FooMethod", "argument")
reporter.assertFatal(func() {
ctrl.Call(subject, "FooMethod", "argument")
})
// If MinTimes is called after MaxTimes is called with 1, MinTimes takes precedence.
reporter, ctrl = createFixtures(t)
subject = new(Subject)
ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(1).MinTimes(2)
for i := 0; i < 100; i++ {
ctrl.Call(subject, "FooMethod", "argument")
}
ctrl.Finish()
} | explode_data.jsonl/17281 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 584
} | [
2830,
3393,
92304,
18889,
1155,
353,
8840,
836,
8,
341,
197,
322,
1084,
14525,
421,
1052,
525,
2686,
6738,
1091,
5189,
198,
69931,
261,
11,
23743,
1669,
1855,
25958,
18513,
1155,
340,
28624,
583,
1669,
501,
7,
13019,
340,
84381,
49959,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProxy(t *testing.T) {
var xff string
p, c := testProxy()
o := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
xff = req.Header.Get("X-Forwarded-For")
}))
defer p.Close()
defer o.Close()
res, err := c.Get(o.URL + "/")
if err != nil {
t.Fatal(err)
}
defer res.Body.Close()
if xff != "127.0.0.1" {
t.Errorf("expected X-Forwarded-For header to be present: expected '%s', got '%s'", "127.0.0.1", xff)
}
} | explode_data.jsonl/12952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
16219,
1155,
353,
8840,
836,
8,
341,
2405,
856,
542,
914,
271,
3223,
11,
272,
1669,
1273,
16219,
741,
22229,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
4232,
353,
1254,
9659,
8,
341,
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... | 1 |
func TestECDSASignatureEncoding(t *testing.T) {
t.Parallel()
v := []byte{0x30, 0x07, 0x02, 0x01, 0x8F, 0x02, 0x02, 0xff, 0xf1}
_, err := asn1.Unmarshal(v, &utils.ECDSASignature{})
if err == nil {
t.Fatalf("Unmarshalling should fail for [% x]", v)
}
t.Logf("Unmarshalling correctly failed for [% x] [%s]", v, err)
v = []byte{0x30, 0x07, 0x02, 0x01, 0x8F, 0x02, 0x02, 0x00, 0x01}
_, err = asn1.Unmarshal(v, &utils.ECDSASignature{})
if err == nil {
t.Fatalf("Unmarshalling should fail for [% x]", v)
}
t.Logf("Unmarshalling correctly failed for [% x] [%s]", v, err)
v = []byte{0x30, 0x07, 0x02, 0x01, 0x8F, 0x02, 0x81, 0x01, 0x01}
_, err = asn1.Unmarshal(v, &utils.ECDSASignature{})
if err == nil {
t.Fatalf("Unmarshalling should fail for [% x]", v)
}
t.Logf("Unmarshalling correctly failed for [% x] [%s]", v, err)
v = []byte{0x30, 0x07, 0x02, 0x01, 0x8F, 0x02, 0x81, 0x01, 0x8F}
_, err = asn1.Unmarshal(v, &utils.ECDSASignature{})
if err == nil {
t.Fatalf("Unmarshalling should fail for [% x]", v)
}
t.Logf("Unmarshalling correctly failed for [% x] [%s]", v, err)
v = []byte{0x30, 0x0A, 0x02, 0x01, 0x8F, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00, 0x8F}
_, err = asn1.Unmarshal(v, &utils.ECDSASignature{})
if err == nil {
t.Fatalf("Unmarshalling should fail for [% x]", v)
}
t.Logf("Unmarshalling correctly failed for [% x] [%s]", v, err)
} | explode_data.jsonl/29269 | {
"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,
7498,
5936,
1911,
622,
1568,
14690,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
5195,
1669,
3056,
3782,
90,
15,
87,
18,
15,
11,
220,
15,
87,
15,
22,
11,
220,
15,
87,
15,
17,
11,
220,
15,
87,
15,
16,
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... | 6 |
func TestNamespaceReadEncodedShardOwned(t *testing.T) {
ctrl := xtest.NewController(t)
defer ctrl.Finish()
ctx := context.NewBackground()
defer ctx.Close()
id := ident.StringID("foo")
start := xtime.Now()
end := start.Add(time.Second)
ns, closer := newTestNamespace(t)
defer closer()
shard := NewMockdatabaseShard(ctrl)
shard.EXPECT().ReadEncoded(ctx, id, start, end, gomock.Any()).Return(nil, nil)
ns.shards[testShardIDs[0].ID()] = shard
shard.EXPECT().IsBootstrapped().Return(true)
_, err := ns.ReadEncoded(ctx, id, start, end)
require.NoError(t, err)
shard.EXPECT().IsBootstrapped().Return(false)
_, err = ns.ReadEncoded(ctx, id, start, end)
require.Error(t, err)
require.True(t, xerrors.IsRetryableError(err))
require.Equal(t, errShardNotBootstrappedToRead, xerrors.GetInnerRetryableError(err))
} | explode_data.jsonl/35344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
22699,
4418,
46795,
2016,
567,
57641,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
856,
1944,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
20985,
1669,
2266,
7121,
8706,
741,
16867,
5635,
10421,
2822,
15710,
1669,
3524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestORM_MergeKlineM1(t *testing.T) {
orm, err := NewSqlite3ORM(false, "/tmp/", "test.db", nil)
require.Nil(t, err)
product := "abc_bcd"
_, err = orm.getLatestKlineM1ByProduct(product, 100)
require.Nil(t, err)
klineM3, e := types.NewKlineFactory("kline_m3", nil)
assert.True(t, klineM3 != nil && e == nil)
_, _, _, err = orm.MergeKlineM1(0, time.Now().Unix()+1, klineM3.(types.IKline))
require.Nil(t, err)
klineM3List := []types.KlineM3{}
err = orm.GetLatestKlinesByProduct(product, 100, -1, &klineM3List)
require.Nil(t, err)
assert.True(t, len(klineM3List) > 0)
} | explode_data.jsonl/77877 | {
"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,
4365,
1245,
10080,
42,
1056,
44,
16,
1155,
353,
8840,
836,
8,
1476,
197,
493,
11,
1848,
1669,
1532,
8269,
632,
18,
4365,
3576,
11,
3521,
5173,
28105,
330,
1944,
7076,
497,
2092,
340,
17957,
59678,
1155,
11,
1848,
340,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidNamed(t *testing.T) {
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
}
}()
type Aaa struct{}
type Bbb struct {
Aaa *Aaa `inject:"unknown_aaa"`
}
b := new(Bbb)
New().
WithNamedObject("aaa", new(Aaa)).
WithObject(b).
InitializeGraph()
assert.Fail(t, "Must panic")
} | explode_data.jsonl/72959 | {
"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,
7928,
15810,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
743,
435,
1669,
11731,
2129,
435,
961,
2092,
341,
298,
11009,
12419,
445,
81476,
304,
282,
497,
435,
340,
197,
197,
532,
197,
66816,
13158,
362,
5305,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCertificateGet(t *testing.T) {
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
cID := "892071a0-bb95-49bc-8021-3afd67a210bf"
tm.certificates.On("Get", cID).Return(&testCertificate, nil)
config.Args = append(config.Args, cID)
err := RunCertificateGet(config)
assert.NoError(t, err)
})
} | explode_data.jsonl/4818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
33202,
1949,
1155,
353,
8840,
836,
8,
341,
46948,
2271,
2959,
1155,
11,
2915,
8754,
353,
15613,
2648,
11,
17333,
353,
10413,
72577,
8,
341,
197,
1444,
915,
1669,
330,
23,
24,
17,
15,
22,
16,
64,
15,
1455,
65,
24,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCalTimeWindow(t *testing.T) {
calc := dayCalculator
assert.Equal(t, 2, calc.CalcTimeWindows(3600000, 3600000*2))
calc = monthCalculator
assert.Equal(t, 2, calc.CalcTimeWindows(86400000, 86400000*2))
calc = yearCalculator
assert.Equal(t, 2, calc.CalcTimeWindows(2592000000, 2592000000*2))
} | explode_data.jsonl/75709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
8851,
1462,
4267,
1155,
353,
8840,
836,
8,
341,
1444,
16927,
1669,
1899,
55743,
198,
6948,
12808,
1155,
11,
220,
17,
11,
10035,
727,
16927,
1462,
13164,
7,
18,
21,
15,
15,
15,
15,
15,
11,
220,
18,
21,
15,
15,
15,
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... | 1 |
func TestMessageExportSettingsIsValidExportFormatInvalid(t *testing.T) {
fs := &FileSettings{
DriverName: NewString("foo"), // bypass file location check
}
mes := &MessageExportSettings{
EnableExport: NewBool(true),
ExportFromTimestamp: NewInt64(0),
DailyRunTime: NewString("15:04"),
BatchSize: NewInt(100),
}
// should fail fast because export format isn't set
require.Error(t, mes.isValid(*fs))
} | explode_data.jsonl/50684 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
2052,
16894,
6086,
55470,
16894,
4061,
7928,
1155,
353,
8840,
836,
8,
341,
53584,
1669,
609,
1703,
6086,
515,
197,
10957,
5469,
675,
25,
1532,
703,
445,
7975,
3975,
442,
30718,
1034,
3728,
1779,
198,
197,
532,
2109,
288,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNonGoFolder(t *testing.T) {
const files = `
-- hello.txt --
hi mom
`
for _, go111module := range []string{"on", "off", ""} {
t.Run(fmt.Sprintf("GO111MODULE_%v", go111module), func(t *testing.T) {
withOptions(EditorConfig{
Env: map[string]string{"GO111MODULE": go111module},
}).run(t, files, func(t *testing.T, env *Env) {
env.OpenFile("hello.txt")
env.Await(
OnceMet(
CompletedWork(lsp.DiagnosticWorkTitle(lsp.FromDidOpen), 1),
NoShowMessage(),
),
)
})
})
}
} | explode_data.jsonl/38919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
8121,
10850,
13682,
1155,
353,
8840,
836,
8,
341,
4777,
3542,
284,
22074,
313,
23811,
3909,
39514,
6023,
3368,
198,
3989,
2023,
8358,
728,
16,
16,
16,
4352,
1669,
2088,
3056,
917,
4913,
263,
497,
330,
1847,
497,
1591,
92,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPublicFromPrivate(t *testing.T) {
var seed [eddilithium4.SeedSize]byte
for i := uint64(0); i < 100; i++ {
binary.LittleEndian.PutUint64(seed[:], i)
pk, sk := eddilithium4.NewKeyFromSeed(&seed)
pk2 := sk.Public().(*eddilithium4.PublicKey)
var pkb1, pkb2 [eddilithium4.PublicKeySize]byte
pk.Pack(&pkb1)
pk2.Pack(&pkb2)
if pkb1 != pkb2 {
t.Fatal()
}
}
} | explode_data.jsonl/73547 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
12676,
3830,
16787,
1155,
353,
8840,
836,
8,
341,
2405,
10320,
508,
53537,
321,
410,
2356,
19,
5732,
291,
1695,
90184,
198,
2023,
600,
1669,
2622,
21,
19,
7,
15,
1215,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
341,
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 TestChatSrvGetThreadLocalMarkAsRead(t *testing.T) {
runWithMemberTypes(t, func(mt chat1.ConversationMembersType) {
// TODO: investigate LocalDb in TestContext and make it behave the same way
// as in real context / docker tests. This test should fail without the fix
// in ConvSource for marking is read, but does not currently.
ctc := makeChatTestContext(t, "GetThreadLocalMarkAsRead", 2)
defer ctc.cleanup()
users := ctc.users()
withUser1 := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT,
mt, ctc.as(t, users[1]).user())
mustPostLocalForTest(t, ctc, users[0], withUser1, chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hello0"}))
mustPostLocalForTest(t, ctc, users[1], withUser1, chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hello1"}))
mustPostLocalForTest(t, ctc, users[0], withUser1, chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hello2"}))
ctx := ctc.as(t, users[0]).startCtx
res, err := ctc.as(t, users[0]).chatLocalHandler().GetInboxSummaryForCLILocal(ctx, chat1.GetInboxSummaryForCLILocalQuery{
TopicType: chat1.TopicType_CHAT,
})
require.NoError(t, err)
require.Equal(t, 1, len(res.Conversations))
require.Equal(t, res.Conversations[0].Info.Id.String(), withUser1.Id.String())
var found bool
for _, m := range res.Conversations[0].MaxMessages {
if m.GetMessageType() == chat1.MessageType_TEXT {
require.NotEqual(t, res.Conversations[0].ReaderInfo.ReadMsgid, m.GetMessageID())
found = true
break
}
}
require.True(t, found)
// Do a get thread local without requesting marking as read first. This
// should cause HybridConversationSource to cache the thread. Then we do
// another call requesting marking as read before checking if the thread is
// marked as read. This is to ensure that when the query requests for a
// mark-as-read, and the thread gets a cache hit, the
// HybridConversationSource should not just return the thread, but also send
// a MarkAsRead RPC to remote. (Currently this is done in
// HybridConversationSource.Pull)
//
// TODO: This doesn't make sense! In integration tests, this isn't necessary
// since a Pull() is called during PostLocal (when populating the Prev
// pointers). However it seems in this test, it doesn't do so. This first
// GetThreadLocal always gets a cache miss, resulting a remote call. If
// PostLocal had worked like integration, this shouldn't be necessary. We
// should find out where the problem is and fix it! Although after that fix,
// this should probably still stay here just in case.
_, err = ctc.as(t, users[0]).chatLocalHandler().GetThreadLocal(ctx, chat1.GetThreadLocalArg{
ConversationID: withUser1.Id,
Query: &chat1.GetThreadQuery{
MarkAsRead: false,
},
})
require.NoError(t, err)
tv, err := ctc.as(t, users[0]).chatLocalHandler().GetThreadLocal(ctx, chat1.GetThreadLocalArg{
ConversationID: withUser1.Id,
Query: &chat1.GetThreadQuery{
MarkAsRead: true,
},
})
require.NoError(t, err)
expectedMessages := 4 // 3 messges and 1 TLF
require.Len(t, tv.Thread.Messages, expectedMessages,
"unexpected response from GetThreadLocal . number of messages")
res, err = ctc.as(t, users[0]).chatLocalHandler().GetInboxSummaryForCLILocal(ctx, chat1.GetInboxSummaryForCLILocalQuery{
TopicType: chat1.TopicType_CHAT,
})
require.NoError(t, err)
require.Equal(t, 1, len(res.Conversations))
found = false
for _, m := range res.Conversations[0].MaxMessages {
if m.GetMessageType() == chat1.MessageType_TEXT {
require.Equal(t, res.Conversations[0].ReaderInfo.ReadMsgid,
m.GetMessageID())
found = true
break
}
}
require.True(t, found)
})
} | explode_data.jsonl/63681 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1333
} | [
2830,
3393,
15672,
50,
10553,
1949,
6855,
7319,
8949,
2121,
4418,
1155,
353,
8840,
836,
8,
341,
56742,
2354,
9366,
4173,
1155,
11,
2915,
81618,
6236,
16,
4801,
22323,
24371,
929,
8,
341,
197,
197,
322,
5343,
25,
19314,
8774,
7994,
304... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetNewTiKVSetForTidbCluster(t *testing.T) {
enable := true
tests := []struct {
name string
tc v1alpha1.TidbCluster
wantErr bool
testSts func(sts *apps.StatefulSet)
}{
{
name: "tikv network is not host",
tc: v1alpha1.TidbCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "tc",
Namespace: "ns",
},
},
testSts: testHostNetwork(t, false, ""),
},
{
name: "tikv network is host",
tc: v1alpha1.TidbCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "tc",
Namespace: "ns",
},
Spec: v1alpha1.TidbClusterSpec{
TiKV: v1alpha1.TiKVSpec{
ComponentSpec: v1alpha1.ComponentSpec{
HostNetwork: &enable,
},
},
},
},
testSts: testHostNetwork(t, true, v1.DNSClusterFirstWithHostNet),
},
{
name: "tikv network is not host when pd is host",
tc: v1alpha1.TidbCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "tc",
Namespace: "ns",
},
Spec: v1alpha1.TidbClusterSpec{
PD: v1alpha1.PDSpec{
ComponentSpec: v1alpha1.ComponentSpec{
HostNetwork: &enable,
},
},
},
},
testSts: testHostNetwork(t, false, ""),
},
{
name: "tikv network is not host when tidb is host",
tc: v1alpha1.TidbCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "tc",
Namespace: "ns",
},
Spec: v1alpha1.TidbClusterSpec{
TiDB: v1alpha1.TiDBSpec{
ComponentSpec: v1alpha1.ComponentSpec{
HostNetwork: &enable,
},
},
},
},
testSts: testHostNetwork(t, false, ""),
},
// TODO add more tests
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sts, err := getNewTiKVSetForTidbCluster(&tt.tc)
if (err != nil) != tt.wantErr {
t.Errorf("error %v, wantErr %v", err, tt.wantErr)
}
tt.testSts(sts)
})
}
} | explode_data.jsonl/37149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 966
} | [
2830,
3393,
1949,
3564,
45351,
82707,
1649,
2461,
51,
307,
65,
28678,
1155,
353,
8840,
836,
8,
341,
197,
12552,
1669,
830,
198,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
78255,
414,
348,
16,
7141,
16,
836,
307,
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 TestTraceExporter_Default(t *testing.T) {
td := pdata.NewTraces()
te, err := NewTraceExporter(fakeTraceExporterConfig, zap.NewNop(), newTraceDataPusher(nil))
assert.NotNil(t, te)
assert.NoError(t, err)
assert.Nil(t, te.ConsumeTraces(context.Background(), td))
assert.Nil(t, te.Shutdown(context.Background()))
} | explode_data.jsonl/70308 | {
"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,
6550,
88025,
60336,
1155,
353,
8840,
836,
8,
341,
76373,
1669,
70311,
7121,
1282,
2434,
741,
197,
665,
11,
1848,
1669,
1532,
6550,
88025,
74138,
6550,
88025,
2648,
11,
32978,
7121,
45,
453,
1507,
501,
6550,
1043,
16644,
261,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAdmissionTenantTerminating(t *testing.T) {
namespace := "test"
tenant := "test-te"
namespacePhases := map[string]v1.NamespacePhase{tenant + "/" + namespace: v1.NamespaceActive}
tenantPhases := map[string]v1.TenantPhase{tenant: v1.TenantTerminating}
mockClient := newMockClientForTest(namespacePhases, tenantPhases)
handler, informerFactory, err := newHandlerForTest(mockClient)
if err != nil {
t.Errorf("unexpected error initializing handler: %v", err)
}
informerFactory.Start(wait.NeverStop)
pod := newPod(namespace, tenant)
// verify create operations cause an error
err = handler.Admit(admission.NewAttributesRecord(&pod, nil, v1.SchemeGroupVersion.WithKind("Pod").GroupKind().WithVersion("version"), pod.Tenant, pod.Namespace, pod.Name, v1.Resource("pods").WithVersion("version"), "", admission.Create, &metav1.CreateOptions{}, false, nil), nil)
if err == nil {
t.Errorf("Expected error rejecting creates when the tenant is terminating")
}
// verify update operations in the namespace can proceed
err = handler.Admit(admission.NewAttributesRecord(&pod, nil, v1.SchemeGroupVersion.WithKind("Pod").GroupKind().WithVersion("version"), pod.Tenant, pod.Namespace, pod.Name, v1.Resource("pods").WithVersion("version"), "", admission.Update, &metav1.UpdateOptions{}, false, nil), nil)
if err != nil {
t.Errorf("Unexpected error returned from admission handler: %v", err)
}
// verify delete operations in the namespace can proceed
err = handler.Admit(admission.NewAttributesRecord(nil, nil, v1.SchemeGroupVersion.WithKind("Pod").GroupKind().WithVersion("version"), pod.Tenant, pod.Namespace, pod.Name, v1.Resource("pods").WithVersion("version"), "", admission.Delete, &metav1.DeleteOptions{}, false, nil), nil)
if err != nil {
t.Errorf("Unexpected error returned from admission handler: %v", err)
}
// verify delete of namespace default can proceed
err = handler.Admit(admission.NewAttributesRecord(nil, nil, v1.SchemeGroupVersion.WithKind("Namespace").GroupKind().WithVersion("version"), tenant, "", metav1.NamespaceDefault, v1.Resource("namespaces").WithVersion("version"), "", admission.Delete, &metav1.DeleteOptions{}, false, nil), nil)
if err != nil {
t.Errorf("Did not expect an error %v", err)
}
// verify delete of namespace other than default can proceed
err = handler.Admit(admission.NewAttributesRecord(nil, nil, v1.SchemeGroupVersion.WithKind("Namespace").GroupKind().WithVersion("version"), tenant, "", "other", v1.Resource("namespaces").WithVersion("version"), "", admission.Delete, &metav1.DeleteOptions{}, false, nil), nil)
if err != nil {
t.Errorf("Did not expect an error %v", err)
}
} | explode_data.jsonl/69162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 832
} | [
2830,
3393,
2589,
2728,
71252,
21209,
64283,
1155,
353,
8840,
836,
8,
341,
56623,
1669,
330,
1944,
698,
197,
43919,
1669,
330,
1944,
48793,
698,
56623,
3357,
2264,
1669,
2415,
14032,
60,
85,
16,
46011,
30733,
90,
43919,
488,
16891,
488,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContinueMulti(t *testing.T) {
protest.AllowRecording(t)
withTestProcess("integrationprog", t, func(p *proc.Target, fixture protest.Fixture) {
bp1 := setFunctionBreakpoint(p, t, "main.main")
bp2 := setFunctionBreakpoint(p, t, "main.sayhi")
mainCount := 0
sayhiCount := 0
for {
err := p.Continue()
if valid, _ := p.Valid(); !valid {
break
}
assertNoError(err, t, "Continue()")
if bp := p.CurrentThread().Breakpoint(); bp.LogicalID() == bp1.LogicalID() {
mainCount++
}
if bp := p.CurrentThread().Breakpoint(); bp.LogicalID() == bp2.LogicalID() {
sayhiCount++
}
}
if mainCount != 1 {
t.Fatalf("Main breakpoint hit wrong number of times: %d\n", mainCount)
}
if sayhiCount != 3 {
t.Fatalf("Sayhi breakpoint hit wrong number of times: %d\n", sayhiCount)
}
})
} | explode_data.jsonl/56221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
23526,
20358,
1155,
353,
8840,
836,
8,
341,
197,
776,
1944,
29081,
52856,
1155,
340,
46948,
2271,
7423,
445,
60168,
32992,
497,
259,
11,
2915,
1295,
353,
15782,
35016,
11,
12507,
8665,
991,
12735,
8,
341,
197,
2233,
79,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorageSmartContract_addBlobber(t *testing.T) {
var (
ssc = newTestStorageSC()
balances = newTestBalances(t, false)
tp int64 = 100
)
setConfig(t, balances)
var (
blob = addBlobber(t, ssc, 2*GB, tp, avgTerms, 50*x10, balances)
b, err = ssc.getBlobber(blob.id, balances)
)
require.NoError(t, err)
// remove
b.Capacity = 0
tp += 100
_, err = updateBlobber(t, b, 0, tp, ssc, balances)
require.NoError(t, err)
var all *StorageNodes
all, err = ssc.getBlobbersList(balances)
require.NoError(t, err)
require.Len(t, all.Nodes, 0)
// reborn
b.Capacity = 2 * GB
tp += 100
_, err = updateBlobber(t, b, 10*x10, tp, ssc, balances)
require.NoError(t, err)
all, err = ssc.getBlobbersList(balances)
require.NoError(t, err)
require.Len(t, all.Nodes, 1)
var ab, ok = all.Nodes.get(b.ID)
require.True(t, ok)
require.NotNil(t, ab)
// update (incl. url)
const NEW_BASE_URL = "https://new-base-url.com"
b.BaseURL = NEW_BASE_URL
b.Capacity = b.Capacity * 2
tp += 100
_, err = updateBlobber(t, b, 0, tp, ssc, balances)
require.NoError(t, err)
all, err = ssc.getBlobbersList(balances)
require.NoError(t, err)
require.Len(t, all.Nodes, 1)
ab, ok = all.Nodes.get(b.ID)
require.True(t, ok)
require.Equal(t, ab.BaseURL, NEW_BASE_URL)
require.Equal(t, ab.Capacity, b.Capacity)
} | explode_data.jsonl/32336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 607
} | [
2830,
3393,
5793,
33817,
14067,
2891,
37985,
652,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
34472,
66,
414,
284,
501,
2271,
5793,
3540,
741,
197,
2233,
278,
3020,
284,
501,
2271,
37889,
3020,
1155,
11,
895,
692,
197,
73423,
526,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateV1Beta1MissingMetadata(t *testing.T) {
manifest := `---
apiVersion: manifests/v1beta1
spec:
charts: []
`
_, err := Validate(manifest)
if err == nil || !strings.Contains(err.Error(), "manifest validation errors") {
t.Errorf("Didn't get expected error from manifest.TestValidateV1Beta1MissingMetadata(), instead got: %s", err)
}
} | explode_data.jsonl/80475 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
17926,
53,
16,
64811,
16,
25080,
14610,
1155,
353,
8840,
836,
8,
341,
197,
42315,
1669,
1565,
10952,
2068,
5637,
25,
83232,
5457,
16,
19127,
16,
198,
9535,
510,
220,
26131,
25,
4167,
3989,
197,
6878,
1848,
1669,
23282,
606... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteRefusedAfterClosed(t *testing.T) {
linkEp := fifo.New(nil, 1, 2)
linkEp.Close()
err := linkEp.WritePacket(nil)
_, ok := err.(*tcpip.ErrClosedForSend)
if !ok {
t.Errorf("got err = %s, want %s", err, &tcpip.ErrClosedForSend{})
}
} | explode_data.jsonl/1083 | {
"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,
7985,
3945,
2591,
6025,
26884,
1155,
353,
8840,
836,
8,
341,
54238,
22373,
1669,
63497,
7121,
27907,
11,
220,
16,
11,
220,
17,
692,
54238,
22373,
10421,
741,
9859,
1669,
2656,
22373,
4073,
16679,
27907,
340,
197,
6878,
5394,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResolver_RefetchAPISpec(t *testing.T) {
// given
testErr := errors.New("test error")
apiID := "apiID"
dataBytes := "data"
modelEventAPISpec := &model.EventAPISpec{
Data: &dataBytes,
}
modelEventAPIDefinition := &model.EventAPIDefinition{
Spec: modelEventAPISpec,
}
clob := graphql.CLOB(dataBytes)
gqlEventAPISpec := &graphql.EventAPISpec{
Data: &clob,
}
gqlEventAPIDefinition := &graphql.EventAPIDefinition{
Spec: gqlEventAPISpec,
}
testCases := []struct {
Name string
ServiceFn func() *automock.EventAPIService
ConvFn func() *automock.EventAPIConverter
ExpectedAPISpec *graphql.EventAPISpec
ExpectedErr error
}{
{
Name: "Success",
ServiceFn: func() *automock.EventAPIService {
svc := &automock.EventAPIService{}
svc.On("RefetchAPISpec", context.TODO(), apiID).Return(modelEventAPISpec, nil).Once()
return svc
},
ConvFn: func() *automock.EventAPIConverter {
conv := &automock.EventAPIConverter{}
conv.On("ToGraphQL", modelEventAPIDefinition).Return(gqlEventAPIDefinition).Once()
return conv
},
ExpectedAPISpec: gqlEventAPISpec,
ExpectedErr: nil,
},
{
Name: "Returns error when refetching EventAPI spec failed",
ServiceFn: func() *automock.EventAPIService {
svc := &automock.EventAPIService{}
svc.On("RefetchAPISpec", context.TODO(), apiID).Return(nil, testErr).Once()
return svc
},
ConvFn: func() *automock.EventAPIConverter {
conv := &automock.EventAPIConverter{}
conv.On("ToGraphQL", modelEventAPIDefinition).Return(gqlEventAPIDefinition).Once()
return conv
},
ExpectedAPISpec: nil,
ExpectedErr: testErr,
},
}
for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
// given
svc := testCase.ServiceFn()
conv := testCase.ConvFn()
resolver := eventapi.NewResolver(nil, svc, nil, conv, nil)
// when
result, err := resolver.RefetchEventAPISpec(context.TODO(), apiID)
// then
assert.Equal(t, testCase.ExpectedAPISpec, result)
assert.Equal(t, testCase.ExpectedErr, err)
svc.AssertExpectations(t)
})
}
} | explode_data.jsonl/2243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 960
} | [
2830,
3393,
18190,
81086,
2995,
2537,
1637,
992,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
18185,
7747,
1669,
5975,
7121,
445,
1944,
1465,
5130,
54299,
915,
1669,
330,
2068,
915,
1837,
8924,
7078,
1669,
330,
691,
698,
19727,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRetrieveByID(t *testing.T) {
repo := postgres.NewConfigRepository(db, testLog)
c := config
// Use UUID to prevent conflicts.
id := uuid.NewV4().String()
c.MFKey = id
c.MFThing = id
c.ExternalID = id
c.ExternalKey = id
id, err := repo.Save(c)
require.Nil(t, err, fmt.Sprintf("Saving config expected to succeed: %s.\n", err))
cases := []struct {
desc string
owner string
id string
err error
}{
{
desc: "retrieve config",
owner: c.Owner,
id: id,
err: nil,
},
{
desc: "retrieve config with wrong owner",
owner: "2",
id: id,
err: bootstrap.ErrNotFound,
},
{
desc: "retrieve a non-existing config",
owner: c.Owner,
id: uuid.NewV4().String(),
err: bootstrap.ErrNotFound,
},
{
desc: "retrieve a config with invalid ID",
owner: c.Owner,
id: "invalid",
err: bootstrap.ErrNotFound,
},
}
for _, tc := range cases {
_, err := repo.RetrieveByID(tc.owner, tc.id)
assert.Equal(t, tc.err, err, fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
}
} | explode_data.jsonl/459 | {
"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,
87665,
60572,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
1669,
59826,
7121,
2648,
4624,
9791,
11,
1273,
2201,
340,
1444,
1669,
2193,
198,
197,
322,
5443,
23698,
311,
5358,
25800,
624,
15710,
1669,
16040,
7121,
53,
19,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientWebsocketPing(t *testing.T) {
t.Parallel()
var (
sendPing = make(chan struct{})
server = wsPingTestServer(t, sendPing)
ctx, cancel = context.WithTimeout(context.Background(), 1*time.Second)
)
defer cancel()
defer server.Shutdown(ctx)
client, err := DialContext(ctx, "ws://"+server.Addr)
if err != nil {
t.Fatalf("client dial error: %v", err)
}
resultChan := make(chan int)
sub, err := client.EthSubscribe(ctx, resultChan, "foo")
if err != nil {
t.Fatalf("client subscribe error: %v", err)
}
// Wait for the context's deadline to be reached before proceeding.
// This is important for reproducing https://github.com/tenderly/optimism/l2geth/issues/19798
<-ctx.Done()
close(sendPing)
// Wait for the subscription result.
timeout := time.NewTimer(5 * time.Second)
for {
select {
case err := <-sub.Err():
t.Error("client subscription error:", err)
case result := <-resultChan:
t.Log("client got result:", result)
return
case <-timeout.C:
t.Error("didn't get any result within the test timeout")
return
}
}
} | explode_data.jsonl/21972 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 400
} | [
2830,
3393,
2959,
5981,
9556,
69883,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
2399,
197,
32817,
69883,
262,
284,
1281,
35190,
2036,
37790,
197,
41057,
414,
284,
17624,
69883,
2271,
5475,
1155,
11,
3624,
69883,
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... | 7 |
func TestUtil_Format_NoArgs(t *testing.T) {
vm := goja.New()
util := New(vm)
var b bytes.Buffer
util.Format(&b, "Test: %s %d, %j")
if res := b.String(); res != "Test: %s %d, %j" {
t.Fatalf("Unexpected result: '%s'", res)
}
} | explode_data.jsonl/60330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
2742,
72999,
36989,
4117,
1155,
353,
8840,
836,
8,
341,
54879,
1669,
728,
5580,
7121,
741,
79138,
1669,
1532,
31723,
692,
2405,
293,
5820,
22622,
198,
79138,
9978,
2099,
65,
11,
330,
2271,
25,
1018,
82,
1018,
67,
11,
1018,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLevelDBReceiptCreateErr(t *testing.T) {
assert := assert.New(t)
conf := &LevelDBReceiptStoreConf{
Path: path.Join(tmpdir, "dummyfile"),
}
_, err := newLevelDBReceipts(conf)
assert.Regexp("Unable to open LevelDB: .*", err)
} | explode_data.jsonl/21449 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
4449,
3506,
67461,
4021,
7747,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
67850,
1669,
609,
4449,
3506,
67461,
6093,
15578,
515,
197,
69640,
25,
1815,
22363,
10368,
3741,
11,
330,
31390,
1192,
4461,
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 TestTxnCoordSenderGCWithAmbiguousResultErr(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
testutils.RunTrueAndFalse(t, "errOnFirst", func(t *testing.T, errOnFirst bool) {
key := roachpb.Key("a")
are := roachpb.NewAmbiguousResultError("very ambiguous")
knobs := &kvserver.StoreTestingKnobs{
TestingResponseFilter: func(ctx context.Context, ba roachpb.BatchRequest, br *roachpb.BatchResponse) *roachpb.Error {
for _, req := range ba.Requests {
if putReq, ok := req.GetInner().(*roachpb.PutRequest); ok && putReq.Key.Equal(key) {
return roachpb.NewError(are)
}
}
return nil
},
}
s := createTestDBWithKnobs(t, knobs)
defer s.Stop()
ctx := context.Background()
txn := kv.NewTxn(ctx, s.DB, 0 /* gatewayNodeID */)
tc := txn.Sender().(*TxnCoordSender)
if !errOnFirst {
otherKey := roachpb.Key("other")
if err := txn.Put(ctx, otherKey, []byte("value")); err != nil {
t.Fatal(err)
}
}
if err := txn.Put(ctx, key, []byte("value")); !testutils.IsError(err, "result is ambiguous") {
t.Fatalf("expected error %v, found %v", are, err)
}
if err := txn.Rollback(ctx); err != nil {
t.Fatal(err)
}
testutils.SucceedsSoon(t, func() error {
// Locking the TxnCoordSender to prevent a data race.
if tc.IsTracking() {
return errors.Errorf("expected garbage collection")
}
return nil
})
verifyCleanup(key, s.Eng, t, tc)
})
} | explode_data.jsonl/76889 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 620
} | [
2830,
3393,
31584,
77,
19437,
20381,
22863,
2354,
54032,
27029,
2077,
7747,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
18185,
6031,
16708,
2514,
3036,
4049,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetContainerTypePodContainer(t *testing.T) {
annotations := map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
}
testGetContainerTypeSuccessful(t, annotations, vc.PodContainer)
} | explode_data.jsonl/44038 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
1949,
4502,
929,
23527,
4502,
1155,
353,
8840,
836,
8,
341,
197,
39626,
1669,
2415,
14032,
30953,
515,
197,
5195,
66,
21418,
33672,
929,
1592,
25,
914,
80698,
88823,
4502,
1326,
197,
630,
18185,
1949,
4502,
929,
36374,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanProcessorFuzzer(t *testing.T) {
zsp := NewSpanProcessor()
tracerProvider := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sdktrace.AlwaysSample()),
sdktrace.WithSpanProcessor(zsp),
)
const numIterations = 200
const numSpansPerIteration = 90
var wg sync.WaitGroup
wg.Add(4)
go func() {
for i := 0; i < numIterations; i++ {
assert.LessOrEqual(t, 0, len(zsp.spansPerMethod()))
assert.GreaterOrEqual(t, 2, len(zsp.spansPerMethod()))
createEndedSpans(tracerProvider.Tracer("test1"), "testSpan1", numSpansPerIteration)
// Call for spans names created by the other goroutines.
assert.LessOrEqual(t, 0, len(zsp.activeSpans("testSpan2")))
assert.LessOrEqual(t, 0, len(zsp.errorSpans("testSpan2")))
assert.LessOrEqual(t, 0, len(zsp.spansByLatency("testSpan2", 1)))
}
wg.Done()
}()
go func() {
for i := 0; i < numIterations; i++ {
assert.LessOrEqual(t, 0, len(zsp.spansPerMethod()))
assert.GreaterOrEqual(t, 2, len(zsp.spansPerMethod()))
createEndedSpans(tracerProvider.Tracer("test2"), "testSpan2", numSpansPerIteration)
// Call for spans names created by the other goroutines.
assert.LessOrEqual(t, 0, len(zsp.activeSpans("testSpan1")))
assert.LessOrEqual(t, 0, len(zsp.errorSpans("testSpan1")))
assert.LessOrEqual(t, 0, len(zsp.spansByLatency("testSpan1", 1)))
}
wg.Done()
}()
go func() {
for i := 0; i < numIterations; i++ {
assert.LessOrEqual(t, 0, len(zsp.spansPerMethod()))
assert.GreaterOrEqual(t, 2, len(zsp.spansPerMethod()))
createEndedSpans(tracerProvider.Tracer("test3"), "testSpan1", numSpansPerIteration)
// Call for spans names created by the other goroutines.
assert.LessOrEqual(t, 0, len(zsp.activeSpans("testSpan2")))
assert.LessOrEqual(t, 0, len(zsp.errorSpans("testSpan2")))
assert.LessOrEqual(t, 0, len(zsp.spansByLatency("testSpan2", 1)))
}
wg.Done()
}()
go func() {
for i := 0; i < numIterations; i++ {
assert.LessOrEqual(t, 0, len(zsp.spansPerMethod()))
assert.GreaterOrEqual(t, 2, len(zsp.spansPerMethod()))
createEndedSpans(tracerProvider.Tracer("test4"), "testSpan2", numSpansPerIteration)
// Call for spans names created by the other goroutines.
assert.LessOrEqual(t, 0, len(zsp.activeSpans("testSpan1")))
assert.LessOrEqual(t, 0, len(zsp.errorSpans("testSpan1")))
assert.LessOrEqual(t, 0, len(zsp.spansByLatency("testSpan1", 1)))
}
wg.Done()
}()
wg.Wait()
} | explode_data.jsonl/34888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1067
} | [
2830,
3393,
12485,
22946,
37,
91447,
1155,
353,
8840,
836,
8,
341,
20832,
2154,
1669,
1532,
12485,
22946,
741,
25583,
9584,
5179,
1669,
45402,
15067,
7121,
1282,
9584,
5179,
1006,
197,
1903,
7584,
15067,
26124,
66048,
1141,
7584,
15067,
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,
1,
1,
1,
1... | 2 |
func TestTfgridReservationVolume1_ToProvisionType(t *testing.T) {
type fields struct {
WorkloadID int64
NodeID string
ReservationID int64
Size int64
Type workloads.VolumeTypeEnum
StatsAggregator []workloads.StatsAggregator
}
tests := []struct {
name string
fields fields
want Volume
wantErr bool
}{
{
name: "HDD",
fields: fields{
WorkloadID: 1,
NodeID: "node1",
Size: 10,
Type: workloads.VolumeTypeHDD,
StatsAggregator: nil,
},
want: Volume{
Size: 10,
Type: pkg.HDDDevice,
},
},
{
name: "SSD",
fields: fields{
WorkloadID: 1,
NodeID: "node1",
Size: 10,
Type: workloads.VolumeTypeSSD,
StatsAggregator: nil,
},
want: Volume{
Size: 10,
Type: pkg.SSDDevice,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := workloads.Volume{
ReservationInfo: workloads.ReservationInfo{
WorkloadId: tt.fields.WorkloadID,
NodeId: tt.fields.NodeID,
},
Size: tt.fields.Size,
Type: tt.fields.Type,
}
got, _, err := VolumeToProvisionType(&v)
if !tt.wantErr {
require.NoError(t, err)
assert.DeepEqual(t, tt.want, got)
} else {
require.Error(t, err)
}
})
}
} | explode_data.jsonl/67195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 724
} | [
2830,
3393,
51,
69,
4203,
54948,
18902,
16,
38346,
1336,
13013,
929,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
6776,
1078,
915,
414,
526,
21,
19,
198,
197,
30217,
915,
688,
914,
198,
197,
197,
54948,
915,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPFetcher_OnlyErrorMessage(t *testing.T) {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadGateway)
_, err := w.Write([]byte(mustReadFile(t, "../testdata/coinmarketcap.error.json")))
require.NoError(t, err)
})
server := httptest.NewServer(handler)
defer server.Close()
feedURL, err := url.ParseRequestURI(server.URL)
require.NoError(t, err)
fetcher := newHTTPFetcher(defaultHTTPTimeout, ethUSDPairing, feedURL, 32768)
price, err := fetcher.Fetch(context.Background(), emptyMeta)
assert.Error(t, err)
assert.Equal(t, decimal.NewFromInt(0).String(), price.String())
assert.Contains(t, err.Error(), "RequestId")
} | explode_data.jsonl/26498 | {
"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,
9230,
97492,
62,
7308,
21349,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
1758,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
15753,
1005,
1649,
445,
2762,
10804,
497,
330,
5132,
8931,
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 TestSortedArray_Sum(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []interface{}{"a", "d", "c", "b", "e", "f"}
a2 := []interface{}{"1", "2", "3", "b", "e", "f"}
a3 := []interface{}{"4", "5", "6"}
func1 := func(v1, v2 interface{}) int {
return strings.Compare(gconv.String(v1), gconv.String(v2))
}
array1 := garray.NewSortedArrayFrom(a1, func1)
array2 := garray.NewSortedArrayFrom(a2, func1)
array3 := garray.NewSortedArrayFrom(a3, func1)
t.Assert(array1.Sum(), 0)
t.Assert(array2.Sum(), 6)
t.Assert(array3.Sum(), 15)
})
} | explode_data.jsonl/67018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
51051,
1857,
1098,
372,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
4970,
6257,
4913,
64,
497,
330,
67,
497,
330,
66,
497,
330,
65,
497,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfig_normalizeAddrs_AdvertiseLocalhost(t *testing.T) {
c := &Config{
BindAddr: "127.0.0.1",
Ports: &Ports{
HTTP: 4646,
RPC: 4647,
Serf: 4648,
},
Addresses: &Addresses{},
AdvertiseAddrs: &AdvertiseAddrs{
HTTP: "127.0.0.1",
RPC: "127.0.0.1",
Serf: "127.0.0.1",
},
DevMode: false,
Server: &ServerConfig{Enabled: true},
}
if err := c.normalizeAddrs(); err != nil {
t.Fatalf("unexpected error when manually setting bind mode: %v", err)
}
if c.AdvertiseAddrs.HTTP != "127.0.0.1:4646" {
t.Errorf("expected localhost HTTP advertise address, got %s", c.AdvertiseAddrs.HTTP)
}
if c.AdvertiseAddrs.RPC != "127.0.0.1:4647" {
t.Errorf("expected localhost RPC advertise address, got %s", c.AdvertiseAddrs.RPC)
}
if c.AdvertiseAddrs.Serf != "127.0.0.1:4648" {
t.Errorf("expected localhost Serf advertise address, got %s", c.AdvertiseAddrs.Serf)
}
} | explode_data.jsonl/76939 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
2648,
80807,
2212,
5428,
23834,
67787,
7319,
3790,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
2648,
515,
197,
197,
9950,
13986,
25,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
756,
197,
197,
68273,
25,
609,
68273,
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... | 5 |
func Test_Mock_Called(t *testing.T) {
var mockedService = new(TestExampleImplementation)
mockedService.On("Test_Mock_Called", 1, 2, 3).Return(5, "6", true)
returnArguments := mockedService.Called(1, 2, 3)
if assert.Equal(t, 1, len(mockedService.Calls)) {
assert.Equal(t, "Test_Mock_Called", mockedService.Calls[0].Method)
assert.Equal(t, 1, mockedService.Calls[0].Arguments[0])
assert.Equal(t, 2, mockedService.Calls[0].Arguments[1])
assert.Equal(t, 3, mockedService.Calls[0].Arguments[2])
}
if assert.Equal(t, 3, len(returnArguments)) {
assert.Equal(t, 5, returnArguments[0])
assert.Equal(t, "6", returnArguments[1])
assert.Equal(t, true, returnArguments[2])
}
} | explode_data.jsonl/8592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 313
} | [
2830,
3393,
1245,
1176,
920,
4736,
1155,
353,
8840,
836,
8,
8022,
2405,
46149,
1860,
284,
501,
31159,
13314,
36850,
7229,
2109,
67385,
1860,
8071,
445,
2271,
1245,
1176,
920,
4736,
497,
220,
16,
11,
220,
17,
11,
220,
18,
568,
5598,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWithResponseHeaders(t *testing.T) {
w := httptest.NewRecorder()
r, err := http.NewRequest(http.MethodGet, "/random", nil)
require.NoError(t, err)
th := func(resp http.ResponseWriter, req *http.Request) {}
middleware.WithResponseHeaders(th)(w, r)
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))
} | explode_data.jsonl/57376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
2354,
2582,
10574,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
54320,
70334,
7121,
47023,
741,
7000,
11,
1848,
1669,
1758,
75274,
19886,
20798,
1949,
11,
3521,
11463,
497,
2092,
340,
17957,
35699,
1155,
11,
1848,
692,
70479,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegisterCmdErrors(t *testing.T) {
t.Parallel()
tests := []struct {
name string
method string
cmdFunc func() interface{}
flags btcjson.UsageFlag
err btcjson.Error
}{
{
name: "duplicate method",
method: "getblock",
cmdFunc: func() interface{} {
return struct{}{}
},
err: btcjson.Error{ErrorCode: btcjson.ErrDuplicateMethod},
},
{
name: "invalid usage flags",
method: "registertestcmd",
cmdFunc: func() interface{} {
return 0
},
flags: btcjson.TstHighestUsageFlagBit,
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidUsageFlags},
},
{
name: "invalid type",
method: "registertestcmd",
cmdFunc: func() interface{} {
return 0
},
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid type 2",
method: "registertestcmd",
cmdFunc: func() interface{} {
return &[]string{}
},
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "embedded field",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrEmbeddedType},
},
{
name: "unexported field",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ a int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnexportedField},
},
{
name: "unsupported field type 1",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A **int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 2",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A chan int }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 3",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A complex64 }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 4",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A complex128 }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 5",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A func() }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "unsupported field type 6",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct{ A interface{} }
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrUnsupportedFieldType},
},
{
name: "required after optional",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A *int
B int
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrNonOptionalField},
},
{
name: "non-optional with default",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A int `jsonrpcdefault:"1"`
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrNonOptionalDefault},
},
{
name: "mismatched default",
method: "registertestcmd",
cmdFunc: func() interface{} {
type test struct {
A *int `jsonrpcdefault:"1.7"`
}
return (*test)(nil)
},
err: btcjson.Error{ErrorCode: btcjson.ErrMismatchedDefault},
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
err := btcjson.RegisterCmd(test.method, test.cmdFunc(),
test.flags)
if reflect.TypeOf(err) != reflect.TypeOf(test.err) {
t.Errorf("Test #%d (%s) wrong error - got %T, "+
"want %T", i, test.name, err, test.err)
continue
}
gotErrorCode := err.(btcjson.Error).ErrorCode
if gotErrorCode != test.err.ErrorCode {
t.Errorf("Test #%d (%s) mismatched error code - got "+
"%v, want %v", i, test.name, gotErrorCode,
test.err.ErrorCode)
continue
}
}
} | explode_data.jsonl/9943 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1864
} | [
2830,
3393,
8690,
15613,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
42257,
220,
914,
198,
197,
25920,
9626,
2915,
368,
3749,
16094,
197,
59516,
256,
86037,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_underscore_arrays_14(t *testing.T) {
tt(t, func() {
test, _ := test_()
test(`
test("lastIndexOf", function() {
var numbers = [1, 0, 1];
equal(_.lastIndexOf(numbers, 1), 2);
numbers = [1, 0, 1, 0, 0, 1, 0, 0, 0];
numbers.lastIndexOf = null;
equal(_.lastIndexOf(numbers, 1), 5, 'can compute lastIndexOf, even without the native function');
equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');
var result = (function(){ return _.lastIndexOf(arguments, 1); })(1, 0, 1, 0, 0, 1, 0, 0, 0);
equal(result, 5, 'works on an arguments object');
equal(_.indexOf(null, 2), -1, 'handles nulls properly');
numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
var index = _.lastIndexOf(numbers, 2, 2);
equal(index, 1, 'supports the fromIndex argument');
});
`)
})
} | explode_data.jsonl/68908 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
62,
53933,
68983,
62,
16,
19,
1155,
353,
8840,
836,
8,
972,
3244,
83,
1155,
11,
2915,
368,
972,
197,
18185,
11,
716,
1669,
1273,
62,
18005,
197,
18185,
5809,
319,
220,
1273,
445,
4259,
27376,
497,
729,
368,
972,
262,
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... | 1 |
func TestTaskSortByCompletedDate(t *testing.T) {
testTasklist.LoadFromPath(testInputSort)
taskID := 11
testTasklist = testTasklist[taskID : taskID+6]
if err := testTasklist.Sort(SortCompletedDateAsc); err != nil {
t.Fatal(err)
}
testExpectedList = []string{
"x Download Todo.txt mobile app @Phone",
"x (C) 2014-01-01 Create golang library documentation @Go +go-todotxt due:2014-01-12",
"2013-02-22 Pick up milk @GroceryStore",
"x 2014-01-02 (B) 2013-12-30 Create golang library test cases @Go +go-todotxt",
"x 2014-01-03 Create golang library @Go +go-todotxt due:2014-01-05",
"x 2014-01-04 2014-01-01 Create some more golang library test cases @Go +go-todotxt",
}
checkTaskListOrder(t, testTasklist, testExpectedList)
if err := testTasklist.Sort(SortCompletedDateDesc); err != nil {
t.Fatal(err)
}
testExpectedList = []string{
"x 2014-01-04 2014-01-01 Create some more golang library test cases @Go +go-todotxt",
"x 2014-01-03 Create golang library @Go +go-todotxt due:2014-01-05",
"x 2014-01-02 (B) 2013-12-30 Create golang library test cases @Go +go-todotxt",
"2013-02-22 Pick up milk @GroceryStore",
"x (C) 2014-01-01 Create golang library documentation @Go +go-todotxt due:2014-01-12",
"x Download Todo.txt mobile app @Phone",
}
checkTaskListOrder(t, testTasklist, testExpectedList)
} | explode_data.jsonl/24863 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 516
} | [
2830,
3393,
6262,
10231,
1359,
22724,
1916,
1155,
353,
8840,
836,
8,
341,
18185,
6262,
1607,
13969,
3830,
1820,
8623,
2505,
10231,
340,
49115,
915,
1669,
220,
16,
16,
271,
18185,
6262,
1607,
284,
1273,
6262,
1607,
58,
8202,
915,
549,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitializeCloudProviderRateLimitConfigWithReadAndWriteRateLimitSettingsFromEnv(t *testing.T) {
emptyConfig := &CloudProviderRateLimitConfig{}
var rateLimitReadQPS float32 = 3.0
rateLimitReadBuckets := 10
var rateLimitWriteQPS float32 = 6.0
rateLimitWriteBuckets := 20
os.Setenv(rateLimitReadQPSEnvVar, fmt.Sprintf("%.1f", rateLimitReadQPS))
os.Setenv(rateLimitReadBucketsEnvVar, fmt.Sprintf("%d", rateLimitReadBuckets))
os.Setenv(rateLimitWriteQPSEnvVar, fmt.Sprintf("%.1f", rateLimitWriteQPS))
os.Setenv(rateLimitWriteBucketsEnvVar, fmt.Sprintf("%d", rateLimitWriteBuckets))
err := InitializeCloudProviderRateLimitConfig(emptyConfig)
assert.NoError(t, err)
assert.Equal(t, emptyConfig.CloudProviderRateLimitQPS, rateLimitReadQPS)
assert.Equal(t, emptyConfig.CloudProviderRateLimitBucket, rateLimitReadBuckets)
assert.Equal(t, emptyConfig.CloudProviderRateLimitQPSWrite, rateLimitWriteQPS)
assert.Equal(t, emptyConfig.CloudProviderRateLimitBucketWrite, rateLimitWriteBuckets)
os.Unsetenv(rateLimitReadQPSEnvVar)
os.Unsetenv(rateLimitReadBucketsEnvVar)
os.Unsetenv(rateLimitWriteQPSEnvVar)
os.Unsetenv(rateLimitWriteBucketsEnvVar)
} | explode_data.jsonl/12801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 416
} | [
2830,
3393,
9928,
16055,
5179,
11564,
16527,
2648,
2354,
4418,
3036,
7985,
11564,
16527,
6086,
3830,
14359,
1155,
353,
8840,
836,
8,
341,
197,
3194,
2648,
1669,
609,
16055,
5179,
11564,
16527,
2648,
16094,
2405,
4379,
16527,
4418,
48,
501... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTradingFees(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("API keys required but not set, skipping test")
}
_, err := b.GetTradingFees()
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/33149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
1949,
96161,
37,
5516,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
7082,
6894,
2567,
714,
537,
738,
11,
42659,
1273,
1138,
197,
532,
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 TestTemplateCommand(t *testing.T) {
exampleDir := filepath.Join("..", "..", "example")
for _, c := range []struct {
name string
args []string
mustContainObj int
mustContain string
}{
{
"chart path only",
[]string{filepath.Join(exampleDir, "namespace")},
3, "myconfigb",
},
{
"latest cluster scoped remote chart",
[]string{"cert-manager", "--repo=https://charts.jetstack.io",
"--trust-any-repo"},
-1, "acme.cert-manager.io",
},
{
"remote chart with version",
[]string{"cert-manager", "--version=0.9.x",
"--repository=https://charts.jetstack.io",
"--repo=https://charts.jetstack.io",
"--trust-any-repo"},
34, "chart: cainjector-v0.9.1",
},
{
"release name",
[]string{filepath.Join(exampleDir, "release-name"), "--name=myrelease"},
1, "myrelease-config",
},
{
"values",
[]string{filepath.Join(exampleDir, "values-inheritance", "chart"),
"--values=" + filepath.Join(exampleDir, "values-inheritance", "values.yaml")},
1, " valueoverwrite: overwritten by file",
},
{
"set",
[]string{filepath.Join(exampleDir, "values-inheritance", "chart"),
"--set=example.other1=a,example.overrideValue=explicitly,example.other2=b", "--set=example.other1=x"},
1, " valueoverwrite: explicitly",
},
{
"set override",
[]string{filepath.Join(exampleDir, "values-inheritance", "chart"),
"--values=" + filepath.Join(exampleDir, "values-inheritance", "values.yaml"),
"--set=example.other1=a,example.overrideValue=explicitly,example.other2=b", "--set=example.other1=x"},
1, " valueoverwrite: explicitly",
},
{
"apiversions",
[]string{filepath.Join(exampleDir, "apiversions-condition", "chart"),
"--api-versions=myfancyapi/v1", "--api-versions=someapi/v1alpha1"},
1, "fancycr",
},
{
"kubeversion",
[]string{filepath.Join(exampleDir, "release-name"),
"--kube-version=1.17"},
1, "k8sVersion: v1.17.0",
},
{
"namespace",
[]string{filepath.Join(exampleDir, "namespace"), "--namespace=mynamespace"},
3, "namespace: mynamespace",
},
{
"force-namespace",
[]string{filepath.Join(exampleDir, "force-namespace"), "--force-namespace=forced-namespace"},
5, "namespace: forced-namespace",
},
{
"chart-hooks",
[]string{filepath.Join(exampleDir, "chart-hooks")},
10, "helm.sh/hook",
},
{
"chart-hooks-excluded",
[]string{filepath.Join(exampleDir, "chart-hooks"), "--no-hooks"},
1, "myvalue",
},
} {
t.Run(c.name, func(t *testing.T) {
var out bytes.Buffer
os.Args = append([]string{"testee", "template"}, c.args...)
err := Execute(nil, &out)
require.NoError(t, err)
validateYAML(t, out.Bytes(), c.mustContainObj)
require.Contains(t, out.String(), c.mustContain, "output of %+v", c.args)
})
}
} | explode_data.jsonl/68789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1243
} | [
2830,
3393,
7275,
4062,
1155,
353,
8840,
836,
8,
341,
8122,
1516,
6184,
1669,
26054,
22363,
95032,
497,
32213,
497,
330,
8687,
1138,
2023,
8358,
272,
1669,
2088,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
31215,
1843,
3056,
917,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHideDecode(t *testing.T) {
for _, name := range loadTestImages(t) {
// load test jpeg
f, err := os.Open("testdata/" + name)
if err != nil {
t.Fatal(err)
}
defer f.Close()
img, err := jpeg.Decode(f)
if err != nil {
t.Fatal(err)
}
// hide data in img
var buf bytes.Buffer
data := []byte("foo bar baz quux")
err = Hide(&buf, img, data, nil)
if err != nil {
t.Fatal(err)
}
// decode img
_, err = jpeg.Decode(&buf)
if err != nil {
t.Fatal(err)
}
}
} | explode_data.jsonl/74659 | {
"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,
21692,
32564,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
829,
1669,
2088,
2795,
2271,
14228,
1155,
8,
341,
197,
197,
322,
2795,
1273,
54566,
198,
197,
1166,
11,
1848,
1669,
2643,
12953,
445,
92425,
11225,
488,
829,
340,
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... | 6 |
func TestNewDNSProviderConfig(t *testing.T) {
testCases := []struct {
desc string
apiKey string
expected string
}{
{
desc: "success",
apiKey: "123",
},
{
desc: "missing credentials",
expected: "vultr: credentials missing",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
config := NewDefaultConfig()
config.APIKey = test.apiKey
p, err := NewDNSProviderConfig(config)
if len(test.expected) == 0 {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
require.NotNil(t, p.client)
} else {
require.EqualError(t, err, test.expected)
}
})
}
} | explode_data.jsonl/7613 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 305
} | [
2830,
3393,
3564,
61088,
5179,
2648,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
54299,
1592,
256,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
515,
298,
41653,
25,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerraformToPulumiName(t *testing.T) {
assert.Equal(t, "", TerraformToPulumiName("", nil, nil, false))
assert.Equal(t, "test", TerraformToPulumiName("test", nil, nil, false))
assert.Equal(t, "testName", TerraformToPulumiName("test_name", nil, nil, false))
assert.Equal(t, "testName_", TerraformToPulumiName("testName_", nil, nil, false))
assert.Equal(t, "tESTNAME", TerraformToPulumiName("t_e_s_t_n_a_m_e", nil, nil, false))
assert.Equal(t, "", TerraformToPulumiName("", nil, nil, true))
assert.Equal(t, "Test", TerraformToPulumiName("test", nil, nil, true))
assert.Equal(t, "TestName", TerraformToPulumiName("test_name", nil, nil, true))
assert.Equal(t, "TestName_", TerraformToPulumiName("testName_", nil, nil, true))
assert.Equal(t, "TESTNAME", TerraformToPulumiName("t_e_s_t_n_a_m_e", nil, nil, true))
} | explode_data.jsonl/36105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
51,
13886,
627,
1249,
47,
65482,
675,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
7342,
49426,
627,
1249,
47,
65482,
675,
19814,
2092,
11,
2092,
11,
895,
1171,
6948,
12808,
1155,
11,
330,
1944,
497,
49426,
627,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrint_bash_global(t *testing.T) {
// replace out (os.Stdout) by a buffer
bak := out
out = new(bytes.Buffer)
defer func() { out = bak }()
d := &Docopts{
Global_prefix: "",
Mangle_key: true,
}
tables, _ := test_json_loader.Load_json("./common_input_test.json")
//tables := []struct{
// input map[string]interface{}
// expect []string
//}{
// {
// map[string]interface{}{ "FILE" : []string{"pipo", "molo", "toto"} },
// []string{
// "FILE=('pipo' 'molo' 'toto')",
// },
// },
// {
// map[string]interface{}{ "--counter" : 2 },
// []string{
// "counter=2",
// },
// },
// {
// map[string]interface{}{ "--counter" : "2" },
// []string{
// "counter='2'",
// },
// },
// {
// map[string]interface{}{ "bool" : true },
// []string{
// "bool=true",
// },
// },
//}
for _, table := range tables {
d.Print_bash_global(table.Input)
res := out.(*bytes.Buffer).String()
expect := strings.Join(table.Expect_global[:],"\n") + "\n"
if res != expect {
t.Errorf("Print_bash_global for '%v'\ngot: '%v'\nwant: '%v'\n", table.Input, res, expect)
}
out.(*bytes.Buffer).Reset()
}
// without Mangle_key
d = &Docopts{
Global_prefix: "",
Mangle_key: false,
}
for _, table := range tables {
d.Print_bash_global(table.Input)
res := out.(*bytes.Buffer).String()
expect := rewrite_not_mangled(table.Input)
if res != expect {
t.Errorf("Mangle_key false: Print_bash_global for '%v'\ngot: '%v'\nwant: '%v'\n", table.Input, res, expect)
}
out.(*bytes.Buffer).Reset()
}
// without Mangle_key
d = &Docopts{
Global_prefix: "ARGS",
Mangle_key: true,
}
for _, table := range tables {
d.Print_bash_global(table.Input)
res := out.(*bytes.Buffer).String()
expect := rewrite_prefix("ARGS", table.Expect_global)
if res != expect {
t.Errorf("with prefix: Print_bash_global for '%v'\ngot: '%v'\nwant: '%v'\n", table.Input, res, expect)
}
out.(*bytes.Buffer).Reset()
}
} | explode_data.jsonl/35250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1159
} | [
2830,
3393,
8994,
880,
988,
19296,
1155,
353,
8840,
836,
8,
341,
262,
442,
8290,
700,
320,
436,
83225,
8,
553,
264,
4147,
198,
262,
36203,
1669,
700,
198,
262,
700,
284,
501,
23158,
22622,
340,
262,
17956,
2915,
368,
314,
700,
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 TestMergeProwPlugin(t *testing.T) {
t.Parallel()
o := TestOptions{}
o.Setup()
o.Kind = prowconfig.Environment
o.EnvironmentNamespace = "jx-staging"
pluginConfig := &plugins.Configuration{}
pluginConfig.Welcome = []plugins.Welcome{{MessageTemplate: "okey dokey"}}
c, err := yaml.Marshal(pluginConfig)
assert.NoError(t, err)
data := make(map[string]string)
data["domain"] = "dummy.domain.nip.io"
data["tls"] = "false"
cm := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: kube.IngressConfigConfigmap,
},
Data: data,
}
_, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Create(cm)
assert.NoError(t, err)
data = make(map[string]string)
data[prow.ProwPluginsFilename] = string(c)
cm = &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: prow.ProwPluginsConfigMapName,
},
Data: data,
}
_, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Create(cm)
assert.NoError(t, err)
err = o.AddProwPlugins()
assert.NoError(t, err)
cm, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Get(prow.ProwPluginsConfigMapName, metav1.GetOptions{})
assert.NoError(t, err)
assert.NoError(t, yaml.Unmarshal([]byte(cm.Data[prow.ProwPluginsFilename]), &pluginConfig))
assert.Equal(t, "okey dokey", pluginConfig.Welcome[0].MessageTemplate)
assert.Equal(t, "test/repo", pluginConfig.Approve[0].Repos[0])
} | explode_data.jsonl/219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 546
} | [
2830,
3393,
52096,
47,
651,
11546,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22229,
1669,
3393,
3798,
16094,
22229,
39820,
741,
22229,
54199,
284,
47558,
1676,
45651,
198,
22229,
45651,
22699,
284,
330,
73,
87,
5477,
4118,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidData(t *testing.T) {
data := []byte("asdfasdfasdf 10 abcdefghij")
buffer := NewSyslogBuffer()
buffer.Append(data)
result := buffer.Next()
assert.NotEqual(t, nil, result)
assert.Equal(t, "abcdefghij", string(result))
} | explode_data.jsonl/18084 | {
"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,
7928,
1043,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
445,
76615,
76615,
76615,
220,
16,
15,
39022,
750,
866,
3172,
5130,
31122,
1669,
1532,
32792,
839,
4095,
741,
31122,
8982,
2592,
692,
9559,
1669,
4147,
18501,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubmitServer_SubmitJob_ReturnsJobItemsInTheSameOrderTheyWereSubmitted(t *testing.T) {
withSubmitServer(func(s *SubmitServer, events repository.EventRepository) {
jobSetId := util.NewULID()
jobRequest := createJobRequest(jobSetId, 5)
response, err := s.SubmitJobs(context.Background(), jobRequest)
assert.Empty(t, err)
jobIds := make([]string, 0, 5)
for _, jobItem := range response.JobResponseItems {
jobIds = append(jobIds, jobItem.JobId)
}
//Get jobs for jobIds returned
jobs, _ := s.jobRepository.GetExistingJobsByIds(jobIds)
jobSet := make(map[string]*api.Job, 5)
for _, job := range jobs {
jobSet[job.Id] = job
}
//Confirm submitted spec and created spec line up, using order of returned jobIds to correlate submitted to created
for i := 0; i < len(jobRequest.JobRequestItems); i++ {
requestItem := jobRequest.JobRequestItems[i]
returnedId := jobIds[i]
createdJob := jobSet[returnedId]
assert.NotNil(t, createdJob)
assert.Equal(t, requestItem.PodSpec, createdJob.PodSpec)
}
})
} | explode_data.jsonl/32524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
8890,
5475,
36359,
1763,
12245,
53316,
82,
12245,
4353,
86093,
19198,
4431,
6865,
88453,
46541,
1155,
353,
8840,
836,
8,
341,
46948,
8890,
5475,
18552,
1141,
353,
8890,
5475,
11,
4357,
12542,
6904,
4624,
8,
341,
197,
68577,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncident_ListIncidentAlertsWithOpts(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/incidents/1/alerts", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
_, _ = w.Write([]byte(`{"alerts": [{"id": "1","summary":"foo"}]}`))
})
listObj := APIListObject{Limit: 0, Offset: 0, More: false, Total: 0}
client := defaultTestClient(server.URL, "foo")
id := "1"
alertOpts := ListIncidentAlertsOptions{
APIListObject: listObj,
Includes: []string{},
}
res, err := client.ListIncidentAlertsWithOpts(id, alertOpts)
want := &ListAlertsResponse{
APIListObject: listObj,
Alerts: []IncidentAlert{
{
APIObject: APIObject{
ID: "1",
Summary: "foo",
},
},
},
}
if err != nil {
t.Fatal(err)
}
testEqual(t, want, res)
} | explode_data.jsonl/76395 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
39245,
1713,
27104,
39245,
1713,
9676,
16056,
43451,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
2840,
6880,
14,
16,
79688,
82,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
965... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdatesForNewValidatorSet(t *testing.T) {
v1 := newValidator([]byte("v1"), 100)
v2 := newValidator([]byte("v2"), 100)
valList := []*Validator{v1, v2}
valSet := NewValidatorSet(valList)
verifyValidatorSet(t, valSet)
// Verify duplicates are caught in NewValidatorSet() and it panics
v111 := newValidator([]byte("v1"), 100)
v112 := newValidator([]byte("v1"), 123)
v113 := newValidator([]byte("v1"), 234)
valList = []*Validator{v111, v112, v113}
assert.Panics(t, func() { NewValidatorSet(valList) })
// Verify set including validator with voting power 0 cannot be created
v1 = newValidator([]byte("v1"), 0)
v2 = newValidator([]byte("v2"), 22)
v3 := newValidator([]byte("v3"), 33)
valList = []*Validator{v1, v2, v3}
assert.Panics(t, func() { NewValidatorSet(valList) })
// Verify set including validator with negative voting power cannot be created
v1 = newValidator([]byte("v1"), 10)
v2 = newValidator([]byte("v2"), -20)
v3 = newValidator([]byte("v3"), 30)
valList = []*Validator{v1, v2, v3}
assert.Panics(t, func() { NewValidatorSet(valList) })
} | explode_data.jsonl/28327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
37091,
2461,
3564,
14256,
1649,
1155,
353,
8840,
836,
8,
1476,
5195,
16,
1669,
501,
14256,
10556,
3782,
445,
85,
16,
3975,
220,
16,
15,
15,
340,
5195,
17,
1669,
501,
14256,
10556,
3782,
445,
85,
17,
3975,
220,
16,
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... | 1 |
func TestConstWhileThrow(t *testing.T) {
const SCRIPT = `
var thrown = false;
try {
while ('s' in true) {
break;
}
} catch (e) {
thrown = e instanceof TypeError
}
thrown;
`
testScript1(SCRIPT, valueTrue, t)
} | explode_data.jsonl/75288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
19167,
7983,
23079,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
14989,
284,
895,
280,
6799,
341,
197,
5217,
4319,
82,
6,
304,
830,
8,
341,
298,
3388,
280,
197,
197,
532,
197,
92,
2287,
320,
68,
8,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_dialtask_newDialState(t *testing.T) {
key, err := crypto.GenPrvKey()
if err != nil {
t.Fatal(err)
}
tab, err := discover.ListenUDP(key, "127.0.0.1:9001", "./d0")
if err != nil {
t.Fatal(err)
}
bootNs := make([]*discover.Node, 0)
for _, nRaw := range boots {
n, err := discover.ParseNode(nRaw)
if err != nil {
t.Fatal(err)
}
bootNs = append(bootNs, n)
}
dynPeers := 10 / 2
ds := newDialState(bootNs, tab, dynPeers)
ps := make(map[discover.NodeId]Peer)
for {
now := time.Now()
ts := ds.newTasks(1, ps, now)
for _, tt := range ts {
tt.Do(nil)
ds.taskDone(tt, now)
}
time.Sleep(10 * time.Second)
}
} | explode_data.jsonl/52639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
814,
530,
8202,
5921,
35,
530,
1397,
1155,
353,
8840,
836,
8,
341,
23634,
11,
1848,
1669,
19028,
65384,
3533,
85,
1592,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
58149,
11,
1848,
1669,
6997,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewMerkleTree(t *testing.T) {
data := [][]byte{
[]byte("data1"),
[]byte("data2"),
[]byte("data3"),
}
// Level 1
n1 := NewMerkleNode(nil, nil, data[0])
n2 := NewMerkleNode(nil, nil, data[1])
n3 := NewMerkleNode(nil, nil, data[2])
n4 := NewMerkleNode(nil, nil, data[2])
// Level 2
n5 := NewMerkleNode(n1, n2, nil)
n6 := NewMerkleNode(n3, n4, nil)
// Level 3
n7 := NewMerkleNode(n5, n6, nil)
fmt.Println(hex.EncodeToString(n7.Data))
root := NewMerkleTree(data)
fmt.Println(hex.EncodeToString(root.RootNode.Data))
//assert.Equal(t, hex.EncodeToString(n7.Data), hex.EncodeToString(root.RootNode.Data), "Root hash is correct")
} | explode_data.jsonl/15494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
3564,
44,
16754,
273,
6533,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
52931,
3782,
515,
197,
197,
1294,
3782,
445,
691,
16,
4461,
197,
197,
1294,
3782,
445,
691,
17,
4461,
197,
197,
1294,
3782,
445,
691,
18,
4461,
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 TestContainsInverseExpression(t *testing.T) {
ctx := test.NewTestContext(t)
c1 := ctx.NewCollection()
c1.MustAdd(hipathsys.NewInteger(10))
c1.MustAdd(hipathsys.NewInteger(11))
e := NewContainsExpression(NewNumberLiteralInt(11), newTestExpression(c1), true)
res, err := e.Evaluate(ctx, nil, nil)
assert.NoError(t, err, "no error expected")
if assert.Implements(t, (*hipathsys.BooleanAccessor)(nil), res) {
assert.Equal(t, true, res.(hipathsys.BooleanAccessor).Bool())
}
} | explode_data.jsonl/54553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
23805,
69179,
9595,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1273,
7121,
2271,
1972,
1155,
340,
1444,
16,
1669,
5635,
7121,
6482,
741,
1444,
16,
50463,
2212,
7,
2151,
587,
7791,
7121,
3486,
7,
16,
15,
1171,
1444,
16,
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... | 2 |
func TestLookUpNoDataResult(t *testing.T) {
zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin", 0)
if err != nil {
t.Fatalf("Expected no error when reading zone, got %q", err)
}
fm := File{Next: test.ErrorHandler(), Zones: Zones{Z: map[string]*Zone{testzone: zone}, Names: []string{testzone}}}
ctx := context.TODO()
var noDataTestCases = []test.Case{
{
Qname: "a.miek.nl.", Qtype: dns.TypeMX,
},
{
Qname: "wildcard.nodata.miek.nl.", Qtype: dns.TypeMX,
},
}
for _, tc := range noDataTestCases {
m := tc.Msg()
state := request.Request{W: &test.ResponseWriter{}, Req: m}
_, _, _, result := fm.Z[testzone].Lookup(ctx, state, tc.Qname)
if result != NoData {
t.Errorf("Expected result == 3 but result == %v ", result)
}
}
} | explode_data.jsonl/68726 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
10380,
2324,
2753,
1043,
2077,
1155,
353,
8840,
836,
8,
341,
197,
8684,
11,
1848,
1669,
14775,
51442,
68587,
9791,
44,
35007,
30042,
701,
1273,
8684,
11,
330,
51602,
497,
220,
15,
340,
743,
1848,
961,
2092,
341,
197,
3244,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBQNoiseIsCorrectlyCalled(t *testing.T) {
bq := getMockBQ(t)
bq.Add(1.0)
bq.Result(0.5) // will fail if parameters are wrong
} | explode_data.jsonl/80632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
33,
48,
61819,
3872,
33092,
398,
20960,
1155,
353,
8840,
836,
8,
341,
2233,
80,
1669,
633,
11571,
33,
48,
1155,
340,
2233,
80,
1904,
7,
16,
13,
15,
340,
2233,
80,
18456,
7,
15,
13,
20,
8,
442,
686,
3690,
421,
5029,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindSetMatches(t *testing.T) {
cases := []struct {
pattern string
exp []string
}{
// Simple sets.
{
pattern: "^(?:foo|bar|baz)$",
exp: []string{
"foo",
"bar",
"baz",
},
},
// Simple sets containing escaped characters.
{
pattern: "^(?:fo\\.o|bar\\?|\\^baz)$",
exp: []string{
"fo.o",
"bar?",
"^baz",
},
},
// Simple sets containing special characters without escaping.
{
pattern: "^(?:fo.o|bar?|^baz)$",
exp: nil,
},
// Missing wrapper.
{
pattern: "foo|bar|baz",
exp: nil,
},
}
for _, c := range cases {
matches := findSetMatches(c.pattern)
if len(c.exp) == 0 {
if len(matches) != 0 {
t.Errorf("Evaluating %s, unexpected result %v", c.pattern, matches)
}
} else {
if len(matches) != len(c.exp) {
t.Errorf("Evaluating %s, length of result not equal to exp", c.pattern)
} else {
for i := 0; i < len(c.exp); i++ {
if c.exp[i] != matches[i] {
t.Errorf("Evaluating %s, unexpected result %s", c.pattern, matches[i])
}
}
}
}
}
} | explode_data.jsonl/50268 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 537
} | [
2830,
3393,
9885,
1649,
42470,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
3223,
3227,
914,
198,
197,
48558,
257,
3056,
917,
198,
197,
59403,
197,
197,
322,
8993,
7289,
624,
197,
197,
515,
298,
3223,
3227,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHardcodedGroupsForParanoia(t *testing.T) {
groups := map[string][]string{
"kn-infra-gcp-org-admins@knative.team": {
"chizhg@google.com",
"cy@borg.dev",
"chizhg@knative.team",
"cy@knative.team",
"hh@cncf.io",
"hh@knative.team",
"racker-maha-66b7d200@gcp.rackspace.com",
"kmahapatra@vmware.com",
"krsna@knative.team",
},
}
found := make(map[string]bool)
for _, g := range cfg.Groups {
if expected, ok := groups[g.EmailId]; ok {
found[g.EmailId] = true
sort.Strings(expected)
actual := make([]string, len(g.Members))
copy(actual, g.Members)
sort.Strings(actual)
if !reflect.DeepEqual(expected, actual) {
t.Errorf("group '%s': expected members '%v', got '%v'", g.Name, expected, actual)
}
}
}
for email := range groups {
if _, ok := found[email]; !ok {
t.Errorf("group '%s' is missing, should be present", email)
}
}
} | explode_data.jsonl/24794 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
26907,
65530,
22173,
2461,
4272,
69895,
1155,
353,
8840,
836,
8,
341,
44260,
82,
1669,
2415,
14032,
45725,
917,
515,
197,
197,
1,
19095,
3419,
42289,
2371,
4672,
71184,
27225,
82,
31,
19095,
1388,
27963,
788,
341,
298,
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... | 6 |
func TestAutoSaveMany2ManyAssociation(t *testing.T) {
type Company struct {
orm.Model
Name string
}
type User struct {
orm.Model
Name string
Companies []Company `orm:"many2many:user_companies;association_autoupdate:false;association_autocreate:false;"`
}
DB.AutoMigrate(&Company{}, &User{})
DB.Save(&User{Name: "jinzhu", Companies: []Company{{Name: "auto_save_m2m_association"}}})
if !DB.Where("name = ?", "auto_save_m2m_association").First(&Company{}).RecordNotFound() {
t.Errorf("Company auto_save_m2m_association should not have been saved when autosave is false")
}
company := Company{Name: "auto_save_m2m_association"}
DB.Save(&company)
company.Name = "auto_save_m2m_association_new_name"
user := User{Name: "jinzhu", Companies: []Company{company, {Name: "auto_save_m2m_association_new_name_2"}}}
DB.Save(&user)
if !DB.Where("name = ?", "auto_save_m2m_association_new_name").First(&Company{}).RecordNotFound() {
t.Errorf("Company should not have been updated")
}
if !DB.Where("name = ?", "auto_save_m2m_association_new_name_2").First(&Company{}).RecordNotFound() {
t.Errorf("Company should not been created")
}
if DB.Model(&user).Association("Companies").Count() != 1 {
t.Errorf("Relationship should been saved")
}
DB.Set("orm:association_autoupdate", true).Set("orm:association_autocreate", true).Save(&user)
if DB.Where("name = ?", "auto_save_m2m_association_new_name").First(&Company{}).RecordNotFound() {
t.Errorf("Company should been updated")
}
if DB.Where("name = ?", "auto_save_m2m_association_new_name_2").First(&Company{}).RecordNotFound() {
t.Errorf("Company should been created")
}
if DB.Model(&user).Association("Companies").Count() != 2 {
t.Errorf("Relationship should been updated")
}
} | explode_data.jsonl/15892 | {
"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,
13253,
8784,
8441,
17,
8441,
63461,
1155,
353,
8840,
836,
8,
341,
13158,
8188,
2036,
341,
197,
197,
493,
5659,
198,
197,
21297,
914,
198,
197,
630,
13158,
2657,
2036,
341,
197,
197,
493,
5659,
198,
197,
21297,
414,
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... | 8 |
func TestGRD(t *testing.T) {
for _, ut := range gRDTests {
if gRD := g(ut.in); ut.out != gRD {
t.Errorf("TestGRD() = %+v, want %+v.", gRD, ut.out)
}
}
} | explode_data.jsonl/22940 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
8626,
35,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
8621,
1669,
2088,
342,
36690,
18200,
341,
394,
421,
342,
36690,
1669,
342,
7,
332,
1858,
1215,
8621,
2532,
961,
342,
36690,
341,
298,
3244,
13080,
445,
2271,
8626,
35,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCurlCommand_newlineInBody(t *testing.T) {
req, _ := http.NewRequest("POST", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString("hello\nworld"))
req.Header.Set("Content-Type", "application/json")
libCommand, _ := http2curl.GetCurlCommand(req)
command, _ := GetCurlCommand(req)
if libCommand.String() != command.String() {
t.Errorf("expected library command: %s and command: %s to match", libCommand, command)
}
// Output:
// curl -X 'POST' -d 'hello
// world' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu'
} | explode_data.jsonl/61003 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
1949,
34,
1085,
4062,
5921,
1056,
641,
5444,
1155,
353,
8840,
836,
8,
341,
24395,
11,
716,
1669,
1758,
75274,
445,
2946,
497,
330,
1254,
1110,
2136,
7724,
905,
14,
13683,
14,
750,
13,
75076,
30,
73,
41748,
27221,
2152,
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,
1,
1,
1,
1... | 2 |
func TestContext(t *testing.T) {
ccEvent := &CCEvent{
BlockNum: 1000,
TxID: txID1,
TxNum: 12,
}
lsccWrite := &LSCCWrite{
BlockNum: 1000,
TxID: txID1,
TxNum: 12,
}
configUpdate := &ConfigUpdate{
BlockNum: 1000,
}
read := &Read{
BlockNum: 1000,
TxID: txID1,
TxNum: 12,
}
write := &Write{
BlockNum: 1000,
TxID: txID1,
TxNum: 12,
}
ctx := newContext(
UnmarshalErr, channelID, 1000,
withTxID(txID1),
withTxNum(12),
withCCEvent(ccEvent),
withConfigUpdate(configUpdate),
withLSCCWrite(lsccWrite),
withRead(read),
withWrite(write),
)
require.NotNil(t, ctx)
require.Equal(t, UnmarshalErr, ctx.Category)
require.Equal(t, channelID, ctx.ChannelID)
require.Equal(t, uint64(1000), ctx.BlockNum)
require.Equal(t, txID1, ctx.TxID)
require.Equal(t, ccEvent, ctx.CCEvent)
require.Equal(t, configUpdate, ctx.ConfigUpdate)
require.Equal(t, lsccWrite, ctx.LSCCWrite)
require.Equal(t, read, ctx.Read)
require.Equal(t, write, ctx.Write)
s := ctx.String()
require.Contains(t, s, "ChannelID: testchannel")
require.Contains(t, s, "Category: UNMARSHAL_ERROR")
require.Contains(t, s, "Block: 1000")
require.Contains(t, s, "TxNum: 12")
require.Contains(t, s, "TxID: tx1")
require.Contains(t, s, "Read:")
require.Contains(t, s, "Write:")
require.Contains(t, s, "CCEvent:")
require.Contains(t, s, "TxID:tx1")
require.Contains(t, s, "TxNum:12")
require.Contains(t, s, "ConfigUpdate:")
} | explode_data.jsonl/9324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 679
} | [
2830,
3393,
1972,
1155,
353,
8840,
836,
8,
341,
63517,
1556,
1669,
609,
3706,
1556,
515,
197,
94940,
4651,
25,
220,
16,
15,
15,
15,
345,
197,
10261,
87,
915,
25,
257,
9854,
915,
16,
345,
197,
10261,
87,
4651,
25,
262,
220,
16,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFiles_Move(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v2/files/move", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testHeader(t, r, "Content-Type", "application/x-www-form-urlencoded")
fmt.Fprintln(w, `{"status":"OK"}`)
})
ctx := context.Background()
// move 1, 2, 3, 4 and 5 to root directory (0).
err := client.Files.Move(ctx, 0, 1, 2, 3, 4, 5)
if err != nil {
t.Error(err)
}
// negative parent id
err = client.Files.Move(ctx, -1, 1, 2, 3, 4, 5)
if err == nil {
t.Errorf("negative parent ID accepted")
}
// negative file id
err = client.Files.Move(ctx, 0, 1, 2, -3)
if err == nil {
t.Errorf("negative file ID accepted")
}
// no files
err = client.Files.Move(ctx, 0)
if err == nil {
t.Errorf("no files given and it is accepted")
}
} | explode_data.jsonl/48319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
10809,
66352,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
85,
17,
33220,
3183,
994,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
18185,
3523,
1155,
11,
435... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGitCommandSquashPreviousTwoCommits(t *testing.T) {
type scenario struct {
testName string
command func(string, ...string) *exec.Cmd
test func(error)
}
scenarios := []scenario{
{
"Git reset triggers an error",
func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"reset", "--soft", "HEAD^"}, args)
return exec.Command("test")
},
func(err error) {
assert.NotNil(t, err)
},
},
{
"Git commit triggers an error",
func(cmd string, args ...string) *exec.Cmd {
if len(args) > 0 && args[0] == "reset" {
return exec.Command("echo")
}
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"commit", "--amend", "-m", "test"}, args)
return exec.Command("test")
},
func(err error) {
assert.NotNil(t, err)
},
},
{
"Stash succeeded",
func(cmd string, args ...string) *exec.Cmd {
if len(args) > 0 && args[0] == "reset" {
return exec.Command("echo")
}
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"commit", "--amend", "-m", "test"}, args)
return exec.Command("echo")
},
func(err error) {
assert.Nil(t, err)
},
},
}
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
gitCmd := newDummyGitCommand()
gitCmd.OSCommand.command = s.command
s.test(gitCmd.SquashPreviousTwoCommits("test"))
})
}
} | explode_data.jsonl/38371 | {
"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,
46562,
4062,
50,
446,
988,
21291,
11613,
17977,
1199,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
18185,
675,
914,
198,
197,
45566,
220,
2915,
3609,
11,
2503,
917,
8,
353,
11748,
64512,
198,
197,
18185,
257... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExportContainerAndImportImage(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)()
client := request.NewAPIClient(t)
ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("true"))
poll.WaitOn(t, container.IsStopped(ctx, client, cID), poll.WithDelay(100*time.Millisecond))
reference := "repo/testexp:v1"
exportResp, err := client.ContainerExport(ctx, cID)
assert.NilError(t, err)
importResp, err := client.ImageImport(ctx, types.ImageImportSource{
Source: exportResp,
SourceName: "-",
}, reference, types.ImageImportOptions{})
assert.NilError(t, err)
// If the import is successfully, then the message output should contain
// the image ID and match with the output from `docker images`.
dec := json.NewDecoder(importResp)
var jm jsonmessage.JSONMessage
err = dec.Decode(&jm)
assert.NilError(t, err)
images, err := client.ImageList(ctx, types.ImageListOptions{
Filters: filters.NewArgs(filters.Arg("reference", reference)),
})
assert.NilError(t, err)
assert.Check(t, is.Equal(jm.Status, images[0].ID))
} | explode_data.jsonl/34687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 393
} | [
2830,
3393,
16894,
4502,
3036,
11511,
1906,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
32901,
1155,
11,
1273,
14359,
909,
64,
7291,
1731,
13,
4233,
499,
961,
330,
14210,
5130,
16867,
6505,
2271,
1155,
8,
741,
25291,
1669,
1681,
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... | 1 |
func TestJSON(t *testing.T) {
log.Errorf("TestJSON: flavor is %s", env.Flavor)
// JSON is supported only after mysql57.
if !strings.Contains(env.Flavor, "mysql57") {
return
}
if err := env.Mysqld.ExecuteSuperQuery(context.Background(), "create table vitess_json(id int default 1, val json, primary key(id))"); err != nil {
// If it's a syntax error, MySQL is an older version. Skip this test.
if strings.Contains(err.Error(), "syntax") {
return
}
t.Fatal(err)
}
defer execStatement(t, "drop table vitess_json")
engine.se.Reload(context.Background())
jsonValues := []string{"{}", "123456", `"vtTablet"`, `{"foo":"bar"}`, `["abc",3.14,true]`}
var inputs, outputs []string
var outputsArray [][]string
fieldAdded := false
var expect = func(in string) string {
return strings.ReplaceAll(in, "\"", "\\\"")
}
for i, val := range jsonValues {
inputs = append(inputs, fmt.Sprintf("insert into vitess_json values(%d, %s)", i+1, encodeString(val)))
outputs = []string{}
outputs = append(outputs, `begin`)
if !fieldAdded {
outputs = append(outputs, `type:FIELD field_event:{table_name:"vitess_json" fields:{name:"id" type:INT32 table:"vitess_json" org_table:"vitess_json" database:"vttest" org_name:"id" column_length:11 charset:63} fields:{name:"val" type:JSON table:"vitess_json" org_table:"vitess_json" database:"vttest" org_name:"val" column_length:4294967295 charset:63}}`)
fieldAdded = true
}
out := expect(val)
outputs = append(outputs, fmt.Sprintf(`type:ROW row_event:{table_name:"vitess_json" row_changes:{after:{lengths:1 lengths:%d values:"%d%s"}}}`,
len(val), i+1 /*id increments*/, out))
outputs = append(outputs, `gtid`)
outputs = append(outputs, `commit`)
outputsArray = append(outputsArray, outputs)
}
testcases := []testcase{{
input: inputs,
output: outputsArray,
}}
runCases(t, nil, testcases, "", nil)
} | explode_data.jsonl/10422 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 715
} | [
2830,
3393,
5370,
1155,
353,
8840,
836,
8,
341,
6725,
13080,
445,
2271,
5370,
25,
17172,
374,
1018,
82,
497,
6105,
73459,
3292,
340,
197,
322,
4718,
374,
7248,
1172,
1283,
10564,
20,
22,
624,
743,
753,
18594,
11545,
16978,
73459,
3292... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUseLockCacheInRCMode(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk3 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2.MustExec("use test")
tk3.MustExec("use test")
tk.MustExec("drop table if exists test_kill")
tk.MustExec("CREATE TABLE SEQUENCE_VALUE_ITEM(SEQ_NAME varchar(60) NOT NULL, SEQ_ID decimal(18,0) DEFAULT NULL, " +
"PRIMARY KEY (SEQ_NAME))")
tk.MustExec("create table t1(c1 int, c2 int, unique key(c1))")
tk.MustExec(`insert into sequence_value_item values("OSCurrentStep", 0)`)
tk.MustExec("insert into t1 values(1, 1)")
tk.MustExec("insert into t1 values(2, 2)")
// tk2 uses RC isolation level
tk2.MustExec("set @@tx_isolation='READ-COMMITTED'")
tk2.MustExec("set autocommit = 0")
// test point get
tk2.MustExec("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME='OSCurrentStep' FOR UPDATE")
tk2.MustExec("UPDATE SEQUENCE_VALUE_ITEM SET SEQ_ID=SEQ_ID+100 WHERE SEQ_NAME='OSCurrentStep'")
tk2.MustExec("rollback")
tk2.MustQuery("select * from t1 where c1 = 1 for update").Check(testkit.Rows("1 1"))
tk2.MustExec("update t1 set c2 = c2 + 10 where c1 = 1")
tk2.MustQuery("select * from t1 where c1 in (1, 2) for update").Check(testkit.Rows("1 11", "2 2"))
tk2.MustExec("update t1 set c2 = c2 + 10 where c1 in (2)")
tk2.MustQuery("select * from t1 where c1 in (1, 2) for update").Check(testkit.Rows("1 11", "2 12"))
tk2.MustExec("commit")
// tk3 uses begin with RC isolation level
tk3.MustQuery("select * from SEQUENCE_VALUE_ITEM").Check(testkit.Rows("OSCurrentStep 0"))
tk3.MustExec("set @@tx_isolation='READ-COMMITTED'")
tk3.MustExec("begin")
tk3.MustExec("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME='OSCurrentStep' FOR UPDATE")
tk3.MustExec("UPDATE SEQUENCE_VALUE_ITEM SET SEQ_ID=SEQ_ID+100 WHERE SEQ_NAME='OSCurrentStep'")
tk3.MustQuery("select * from t1 where c1 = 1 for update").Check(testkit.Rows("1 11"))
tk3.MustExec("update t1 set c2 = c2 + 10 where c1 = 1")
tk3.MustQuery("select * from t1 where c1 in (1, 2) for update").Check(testkit.Rows("1 21", "2 12"))
tk3.MustExec("update t1 set c2 = c2 + 10 where c1 in (2)")
tk3.MustQuery("select * from t1 where c1 in (1, 2) for update").Check(testkit.Rows("1 21", "2 22"))
tk3.MustExec("commit")
// verify
tk.MustQuery("select * from SEQUENCE_VALUE_ITEM").Check(testkit.Rows("OSCurrentStep 100"))
tk.MustQuery("select * from SEQUENCE_VALUE_ITEM where SEQ_ID = 100").Check(testkit.Rows("OSCurrentStep 100"))
tk.MustQuery("select * from t1 where c1 = 2").Check(testkit.Rows("2 22"))
tk.MustQuery("select * from t1 where c1 in (1, 2, 3)").Check(testkit.Rows("1 21", "2 22"))
// test batch point get
tk2.MustExec("set autocommit = 1")
tk2.MustExec("set autocommit = 0")
tk2.MustExec("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME in ('OSCurrentStep') FOR UPDATE")
tk2.MustExec("UPDATE SEQUENCE_VALUE_ITEM SET SEQ_ID=SEQ_ID+100 WHERE SEQ_NAME in ('OSCurrentStep')")
tk2.MustQuery("select * from t1 where c1 in (1, 2, 3, 4, 5) for update").Check(testkit.Rows("1 21", "2 22"))
tk2.MustExec("update t1 set c2 = c2 + 10 where c1 in (1, 2, 3, 4, 5)")
tk2.MustQuery("select * from t1 where c1 in (1, 2, 3, 4, 5) for update").Check(testkit.Rows("1 31", "2 32"))
tk2.MustExec("commit")
tk2.MustExec("SELECT SEQ_ID FROM SEQUENCE_VALUE_ITEM WHERE SEQ_NAME in ('OSCurrentStep') FOR UPDATE")
tk2.MustExec("UPDATE SEQUENCE_VALUE_ITEM SET SEQ_ID=SEQ_ID+100 WHERE SEQ_NAME in ('OSCurrentStep')")
tk2.MustExec("rollback")
tk.MustQuery("select * from SEQUENCE_VALUE_ITEM").Check(testkit.Rows("OSCurrentStep 200"))
tk.MustQuery("select * from SEQUENCE_VALUE_ITEM where SEQ_NAME in ('OSCurrentStep')").Check(testkit.Rows("OSCurrentStep 200"))
tk.MustQuery("select * from t1 where c1 in (1, 2, 3)").Check(testkit.Rows("1 31", "2 32"))
tk.MustExec("rollback")
tk2.MustExec("rollback")
tk3.MustExec("rollback")
} | explode_data.jsonl/12488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1556
} | [
2830,
3393,
10253,
11989,
8233,
641,
7380,
3636,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMakeVirtualServiceSpec_CorrectRoutes(t *testing.T) {
ci := &v1alpha1.ClusterIngress{
ObjectMeta: metav1.ObjectMeta{
Name: "test-ingress",
},
Spec: v1alpha1.IngressSpec{
Rules: []v1alpha1.ClusterIngressRule{{
Hosts: []string{
"domain.com",
"test-route.test-ns.svc.cluster.local",
"test-route.test-ns.svc",
"test-route.test-ns",
},
HTTP: &v1alpha1.HTTPClusterIngressRuleValue{
Paths: []v1alpha1.HTTPClusterIngressPath{{
Path: "^/pets/(.*?)?",
Splits: []v1alpha1.ClusterIngressBackendSplit{{
ClusterIngressBackend: v1alpha1.ClusterIngressBackend{
ServiceNamespace: "test-ns",
ServiceName: "v2-service",
ServicePort: intstr.FromInt(80),
},
Percent: 100,
}},
Timeout: &metav1.Duration{Duration: v1alpha1.DefaultTimeout},
Retries: &v1alpha1.HTTPRetry{
PerTryTimeout: &metav1.Duration{Duration: v1alpha1.DefaultTimeout},
Attempts: v1alpha1.DefaultRetryCount,
},
}},
},
}, {
Hosts: []string{
"v1.domain.com",
},
HTTP: &v1alpha1.HTTPClusterIngressRuleValue{
Paths: []v1alpha1.HTTPClusterIngressPath{{
Path: "^/pets/(.*?)?",
Splits: []v1alpha1.ClusterIngressBackendSplit{{
ClusterIngressBackend: v1alpha1.ClusterIngressBackend{
ServiceNamespace: "test-ns",
ServiceName: "v1-service",
ServicePort: intstr.FromInt(80),
},
Percent: 100,
}},
Timeout: &metav1.Duration{Duration: v1alpha1.DefaultTimeout},
Retries: &v1alpha1.HTTPRetry{
PerTryTimeout: &metav1.Duration{Duration: v1alpha1.DefaultTimeout},
Attempts: v1alpha1.DefaultRetryCount,
},
}},
},
},
},
},
}
expected := []v1alpha3.HTTPRoute{{
Match: []v1alpha3.HTTPMatchRequest{{
Uri: &istiov1alpha1.StringMatch{Regex: "^/pets/(.*?)?"},
Authority: &istiov1alpha1.StringMatch{Exact: "domain.com"},
}, {
Uri: &istiov1alpha1.StringMatch{Regex: "^/pets/(.*?)?"},
Authority: &istiov1alpha1.StringMatch{Exact: "test-route.test-ns.svc.cluster.local"},
}, {
Uri: &istiov1alpha1.StringMatch{Regex: "^/pets/(.*?)?"},
Authority: &istiov1alpha1.StringMatch{Exact: "test-route.test-ns.svc"},
}, {
Uri: &istiov1alpha1.StringMatch{Regex: "^/pets/(.*?)?"},
Authority: &istiov1alpha1.StringMatch{Exact: "test-route.test-ns"},
}},
Route: []v1alpha3.DestinationWeight{{
Destination: v1alpha3.Destination{
Host: "v2-service.test-ns.svc.cluster.local",
Port: v1alpha3.PortSelector{Number: 80},
},
Weight: 100,
}},
Timeout: v1alpha1.DefaultTimeout.String(),
Retries: &v1alpha3.HTTPRetry{
Attempts: v1alpha1.DefaultRetryCount,
PerTryTimeout: v1alpha1.DefaultTimeout.String(),
},
WebsocketUpgrade: true,
}, {
Match: []v1alpha3.HTTPMatchRequest{{
Uri: &istiov1alpha1.StringMatch{Regex: "^/pets/(.*?)?"},
Authority: &istiov1alpha1.StringMatch{Exact: "v1.domain.com"},
}},
Route: []v1alpha3.DestinationWeight{{
Destination: v1alpha3.Destination{
Host: "v1-service.test-ns.svc.cluster.local",
Port: v1alpha3.PortSelector{Number: 80},
},
Weight: 100,
}},
Timeout: v1alpha1.DefaultTimeout.String(),
Retries: &v1alpha3.HTTPRetry{
Attempts: v1alpha1.DefaultRetryCount,
PerTryTimeout: v1alpha1.DefaultTimeout.String(),
},
WebsocketUpgrade: true,
}}
routes := MakeVirtualService(ci, []string{}).Spec.Http
if diff := cmp.Diff(expected, routes); diff != "" {
fmt.Printf("%+v\n", routes)
fmt.Printf("%+v\n", expected)
t.Errorf("Unexpected routes (-want +got): %v", diff)
}
} | explode_data.jsonl/68606 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1761
} | [
2830,
3393,
8078,
33026,
1860,
8327,
920,
27034,
26653,
1155,
353,
8840,
836,
8,
341,
1444,
72,
1669,
609,
85,
16,
7141,
16,
72883,
641,
2483,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
330,
1944,
83905,
673,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGet(t *testing.T) {
// Test Setup
state := NewMockManager()
state.ToggleLogs()
user1 := user.New("1", "Franco", "franco@gmail.com")
state.Stage(user1, "insert")
state.Commit()
state.Cache.Purge()
// Should be able to get a model that exists
res := &user.User{}
err := state.Get(res, "1")
assert.Nil(t, err)
assert.Equal(t, "1", res.ID)
assert.Equal(t, "Franco", res.Name)
assert.Equal(t, "franco@gmail.com", res.Email)
// Should not be able to get a model that doesnt exist
res = &user.User{}
err = state.Get(res, "31231")
assert.NotNil(t, err)
assert.Equal(t, ez.ENOTFOUND, ez.ErrorCode(err))
} | explode_data.jsonl/58869 | {
"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,
1949,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
18626,
198,
24291,
1669,
1532,
11571,
2043,
741,
24291,
80700,
51053,
741,
19060,
16,
1669,
1196,
7121,
445,
16,
497,
330,
75331,
1015,
497,
330,
1626,
18557,
10375,
905,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_TryMergeUnmergeableResponseWithValue(t *testing.T) {
mct := newMemcacheTest(defaultConfig)
msg1 := textParseNoFail(t, "VALUE k 1 5 3\r\nvalue\r\n")
msg2 := textParseNoFail(t, "0\r\n")
b, err := tryMergeResponses(mct.mc, msg1, msg2)
assert.False(t, b)
assert.Nil(t, err)
} | explode_data.jsonl/15052 | {
"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,
1139,
884,
52096,
1806,
19052,
480,
2582,
22767,
1155,
353,
8840,
836,
8,
341,
2109,
302,
1669,
501,
18816,
9360,
2271,
18978,
2648,
340,
21169,
16,
1669,
1467,
14463,
2753,
19524,
1155,
11,
330,
23832,
595,
220,
16,
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 TestSpanStatRaceCondition(t *testing.T) {
type fields struct {
runFunc func(span *SpanStat) float64
}
tests := []struct {
name string
fields fields
}{
{
name: "End function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.End(true).Seconds()
},
},
},
{
name: "EndError function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.EndError(fmt.Errorf("dummy error")).Seconds()
},
},
},
{
name: "Seconds function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.Seconds()
},
},
},
{
name: "Total function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.Total().Seconds() + 1
},
},
},
{
name: "FailureTotal function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.FailureTotal().Seconds() + 1
},
},
},
{
name: "SuccessTotal function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
return span.SuccessTotal().Seconds() + 1
},
},
},
{
name: "Reset function",
fields: fields{
runFunc: func(span *SpanStat) float64 {
span.Reset()
return 1
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
span := Start()
var wg sync.WaitGroup
for i := 0; i < 5; i++ {
wg.Add(1)
go func(span *SpanStat) {
defer wg.Done()
assert.NotEqual(t, tt.fields.runFunc(span), float64(0))
}(span)
}
wg.Wait()
})
}
} | explode_data.jsonl/80880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 761
} | [
2830,
3393,
12485,
15878,
55991,
10547,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
56742,
9626,
2915,
66092,
353,
12485,
15878,
8,
2224,
21,
19,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_PopLeftsAndPopRights(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
array := garray.New()
v, ok := array.PopLeft()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopLefts(10), nil)
v, ok = array.PopRight()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopRights(10), nil)
v, ok = array.PopRand()
t.Assert(v, nil)
t.Assert(ok, false)
t.Assert(array.PopRands(10), nil)
})
gtest.C(t, func(t *gtest.T) {
value1 := []interface{}{0, 1, 2, 3, 4, 5, 6}
value2 := []interface{}{0, 1, 2, 3, 4, 5, 6}
array1 := garray.NewArrayFrom(value1)
array2 := garray.NewArrayFrom(value2)
t.Assert(array1.PopLefts(2), []interface{}{0, 1})
t.Assert(array1.Slice(), []interface{}{2, 3, 4, 5, 6})
t.Assert(array1.PopRights(2), []interface{}{5, 6})
t.Assert(array1.Slice(), []interface{}{2, 3, 4})
t.Assert(array1.PopRights(20), []interface{}{2, 3, 4})
t.Assert(array1.Slice(), []interface{}{})
t.Assert(array2.PopLefts(20), []interface{}{0, 1, 2, 3, 4, 5, 6})
t.Assert(array2.Slice(), []interface{}{})
})
} | explode_data.jsonl/13897 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 519
} | [
2830,
3393,
1857,
1088,
453,
5415,
82,
3036,
11598,
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,
741,
197,
5195,
11,
5394,
1669,
1334,
47424,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelTranscodeJob(t *testing.T) {
var tests = []struct {
givenTestCase string
givenJobID string
givenTriggerDBError bool
wantCode int
wantBody map[string]interface{}
}{
{
"valid job",
"job-123",
false,
http.StatusOK,
map[string]interface{}{
"providerJobId": "provider-job-123",
"status": "canceled",
"providerName": "fake",
"statusMessage": "The job is finished",
"progress": 10.3,
"providerStatus": map[string]interface{}{
"progress": 10.3,
"sourcefile": "http://some.source.file",
},
"output": map[string]interface{}{
"destination": "s3://mybucket/some/dir/job-123",
},
"sourceInfo": map[string]interface{}{
"width": float64(4096),
"height": float64(2160),
"duration": 183e9,
"videoCodec": "VP9",
},
},
},
{
"job that doesn't exist in the provider",
"job-1234",
false,
http.StatusGone,
map[string]interface{}{"error": "could not found job with id: some-job"},
},
{
"non-existing job",
"some-id",
false,
http.StatusNotFound,
map[string]interface{}{"error": db.ErrJobNotFound.Error()},
},
{
"db error",
"job-123",
true,
http.StatusInternalServerError,
map[string]interface{}{"error": `error retrieving job with id "job-123": database error`},
},
}
defer func() { fprovider.canceledJobs = nil }()
for _, test := range tests {
fprovider.canceledJobs = nil
srvr := server.NewSimpleServer(&server.Config{})
fakeDBObj := dbtest.NewFakeRepository(test.givenTriggerDBError)
fakeDBObj.CreateJob(&db.Job{
ID: "job-123",
ProviderName: "fake",
ProviderJobID: "provider-job-123",
})
fakeDBObj.CreateJob(&db.Job{
ID: "job-1234",
ProviderName: "fake",
ProviderJobID: "some-job",
})
service, err := NewTranscodingService(&config.Config{Server: &server.Config{}}, logrus.New())
if err != nil {
t.Fatal(err)
}
service.db = fakeDBObj
srvr.Register(service)
r, _ := http.NewRequest("POST", "/jobs/"+test.givenJobID+"/cancel", bytes.NewReader(nil))
r.Header.Set("Content-Type", "application/json")
w := httptest.NewRecorder()
srvr.ServeHTTP(w, r)
if w.Code != test.wantCode {
t.Errorf("%s: wrong code returned. Want %d. Got %d", test.givenTestCase, test.wantCode, w.Code)
}
var body map[string]interface{}
err = json.Unmarshal(w.Body.Bytes(), &body)
if err != nil {
t.Fatalf("%s: %s", test.givenTestCase, err)
}
if !reflect.DeepEqual(body, test.wantBody) {
t.Errorf("%s: wrong body returned.\nWant %#v\nGot %#v", test.givenTestCase, test.wantBody, body)
}
if test.wantCode == http.StatusOK {
if len(fprovider.canceledJobs) < 1 {
t.Errorf("%s: did not cancel the job in the provider", test.givenTestCase)
} else if fprovider.canceledJobs[0] != "provider-job-123" {
t.Errorf("%s: did not send the correct job id to the provider. Want %q. Got %q", test.givenTestCase, "provider-job-123", fprovider.canceledJobs[0])
}
}
}
} | explode_data.jsonl/30224 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1356
} | [
2830,
3393,
9269,
3167,
1851,
12245,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
3174,
2071,
16458,
981,
914,
198,
197,
3174,
2071,
12245,
915,
688,
914,
198,
197,
3174,
2071,
17939,
3506,
1454,
1807,
271,
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 TestPublishJWTAuthority(t *testing.T) {
test := setupServiceTest(t)
defer test.Cleanup()
pkixBytes, err := base64.StdEncoding.DecodeString("MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYSlUVLqTD8DEnA4F1EWMTf5RXc5lnCxw+5WKJwngEL3rPc9i4Tgzz9riR3I/NiSlkgRO1WsxBusqpC284j9dXA==")
pkixHashed := api.HashByte(pkixBytes)
require.NoError(t, err)
expiresAt := time.Now().Unix()
expiresAtStr := strconv.FormatInt(expiresAt, 10)
jwtKey1 := &types.JWTKey{
ExpiresAt: expiresAt,
KeyId: "key1",
PublicKey: pkixBytes,
}
_, expectedJWTErr := x509.ParsePKIXPublicKey([]byte("malformed key"))
require.Error(t, expectedJWTErr)
for _, tt := range []struct {
name string
code codes.Code
err string
expectLogs []spiretest.LogEntry
resultKeys []*types.JWTKey
fakeErr error
fakeExpectKey *common.PublicKey
jwtKey *types.JWTKey
rateLimiterErr error
}{
{
name: "success",
jwtKey: jwtKey1,
fakeExpectKey: &common.PublicKey{
PkixBytes: pkixBytes,
Kid: "key1",
NotAfter: expiresAt,
},
resultKeys: []*types.JWTKey{
{
ExpiresAt: expiresAt,
KeyId: "key1",
PublicKey: pkixBytes,
},
},
expectLogs: []spiretest.LogEntry{
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "success",
telemetry.Type: "audit",
telemetry.JWTAuthorityKeyID: "key1",
telemetry.JWTAuthorityPublicKeySHA256: pkixHashed,
telemetry.JWTAuthorityExpiresAt: expiresAtStr,
},
},
},
},
{
name: "rate limit fails",
jwtKey: jwtKey1,
rateLimiterErr: status.Error(codes.Internal, "limit error"),
code: codes.Internal,
err: "rejecting request due to key publishing rate limiting: limit error",
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Rejecting request due to key publishing rate limiting",
Data: logrus.Fields{
logrus.ErrorKey: "rpc error: code = Internal desc = limit error",
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "Internal",
telemetry.StatusMessage: "rejecting request due to key publishing rate limiting: limit error",
telemetry.Type: "audit",
telemetry.JWTAuthorityKeyID: "key1",
telemetry.JWTAuthorityPublicKeySHA256: pkixHashed,
telemetry.JWTAuthorityExpiresAt: expiresAtStr,
},
},
},
},
{
name: "missing JWT authority",
code: codes.InvalidArgument,
err: "missing JWT authority",
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: missing JWT authority",
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: "missing JWT authority",
telemetry.Type: "audit",
},
},
},
},
{
name: "malformed key",
code: codes.InvalidArgument,
err: "invalid JWT authority: asn1:",
jwtKey: &types.JWTKey{
ExpiresAt: expiresAt,
KeyId: "key1",
PublicKey: []byte("malformed key"),
},
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: invalid JWT authority",
Data: logrus.Fields{
logrus.ErrorKey: expectedJWTErr.Error(),
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: fmt.Sprintf("invalid JWT authority: %v", expectedJWTErr),
telemetry.Type: "audit",
telemetry.JWTAuthorityKeyID: "key1",
telemetry.JWTAuthorityPublicKeySHA256: api.HashByte([]byte("malformed key")),
telemetry.JWTAuthorityExpiresAt: expiresAtStr,
},
},
},
},
{
name: "missing key ID",
code: codes.InvalidArgument,
err: "invalid JWT authority: missing key ID",
jwtKey: &types.JWTKey{
ExpiresAt: expiresAt,
PublicKey: jwtKey1.PublicKey,
},
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: invalid JWT authority",
Data: logrus.Fields{
logrus.ErrorKey: "missing key ID",
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: "invalid JWT authority: missing key ID",
telemetry.Type: "audit",
telemetry.JWTAuthorityKeyID: "",
telemetry.JWTAuthorityPublicKeySHA256: pkixHashed,
telemetry.JWTAuthorityExpiresAt: expiresAtStr,
},
},
},
},
{
name: "fail to publish",
code: codes.Internal,
err: "failed to publish JWT key: publish error",
fakeErr: errors.New("publish error"),
jwtKey: jwtKey1,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Failed to publish JWT key",
Data: logrus.Fields{
logrus.ErrorKey: "publish error",
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "Internal",
telemetry.StatusMessage: "failed to publish JWT key: publish error",
telemetry.Type: "audit",
telemetry.JWTAuthorityKeyID: "key1",
telemetry.JWTAuthorityPublicKeySHA256: pkixHashed,
telemetry.JWTAuthorityExpiresAt: expiresAtStr,
},
},
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
test.logHook.Reset()
// Setup fake
test.up.t = t
test.up.err = tt.fakeErr
test.up.expectKey = tt.fakeExpectKey
// Setup rate limiter
test.rateLimiter.count = 1
test.rateLimiter.err = tt.rateLimiterErr
resp, err := test.client.PublishJWTAuthority(ctx, &bundlev1.PublishJWTAuthorityRequest{
JwtAuthority: tt.jwtKey,
})
spiretest.AssertLogs(t, test.logHook.AllEntries(), tt.expectLogs)
if err != nil {
spiretest.RequireGRPCStatusContains(t, err, tt.code, tt.err)
require.Nil(t, resp)
return
}
require.NoError(t, err)
require.NotNil(t, resp)
spiretest.RequireProtoEqual(t, &bundlev1.PublishJWTAuthorityResponse{
JwtAuthorities: tt.resultKeys,
}, resp)
})
}
} | explode_data.jsonl/45889 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3566
} | [
2830,
3393,
50145,
55172,
45532,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
6505,
1860,
2271,
1155,
340,
16867,
1273,
727,
60639,
2822,
3223,
74,
941,
7078,
11,
1848,
1669,
2331,
21,
19,
36086,
14690,
56372,
703,
445,
31607,
28600,
36,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.