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 TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
fixtures.HandleGetSuccessfully(t)
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
actual, err := Get(client.ServiceClient(), serverId, aId).Extract()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, &SecondVolumeAttachment, actual)
} | explode_data.jsonl/34615 | {
"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,
1949,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
1166,
941,
18513,
31421,
1949,
35959,
1155,
340,
11323,
764,
1669,
330,
64,
17,
21,
23,
23,
22,
66,
21,
1786,
19,
22,
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... | 1 |
func TestMoveByStops(t *testing.T) {
tests := []MoveTest{
{
[]Region{{45, 45}},
"stops",
false,
true,
[]Region{{56, 56}},
Args{"word_end": true},
},
{
[]Region{{45, 45}},
"stops",
false,
true,
[]Region{{46, 46}},
Args{"word_end": true, "separators": ""},
},
{
[]Region{{8, 8}},
"stops",
false,
true,
[]Region{{24, 24}},
Args{"empty_line": true},
},
{
[]Region{{0, 0}},
"stops",
false,
true,
[]Region{{4, 4}},
Args{"word_begin": true, "separators": "l"},
},
{
[]Region{{58, 58}},
"stops",
false,
true,
[]Region{{61, 61}},
Args{"punct_begin": true},
},
{
[]Region{{7, 7}},
"stops",
false,
true,
[]Region{{12, 12}},
Args{"punct_end": true},
},
}
runMoveTest(tests, t, "Hello WorLd!\nTest12312{\n\n3Stop (testing) tada}\n Abr_akad[abra")
} | explode_data.jsonl/27886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 469
} | [
2830,
3393,
9860,
1359,
623,
3721,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
9860,
2271,
515,
197,
197,
515,
298,
197,
1294,
14091,
2979,
19,
20,
11,
220,
19,
20,
22050,
298,
197,
1,
98020,
756,
298,
36012,
345,
298,
42808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUserHomeDirectory(t *testing.T) {
users := TestUsers()
SetupTestHooks(users)
usr, err := currentUser()
assert.NoError(t, err, "getting current user failed")
testCases := []struct {
user *user.User
home string
expectedHomeDir string
}{
{users["alice"], users["alice"].HomeDir, "/home/alice"},
{users["bob"], users["bob"].HomeDir, "/home/bob"},
{users["michael"], users["michael"].HomeDir, usr.HomeDir},
}
for _, testCase := range testCases {
os.Setenv("HOME", testCase.home)
actual := GetUserHomeDirectory()
assert.Equal(t, testCase.expectedHomeDir, actual, "HOME is different")
}
TearDownTestHooks()
usr, err = currentUser()
assert.NoError(t, err, "getting current user failed")
assert.Equal(t, usr.HomeDir, GetUserHomeDirectory(), "HOME is different")
} | explode_data.jsonl/54589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
1949,
1474,
7623,
9310,
1155,
353,
8840,
836,
8,
341,
90896,
1669,
3393,
7137,
741,
197,
21821,
2271,
67769,
35438,
340,
197,
7063,
11,
1848,
1669,
31443,
741,
6948,
35699,
1155,
11,
1848,
11,
330,
50110,
1482,
1196,
4641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadingMap(t *testing.T) {
flightMap, err := LoadMap("input.txt")
if err != nil {
t.Fatal(err)
}
fmt.Printf("%v", flightMap[0])
if len(flightMap) != 11 {
t.Errorf("Expected length of 11, Got %d", len(flightMap))
}
if len(flightMap[1]) != 11 {
t.Errorf("Expected length of 11, Got %d", len(flightMap[0]))
}
} | explode_data.jsonl/51689 | {
"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,
8578,
2227,
1155,
353,
8840,
836,
8,
341,
1166,
4145,
2227,
11,
1848,
1669,
8893,
2227,
445,
1355,
3909,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
11009,
19367,
4430,
85,
497,
10971,
2227,
58,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConn_ReadWrite(t *testing.T) {
requireVCAN0(t)
// given a reader and writer
reader, err := Dial("can", "vcan0")
assert.NilError(t, err)
writer, err := Dial("can", "vcan0")
assert.NilError(t, err)
// when the reader reads
var g errgroup.Group
var readFrame can.Frame
g.Go(func() error {
rec := NewReceiver(reader)
if !rec.Receive() {
return fmt.Errorf("receive")
}
readFrame = rec.Frame()
return reader.Close()
})
// and the writer writes
writeFrame := can.Frame{ID: 32}
tr := NewTransmitter(writer)
ctx, done := context.WithTimeout(context.Background(), time.Second)
defer done()
assert.NilError(t, tr.TransmitFrame(ctx, writeFrame))
assert.NilError(t, writer.Close())
// then the written and read frames should be identical
assert.NilError(t, g.Wait())
assert.DeepEqual(t, writeFrame, readFrame)
} | explode_data.jsonl/35858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
9701,
38381,
7985,
1155,
353,
8840,
836,
8,
341,
17957,
11287,
1093,
15,
1155,
340,
197,
322,
2661,
264,
6604,
323,
6916,
198,
61477,
11,
1848,
1669,
66155,
445,
4814,
497,
330,
85,
4814,
15,
1138,
6948,
59678,
1454,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMemCache_Clean(t *testing.T) {
assert := assert.New(t)
err := cMem.Set("test", "aaa", time.Millisecond*500)
assert.Nil(err)
cMem.Clear()
_, err = cMem.Get("test")
assert.True(isNotExits(err))
} | explode_data.jsonl/74757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
18816,
8233,
920,
2675,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
9859,
1669,
272,
18816,
4202,
445,
1944,
497,
330,
32646,
497,
882,
71482,
9,
20,
15,
15,
340,
6948,
59678,
3964,
340,
1444,
18816,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test64BitValues(t *testing.T) {
bmp := New()
bmp.SetCopyOnWrite(true)
for i := 100; i < 1000; i++ {
bmp.Add(uint64(i))
}
var i uint64
for i = 14000000000000000100; i < 14000000000000001000; i++ {
bmp.Add(i)
}
assert.True(t, bmp.Contains(uint64(14000000000000000500)))
array := []uint64{5, 1, 2, 234294967296, 195839473298, 14000000000000000100}
bmp2 := New()
bmp2.AddMany(array)
v, err := bmp2.Select(uint64(5))
assert.Nil(t, err)
assert.True(t, v == uint64(14000000000000000100))
assert.True(t, bmp2.Minimum() == uint64(1))
assert.True(t, bmp2.Maximum() == uint64(14000000000000000100))
assert.True(t, bmp2.Rank(uint64(195839473298)) == uint64(4))
} | explode_data.jsonl/20355 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
21,
19,
8344,
6227,
1155,
353,
8840,
836,
8,
341,
2233,
1307,
1669,
1532,
741,
2233,
1307,
4202,
12106,
1925,
7985,
3715,
340,
2023,
600,
1669,
220,
16,
15,
15,
26,
600,
366,
220,
16,
15,
15,
15,
26,
600,
1027,
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... | 3 |
func TestAddImagePullSecrets(t *testing.T) {
ns := "myns"
admit := NewServiceAccount()
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
admit.SetExternalKubeInformerFactory(informerFactory)
admit.LimitSecretReferences = true
admit.RequireAPIToken = false
sa := &corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: DefaultServiceAccountName,
Namespace: ns,
},
ImagePullSecrets: []corev1.LocalObjectReference{
{Name: "foo"},
{Name: "bar"},
},
}
// Add the default service account for the ns with a secret reference into the cache
informerFactory.Core().V1().ServiceAccounts().Informer().GetStore().Add(sa)
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)
}
assert.EqualValues(t, sa.ImagePullSecrets, pod.Spec.ImagePullSecrets, "expected %v, got %v", sa.ImagePullSecrets, pod.Spec.ImagePullSecrets)
pod.Spec.ImagePullSecrets[1] = api.LocalObjectReference{Name: "baz"}
if reflect.DeepEqual(sa.ImagePullSecrets, pod.Spec.ImagePullSecrets) {
t.Errorf("accidentally mutated the ServiceAccount.ImagePullSecrets: %v", sa.ImagePullSecrets)
}
} | explode_data.jsonl/61355 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
2212,
1906,
36068,
19773,
82,
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,
7121,
16997,
641,
34527,
4153,
27907,
11,
6461,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDexPreoptSystemOther(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
ctx := android.BuilderContextForTesting(config)
globalSoong := globalSoongConfigForTests()
global := GlobalConfigForTests(ctx)
systemModule := testSystemModuleConfig(ctx, "Stest")
systemProductModule := testSystemProductModuleConfig(ctx, "SPtest")
productModule := testProductModuleConfig(ctx, "Ptest")
global.HasSystemOther = true
type moduleTest struct {
module *ModuleConfig
expectedPartition string
}
tests := []struct {
patterns []string
moduleTests []moduleTest
}{
{
patterns: []string{"app/%"},
moduleTests: []moduleTest{
{module: systemModule, expectedPartition: "system_other/system"},
{module: systemProductModule, expectedPartition: "system/product"},
{module: productModule, expectedPartition: "product"},
},
},
// product/app/% only applies to product apps inside the system partition
{
patterns: []string{"app/%", "product/app/%"},
moduleTests: []moduleTest{
{module: systemModule, expectedPartition: "system_other/system"},
{module: systemProductModule, expectedPartition: "system_other/system/product"},
{module: productModule, expectedPartition: "product"},
},
},
}
for _, test := range tests {
global.PatternsOnSystemOther = test.patterns
for _, mt := range test.moduleTests {
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module)
if err != nil {
t.Fatal(err)
}
name := mt.module.Name
wantInstalls := android.RuleBuilderInstalls{
{android.PathForOutput(ctx, name+"/oat/arm/package.odex"), fmt.Sprintf("/%s/app/test/oat/arm/%s.odex", mt.expectedPartition, name)},
{android.PathForOutput(ctx, name+"/oat/arm/package.vdex"), fmt.Sprintf("/%s/app/test/oat/arm/%s.vdex", mt.expectedPartition, name)},
}
if rule.Installs().String() != wantInstalls.String() {
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
}
}
}
} | explode_data.jsonl/56808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 742
} | [
2830,
3393,
35,
327,
4703,
2912,
2320,
11409,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2103,
8787,
2648,
445,
411,
497,
2092,
11,
7342,
2092,
340,
20985,
1669,
2103,
15641,
1972,
2461,
16451,
8754,
340,
18842,
4416,
644,
1669,
3644,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVersion(t *testing.T) {
expected := "tarsum"
var v Version
if v.String() != expected {
t.Errorf("expected %q, got %q", expected, v.String())
}
expected = "tarsum.v1"
v = 1
if v.String() != expected {
t.Errorf("expected %q, got %q", expected, v.String())
}
expected = "tarsum.dev"
v = 2
if v.String() != expected {
t.Errorf("expected %q, got %q", expected, v.String())
}
} | explode_data.jsonl/63049 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
5637,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
330,
26737,
1242,
698,
2405,
348,
6079,
198,
743,
348,
6431,
368,
961,
3601,
341,
197,
3244,
13080,
445,
7325,
1018,
80,
11,
2684,
1018,
80,
497,
3601,
11,
348,
6431,
2398... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEndBytes(t *testing.T) {
serverOutput := "hello world"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte(serverOutput))
}))
defer ts.Close()
// Callback.
{
resp, bodyBytes, errs := New().Get(ts.URL).EndBytes(func(resp Response, body []byte, errs []error) {
if len(errs) > 0 {
t.Fatalf("Unexpected errors: %s", errs)
}
if resp.StatusCode != 200 {
t.Fatalf("Expected StatusCode=200, actual StatusCode=%v", resp.StatusCode)
}
if string(body) != serverOutput {
t.Errorf("Expected bodyBytes=%s, actual bodyBytes=%s", serverOutput, string(body))
}
})
if len(errs) > 0 {
t.Fatalf("Unexpected errors: %s", errs)
}
if resp.StatusCode != 200 {
t.Fatalf("Expected StatusCode=200, actual StatusCode=%v", resp.StatusCode)
}
if string(bodyBytes) != serverOutput {
t.Errorf("Expected bodyBytes=%s, actual bodyBytes=%s", serverOutput, string(bodyBytes))
}
}
// No callback.
{
resp, bodyBytes, errs := New().Get(ts.URL).EndBytes()
if len(errs) > 0 {
t.Errorf("Unexpected errors: %s", errs)
}
if resp.StatusCode != 200 {
t.Errorf("Expected StatusCode=200, actual StatusCode=%v", resp.StatusCode)
}
if string(bodyBytes) != serverOutput {
t.Errorf("Expected bodyBytes=%s, actual bodyBytes=%s", serverOutput, string(bodyBytes))
}
}
} | explode_data.jsonl/25471 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
3727,
7078,
1155,
353,
8840,
836,
8,
341,
41057,
5097,
1669,
330,
14990,
1879,
698,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
69794,
7,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnnounceTimeout(t *testing.T) {
s, err := NewServer(&ServerConfig{
StartingNodes: addrResolver("1.2.3.4:5"),
Conn: mustListen(":0"),
QueryResendDelay: func() time.Duration {
return 0
},
})
require.NoError(t, err)
var ih [20]byte
copy(ih[:], "12341234123412341234")
a, err := s.Announce(ih, 0, true)
assert.NoError(t, err)
<-a.Peers
a.Close()
s.Close()
} | explode_data.jsonl/35953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
27093,
9734,
7636,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
1532,
5475,
2099,
5475,
2648,
515,
197,
197,
24617,
12288,
25,
10789,
18190,
445,
16,
13,
17,
13,
18,
13,
19,
25,
20,
4461,
197,
197,
9701,
25,
688... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_defaultFiltersFlags_String(t *testing.T) {
tests := []struct {
name string
filters []*eskip.Filter
want string
}{
{
name: "test string",
filters: []*eskip.Filter{},
want: "<default filters>",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dpf := &defaultFiltersFlags{
filters: tt.filters,
}
if got := dpf.String(); got != tt.want {
t.Errorf("defaultFiltersFlags.String() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/22589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
9993,
28351,
9195,
31777,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
1166,
8612,
29838,
288,
13389,
31696,
198,
197,
50780,
262,
914,
198,
197,
59403,
197,
197,
515,
298,
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... | 2 |
func TestHealth(t *testing.T) {
Convey("Given I register the health handler", t, func() {
lc := fxtest.NewLifecycle(t)
logger, err := zap.NewLogger(lc, zap.NewConfig())
So(err, ShouldBeNil)
cc := checker.NewHTTPChecker("https://httpstat.us/200", test.NewHTTPClient(logger))
hr := server.NewRegistration("http", 10*time.Millisecond, cc)
regs := health.Registrations{hr}
server, err := health.NewServer(lc, regs)
So(err, ShouldBeNil)
o, err := server.Observe("http")
So(err, ShouldBeNil)
cfg := &pkgHTTP.Config{Port: test.GenerateRandomPort()}
httpServer := pkgHTTP.NewServer(lc, test.NewShutdowner(), cfg, logger)
err = healthHTTP.Register(httpServer, &healthHTTP.HealthObserver{Observer: o}, &healthHTTP.LivenessObserver{Observer: o}, &healthHTTP.ReadinessObserver{Observer: o})
So(err, ShouldBeNil)
lc.RequireStart()
Convey("When I query health", func() {
client := test.NewHTTPClient(logger)
req, err := http.NewRequestWithContext(context.Background(), "GET", fmt.Sprintf("http://localhost:%s/health", cfg.Port), nil)
So(err, ShouldBeNil)
resp, err := client.Do(req)
So(err, ShouldBeNil)
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
So(err, ShouldBeNil)
actual := strings.TrimSpace(string(body))
lc.RequireStop()
Convey("Then I should have a healthy response", func() {
So(actual, ShouldEqual, `{"status":"SERVING"}`)
})
})
})
} | explode_data.jsonl/49474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 561
} | [
2830,
3393,
14542,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
358,
4161,
279,
2820,
7013,
497,
259,
11,
2915,
368,
341,
197,
8810,
66,
1669,
33219,
1944,
7121,
62731,
1155,
692,
197,
17060,
11,
1848,
1669,
32978,
7121,
739... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransferInputVerifyNoValue(t *testing.T) {
in := TransferInput{
Amt: 0,
Input: Input{
SigIndices: []uint32{0, 1},
},
}
err := in.Verify()
if err == nil {
t.Fatalf("Should have errored with a no value input")
}
} | explode_data.jsonl/31622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
21970,
2505,
32627,
2753,
1130,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
23200,
2505,
515,
197,
22985,
2501,
25,
220,
15,
345,
197,
66588,
25,
5571,
515,
298,
7568,
343,
31941,
25,
3056,
2496,
18,
17,
90,
15,
11,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPermError(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mw := NewMailWorker()
go func(ctx context.Context) {
mw.Start(ctx)
}(ctx)
expectedError := &textproto.Error{
Code: 500,
Msg: "Permanent error",
}
sender := newMockErrorSender(expectedError)
dialer := newMockDialer()
dialer.setDial(func() (Sender, error) {
return sender, nil
})
messages := generateMessages(dialer)
// Send the campaign
mw.Queue(MailJob{Bcc: false, Mails: messages})
got := []*mockMessage{}
for message := range sender.messageChan {
got = append(got, message)
}
// Check that we only sent one message
expectedCount := 1
if len(got) != expectedCount {
t.Fatalf("Unexpected number of messages received. Expected %d Got %d", len(got), expectedCount)
}
// Check that it's the correct message
originalFrom := messages[1].(*mockMessage).from
if got[0].from != originalFrom {
t.Fatalf("Invalid message received. Expected %s, Got %s", originalFrom, got[0].from)
}
message := messages[0].(*mockMessage)
// Check that the first message did not perform a backoff
expectedBackoffCount := 0
backoffCount := message.backoffCount
if backoffCount != expectedBackoffCount {
t.Fatalf("Did not receive expected backoff. Got backoffCount %d, Expected %d", backoffCount, expectedCount)
}
// Check that there was a reset performed on the sender
if sender.resetCount != expectedCount {
t.Fatalf("Did not receive expected reset. Got resetCount %d, expected %d", sender.resetCount, expectedCount)
}
// Check that the email errored out appropriately
if !reflect.DeepEqual(message.err, expectedError) {
t.Fatalf("Did not received expected error. Got %#v\nExpected %#v", message.err, expectedError)
}
} | explode_data.jsonl/55822 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 583
} | [
2830,
3393,
81245,
1454,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
2109,
86,
1669,
1532,
16702,
21936,
741,
30680,
2915,
7502,
2266,
9328,
8,
341,
197,
2109,
86,
12101,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRetryEvent(t *testing.T) {
e, err := unmarshal([]string{"retry:"})
if err != nil {
t.Errorf("Unexpected failure while unmarshaling valid EventsResponse")
}
if e.Type != eventRetry {
t.Errorf("Parsed event type is supposed to be retry")
}
} | explode_data.jsonl/78027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
51560,
1556,
1155,
353,
8840,
836,
8,
341,
7727,
11,
1848,
1669,
650,
27121,
10556,
917,
4913,
44848,
2974,
3518,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
29430,
7901,
1393,
650,
36239,
6132,
2697,
17627,
2582,
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 TestShuffle(t *testing.T) {
endorsers := make(Endorsers, 1000)
for i := 0; i < len(endorsers); i++ {
endorsers[i] = &Peer{
StateInfoMessage: stateInfoWithHeight(uint64(i)),
}
}
isHeightAscending := func(endorsers Endorsers) bool {
for i := 0; i < len(endorsers)-1; i++ {
currHeight := endorsers[i].StateInfoMessage.GetStateInfo().Properties.LedgerHeight
nextHeight := endorsers[i+1].StateInfoMessage.GetStateInfo().Properties.LedgerHeight
if currHeight > nextHeight {
return false
}
}
return true
}
assert.True(t, isHeightAscending(endorsers))
assert.False(t, isHeightAscending(endorsers.Shuffle()))
} | explode_data.jsonl/38942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 256
} | [
2830,
3393,
2016,
13208,
1155,
353,
8840,
836,
8,
341,
6246,
1087,
388,
1669,
1281,
7,
3727,
1087,
388,
11,
220,
16,
15,
15,
15,
340,
2023,
600,
1669,
220,
15,
26,
600,
366,
2422,
15076,
1087,
388,
1215,
600,
1027,
341,
197,
6246,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMap(t *testing.T) {
type Test struct {
Map map[string]string `s:"defaultMap,dive,defaultStr"`
}
set := New()
set.SetTagName("s")
set.Register("defaultMap", func(ctx context.Context, t *Transformer, value reflect.Value, param string) error {
if HasValue(value) {
return nil
}
value.Set(reflect.MakeMap(value.Type()))
return nil
})
set.Register("defaultStr", func(ctx context.Context, t *Transformer, value reflect.Value, param string) error {
if value.String() == "ok" {
return errors.New("ALREADY OK")
}
value.SetString("default")
return nil
})
var tt Test
err := set.Struct(context.Background(), &tt)
Equal(t, err, nil)
Equal(t, len(tt.Map), 0)
tt2 := Test{
Map: map[string]string{"key": ""},
}
err = set.Struct(context.Background(), &tt2)
Equal(t, err, nil)
Equal(t, len(tt2.Map), 1)
Equal(t, tt2.Map["key"], "default")
tt3 := Test{
Map: map[string]string{"key": "ok"},
}
err = set.Struct(context.Background(), &tt3)
NotEqual(t, err, nil)
Equal(t, err.Error(), "ALREADY OK")
} | explode_data.jsonl/43617 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 420
} | [
2830,
3393,
2227,
1155,
353,
8840,
836,
8,
341,
13158,
3393,
2036,
341,
197,
26873,
2415,
14032,
30953,
1565,
82,
2974,
2258,
2227,
11991,
533,
87696,
2580,
8805,
197,
630,
8196,
1669,
1532,
741,
8196,
4202,
22616,
445,
82,
1138,
8196,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPatchTeamSanitization(t *testing.T) {
th := Setup(t)
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
})
CheckNoError(t, resp)
// Non-admin users cannot update the team
t.Run("team admin", func(t *testing.T) {
rteam, resp := th.Client.PatchTeam(team.Id, &model.TeamPatch{})
CheckNoError(t, resp)
require.NotEmpty(t, rteam.Email, "should not have sanitized email for admin")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
})
t.Run("system admin", func(t *testing.T) {
rteam, resp := th.SystemAdminClient.PatchTeam(team.Id, &model.TeamPatch{})
CheckNoError(t, resp)
require.NotEmpty(t, rteam.Email, "should not have sanitized email for admin")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
})
} | explode_data.jsonl/70707 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
43622,
14597,
23729,
275,
2022,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
340,
16867,
270,
836,
682,
4454,
2822,
197,
9196,
11,
9039,
1669,
270,
11716,
7251,
14597,
2099,
2528,
65842,
515,
197,
197,
26456,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_String(t *testing.T) {
a := assert.New(t)
a.Equal(String("", "foo"), "foo")
a.Equal(String("bar", "foo"), "bar")
var s string
a.Equal(String(s, "foo"), "foo")
} | explode_data.jsonl/12070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
31777,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
692,
11323,
12808,
2242,
19814,
330,
7975,
3975,
330,
7975,
1138,
11323,
12808,
2242,
445,
2257,
497,
330,
7975,
3975,
330,
2257,
1138,
2405,
274,
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 |
func TestClient_CoinsData(t *testing.T) {
cd, err := client.CoinsID(CoinsDataParams{Id: "solana"})
require.NoError(t, err)
require.Equal(t, "solana", cd.Id)
require.Equal(t, "sol", cd.Symbol)
require.Equal(t, "Solana", cd.Name)
} | explode_data.jsonl/37792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
2959,
920,
68798,
1043,
1155,
353,
8840,
836,
8,
341,
72826,
11,
1848,
1669,
2943,
52114,
1330,
915,
3025,
68798,
1043,
4870,
90,
764,
25,
330,
38198,
3362,
23625,
17957,
35699,
1155,
11,
1848,
340,
17957,
12808,
1155,
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... | 1 |
func TestGatewayConformance(t *testing.T) {
framework.
NewTest(t).
RequiresSingleCluster().
Features("traffic.gateway").
Run(func(ctx framework.TestContext) {
if !supportsCRDv1(ctx) {
t.Skip("Not supported; requires CRDv1 support.")
}
if err := ctx.ConfigIstio().
File("", "testdata/gateway-api-crd.yaml").
Apply(apply.NoCleanup); err != nil {
ctx.Fatal(err)
}
// Wait until our GatewayClass is ready
retry.UntilSuccessOrFail(ctx, func() error {
_, err := ctx.Clusters().Default().GatewayAPI().GatewayV1alpha2().GatewayClasses().Get(context.Background(), "istio", metav1.GetOptions{})
return err
})
mapper, _ := gatewayConformanceInputs.Client.UtilFactory().ToRESTMapper()
c, err := client.New(gatewayConformanceInputs.Client.RESTConfig(), client.Options{
Scheme: kube.IstioScheme,
Mapper: mapper,
})
if err != nil {
t.Fatal(err)
}
opts := suite.Options{
Client: c,
GatewayClassName: "istio",
Debug: scopes.Framework.DebugEnabled(),
CleanupBaseResources: gatewayConformanceInputs.Cleanup,
}
if rev := ctx.Settings().Revisions.Default(); rev != "" {
opts.NamespaceLabels = map[string]string{
"istio.io/rev": rev,
}
}
csuite := suite.New(opts)
csuite.Setup(t)
for _, ct := range tests.ConformanceTests {
t.Run(ct.ShortName, func(t *testing.T) {
ct.Run(t, csuite)
})
}
})
} | explode_data.jsonl/48646 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 654
} | [
2830,
3393,
40709,
1109,
11795,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
624,
197,
197,
3564,
2271,
1155,
4292,
197,
197,
46961,
10888,
28678,
25829,
197,
197,
21336,
445,
53987,
80292,
38609,
197,
85952,
18552,
7502,
12626,
8787,
1972,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyAndToSql(t *testing.T) {
sql, args, err := And{}.ToSql()
assert.NoError(t, err)
expectedSql := "(1=1)"
assert.Equal(t, expectedSql, sql)
expectedArgs := []interface{}{}
assert.Equal(t, expectedArgs, args)
} | explode_data.jsonl/44175 | {
"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,
3522,
3036,
1249,
8269,
1155,
353,
8840,
836,
8,
341,
30633,
11,
2827,
11,
1848,
1669,
1597,
46391,
1249,
8269,
741,
6948,
35699,
1155,
11,
1848,
692,
42400,
8269,
1669,
11993,
16,
28,
16,
12954,
6948,
12808,
1155,
11,
360... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransformGroup(t *testing.T) {
tests := []struct {
commonFields common.Fields
expected []string
}{
{
commonFields: common.Fields{common.Field{Name: "context", Path: "something"}},
expected: []string{"context"},
},
{
commonFields: common.Fields{
common.Field{
Name: "context",
Type: "group",
Fields: common.Fields{
common.Field{Name: "another", Type: ""},
},
},
common.Field{
Name: "context",
Type: "group",
Fields: common.Fields{
common.Field{Name: "type", Type: ""},
common.Field{
Name: "metric",
Type: "group",
Fields: common.Fields{
common.Field{Name: "object"},
},
},
},
},
},
expected: []string{"context.another", "context.type", "context.metric.object"},
},
}
for idx, test := range tests {
trans, _ := newFieldsTransformer(version, test.commonFields)
transformed, err := trans.transform()
assert.NoError(t, err)
out := transformed["fields"].([]common.MapStr)
assert.Equal(t, len(test.expected)+ctMetaData, len(out))
for i, e := range test.expected {
assert.Equal(t, e, out[i]["name"], fmt.Sprintf("Failed for idx %v", idx))
}
}
} | explode_data.jsonl/37635 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 548
} | [
2830,
3393,
8963,
2808,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
83825,
8941,
4185,
42809,
198,
197,
42400,
257,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
83825,
8941,
25,
4185,
42809,
90,
5464,
17087,
63... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLimitStep(t *testing.T) {
tc := newFakeTableClient()
_, flowChan := tc.t.Start()
defer tc.t.Stop()
for tc.t.State() != common.RunningState {
time.Sleep(100 * time.Millisecond)
}
flowChan <- newICMPFlow(222)
flowChan <- newICMPFlow(444)
time.Sleep(time.Second)
query := `G.Flows()`
res := execTraversalQuery(t, tc, query)
if len(res.Values()) != 2 {
t.Fatalf("Should return 2 result, returned: %v", res.Values())
}
query = `G.Flows().Limit(1)`
res = execTraversalQuery(t, tc, query)
if len(res.Values()) != 1 {
t.Fatalf("Should return 1 result, returned: %v", res.Values())
}
} | explode_data.jsonl/45639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
16527,
8304,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
501,
52317,
2556,
2959,
2822,
197,
6878,
6396,
46019,
1669,
17130,
734,
12101,
741,
16867,
17130,
734,
30213,
741,
2023,
17130,
734,
18942,
368,
961,
4185,
2013,
11216,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCopy(t *testing.T) {
var e1, e2 float32
e := createRandomObject(e1)
if v, ok := e.(float32); ok {
e1 = v
}
e = createRandomObject(e2)
if v, ok := e.(float32); ok {
e2 = v
}
s1 := New()
s1.Add(e1)
s1.Add(e2)
s2 := s1.Copy()
if !s2.IsEqual(s1) {
t.Errorf("expected %v to be equal to %v after copy", s1, s2)
}
} | explode_data.jsonl/35015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
12106,
1155,
353,
8840,
836,
8,
341,
2405,
384,
16,
11,
384,
17,
2224,
18,
17,
198,
7727,
1669,
1855,
13999,
1190,
2026,
16,
340,
743,
348,
11,
5394,
1669,
384,
12832,
3649,
18,
17,
1215,
5394,
341,
197,
7727,
16,
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... | 4 |
func TestScrapeLoopStopBeforeRun(t *testing.T) {
scraper := &testScraper{}
sl := newScrapeLoop(context.Background(),
scraper,
nil, nil,
nopMutator,
nopMutator,
nil, nil, 0,
true,
)
// The scrape pool synchronizes on stopping scrape loops. However, new scrape
// loops are started asynchronously. Thus it's possible, that a loop is stopped
// again before having started properly.
// Stopping not-yet-started loops must block until the run method was called and exited.
// The run method must exit immediately.
stopDone := make(chan struct{})
go func() {
sl.stop()
close(stopDone)
}()
select {
case <-stopDone:
t.Fatalf("Stopping terminated before run exited successfully")
case <-time.After(500 * time.Millisecond):
}
// Running the scrape loop must exit before calling the scraper even once.
scraper.scrapeFunc = func(context.Context, io.Writer) error {
t.Fatalf("scraper was called for terminated scrape loop")
return nil
}
runDone := make(chan struct{})
go func() {
sl.run(1, 0, nil)
close(runDone)
}()
select {
case <-runDone:
case <-time.After(1 * time.Second):
t.Fatalf("Running terminated scrape loop did not exit")
}
select {
case <-stopDone:
case <-time.After(1 * time.Second):
t.Fatalf("Stopping did not terminate after running exited")
}
} | explode_data.jsonl/56118 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
3326,
19842,
14620,
10674,
10227,
6727,
1155,
353,
8840,
836,
8,
341,
1903,
86282,
1669,
609,
1944,
65508,
3191,
31483,
78626,
1669,
501,
3326,
19842,
14620,
5378,
19047,
3148,
197,
1903,
86282,
345,
197,
84131,
11,
2092,
345,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAgentConnectAuthorize_deny(t *testing.T) {
t.Parallel()
assert := assert.New(t)
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
target := "db"
// Create some intentions
{
req := structs.IntentionRequest{
Datacenter: "dc1",
Op: structs.IntentionOpCreate,
Intention: structs.TestIntention(t),
}
req.Intention.SourceNS = structs.IntentionDefaultNamespace
req.Intention.SourceName = "web"
req.Intention.DestinationNS = structs.IntentionDefaultNamespace
req.Intention.DestinationName = target
req.Intention.Action = structs.IntentionActionDeny
var reply string
assert.Nil(a.RPC("Intention.Apply", &req, &reply))
}
args := &structs.ConnectAuthorizeRequest{
Target: target,
ClientCertURI: connect.TestSpiffeIDService(t, "web").URI().String(),
}
req, _ := http.NewRequest("POST", "/v1/agent/connect/authorize", jsonReader(args))
resp := httptest.NewRecorder()
respRaw, err := a.srv.AgentConnectAuthorize(resp, req)
assert.Nil(err)
assert.Equal(200, resp.Code)
obj := respRaw.(*connectAuthorizeResp)
assert.False(obj.Authorized)
assert.Contains(obj.Reason, "Matched")
} | explode_data.jsonl/33670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
16810,
14611,
37483,
814,
32395,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
14676,
16867,
264,
10849,
18452,
2822,
28861,
1669,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReconcileCancelledRunFinallyFailsTaskRunCancellation(t *testing.T) {
// TestReconcileCancelledRunFinallyFailsTaskRunCancellation runs "Reconcile" on a PipelineRun with a single TaskRun.
// The TaskRun cannot be cancelled. Check that the pipelinerun graceful cancel fails, that reconcile fails and
// an event is generated
names.TestingSeed()
ptName := "hello-world-1"
prName := "test-pipeline-fails-to-cancel"
prs := []*v1beta1.PipelineRun{{
ObjectMeta: baseObjectMeta(prName, "foo"),
Spec: v1beta1.PipelineRunSpec{
PipelineRef: &v1beta1.PipelineRef{Name: "test-pipeline"},
Status: v1beta1.PipelineRunSpecStatusCancelledRunFinally,
},
Status: v1beta1.PipelineRunStatus{
Status: duckv1beta1.Status{
Conditions: duckv1beta1.Conditions{
apis.Condition{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: v1beta1.PipelineRunReasonRunning.String(),
Message: "running...",
},
},
},
PipelineRunStatusFields: v1beta1.PipelineRunStatusFields{
TaskRuns: map[string]*v1beta1.PipelineRunTaskRunStatus{
prName + ptName: {
PipelineTaskName: ptName,
Status: &v1beta1.TaskRunStatus{},
},
},
StartTime: &metav1.Time{Time: now},
},
},
}}
ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline}
ts := []*v1beta1.Task{
simpleHelloWorldTask,
}
trs := []*v1beta1.TaskRun{
getTaskRun(
t,
"test-pipeline-fails-to-cancelhello-world-1",
prName,
"test-pipeline",
"hello-world",
corev1.ConditionUnknown,
),
}
cms := []*corev1.ConfigMap{withEnabledAlphaAPIFields(newFeatureFlagsConfigMap())}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
TaskRuns: trs,
ConfigMaps: cms,
}
testAssets, cancel := getPipelineRunController(t, d)
defer cancel()
c := testAssets.Controller
clients := testAssets.Clients
failingReactorActivated := true
// Make the patch call fail, i.e. make it so that the controller fails to cancel the TaskRun
clients.Pipeline.PrependReactor("patch", "taskruns", func(action ktesting.Action) (bool, runtime.Object, error) {
return failingReactorActivated, nil, fmt.Errorf("i'm sorry Dave, i'm afraid i can't do that")
})
err := c.Reconciler.Reconcile(testAssets.Ctx, "foo/test-pipeline-fails-to-cancel")
if err == nil {
t.Errorf("Expected to see error returned from reconcile after failing to cancel TaskRun but saw none!")
}
// Check that the PipelineRun is still running with correct error message
reconciledRun, err := clients.Pipeline.TektonV1beta1().PipelineRuns("foo").Get(testAssets.Ctx, "test-pipeline-fails-to-cancel", metav1.GetOptions{})
if err != nil {
t.Fatalf("Somehow had error getting reconciled run out of fake client: %s", err)
}
// The PipelineRun should not be cancelled b/c we couldn't cancel the TaskRun
condition := reconciledRun.Status.GetCondition(apis.ConditionSucceeded)
if !condition.IsUnknown() {
t.Errorf("Expected PipelineRun to still be running since the TaskRun could not be cancelled but succeeded condition is %v", condition.Status)
}
if condition.Reason != ReasonCouldntCancel {
t.Errorf("Expected PipelineRun condition to indicate the cancellation failed but reason was %s", condition.Reason)
}
// The event here is "Normal" because in case we fail to cancel we leave the condition to unknown
// Further reconcile might converge then the status of the pipeline.
// See https://github.com/tektoncd/pipeline/issues/2647 for further details.
wantEvents := []string{
"Normal PipelineRunCouldntCancel PipelineRun \"test-pipeline-fails-to-cancel\" was cancelled but had errors trying to cancel TaskRuns",
"Warning InternalError 1 error occurred",
}
err = eventstest.CheckEventsOrdered(t, testAssets.Recorder.Events, prName, wantEvents)
if !(err == nil) {
t.Errorf(err.Error())
}
// Turn off failing reactor and retry reconciliation
failingReactorActivated = false
err = c.Reconciler.Reconcile(testAssets.Ctx, "foo/test-pipeline-fails-to-cancel")
if err == nil {
// No error is ok
} else if ok, _ := controller.IsRequeueKey(err); !ok { // Requeue is also fine.
t.Errorf("Expected to cancel TaskRun successfully!")
}
} | explode_data.jsonl/27289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1584
} | [
2830,
3393,
693,
40446,
457,
39473,
6727,
23949,
37,
6209,
6262,
6727,
82298,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
693,
40446,
457,
39473,
6727,
23949,
37,
6209,
6262,
6727,
82298,
8473,
330,
693,
40446,
457,
1,
389,
264,
409... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeletePolicy(t *testing.T) {
appProtectConfiguration := NewAppProtectConfiguration()
appProtectConfiguration.Policies["testing/test"] = &AppProtectPolicyEx{}
tests := []struct {
key string
expectedChanges []AppProtectChange
expectedProblems []AppProtectProblem
msg string
}{
{
key: "testing/test",
expectedChanges: []AppProtectChange{
{
Op: Delete,
Resource: &AppProtectPolicyEx{},
},
},
expectedProblems: nil,
msg: "Positive",
},
{
key: "testing/notpresent",
expectedChanges: nil,
expectedProblems: nil,
msg: "Negative",
},
}
for _, test := range tests {
apChan, apProbs := appProtectConfiguration.DeletePolicy(test.key)
if diff := cmp.Diff(test.expectedChanges, apChan); diff != "" {
t.Errorf("DeletePolicy() %q changes returned unexpected result (-want +got):\n%s", test.msg, diff)
}
if diff := cmp.Diff(test.expectedProblems, apProbs); diff != "" {
t.Errorf("DeletePolicy() %q problems returned unexpected result (-want +got):\n%s", test.msg, diff)
}
}
} | explode_data.jsonl/19387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
6435,
13825,
1155,
353,
8840,
836,
8,
341,
28236,
61547,
7688,
1669,
1532,
2164,
61547,
7688,
741,
28236,
61547,
7688,
1069,
42038,
1183,
8840,
12697,
1341,
284,
609,
2164,
61547,
13825,
840,
16094,
78216,
1669,
3056,
1235,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test_Bitmap_003(t *testing.T) {
tool.Test(t, nil, new(App), func(app *App) {
app.Require(app.Bitmaps)
reader, err := os.Open(PNG_FILEPATH)
if err != nil {
t.Fatal(err)
}
defer reader.Close()
if bitmap, _, err := image.Decode(reader); err != nil {
t.Error(err)
} else if dest, err := app.NewBitmap(gopi.SURFACE_FMT_RGBA32, uint32(bitmap.Bounds().Dx()), uint32(bitmap.Bounds().Dy())); err != nil {
t.Error(err)
} else {
bounds := bitmap.Bounds()
for y := bounds.Min.Y; y <= bounds.Max.Y; y++ {
for x := bounds.Min.X; x <= bounds.Max.X; x++ {
c := bitmap.At(x, y)
dest.SetAt(c, x, y)
}
}
if writer, err := ioutil.TempFile("", "png"); err != nil {
t.Error(err)
} else if err := png.Encode(writer, dest); err != nil {
t.Error(err)
} else {
writer.Close()
t.Log(writer.Name())
}
}
})
} | explode_data.jsonl/15083 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 426
} | [
2830,
3393,
1668,
19244,
62,
15,
15,
18,
1155,
353,
8840,
836,
8,
341,
197,
14172,
8787,
1155,
11,
2092,
11,
501,
23231,
701,
2915,
11462,
353,
2164,
8,
341,
197,
28236,
81288,
11462,
68866,
17640,
692,
197,
61477,
11,
1848,
1669,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestVersionObjectList(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithVersionsObject(t)
defer rollback()
if skipVersionTests {
t.Log("Server doesn't support Versions - skipping test")
return
}
list, err := c.VersionObjectList(ctx, VERSIONS_CONTAINER, OBJECT)
if err != nil {
t.Fatal(err)
}
if len(list) != 2 {
t.Error("Version list should return 2 objects")
}
} | explode_data.jsonl/12711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
5637,
1190,
852,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
69015,
1190,
1155,
340,
16867,
60414,
741,
743,
10706,
5637,
18200,
341,
197,
3244,
5247,
445,
5475,
3171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractTLSSecretName(t *testing.T) {
testCases := map[string]struct {
host string
ingress *ingress.Ingress
fn func(string) (*ingress.SSLCert, error)
expName string
}{
"nil ingress": {
"foo.bar",
nil,
func(string) (*ingress.SSLCert, error) {
return nil, nil
},
"",
},
"empty ingress": {
"foo.bar",
&ingress.Ingress{},
func(string) (*ingress.SSLCert, error) {
return nil, nil
},
"",
},
"ingress tls, nil secret": {
"foo.bar",
&ingress.Ingress{
Ingress: networking.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: networking.IngressSpec{
TLS: []networking.IngressTLS{
{SecretName: "demo"},
},
Rules: []networking.IngressRule{
{
Host: "foo.bar",
},
},
},
},
},
func(string) (*ingress.SSLCert, error) {
return nil, nil
},
"",
},
"ingress tls, no host, matching cert cn": {
"foo.bar",
&ingress.Ingress{
Ingress: networking.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: networking.IngressSpec{
TLS: []networking.IngressTLS{
{SecretName: "demo"},
},
Rules: []networking.IngressRule{
{
Host: "foo.bar",
},
},
},
},
},
func(string) (*ingress.SSLCert, error) {
return &ingress.SSLCert{
Certificate: fakeX509Cert([]string{"foo.bar", "example.com"}),
}, nil
},
"demo",
},
"ingress tls, no host, wildcard cert with matching cn": {
"foo.bar",
&ingress.Ingress{
Ingress: networking.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: networking.IngressSpec{
TLS: []networking.IngressTLS{
{
SecretName: "demo",
},
},
Rules: []networking.IngressRule{
{
Host: "test.foo.bar",
},
},
},
},
},
func(string) (*ingress.SSLCert, error) {
return &ingress.SSLCert{
Certificate: fakeX509Cert([]string{"*.foo.bar", "foo.bar"}),
}, nil
},
"demo",
},
"ingress tls, hosts, matching cert cn": {
"foo.bar",
&ingress.Ingress{
Ingress: networking.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: networking.IngressSpec{
TLS: []networking.IngressTLS{
{
Hosts: []string{"foo.bar", "example.com"},
SecretName: "demo",
},
},
Rules: []networking.IngressRule{
{
Host: "foo.bar",
},
},
},
},
},
func(string) (*ingress.SSLCert, error) {
return nil, nil
},
"demo",
},
}
for title, tc := range testCases {
t.Run(title, func(t *testing.T) {
name := extractTLSSecretName(tc.host, tc.ingress, tc.fn)
if name != tc.expName {
t.Errorf("Expected Secret name %q (got %q)", tc.expName, name)
}
})
}
} | explode_data.jsonl/69683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1534
} | [
2830,
3393,
28959,
13470,
1220,
50856,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
63104,
262,
914,
198,
197,
197,
287,
673,
353,
287,
673,
5337,
2483,
198,
197,
40095,
414,
2915,
3609,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrometheusTracer_ResolveFieldDidStart(t *testing.T) {
mockTime, cleanup := mockTime()
defer cleanup()
tests := []struct {
name string
allowList []string
delta time.Duration
runs int
err error
want string
}{
{
name: "omitted from allow list",
allowList: []string{KeyExecuteQuery},
delta: 10,
runs: 20,
want: "",
},
{
name: "single run",
allowList: []string{KeyExecuteField},
delta: 120,
runs: 1,
want: summaryMetadata + `
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.5"} 120
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.9"} 120
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.99"} 120
graphql_duration_seconds_sum{err="<nil>",key="execute_field",platform_key="Check.interval"} 120
graphql_duration_seconds_count{err="<nil>",key="execute_field",platform_key="Check.interval"} 1
`,
},
{
name: "multiple runs",
allowList: []string{KeyExecuteField},
delta: 15,
runs: 7,
want: summaryMetadata + `
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.5"} 15
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.9"} 15
graphql_duration_seconds{err="<nil>",key="execute_field",platform_key="Check.interval",quantile="0.99"} 15
graphql_duration_seconds_sum{err="<nil>",key="execute_field",platform_key="Check.interval"} 105
graphql_duration_seconds_count{err="<nil>",key="execute_field",platform_key="Check.interval"} 7
`,
},
{
name: "encountered error",
allowList: []string{KeyExecuteField},
delta: 15,
runs: 7,
err: context.DeadlineExceeded,
want: summaryMetadata + `
graphql_duration_seconds{err="context.deadlineExceededError",key="execute_field",platform_key="Check.interval",quantile="0.5"} 15
graphql_duration_seconds{err="context.deadlineExceededError",key="execute_field",platform_key="Check.interval",quantile="0.9"} 15
graphql_duration_seconds{err="context.deadlineExceededError",key="execute_field",platform_key="Check.interval",quantile="0.99"} 15
graphql_duration_seconds_sum{err="context.deadlineExceededError",key="execute_field",platform_key="Check.interval"} 105
graphql_duration_seconds_count{err="context.deadlineExceededError",key="execute_field",platform_key="Check.interval"} 7
`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
trace := newTracer(tt.allowList)
info := &graphql.ResolveInfo{
FieldName: "interval",
ParentType: &checkType{},
}
for i := 0; i < tt.runs; i++ {
_, fn := trace.ResolveFieldDidStart(context.Background(), info)
mockTime.Set(time.Now().Add(tt.delta * time.Millisecond))
fn(nil, tt.err)
}
if err := testutil.CollectAndCompare(trace.Collector(), strings.NewReader(tt.want), "graphql_duration_seconds"); err != nil {
t.Errorf("unexpected collecting result:\n%s", err)
}
})
}
} | explode_data.jsonl/82526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1371
} | [
2830,
3393,
35186,
39705,
1282,
9584,
62,
56808,
1877,
6986,
3479,
1155,
353,
8840,
836,
8,
341,
77333,
1462,
11,
21290,
1669,
7860,
1462,
741,
16867,
21290,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
197,
7183,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAPITimeUnmarshalJSONSupportsRFC3339Nano(t *testing.T) {
var (
when = time.Now().Add(1 * time.Nanosecond)
format = time.RFC3339Nano
marshaledExample = []byte(fmt.Sprintf(`"%s"`, when.Format(format)))
actual repo.APITime
)
if err := json.Unmarshal(marshaledExample, &actual); err != nil {
t.Logf("output: %s", string(marshaledExample))
t.Fatal(err)
}
if !when.Equal(actual.Time) {
t.Errorf("expected (%s) to equal (%s), but did not when using format (%s)", actual.Time, when, format)
}
} | explode_data.jsonl/19475 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
2537,
952,
545,
1806,
27121,
5370,
7916,
82,
64371,
18,
18,
18,
24,
83819,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
60180,
1797,
284,
882,
13244,
1005,
2212,
7,
16,
353,
882,
2067,
276,
960,
1297,
340,
197,
59416,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateJob(t *testing.T) {
t.Parallel()
store, cleanup := cltest.NewStore(t)
defer cleanup()
// Create a funding key.
require.NoError(t, store.KeyStore.Unlock(cltest.Password))
funding, err := store.KeyStore.NewAccount()
require.NoError(t, err)
fundingKey := models.Key{
Address: models.EIP55Address(funding.Address.Hex()),
IsFunding: true,
JSON: models.JSON{
Result: gjson.ParseBytes([]byte(`{"json" : true}`)),
},
}
require.NoError(t, store.CreateKeyIfNotExists(fundingKey))
tests := []struct {
name string
input []byte
want error
}{
{"base case", cltest.MustReadFile(t, "testdata/hello_world_job.json"), nil},
{
"error in job",
cltest.MustReadFile(t, "testdata/invalid_endat_job.json"),
models.NewJSONAPIErrorsWith("StartAt cannot be before EndAt"),
},
{
"error in runat initr",
cltest.MustReadFile(t, "testdata/run_at_wo_time_job.json"),
models.NewJSONAPIErrorsWith("RunAt must have a time"),
},
{
"error in task",
cltest.MustReadFile(t, "testdata/nonexistent_task_job.json"),
models.NewJSONAPIErrorsWith("idonotexist is not a supported adapter type"),
},
{
"zero initiators",
cltest.MustReadFile(t, "testdata/zero_initiators.json"),
models.NewJSONAPIErrorsWith("Must have at least one Initiator and one Task"),
},
{
"one initiator only",
cltest.MustReadFile(t, "testdata/initiator_only_job.json"),
models.NewJSONAPIErrorsWith("Must have at least one Initiator and one Task"),
},
{
"one task only",
cltest.MustReadFile(t, "testdata/task_only_job.json"),
models.NewJSONAPIErrorsWith("Must have at least one Initiator and one Task"),
},
{
"runlog and ethtx with an address",
cltest.MustReadFile(t, "testdata/runlog_ethtx_w_address_job.json"),
models.NewJSONAPIErrorsWith("Cannot set EthTx Task's address parameter with a RunLog Initiator"),
},
{
"runlog and ethtx with a function selector",
cltest.MustReadFile(t, "testdata/runlog_ethtx_w_funcselector_job.json"),
models.NewJSONAPIErrorsWith("Cannot set EthTx Task's function selector parameter with a RunLog Initiator"),
},
{
"runlog and ethtx with a fromAddress that doesn't match one of our keys",
cltest.MustReadFile(t, "testdata/runlog_ethtx_w_missing_fromAddress_job.json"),
models.NewJSONAPIErrorsWith("error record not found finding key for address 0x0f416a5a298f05d386cfe8164f342bec5b5e10d7"),
},
{
"runlog with two ethtx tasks",
cltest.MustReadFile(t, "testdata/runlog_2_ethlogs_job.json"),
models.NewJSONAPIErrorsWith("Cannot RunLog initiated jobs cannot have more than one EthTx Task"),
},
{
"cannot use funding key",
[]byte(fmt.Sprintf(string(cltest.MustReadFile(t, "testdata/runlog_ethtx_template_fromAddress_job.json")), fundingKey.Address.String())),
models.NewJSONAPIErrorsWith(fmt.Sprintf("address %v is a funding address, cannot use it to send transactions", fundingKey.Address.String())),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var j models.JobSpec
assert.NoError(t, json.Unmarshal(test.input, &j))
result := services.ValidateJob(j, store)
assert.Equal(t, test.want, result)
})
}
} | explode_data.jsonl/75327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1241
} | [
2830,
3393,
17926,
12245,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
57279,
11,
21290,
1669,
1185,
1944,
7121,
6093,
1155,
340,
16867,
21290,
2822,
197,
322,
4230,
264,
10773,
1376,
624,
17957,
35699,
1155,
11,
3553,
9610,
60... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiRangeScanReverseScanInconsistent(t *testing.T) {
defer leaktest.AfterTest(t)()
for _, rc := range []roachpb.ReadConsistencyType{
roachpb.READ_UNCOMMITTED,
roachpb.INCONSISTENT,
} {
t.Run(rc.String(), func(t *testing.T) {
s, _ := startNoSplitMergeServer(t)
ctx := context.TODO()
defer s.Stopper().Stop(ctx)
db := s.DB()
if err := setupMultipleRanges(ctx, db, "b"); err != nil {
t.Fatal(err)
}
// Write keys "a" and "b", the latter of which is the first key in the
// second range.
keys := [2]string{"a", "b"}
ts := [2]hlc.Timestamp{}
for i, key := range keys {
b := &client.Batch{}
b.Put(key, "value")
if err := db.Run(ctx, b); err != nil {
t.Fatal(err)
}
ts[i] = s.Clock().Now()
log.Infof(ctx, "%d: %s %d", i, key, ts[i])
if i == 0 {
testutils.SucceedsSoon(t, func() error {
// Enforce that when we write the second key, it's written
// with a strictly higher timestamp. We're dropping logical
// ticks and the clock may just have been pushed into the
// future, so that's necessary. See #3122.
if ts[0].WallTime >= s.Clock().Now().WallTime {
return errors.New("time stands still")
}
return nil
})
}
}
// Do an inconsistent Scan/ReverseScan from a new DistSender and verify
// it does the read at its local clock and doesn't receive an
// OpRequiresTxnError. We set the local clock to the timestamp of
// just above the first key to verify it's used to read only key "a".
for i, request := range []roachpb.Request{
roachpb.NewScan(roachpb.Key("a"), roachpb.Key("c")),
roachpb.NewReverseScan(roachpb.Key("a"), roachpb.Key("c")),
} {
manual := hlc.NewManualClock(ts[0].WallTime + 1)
clock := hlc.NewClock(manual.UnixNano, time.Nanosecond)
ds := kv.NewDistSender(
kv.DistSenderConfig{
AmbientCtx: log.AmbientContext{Tracer: s.ClusterSettings().Tracer},
Clock: clock,
RPCContext: s.RPCContext(),
NodeDialer: nodedialer.New(s.RPCContext(), gossip.AddressResolver(s.(*server.TestServer).Gossip())),
},
s.(*server.TestServer).Gossip(),
)
reply, err := client.SendWrappedWith(context.Background(), ds, roachpb.Header{
ReadConsistency: rc,
}, request)
if err != nil {
t.Fatal(err)
}
var rows []roachpb.KeyValue
switch r := reply.(type) {
case *roachpb.ScanResponse:
rows = r.Rows
case *roachpb.ReverseScanResponse:
rows = r.Rows
default:
t.Fatalf("unexpected response %T: %v", reply, reply)
}
if l := len(rows); l != 1 {
t.Fatalf("%d: expected 1 row; got %d\n%v", i, l, rows)
}
if key := string(rows[0].Key); keys[0] != key {
t.Errorf("expected key %q; got %q", keys[0], key)
}
}
})
}
} | explode_data.jsonl/36460 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1263
} | [
2830,
3393,
20358,
6046,
26570,
45695,
26570,
641,
78399,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
2023,
8358,
10192,
1669,
2088,
3056,
64500,
16650,
6503,
15220,
47094,
929,
515,
197,
197,
64500,
1665... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_Notify(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
ctx := context.Background()
webhookURL := "https://test.example.com/v1/api-endpoint"
type args struct {
modelType string
eventType EventType
model interface{}
id string
}
useArgs := args{
modelType: "transaction",
eventType: EventTypeCreate,
model: map[string]interface{}{},
id: "test-id",
}
var tests = []struct {
name string
options []ClientOps
args args
wantErr assert.ErrorAssertionFunc
httpCalls int
httpMock func()
}{
{
name: "empty notification",
options: nil,
args: useArgs,
wantErr: assert.NoError,
httpCalls: 0,
httpMock: func() {},
},
{
name: "http call done",
options: []ClientOps{
WithNotifications(webhookURL),
},
args: useArgs,
wantErr: assert.NoError,
httpCalls: 1,
httpMock: func() {
httpmock.RegisterResponder(http.MethodPost, webhookURL,
httpmock.NewStringResponder(
http.StatusOK,
`OK`,
),
)
},
},
{
name: "http error",
options: []ClientOps{
WithNotifications(webhookURL),
},
args: useArgs,
wantErr: assert.Error,
httpCalls: 1,
httpMock: func() {
httpmock.RegisterResponder(http.MethodPost, webhookURL,
httpmock.NewErrorResponder(errors.New("error")),
)
},
},
}
for _, tt := range tests {
httpmock.Reset()
tt.httpMock()
t.Run(tt.name, func(t *testing.T) {
c, err := NewClient(tt.options...)
require.NoError(t, err)
tt.wantErr(t, c.Notify(ctx, tt.args.modelType, tt.args.eventType, tt.args.model, tt.args.id), fmt.Sprintf("Notify(%v, %v, %v, %v, %v)", ctx, tt.args.modelType, tt.args.eventType, tt.args.model, tt.args.id))
assert.Equal(t, tt.httpCalls, httpmock.GetTotalCallCount())
})
}
} | explode_data.jsonl/26277 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 880
} | [
2830,
3393,
2959,
1604,
37253,
1155,
353,
8840,
836,
8,
341,
28080,
16712,
14140,
731,
741,
16867,
1758,
16712,
8934,
16856,
3036,
14828,
2822,
20985,
1669,
2266,
19047,
741,
97250,
20873,
3144,
1669,
330,
2428,
1110,
1944,
7724,
905,
545... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestCtxSendFile(t *testing.T) {
var ctx RequestCtx
var req Request
ctx.Init(&req, nil, defaultLogger)
filePath := "./server_test.go"
ctx.SendFile(filePath)
w := &bytes.Buffer{}
bw := bufio.NewWriter(w)
if err := ctx.Response.Write(bw); err != nil {
t.Fatalf("error when writing response: %s", err)
}
if err := bw.Flush(); err != nil {
t.Fatalf("error when flushing response: %s", err)
}
var resp Response
br := bufio.NewReader(w)
if err := resp.Read(br); err != nil {
t.Fatalf("error when reading response: %s", err)
}
if resp.StatusCode() != StatusOK {
t.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode(), StatusOK)
}
f, err := os.Open(filePath)
if err != nil {
t.Fatalf("cannot open file: %s", err)
}
body, err := ioutil.ReadAll(f)
f.Close()
if err != nil {
t.Fatalf("error when reading file: %s", err)
}
if !bytes.Equal(resp.Body(), body) {
t.Fatalf("unexpected response body: %q. Expecting %q", resp.Body(), body)
}
} | explode_data.jsonl/73295 | {
"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,
1900,
23684,
11505,
1703,
1155,
353,
8840,
836,
8,
341,
2405,
5635,
6145,
23684,
198,
2405,
4232,
6145,
198,
20985,
26849,
2099,
2958,
11,
2092,
11,
1638,
7395,
692,
17661,
1820,
1669,
5924,
4030,
4452,
18002,
698,
20985,
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... | 8 |
func TestPruneStalePeers(t *testing.T) {
// complicated node graph
node := testSetup()
nodes := node.Nodes()
// this will delete all nodes besides the root node
pruneTime := 10 * time.Millisecond
time.Sleep(pruneTime)
// should delete all nodes besides (root) node
pruned := node.PruneStalePeers(pruneTime)
if len(pruned) != len(nodes)-1 {
t.Errorf("Expected pruned node count: %d, got: %d", len(nodes)-1, len(pruned))
}
// complicated node graph
node = testSetup()
nodes = node.Nodes()
// set prune time to 100ms and wait for half of it
pruneTime = 100 * time.Millisecond
time.Sleep(pruneTime)
// update the time of peer1
node.peers["peer1"].lastSeen = time.Now()
// should prune all but the root nodes and peer1
pruned = node.PruneStalePeers(pruneTime)
if len(pruned) != len(nodes)-2 {
t.Errorf("Expected pruned node count: %d, got: %d", len(nodes)-2, len(pruned))
}
} | explode_data.jsonl/23548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
3533,
2886,
623,
1574,
10197,
388,
1155,
353,
8840,
836,
8,
341,
197,
322,
16965,
2436,
4771,
198,
20831,
1669,
1273,
21821,
741,
79756,
1669,
2436,
52184,
741,
197,
322,
419,
686,
3698,
678,
7798,
27758,
279,
3704,
2436,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransactionsEpoch(t *testing.T) {
p := NewPersist()
ctx := context.Background()
tm := time.Now().UTC().Truncate(1 * time.Second)
v := &TransactionsEpoch{}
v.ID = "id1"
v.Epoch = 10
v.VertexID = "vid1"
v.CreatedAt = tm
stream := health.NewStream()
rawDBConn, err := dbr.Open(TestDB, TestDSN, stream)
if err != nil {
t.Fatal("db fail", err)
}
_, _ = rawDBConn.NewSession(stream).DeleteFrom(TableTransactionsEpochs).Exec()
err = p.InsertTransactionsEpoch(ctx, rawDBConn.NewSession(stream), v, true)
if err != nil {
t.Fatal("insert fail", err)
}
fv, err := p.QueryTransactionsEpoch(ctx, rawDBConn.NewSession(stream), v)
if err != nil {
t.Fatal("query fail", err)
}
if !reflect.DeepEqual(*v, *fv) {
t.Fatal("compare fail")
}
v.Epoch = 11
v.VertexID = "vid2"
v.CreatedAt = tm
err = p.InsertTransactionsEpoch(ctx, rawDBConn.NewSession(stream), v, true)
if err != nil {
t.Fatal("insert fail", err)
}
fv, err = p.QueryTransactionsEpoch(ctx, rawDBConn.NewSession(stream), v)
if err != nil {
t.Fatal("query fail", err)
}
if fv.VertexID != "vid2" {
t.Fatal("compare fail")
}
if !reflect.DeepEqual(*v, *fv) {
t.Fatal("compare fail")
}
} | explode_data.jsonl/12931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 520
} | [
2830,
3393,
48761,
44338,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1532,
61267,
741,
20985,
1669,
2266,
19047,
741,
3244,
76,
1669,
882,
13244,
1005,
21183,
1005,
1282,
26900,
7,
16,
353,
882,
32435,
692,
5195,
1669,
609,
48761,
44338,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestBuffer_RejectCallsMetricRejectWithOverwritten(t *testing.T) {
var reject int
mm := &MockMetric{
Metric: Metric(),
RejectF: func() {
reject++
},
}
b := setup(NewBuffer("test", 5))
b.Add(mm, mm, mm, mm, mm)
batch := b.Batch(5)
b.Add(mm, mm)
require.Equal(t, 0, reject)
b.Reject(batch)
require.Equal(t, 2, reject)
} | explode_data.jsonl/17696 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
4095,
50693,
583,
55292,
54310,
78413,
2354,
1918,
25569,
1155,
353,
8840,
836,
8,
341,
2405,
7850,
526,
198,
2109,
76,
1669,
609,
11571,
54310,
515,
197,
9209,
16340,
25,
52458,
3148,
197,
197,
78413,
37,
25,
2915,
368,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGC_TrackDeletedManifests_DoesNothingIfTriggerDisabled(t *testing.T) {
require.NoError(t, testutil.TruncateAllTables(suite.db))
enable, err := testutil.GCTrackDeletedManifestsTrigger.Disable(suite.db)
require.NoError(t, err)
defer enable()
// disable other triggers that also insert on gc_blob_review_queue so that they don't interfere with this test
enable, err = testutil.GCTrackConfigurationBlobsTrigger.Disable(suite.db)
require.NoError(t, err)
defer enable()
enable, err = testutil.GCTrackBlobUploadsTrigger.Disable(suite.db)
require.NoError(t, err)
defer enable()
// create repo
r := randomRepository(t)
rs := datastore.NewRepositoryStore(suite.db)
r, err = rs.CreateByPath(suite.ctx, r.Path)
require.NoError(t, err)
// create config blob
bs := datastore.NewBlobStore(suite.db)
b := randomBlob(t)
err = bs.Create(suite.ctx, b)
require.NoError(t, err)
err = rs.LinkBlob(suite.ctx, r, b.Digest)
require.NoError(t, err)
// create manifest
ms := datastore.NewManifestStore(suite.db)
m := randomManifest(t, r, b)
err = ms.Create(suite.ctx, m)
require.NoError(t, err)
// delete manifest
ok, err := rs.DeleteManifest(suite.ctx, r, m.Digest)
require.NoError(t, err)
require.True(t, ok)
// check that no review records were created
brs := datastore.NewGCBlobTaskStore(suite.db)
count, err := brs.Count(suite.ctx)
require.NoError(t, err)
require.Zero(t, count)
} | explode_data.jsonl/48566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 542
} | [
2830,
3393,
22863,
21038,
473,
26039,
38495,
82,
1557,
7072,
23780,
2679,
17939,
25907,
1155,
353,
8840,
836,
8,
341,
17957,
35699,
1155,
11,
1273,
1314,
8240,
26900,
2403,
21670,
89516,
7076,
4390,
197,
12552,
11,
1848,
1669,
1273,
1314,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigSetValues(t *testing.T) {
var err error
assert := asrt.New(t)
// Create a temporary directory and switch to it.
tmpdir := testcommon.CreateTmpDir(t.Name())
defer testcommon.CleanupDir(tmpdir)
defer testcommon.Chdir(tmpdir)()
// Create an existing docroot
docroot := "web"
if err = os.MkdirAll(filepath.Join(tmpdir, docroot), 0755); err != nil {
t.Errorf("Could not create docroot %s in %s", docroot, tmpdir)
}
err = os.Chdir(tmpdir)
assert.NoError(err)
// Build config args
projectName := "my-project-name"
projectType := nodeps.AppTypeTYPO3
phpVersion := nodeps.PHP71
httpPort := "81"
httpsPort := "444"
hostDBPort := "60001"
hostWebserverPort := "60002"
hostHTTPSPort := "60003"
xdebugEnabled := true
noProjectMount := true
composerVersion := "2.0.0-RC2"
additionalHostnamesSlice := []string{"abc", "123", "xyz"}
additionalHostnames := strings.Join(additionalHostnamesSlice, ",")
additionalFQDNsSlice := []string{"abc.com", "123.pizza", "xyz.co.uk"}
additionalFQDNs := strings.Join(additionalFQDNsSlice, ",")
omitContainersSlice := []string{"dba", "ddev-ssh-agent"}
omitContainers := strings.Join(omitContainersSlice, ",")
webimageExtraPackagesSlice := []string{"php-bcmath", "php7.3-tidy"}
webimageExtraPackages := strings.Join(webimageExtraPackagesSlice, ",")
dbimageExtraPackagesSlice := []string{"netcat", "ncdu"}
dbimageExtraPackages := strings.Join(dbimageExtraPackagesSlice, ",")
uploadDir := filepath.Join("custom", "config", "path")
webserverType := nodeps.WebserverApacheFPM
webImage := "custom-web-image"
dbImage := "custom-db-image"
dbaImage := "custom-dba-image"
webWorkingDir := "/custom/web/dir"
dbWorkingDir := "/custom/db/dir"
dbaWorkingDir := "/custom/dba/dir"
phpMyAdminPort := "5000"
mailhogPort := "5001"
projectTLD := "nowhere.example.com"
useDNSWhenPossible := false
timezone := "America/Chicago"
webEnv := "SOMEENV=someval"
args := []string{
"config",
"--project-name", projectName,
"--docroot", docroot,
"--project-type", projectType,
"--php-version", phpVersion,
"--composer-version", composerVersion,
"--http-port", httpPort,
"--https-port", httpsPort,
fmt.Sprintf("--xdebug-enabled=%t", xdebugEnabled),
fmt.Sprintf("--no-project-mount=%t", noProjectMount),
"--additional-hostnames", additionalHostnames,
"--additional-fqdns", additionalFQDNs,
"--upload-dir", uploadDir,
"--webserver-type", webserverType,
"--web-image", webImage,
"--db-image", dbImage,
"--dba-image", dbaImage,
"--web-working-dir", webWorkingDir,
"--db-working-dir", dbWorkingDir,
"--dba-working-dir", dbaWorkingDir,
"--omit-containers", omitContainers,
"--host-db-port", hostDBPort,
"--host-webserver-port", hostWebserverPort,
"--host-https-port", hostHTTPSPort,
"--webimage-extra-packages", webimageExtraPackages,
"--dbimage-extra-packages", dbimageExtraPackages,
"--phpmyadmin-port", phpMyAdminPort,
"--mailhog-port", mailhogPort,
"--project-tld", projectTLD,
"--web-environment", webEnv,
fmt.Sprintf("--use-dns-when-possible=%t", useDNSWhenPossible),
"--timezone", timezone,
}
out, err := exec.RunCommand(DdevBin, args)
assert.NoError(err, "error running ddev %v: %v, output=%s", args, err, out)
configFile := filepath.Join(tmpdir, ".ddev", "config.yaml")
configContents, err := ioutil.ReadFile(configFile)
if err != nil {
t.Errorf("Unable to read %s: %v", configFile, err)
}
app := &ddevapp.DdevApp{}
if err = yaml.Unmarshal(configContents, app); err != nil {
t.Errorf("Could not unmarshal %s: %v", configFile, err)
}
assert.Equal(projectName, app.Name)
assert.Equal(docroot, app.Docroot)
assert.Equal(projectType, app.Type)
assert.Equal(phpVersion, app.PHPVersion)
assert.Equal(composerVersion, app.ComposerVersion)
assert.Equal(httpPort, app.RouterHTTPPort)
assert.Equal(httpsPort, app.RouterHTTPSPort)
assert.Equal(hostWebserverPort, app.HostWebserverPort)
assert.Equal(hostDBPort, app.HostDBPort)
assert.Equal(xdebugEnabled, app.XdebugEnabled)
assert.Equal(noProjectMount, app.NoProjectMount)
assert.Equal(additionalHostnamesSlice, app.AdditionalHostnames)
assert.Equal(additionalFQDNsSlice, app.AdditionalFQDNs)
assert.Equal(uploadDir, app.UploadDir)
assert.Equal(webserverType, app.WebserverType)
assert.Equal(webImage, app.WebImage)
assert.Equal(dbImage, app.DBImage)
assert.Equal(dbaImage, app.DBAImage)
assert.Equal(webWorkingDir, app.WorkingDir["web"])
assert.Equal(dbWorkingDir, app.WorkingDir["db"])
assert.Equal(dbaWorkingDir, app.WorkingDir["dba"])
assert.Equal(webimageExtraPackagesSlice, app.WebImageExtraPackages)
assert.Equal(dbimageExtraPackagesSlice, app.DBImageExtraPackages)
assert.Equal(phpMyAdminPort, app.PHPMyAdminPort)
assert.Equal(mailhogPort, app.MailhogPort)
assert.Equal(useDNSWhenPossible, app.UseDNSWhenPossible)
assert.Equal(projectTLD, app.ProjectTLD)
assert.Equal(timezone, app.Timezone)
require.NotEmpty(t, app.WebEnvironment)
assert.Equal(webEnv, app.WebEnvironment[0])
// Test that container images and working dirs can be unset with default flags
args = []string{
"config",
"--web-image-default",
"--db-image-default",
"--dba-image-default",
"--web-working-dir-default",
"--db-working-dir-default",
"--dba-working-dir-default",
}
_, err = exec.RunCommand(DdevBin, args)
assert.NoError(err)
configContents, err = ioutil.ReadFile(configFile)
assert.NoError(err, "Unable to read %s: %v", configFile, err)
app = &ddevapp.DdevApp{}
err = yaml.Unmarshal(configContents, app)
assert.NoError(err, "Could not unmarshal %s: %v", configFile, err)
assert.Equal(app.WebImage, "")
assert.Equal(app.DBImage, "")
assert.Equal(app.DBAImage, "")
assert.Equal(len(app.WorkingDir), 0)
// Test that all container images and working dirs can each be unset with single default images flag
args = []string{
"config",
"--web-image", webImage,
"--db-image", dbImage,
"--dba-image", dbaImage,
"--web-working-dir", webWorkingDir,
"--db-working-dir", dbWorkingDir,
"--dba-working-dir", dbaWorkingDir,
}
_, err = exec.RunCommand(DdevBin, args)
assert.NoError(err)
args = []string{
"config",
"--image-defaults",
"--working-dir-defaults",
}
_, err = exec.RunCommand(DdevBin, args)
assert.NoError(err)
configContents, err = ioutil.ReadFile(configFile)
assert.NoError(err, "Unable to read %s: %v", configFile, err)
app = &ddevapp.DdevApp{}
err = yaml.Unmarshal(configContents, app)
assert.NoError(err, "Could not unmarshal %s: %v", configFile, err)
assert.Equal(app.WebImage, "")
assert.Equal(app.DBImage, "")
assert.Equal(app.DBAImage, "")
assert.Equal(len(app.WorkingDir), 0)
} | explode_data.jsonl/76711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2609
} | [
2830,
3393,
2648,
1649,
6227,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
6948,
1669,
438,
3342,
7121,
1155,
692,
197,
322,
4230,
264,
13340,
6220,
323,
3398,
311,
432,
624,
20082,
3741,
1669,
1273,
5464,
7251,
35986,
6184,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewWithEmptyApiToken(t *testing.T) {
_, err := users.New("", "any-base-url")
if err == nil {
t.Fatal("Expected error when API token is empty")
}
if err.Error() != "API token not defined" {
t.Fatalf("The expected error message to be '%s' but was '%s'",
"API token not defined", err.Error())
}
} | explode_data.jsonl/30295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
3564,
2354,
3522,
6563,
3323,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
3847,
7121,
19814,
330,
3767,
30013,
25443,
5130,
743,
1848,
621,
2092,
341,
197,
3244,
26133,
445,
18896,
1465,
979,
5333,
3950,
374,
4287,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_gap_in_body_http1dot0_fin(t *testing.T) {
if testing.Verbose() {
logp.LogInit(logp.LOG_DEBUG, "", false, true, []string{"http",
"httpdetailed"})
}
http := HttpModForTests()
data1 := []byte("GET / HTTP/1.0\r\n\r\n")
data2 := []byte("HTTP/1.0 200 OK\r\n" +
"Date: Tue, 14 Aug 2012 22:31:45 GMT\r\n" +
"Expires: -1\r\n" +
"Cache-Control: private, max-age=0\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n" +
"Content-Encoding: gzip\r\n" +
"Server: gws\r\n" +
"X-XSS-Protection: 1; mode=block\r\n" +
"X-Frame-Options: SAMEORIGIN\r\n" +
"\r\n" +
"xxxxxxxxxxxxxxxxxxxx")
tcptuple := testTcpTuple()
req := protos.Packet{Payload: data1}
resp := protos.Packet{Payload: data2}
private := protos.ProtocolData(new(httpPrivateData))
private = http.Parse(&req, tcptuple, 0, private)
private = http.ReceivedFin(tcptuple, 0, private)
private = http.Parse(&resp, tcptuple, 1, private)
logp.Debug("http", "Now sending gap..")
private, drop := http.GapInStream(tcptuple, 1, 10, private)
assert.Equal(t, false, drop)
private = http.ReceivedFin(tcptuple, 1, private)
trans := expectTransaction(t, http)
assert.NotNil(t, trans)
assert.Equal(t, trans["notes"], []string{"Packet loss while capturing the response"})
} | explode_data.jsonl/6851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 541
} | [
2830,
3393,
51790,
1243,
14114,
25888,
16,
16119,
15,
39737,
1155,
353,
8840,
836,
8,
341,
743,
7497,
42505,
8297,
368,
341,
197,
6725,
79,
5247,
3803,
12531,
79,
36202,
11139,
11,
7342,
895,
11,
830,
11,
3056,
917,
4913,
1254,
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... | 2 |
func TestDeleteLines(t *testing.T) {
origin := `111
222
333
444
555`
content := []byte(origin)
lines := bytes.Split(content, []byte{'\n'})
assert.Equal(t, 5, len(lines))
var (
res []byte
err error
)
// 常规操作
res, err = DeleteLines(content, LineRange{From: 1, To: 1})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`222
333
444
555`), res)
res, err = DeleteLines(content, LineRange{From: -5, To: -5})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`222
333
444
555`), res)
res, err = DeleteLines(content, LineRange{From: 2, To: 2})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
333
444
555`), res)
res, err = DeleteLines(content, LineRange{From: -4, To: -4})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
333
444
555`), res)
res, err = DeleteLines(content, LineRange{From: 4, To: 4})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222
333
555`), res)
res, err = DeleteLines(content, LineRange{From: -2, To: -2})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222
333
555`), res)
res, err = DeleteLines(content, LineRange{From: 5, To: 5})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222
333
444`), res)
res, err = DeleteLines(content, LineRange{From: -1, To: -1})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222
333
444`), res)
res, err = DeleteLines(content, LineRange{From: 1, To: 3})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`444
555`), res)
res, err = DeleteLines(content, LineRange{From: -5, To: -3})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`444
555`), res)
res, err = DeleteLines(content, LineRange{From: 3, To: 5})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222`), res)
res, err = DeleteLines(content, LineRange{From: -3, To: -1})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
222`), res)
res, err = DeleteLines(content, LineRange{From: 2, To: 4})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
555`), res)
res, err = DeleteLines(content, LineRange{From: -4, To: -2})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
555`), res)
// 非常规操作
res, err = DeleteLines(content, LineRange{From: 4, To: 2})
assert.Equal(t, nil, err)
assert.Equal(t, []byte(`111
555`), res)
res, err = DeleteLines(content, LineRange{From: 0, To: 1})
assert.Equal(t, ErrLineRange, err)
res, err = DeleteLines(content, LineRange{From: 1, To: 0})
assert.Equal(t, ErrLineRange, err)
res, err = DeleteLines(content, LineRange{From: 10, To: 20})
assert.Equal(t, ErrLineRange, err)
} | explode_data.jsonl/57671 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1118
} | [
2830,
3393,
6435,
16794,
1155,
353,
8840,
836,
8,
341,
197,
8611,
1669,
1565,
16,
16,
16,
198,
17,
17,
17,
198,
18,
18,
18,
198,
19,
19,
19,
198,
20,
20,
20,
19324,
27751,
1669,
3056,
3782,
45375,
340,
78390,
1669,
5820,
19823,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandleInboundIpv4RulesWithWildCard(t *testing.T) {
cfg := constructTestConfig()
iptConfigurator := NewIptablesConfigurator(cfg, &dep.StdoutStubDependencies{})
ipv4Range := NetworkRange{
IsWildcard: true,
IPNets: nil,
}
iptConfigurator.handleInboundIpv4Rules(ipv4Range)
actual := FormatIptablesCommands(iptConfigurator.iptables.BuildV4())
expected := []string{
"iptables -t nat -N ISTIO_OUTPUT",
"iptables -t nat -A ISTIO_OUTPUT -j ISTIO_REDIRECT",
}
if !reflect.DeepEqual(actual, expected) {
t.Errorf("Output mismatch.\nExpected: %#v\nActual: %#v", expected, actual)
}
} | explode_data.jsonl/65386 | {
"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,
6999,
641,
10891,
80656,
19,
26008,
2354,
40603,
5770,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
9245,
2271,
2648,
2822,
8230,
417,
2648,
57383,
1669,
1532,
40,
417,
4788,
2648,
57383,
28272,
11,
609,
14891,
83225,
33838,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveProjectDestination(t *testing.T) {
fixture.EnsureCleanState(t)
projectName := "proj-" + strconv.FormatInt(time.Now().Unix(), 10)
_, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Create(context.Background(), &v1alpha1.AppProject{
ObjectMeta: metav1.ObjectMeta{Name: projectName},
Spec: v1alpha1.AppProjectSpec{
Destinations: []v1alpha1.ApplicationDestination{{
Server: "https://192.168.99.100:8443",
Namespace: "test",
}},
},
}, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Unable to create project %v", err)
}
_, err = fixture.RunCli("proj", "remove-destination", projectName,
"https://192.168.99.100:8443",
"test",
)
if err != nil {
t.Fatalf("Unable to remove project destination %v", err)
}
_, err = fixture.RunCli("proj", "remove-destination", projectName,
"https://192.168.99.100:8443",
"test1",
)
assert.Error(t, err)
assert.Contains(t, err.Error(), "does not exist")
proj, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Get(context.Background(), projectName, metav1.GetOptions{})
if err != nil {
t.Fatalf("Unable to get project %v", err)
}
assert.Equal(t, projectName, proj.Name)
assert.Equal(t, 0, len(proj.Spec.Destinations))
assertProjHasEvent(t, proj, "update", argo.EventReasonResourceUpdated)
} | explode_data.jsonl/58442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 536
} | [
2830,
3393,
13021,
7849,
33605,
1155,
353,
8840,
836,
8,
341,
1166,
12735,
22834,
19098,
27529,
1397,
1155,
692,
72470,
675,
1669,
330,
30386,
27651,
488,
33317,
9978,
1072,
9730,
13244,
1005,
55832,
1507,
220,
16,
15,
340,
197,
6878,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWritePartitionContents(t *testing.T) {
table := GetValidTable()
request := 0
size := table.Partitions[request].Size
b := make([]byte, size, size)
rand.Read(b)
reader := bytes.NewReader(b)
b2 := make([]byte, 0, size)
f := &testhelper.FileImpl{
Writer: func(b []byte, offset int64) (int, error) {
b2 = append(b2, b...)
return len(b), nil
},
}
written, err := table.Partitions[request].WriteContents(f, reader)
if written != uint64(size) {
t.Errorf("Returned %d bytes written instead of %d", written, size)
}
if err != nil {
t.Errorf("Error was not nil: %v", err)
}
if bytes.Compare(b2, b) != 0 {
t.Errorf("Bytes mismatch")
t.Log(b)
t.Log(b2)
}
} | explode_data.jsonl/61031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 284
} | [
2830,
3393,
7985,
49978,
14803,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
2126,
4088,
2556,
741,
23555,
1669,
220,
15,
198,
13832,
1669,
1965,
52250,
5930,
58,
2035,
936,
1695,
198,
2233,
1669,
1281,
10556,
3782,
11,
1379,
11,
1379,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoneSignDoesntBarfOnNil(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Errorf("%v", r)
}
}()
credentials.None.Sign(nil)
} | explode_data.jsonl/48264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
4064,
7264,
21468,
406,
3428,
69,
1925,
19064,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
743,
435,
1669,
11731,
2129,
435,
961,
2092,
341,
298,
3244,
13080,
4430,
85,
497,
435,
340,
197,
197,
532,
197,
66... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClusterAdmin(t *testing.T) {
seedBroker := NewMockBroker(t, 1)
defer seedBroker.Close()
seedBroker.SetHandlerByMap(map[string]MockResponse{
"MetadataRequest": NewMockMetadataResponse(t).
SetController(seedBroker.BrokerID()).
SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
})
config := NewTestConfig()
config.Version = V1_0_0_0
admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
if err != nil {
t.Fatal(err)
}
err = admin.Close()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/40775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
28678,
7210,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
340,
16867,
10320,
65545,
10421,
2822,
197,
22602,
65545,
4202,
3050,
1359,
2227,
9147,
14032,
60,
11571,
2582,
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... | 3 |
func TestKeycloakClientReconciler_Test_ClientScope_DifferenceIntersection(t *testing.T) {
// given
a := []v1alpha1.KeycloakClientScope{
{Name: "a"},
{ID: "ignored", Name: "b"},
{ID: "cID", Name: "c"},
}
b := []v1alpha1.KeycloakClientScope{
{Name: "b"},
{ID: "cID", Name: "differentName"},
{Name: "d"},
}
// when
difference, intersection := ClientScopeDifferenceIntersection(a, b)
// then
expectedDifference := []v1alpha1.KeycloakClientScope{
{Name: "a"},
}
expectedIntersection := []v1alpha1.KeycloakClientScope{
{ID: "ignored", Name: "b"},
{ID: "cID", Name: "c"},
}
assert.Equal(t, expectedDifference, difference)
assert.Equal(t, expectedIntersection, intersection)
} | explode_data.jsonl/28521 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
1592,
88751,
2959,
693,
40446,
5769,
32541,
46102,
10803,
1557,
18192,
72927,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
11323,
1669,
3056,
85,
16,
7141,
16,
9610,
88751,
2959,
10803,
515,
197,
197,
63121,
25,
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 TestDegenerateRenderThingMissingTemplate(t *testing.T) {
t.Parallel()
cfg, fs := newTestCfg()
writeSource(t, fs, filepath.Join("content", "a", "file.md"), pageSimpleTitle)
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
require.Len(t, s.RegularPages, 1)
p := s.RegularPages[0]
err := s.renderThing(p, "foobar", nil)
if err == nil {
t.Errorf("Expected err to be returned when missing the template.")
}
} | explode_data.jsonl/40662 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
45657,
13220,
6750,
52940,
25080,
7275,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
11,
8619,
1669,
501,
2271,
42467,
2822,
24945,
3608,
1155,
11,
8619,
11,
26054,
22363,
445,
1796,
497,
330,
64,
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... | 2 |
func Test_deleteQueue(t *testing.T) {
tests := []struct {
name string
client *mockSQSclient
err bool
}{
{
name: "delete SQS queue",
client: &mockSQSclient{},
err: false,
},
{
name: "delete SQS queue error",
client: &mockSQSclient{
err: errors.New("unable to delete SQS queue"),
},
err: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
client := sqsClient{
client: test.client,
queueURL: "https://localhost",
arn: arn,
}
err := client.deleteQueue(context.Background())
if test.err {
assert.Error(t, err)
return
}
assert.NoError(t, err)
})
}
} | explode_data.jsonl/40273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 323
} | [
2830,
3393,
11353,
7554,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
25291,
353,
16712,
64308,
50,
2972,
198,
197,
9859,
262,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
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 TestEtcdDeletePod(t *testing.T) {
ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t)
fakeClient.TestIndex = true
key, _ := makePodKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
TypeMeta: api.TypeMeta{ID: "foo"},
DesiredState: api.PodState{Host: "machine"},
}), 0)
fakeClient.Set("/registry/hosts/machine/kubelet", runtime.EncodeOrDie(latest.Codec, &api.ContainerManifestList{
Items: []api.ContainerManifest{
{ID: "foo"},
},
}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.DeletePod(ctx, "foo")
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(fakeClient.DeletedKeys) != 1 {
t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys)
} else if fakeClient.DeletedKeys[0] != key {
t.Errorf("Unexpected key: %s, expected %s", fakeClient.DeletedKeys[0], key)
}
response, err := fakeClient.Get("/registry/hosts/machine/kubelet", false, false)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
var manifests api.ContainerManifestList
latest.Codec.DecodeInto([]byte(response.Node.Value), &manifests)
if len(manifests.Items) != 0 {
t.Errorf("Unexpected container set: %s, expected empty", response.Node.Value)
}
} | explode_data.jsonl/8149 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 487
} | [
2830,
3393,
31860,
4385,
6435,
23527,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6330,
7121,
3675,
1972,
741,
1166,
726,
2959,
1669,
7375,
7121,
52317,
31860,
4385,
2959,
1155,
340,
1166,
726,
2959,
8787,
1552,
284,
830,
271,
23634,
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 TestNotNilPointer(t *testing.T) {
c := "Name"
name := &c
eq := Eq{"name": name}
sql, args, err := eq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{"Name"}, args)
assert.Equal(t, "name = ?", sql)
neq := NotEq{"name": name}
sql, args, err = neq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{"Name"}, args)
assert.Equal(t, "name <> ?", sql)
s := []int{1, 2, 3}
ids := &s
eq = Eq{"id": ids}
sql, args, err = eq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{1, 2, 3}, args)
assert.Equal(t, "id IN (?,?,?)", sql)
neq = NotEq{"id": ids}
sql, args, err = neq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{1, 2, 3}, args)
assert.Equal(t, "id NOT IN (?,?,?)", sql)
a := [3]int{1, 2, 3}
ida := &a
eq = Eq{"id": ida}
sql, args, err = eq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{1, 2, 3}, args)
assert.Equal(t, "id IN (?,?,?)", sql)
neq = NotEq{"id": ida}
sql, args, err = neq.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{1, 2, 3}, args)
assert.Equal(t, "id NOT IN (?,?,?)", sql)
} | explode_data.jsonl/44174 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 526
} | [
2830,
3393,
96144,
9084,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
330,
675,
698,
11609,
1669,
609,
66,
198,
7727,
80,
1669,
33122,
4913,
606,
788,
829,
532,
30633,
11,
2827,
11,
1848,
1669,
8939,
3274,
8269,
2822,
6948,
35699,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRepositoryCreate(t *testing.T) {
defer gock.Off()
gock.New("https://api.github.com").
Post("/orgs/octocat/repos").
Reply(201).
Type("application/json").
SetHeaders(mockHeaders).
File("testdata/repo_create.json")
in := &scm.RepositoryInput{
Namespace: "octocat",
Name: "Hello-World",
}
client := NewDefault()
got, res, err := client.Repositories.Create(context.Background(), in)
if err != nil {
t.Error(err)
return
}
want := new(scm.Repository)
raw, _ := ioutil.ReadFile("testdata/repo_create.json.golden")
json.Unmarshal(raw, want)
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("Unexpected Results")
t.Log(diff)
data, _ := json.Marshal(got)
t.Log("got JSON:")
t.Log(string(data))
}
t.Run("Request", testRequest(res))
t.Run("Rate", testRate(res))
} | explode_data.jsonl/29876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 345
} | [
2830,
3393,
4624,
4021,
1155,
353,
8840,
836,
8,
341,
16867,
728,
377,
13,
4596,
2822,
3174,
1176,
7121,
445,
2428,
1110,
2068,
11021,
905,
38609,
197,
197,
4133,
4283,
1775,
82,
59182,
509,
266,
49505,
38609,
197,
197,
20841,
7,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUtilsBasic(t *testing.T) {
basicTest(t, ConsortiumValue("foo"))
basicTest(t, HashingAlgorithmValue())
basicTest(t, BlockDataHashingStructureValue())
basicTest(t, OrdererAddressesValue([]string{"foo:1", "bar:2"}))
basicTest(t, ConsensusTypeValue("foo", []byte("bar")))
basicTest(t, BatchSizeValue(1, 2, 3))
basicTest(t, BatchTimeoutValue("1s"))
basicTest(t, ChannelRestrictionsValue(7))
basicTest(t, KafkaBrokersValue([]string{"foo:1", "bar:2"}))
basicTest(t, MSPValue(&mspprotos.MSPConfig{}))
basicTest(t, CapabilitiesValue(map[string]bool{"foo": true, "bar": false}))
basicTest(t, AnchorPeersValue([]*pb.AnchorPeer{{}, {}}))
basicTest(t, ChannelCreationPolicyValue(&cb.Policy{}))
basicTest(t, ACLValues(map[string]string{"foo": "fooval", "bar": "barval"}))
} | explode_data.jsonl/53196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 299
} | [
2830,
84745,
15944,
1155,
353,
8840,
836,
8,
341,
2233,
5971,
2271,
1155,
11,
72447,
1130,
445,
7975,
5455,
2233,
5971,
2271,
1155,
11,
6531,
287,
27847,
1130,
2398,
2233,
5971,
2271,
1155,
11,
8362,
1043,
6370,
287,
22952,
1130,
2398,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAttributesAll(t *testing.T) {
t.Parallel()
ctx, cancel := testAllocate(t, "image.html")
defer cancel()
tests := []struct {
sel string
by QueryOption
exp []map[string]string
}{
{
"img", ByQueryAll,
[]map[string]string{
{
"alt": "Brankas - Easy Money Management",
"id": "icon-brankas",
"src": "images/brankas.png",
},
{
"alt": "How people build software",
"id": "icon-github",
"src": "images/github.png",
},
},
},
}
for i, test := range tests {
var attrs []map[string]string
if err := Run(ctx, AttributesAll(test.sel, &attrs, test.by)); err != nil {
t.Fatalf("test %d got error: %v", i, err)
}
if !reflect.DeepEqual(test.exp, attrs) {
t.Errorf("test %d expected %v, got: %v", i, test.exp, attrs)
}
}
} | explode_data.jsonl/59476 | {
"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,
10516,
2403,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
1273,
75380,
1155,
11,
330,
1805,
2564,
1138,
16867,
9121,
2822,
78216,
1669,
3056,
1235,
341,
197,
1903,
301,
914,
198,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestUnwrapDelay(t *testing.T) {
for i, tc := range unwrapValidTestCases {
t.Run(fmt.Sprintf("valid:%d", i), func(t *testing.T) {
var del *delay.Delay
if !tc.noDelay {
del = &delay.Delay{}
}
r, err := forward.Unwrap(del, xml.NewDecoder(strings.NewReader(tc.inXML)))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
var buf strings.Builder
e := xml.NewEncoder(&buf)
_, err = xmlstream.Copy(e, r)
if err != nil {
t.Fatalf("error encoding: %v", err)
}
err = e.Flush()
if err != nil {
t.Fatalf("error flushing: %v", err)
}
if out := buf.String(); out != tc.unwrappedXML {
t.Errorf("wrong XML: want=%v, got=%v", tc.unwrappedXML, out)
}
if del != nil && del.Reason != tc.reason {
t.Errorf("did not unmarshal delay: want=%v, got=%v", tc.reason, del.Reason)
}
})
}
for i, tc := range unwrapInvalidTestCases {
t.Run(fmt.Sprintf("invalid:%d", i), func(t *testing.T) {
_, err := forward.Unwrap(nil, xml.NewDecoder(strings.NewReader(tc.inXML)))
if err == nil {
t.Error("expected a non nil error")
}
})
}
} | explode_data.jsonl/26570 | {
"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,
1806,
10097,
20039,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
17130,
1669,
2088,
79813,
4088,
2271,
37302,
341,
197,
3244,
16708,
28197,
17305,
445,
1891,
7533,
67,
497,
600,
701,
2915,
1155,
353,
8840,
836,
8,
341,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func Test_getConfig(t *testing.T) {
var configOpts = []struct {
name string
value string
defaultValue string
isConfugured bool
}{
{
name: "scaling_max_limit",
value: "",
defaultValue: "4",
isConfugured: true,
},
{
name: "scaling_max_limit",
value: "10",
defaultValue: "4",
isConfugured: true,
},
{
name: "random_config",
value: "",
defaultValue: "18",
isConfugured: false,
},
}
for _, config := range configOpts {
t.Run(config.name, func(t *testing.T) {
if config.isConfugured {
os.Setenv(config.name, config.value)
}
value := getConfig(config.name, config.defaultValue)
want := config.defaultValue
if len(config.value) > 0 {
want = config.value
}
if value != want {
t.Errorf("want %s, but got %s", want, value)
}
})
}
} | explode_data.jsonl/11983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 434
} | [
2830,
3393,
3062,
2648,
1155,
353,
8840,
836,
8,
1476,
2405,
2193,
43451,
284,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
16309,
286,
914,
198,
197,
11940,
1130,
914,
198,
197,
19907,
15578,
768,
3073,
1807,
198,
197,
59403,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestServiceDiscoveryGetProxyServiceInstances(t *testing.T) {
store, sd, _, stopFn := initServiceDiscovery()
defer stopFn()
createConfigs([]*model.Config{httpStatic, tcpStatic}, store, t)
expectProxyInstances(t, sd, []*model.ServiceInstance{
makeInstance(httpStatic, "2.2.2.2", 7080, httpStatic.Spec.(*networking.ServiceEntry).Ports[0], nil, MTLS),
makeInstance(httpStatic, "2.2.2.2", 18080, httpStatic.Spec.(*networking.ServiceEntry).Ports[1], nil, MTLS),
makeInstance(tcpStatic, "2.2.2.2", 444, tcpStatic.Spec.(*networking.ServiceEntry).Ports[0], nil, MTLS),
}, "2.2.2.2")
} | explode_data.jsonl/12838 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
1860,
67400,
1949,
16219,
1860,
42725,
1155,
353,
8840,
836,
8,
341,
57279,
11,
20585,
11,
8358,
2936,
24911,
1669,
2930,
1860,
67400,
741,
16867,
2936,
24911,
2822,
39263,
84905,
85288,
2528,
10753,
90,
1254,
11690,
11,
28051... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitFunctions(t *testing.T) {
// the "github.com/netapp/trident/storage_drivers/ontap/api/rest/models" uses a lot of init()
// the way they are generated within go-swagger, they can fail and cause our other unit tests
// to fail as a side effect. this test exists as a quick sanity test to make sure those init
// functions can be executed without generating panics.
// this could be any class from the models package, it will still cause all of the init
// functions within the package to be executed. choosing this one as it has been a root
// cause of failures.
assert.NotNil(t, new(models.StorageBridge))
} | explode_data.jsonl/23606 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
3803,
25207,
1155,
353,
8840,
836,
8,
1476,
197,
322,
279,
330,
5204,
905,
38065,
676,
21485,
1713,
53345,
26680,
1945,
14,
544,
391,
10508,
45265,
20268,
1,
5711,
264,
2696,
315,
2930,
741,
197,
322,
279,
1616,
807,
525,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegisterFlagsInvalidArgs(t *testing.T) {
data := struct{ Field string }{}
err := RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Field is missing a help tag")
data2 := struct{ Field bool }{}
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data2, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Field is missing a help tag")
data3 := struct{ Field int }{}
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data3, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Field is missing a help tag")
data4 := struct{ Field []string }{}
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data4, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Field is missing a help tag")
data5 := struct{ Field time.Duration }{}
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data5, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Field is missing a help tag")
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &DurBad{}, nil)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Invalid duration value in 'def' tag")
data6 := struct{ Field float32 }{}
err = RegisterFlags(viper.GetViper(), &pflag.FlagSet{}, &data6, nil)
assert.NoError(t, err)
} | explode_data.jsonl/75465 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
8690,
9195,
7928,
4117,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
2036,
90,
8601,
914,
335,
16094,
9859,
1669,
8451,
9195,
3747,
12858,
2234,
53,
12858,
1507,
609,
79,
9903,
80911,
1649,
22655,
609,
691,
11,
2092,
340,
694... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReportSinceLastUpdated(t *testing.T) {
tmpDir := filepath.Clean(os.TempDir())
var tests = []struct {
description string
ae proto.ActionableErr
logs []string
expected string
expectedMute string
}{
{
description: "logs more than 3 lines",
ae: proto.ActionableErr{Message: "waiting for 0/1 deplotment to rollout\n"},
logs: []string{
"[pod container] Waiting for mongodb to start...",
"[pod container] Waiting for connection for 2 sec",
"[pod container] Retrying 1st attempt ....",
"[pod container] Waiting for connection for 2 sec",
"[pod container] Terminating with exit code 11",
},
expectedMute: fmt.Sprintf(` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
> [pod container] Retrying 1st attempt ....
> [pod container] Waiting for connection for 2 sec
> [pod container] Terminating with exit code 11
Full logs at %s
`, filepath.Join(tmpDir, "skaffold", "statuscheck", "foo.log")),
expected: ` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
> [pod container] Waiting for mongodb to start...
> [pod container] Waiting for connection for 2 sec
> [pod container] Retrying 1st attempt ....
> [pod container] Waiting for connection for 2 sec
> [pod container] Terminating with exit code 11
`,
},
{
description: "logs less than 3 lines",
ae: proto.ActionableErr{Message: "waiting for 0/1 deplotment to rollout\n"},
logs: []string{
"[pod container] Waiting for mongodb to start...",
"[pod container] Waiting for connection for 2 sec",
"[pod container] Terminating with exit code 11",
},
expected: ` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
> [pod container] Waiting for mongodb to start...
> [pod container] Waiting for connection for 2 sec
> [pod container] Terminating with exit code 11
`,
expectedMute: ` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
> [pod container] Waiting for mongodb to start...
> [pod container] Waiting for connection for 2 sec
> [pod container] Terminating with exit code 11
`,
},
{
description: "no logs or empty",
ae: proto.ActionableErr{Message: "waiting for 0/1 deplotment to rollout\n"},
expected: ` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
`,
expectedMute: ` - test-ns:deployment/test: container terminated with exit code 11
- test:pod/foo: container terminated with exit code 11
`,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
dep := NewDeployment("test", "test-ns", 1)
dep.pods = map[string]validator.Resource{
"foo": validator.NewResource(
"test",
"pod",
"foo",
"Pending",
proto.ActionableErr{
ErrCode: proto.StatusCode_STATUSCHECK_RUN_CONTAINER_ERR,
Message: "container terminated with exit code 11"},
test.logs,
),
}
dep.UpdateStatus(test.ae)
t.CheckDeepEqual(test.expectedMute, dep.ReportSinceLastUpdated(true))
t.CheckTrue(dep.status.changed)
// force report to false and Report again with mute logs false
dep.status.reported = false
t.CheckDeepEqual(test.expected, dep.ReportSinceLastUpdated(false))
})
}
} | explode_data.jsonl/81098 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1314
} | [
2830,
3393,
10361,
12549,
5842,
16196,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
1669,
26054,
727,
2675,
9638,
65009,
6184,
2398,
2405,
7032,
284,
3056,
1235,
341,
197,
42407,
220,
914,
198,
197,
197,
5918,
1843,
18433,
11360,
480,
774... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrintServiceAccount(t *testing.T) {
tests := []struct {
serviceAccount api.ServiceAccount
expected []metav1.TableRow
}{
// Basic service account without secrets
{
serviceAccount: api.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: "sa1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Secrets: []api.ObjectReference{},
},
// Columns: Name, (Num) Secrets, Age
expected: []metav1.TableRow{{Cells: []interface{}{"sa1", int64(0), "0s"}}},
},
// Basic service account with two secrets.
{
serviceAccount: api.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: "sa1",
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
},
Secrets: []api.ObjectReference{
{Name: "Secret1"},
{Name: "Secret2"},
},
},
// Columns: Name, (Num) Secrets, Age
expected: []metav1.TableRow{{Cells: []interface{}{"sa1", int64(2), "0s"}}},
},
}
for i, test := range tests {
rows, err := printServiceAccount(&test.serviceAccount, printers.GenerateOptions{})
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 583
} | [
2830,
3393,
8994,
1860,
7365,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
52934,
7365,
6330,
13860,
7365,
198,
197,
42400,
981,
3056,
4059,
402,
16,
18257,
3102,
198,
197,
59403,
197,
197,
322,
14625,
2473,
2692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnv2Variables(t *testing.T) {
variables := []string{"var1", "val1", "var2", "val2"}
bflags := &BFlags{}
config := &container.Config{}
b := &Builder{flags: bflags, runConfig: config, disableCommit: true}
if err := env(b, variables, nil, ""); err != nil {
t.Fatalf("Error when executing env: %s", err.Error())
}
expectedVar1 := fmt.Sprintf("%s=%s", variables[0], variables[1])
expectedVar2 := fmt.Sprintf("%s=%s", variables[2], variables[3])
if b.runConfig.Env[0] != expectedVar1 {
t.Fatalf("Wrong env output for first variable. Got: %s. Should be: %s", b.runConfig.Env[0], expectedVar1)
}
if b.runConfig.Env[1] != expectedVar2 {
t.Fatalf("Wrong env output for second variable. Got: %s, Should be: %s", b.runConfig.Env[1], expectedVar2)
}
} | explode_data.jsonl/28273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 299
} | [
2830,
3393,
14359,
17,
22678,
1155,
353,
8840,
836,
8,
341,
2405,
2156,
82,
1669,
3056,
917,
4913,
947,
16,
497,
330,
831,
16,
497,
330,
947,
17,
497,
330,
831,
17,
63159,
2233,
11161,
1669,
609,
33,
9195,
16094,
25873,
1669,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFavoritesAddTwice(t *testing.T) {
mockCtrl, config, ctx := favTestInit(t, false)
f := NewFavorites(config)
f.InitForTest()
defer favTestShutdown(t, mockCtrl, config, f)
// Call Add twice in a row, but only get one Add KBPKI call
fav1 := favorites.ToAdd{
Folder: favorites.Folder{
Name: "test",
Type: tlf.Public,
},
Data: favorites.Data{},
Created: false,
}
config.mockKbpki.EXPECT().FavoriteList(gomock.Any()).Return(keybase1.FavoritesResult{}, nil)
config.mockKbpki.EXPECT().FavoriteAdd(gomock.Any(), fav1.ToKBFolder()).
Return(nil)
config.mockClock.EXPECT().Now().Return(time.Unix(0, 0)).Times(2)
if err := f.Add(ctx, fav1); err != nil {
t.Fatalf("Couldn't add favorite: %v", err)
}
// A second add shouldn't result in a KBPKI call
if err := f.Add(ctx, fav1); err != nil {
t.Fatalf("Couldn't re-add same favorite: %v", err)
}
} | explode_data.jsonl/14679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 357
} | [
2830,
3393,
85221,
2212,
22816,
558,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
11,
2193,
11,
5635,
1669,
9244,
2271,
3803,
1155,
11,
895,
340,
1166,
1669,
1532,
85221,
8754,
340,
1166,
26849,
2461,
2271,
741,
16867,
9244,
2271,
62004,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSlashValidatorAtCurrentHeight(t *testing.T) {
ctx, keeper, _ := setupHelper(t, 10)
consAddr := sdk.ConsAddress(PKs[0].Address())
fraction := sdk.NewDecWithPrec(5, 1)
oldPool := keeper.GetPool(ctx)
validator, found := keeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
keeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction)
// read updated state
validator, found = keeper.GetValidatorByConsAddr(ctx, consAddr)
require.True(t, found)
newPool := keeper.GetPool(ctx)
// end block
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 1, len(updates), "cons addr: %v, updates: %v", []byte(consAddr), updates)
validator = keeper.mustGetValidator(ctx, validator.OperatorAddr)
// power decreased
require.Equal(t, sdk.NewDec(5), validator.GetPower())
// pool bonded shares decreased
require.Equal(t, sdk.NewDec(5).RoundInt64(), oldPool.BondedTokens.Sub(newPool.BondedTokens).RoundInt64())
} | explode_data.jsonl/49546 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 350
} | [
2830,
3393,
88004,
14256,
1655,
5405,
3640,
1155,
353,
8840,
836,
8,
341,
20985,
11,
53416,
11,
716,
1669,
6505,
5511,
1155,
11,
220,
16,
15,
340,
197,
6254,
13986,
1669,
45402,
94594,
4286,
5304,
42,
82,
58,
15,
936,
4286,
2398,
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... | 1 |
func TestGenerateNodesURITemplate(t *testing.T) {
assert := assert.New(t)
cluster := testCluster(t)
assert.Equal(
fmt.Sprintf("%s-%s-node.%s.svc.cluster.local:%d",
clusterName, "%d", clusterNamespace, httpContainerPort),
generateNodesURITemplate(cluster))
} | explode_data.jsonl/28890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
31115,
12288,
1511,
952,
3708,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
197,
18855,
1669,
1273,
28678,
1155,
692,
6948,
12808,
1006,
197,
11009,
17305,
4430,
82,
11069,
82,
39054,
22445,
82,
514,
7362... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWithStreamDownloader(t *testing.T) {
var db *sql.DB
var err error
if db, err = sql.Open("snowflake", dsn); err != nil {
t.Fatalf("failed to open db. %v, err: %v", dsn, err)
}
defer db.Close()
ctx := WithStreamDownloader(context.Background())
numrows := 100000
rows, _ := db.QueryContext(ctx, fmt.Sprintf("SELECT SEQ8(), RANDSTR(1000, RANDOM()) FROM TABLE(GENERATOR(ROWCOUNT=>%v))", numrows))
defer rows.Close()
cnt := 0
var idx int
var v string
// Next() will block and wait until results are available
for rows.Next() {
err := rows.Scan(&idx, &v)
if err != nil {
t.Fatal(err)
}
cnt++
}
logger.Infof("NextResultSet: %v", rows.NextResultSet())
if cnt != numrows {
t.Errorf("number of rows didn't match. expected: %v, got: %v", numrows, cnt)
}
} | explode_data.jsonl/23257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
2354,
3027,
92698,
1155,
353,
8840,
836,
8,
341,
2405,
2927,
353,
3544,
22537,
198,
2405,
1848,
1465,
271,
743,
2927,
11,
1848,
284,
5704,
12953,
445,
74478,
63456,
497,
294,
9613,
1215,
1848,
961,
2092,
341,
197,
3244,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReserveExecute_WithTx(t *testing.T) {
db, tsv := setupTabletServerTest(t, "")
defer tsv.StopService()
defer db.Close()
target := querypb.Target{TabletType: topodatapb.TabletType_PRIMARY}
transactionID, _, err := tsv.Begin(ctx, &target, &querypb.ExecuteOptions{})
require.NoError(t, err)
require.NotEqual(t, int64(0), transactionID)
db.ResetQueryLog()
_, reservedID, _, err := tsv.ReserveExecute(ctx, &target, []string{"select 43"}, "select 42", nil, transactionID, &querypb.ExecuteOptions{})
require.NoError(t, err)
defer tsv.Release(ctx, &target, transactionID, reservedID)
assert.Equal(t, transactionID, reservedID, "reservedID should be equal to transactionID")
expected := []string{
"select 43",
"select 42 from dual where 1 != 1",
"select 42 from dual limit 10001",
}
splitOutput := strings.Split(db.QueryLog(), ";")
for _, exp := range expected {
assert.Contains(t, splitOutput, exp, "expected queries to run")
}
err = tsv.Release(ctx, &target, transactionID, reservedID)
require.NoError(t, err)
} | explode_data.jsonl/80026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
1061,
5852,
17174,
62,
2354,
31584,
1155,
353,
8840,
836,
8,
341,
20939,
11,
259,
3492,
1669,
6505,
2556,
83,
5475,
2271,
1155,
11,
14676,
16867,
259,
3492,
30213,
1860,
741,
16867,
2927,
10421,
741,
28861,
1669,
3239,
16650... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateAndBuildNodeBIdKeyNodeTypeValidationFailure(t *testing.T) {
plmnId := "dddd"
nbId := "eeee"
_, err := ValidateAndBuildNodeBIdKey("", plmnId, nbId)
assert.NotNil(t, err)
assert.IsType(t, &ValidationError{}, err)
assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty node type received", err.Error())
} | explode_data.jsonl/33041 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
17926,
3036,
11066,
1955,
33,
764,
1592,
66137,
13799,
17507,
1155,
353,
8840,
836,
8,
341,
72213,
21775,
764,
1669,
330,
64100,
698,
9038,
65,
764,
1669,
330,
68616,
698,
197,
6878,
1848,
1669,
23282,
3036,
11066,
1955,
33,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEncodeByProtocol(t *testing.T) {
type args struct {
in []byte
protocol string
}
tests := []struct {
name string
args args
wantEncoded string
wantEncodingType string
wantErr bool
}{
{
"ethereum",
args{
testutil.MustHexDecodeString("5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761"),
"ethereum",
},
"0x5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761",
encoding.TypeHex0XPrefix,
false,
},
{
"err",
args{
testutil.MustHexDecodeString("5602ea95540bee46d03ba335eed6f49d117eab95c8ab8b71bae2cdd1e564a761"),
"invalid",
},
"",
"",
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotEncoded, gotEncodingType, err := EncodeByProtocol(tt.args.in, tt.args.protocol)
if (err != nil) != tt.wantErr {
t.Errorf("EncodeByProtocol() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotEncoded != tt.wantEncoded {
t.Errorf("EncodeByProtocol() gotEncoded = %v, want %v", gotEncoded, tt.wantEncoded)
}
if gotEncodingType != tt.wantEncodingType {
t.Errorf("EncodeByProtocol() gotEncodingType = %v, want %v", gotEncodingType, tt.wantEncodingType)
}
})
}
} | explode_data.jsonl/81157 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 657
} | [
2830,
3393,
32535,
1359,
20689,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
17430,
981,
3056,
3782,
198,
197,
197,
17014,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
1797,
914,
198,
197,
31215,
1797,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestMigrate(t *testing.T) {
encodingConfig := simapp.MakeTestEncodingConfig()
clientCtx := client.Context{}.
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithCodec(encodingConfig.Codec)
addr1, err := sdk.ConsAddressFromBech32("cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685")
require.NoError(t, err)
addr2, err := sdk.ConsAddressFromBech32("cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph")
require.NoError(t, err)
gs := v039slashing.GenesisState{
Params: v039slashing.DefaultParams(),
SigningInfos: map[string]v039slashing.ValidatorSigningInfo{
"cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph": {
Address: addr2,
IndexOffset: 615501,
MissedBlocksCounter: 1,
Tombstoned: false,
},
"cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685": {
Address: addr1,
IndexOffset: 2,
MissedBlocksCounter: 2,
Tombstoned: false,
},
},
MissedBlocks: map[string][]v039slashing.MissedBlock{
"cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph": {
{
Index: 2,
Missed: true,
},
},
"cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685": {
{
Index: 3,
Missed: true,
},
{
Index: 4,
Missed: true,
},
},
},
}
migrated := v040slashing.Migrate(gs)
// Check that in `signing_infos` and `missed_blocks`, the address
// cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685
// should always come before the address
// cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph
// (in alphabetic order, basically).
expected := `{
"missed_blocks": [
{
"address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685",
"missed_blocks": [
{
"index": "3",
"missed": true
},
{
"index": "4",
"missed": true
}
]
},
{
"address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph",
"missed_blocks": [
{
"index": "2",
"missed": true
}
]
}
],
"params": {
"downtime_jail_duration": "600s",
"min_signed_per_window": "0.500000000000000000",
"signed_blocks_window": "100",
"slash_fraction_double_sign": "0.050000000000000000",
"slash_fraction_downtime": "0.010000000000000000"
},
"signing_infos": [
{
"address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685",
"validator_signing_info": {
"address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685",
"index_offset": "2",
"jailed_until": "0001-01-01T00:00:00Z",
"missed_blocks_counter": "2",
"start_height": "0",
"tombstoned": false
}
},
{
"address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph",
"validator_signing_info": {
"address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph",
"index_offset": "615501",
"jailed_until": "0001-01-01T00:00:00Z",
"missed_blocks_counter": "1",
"start_height": "0",
"tombstoned": false
}
}
]
}`
bz, err := clientCtx.Codec.MarshalJSON(migrated)
require.NoError(t, err)
// Indent the JSON bz correctly.
var jsonObj map[string]interface{}
err = json.Unmarshal(bz, &jsonObj)
require.NoError(t, err)
indentedBz, err := json.MarshalIndent(jsonObj, "", " ")
require.NoError(t, err)
require.Equal(t, expected, string(indentedBz))
} | explode_data.jsonl/74984 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1857
} | [
2830,
3393,
44,
34479,
1155,
353,
8840,
836,
8,
341,
197,
17159,
2648,
1669,
1643,
676,
50133,
2271,
14690,
2648,
741,
25291,
23684,
1669,
2943,
9328,
6257,
624,
197,
197,
2354,
5051,
15603,
85863,
2648,
41065,
15603,
4292,
197,
197,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetIteratorAt(t *testing.T) {
assert := assert.New(t)
vs := newTestValueStore()
numbers := append(generateNumbersAsValues(5), Float(10))
s, err := NewSet(context.Background(), vs, numbers...)
assert.NoError(err)
i, err := s.IteratorAt(context.Background(), 0)
assert.NoError(err)
vals, err := iterToSlice(i)
assert.NoError(err)
assert.True(vals.Equals(numbers), "Expected: %v != actual: %v", numbers, vs)
i, err = s.IteratorAt(context.Background(), 2)
assert.NoError(err)
vals, err = iterToSlice(i)
assert.NoError(err)
assert.True(vals.Equals(numbers[2:]), "Expected: %v != actual: %v", numbers[2:], vs)
i, err = s.IteratorAt(context.Background(), 10)
assert.NoError(err)
vals, err = iterToSlice(i)
assert.NoError(err)
assert.True(vals.Equals(nil), "Expected: %v != actual: %v", nil, vs)
} | explode_data.jsonl/10996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
1649,
11951,
1655,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
5195,
82,
1669,
501,
2271,
1130,
6093,
2822,
22431,
1902,
1669,
8737,
3268,
13220,
27237,
2121,
6227,
7,
20,
701,
13001,
7,
16,
15,
1171,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAuthEdgeCases(t *testing.T) {
t.Run("ReadConfig/MissedConfig", func(t *testing.T) {
cnfg := &AuthCnfg{}
if err := cnfg.ReadConfig("wrong_path.json"); err == nil {
t.Error("wrong_path config should not pass")
}
})
t.Run("ReadConfig/MissedConfig", func(t *testing.T) {
cnfg := &AuthCnfg{}
if err := cnfg.ReadConfig(u.ResolveCnfgPath("./test/config/malformed.json")); err == nil {
t.Error("malformed config should not pass")
}
})
t.Run("WriteConfig", func(t *testing.T) {
folderPath := u.ResolveCnfgPath("./test/tmp")
filePath := u.ResolveCnfgPath("./test/tmp/anon.json")
cnfg := &AuthCnfg{SiteURL: "test"}
_ = os.MkdirAll(folderPath, os.ModePerm)
if err := cnfg.WriteConfig(filePath); err != nil {
t.Error(err)
}
_ = os.RemoveAll(filePath)
})
t.Run("GetStrategy", func(t *testing.T) {
cnfg := &AuthCnfg{SiteURL: "test"}
if cnfg.GetStrategy() != "anonymous" {
t.Errorf(`wrong strategy name, expected "anonymous" got "%s"`, cnfg.GetStrategy())
}
})
t.Run("GetStrategy", func(t *testing.T) {
cnfg := &AuthCnfg{SiteURL: "http://test"}
if cnfg.GetStrategy() != "anonymous" {
t.Errorf(`wrong strategy name, expected "anonymous" got "%s"`, cnfg.GetStrategy())
}
})
t.Run("GetSiteURL", func(t *testing.T) {
cnfg := &AuthCnfg{SiteURL: "http://test"}
if cnfg.GetSiteURL() != "http://test" {
t.Errorf(`wrong strategy name, expected "http://test" got "%s"`, cnfg.GetSiteURL())
}
})
t.Run("GetAuth", func(t *testing.T) {
cnfg := &AuthCnfg{SiteURL: "http://test"}
if _, _, err := cnfg.GetAuth(); err != nil {
t.Error(err)
}
})
t.Run("SetAuth", func(t *testing.T) {
cnfg := &AuthCnfg{SiteURL: "http://test"}
req := &http.Request{}
client := &gosip.SPClient{AuthCnfg: cnfg}
if err := cnfg.SetAuth(req, client); err != nil {
t.Error(err)
}
})
} | explode_data.jsonl/31319 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 819
} | [
2830,
3393,
5087,
11656,
37302,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
4418,
2648,
10270,
1038,
291,
2648,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1444,
77,
4817,
1669,
609,
5087,
34,
77,
4817,
16094,
197,
743,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMineVbkBlock(t *testing.T) {
assert := assert.New(t)
mockMiner := NewMockMiner()
blockTip, err := mockMiner.MineVbkBlockTip()
assert.NoError(err)
assert.Equal(uint32(1), blockTip.Height)
blockTip, err = mockMiner.MineVbkBlock(blockTip.GetHash())
assert.NoError(err)
assert.Equal(uint32(2), blockTip.Height)
blockTip, err = mockMiner.MineVbkBlockTip()
assert.NoError(err)
assert.Equal(uint32(3), blockTip.Height)
} | explode_data.jsonl/39848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
63495,
53,
40029,
4713,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
77333,
6217,
261,
1669,
1532,
11571,
6217,
261,
2822,
47996,
16011,
11,
1848,
1669,
7860,
6217,
261,
1321,
482,
53,
40029,
4713,
16011,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_FetchOrder(t *testing.T) {
account, order := makeOrder(t)
if _, err := testClient.FetchOrder(account, testClient.Directory().URL+"/asdasdasd"); err == nil {
t.Fatal("expected error, got none")
}
fetchedOrder, err := testClient.FetchOrder(account, order.URL)
if err != nil {
t.Fatalf("unexpected error fetching order: %v", err)
}
// boulder seems to return slightly different expiry times, workaround for deepequal check
fetchedOrder.Expires = order.Expires
if !reflect.DeepEqual(order, fetchedOrder) {
t.Fatalf("fetched order different to order, order: %+v, fetchedOrder: %+v", order, fetchedOrder)
}
} | explode_data.jsonl/68106 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
2959,
1400,
2995,
4431,
1155,
353,
8840,
836,
8,
341,
86866,
11,
1973,
1669,
1281,
4431,
1155,
692,
743,
8358,
1848,
1669,
1273,
2959,
78506,
4431,
23758,
11,
1273,
2959,
54107,
1005,
3144,
27569,
300,
34889,
34889,
67,
5038... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoundEdgeCases(t *testing.T) {
type testException struct {
number float64
decimalPlaces int
expected error
}
errorString := "parameters too big"
tests := []testException{
{number: 1.80, decimalPlaces: 308, expected: &RoundError{Err: errorString}},
{number: 180.43, decimalPlaces: 3108, expected: &RoundError{Err: errorString}},
{number: 1.80, decimalPlaces: -3, expected: &RoundError{Err: "utilities.Round: decimalPlace parameter must be a positive number"}},
}
for i, test := range tests {
_, e := Round(test.number, test.decimalPlaces)
if err := a.AssertDeepException(test.expected, e); err != nil {
t.Error(m.ErrorMessageTestCount(i+1, err))
}
}
} | explode_data.jsonl/9016 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
27497,
11656,
37302,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
1354,
2036,
341,
197,
57135,
286,
2224,
21,
19,
198,
197,
197,
23289,
58825,
526,
198,
197,
42400,
414,
1465,
198,
197,
630,
18290,
703,
1669,
330,
13786,
223... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppendToPrefixed(t *testing.T) {
form := &Values{}
data := &testStruct{String: "foo"}
AppendToPrefixed(form, data, []string{"prefix"})
assert.Equal(t, []string{"foo"}, form.Get("prefix[string]"))
} | explode_data.jsonl/30324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
23877,
1249,
29978,
3286,
1155,
353,
8840,
836,
8,
341,
37410,
1669,
609,
6227,
16094,
8924,
1669,
609,
1944,
9422,
90,
703,
25,
330,
7975,
16707,
197,
23877,
1249,
29978,
3286,
16760,
11,
821,
11,
3056,
917,
4913,
11849,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDomainName_RejectingTrailingDot(t *testing.T) {
cases := []struct {
domain string
valid bool
}{
{"", false},
{" ", false},
{"a", true},
{".", false},
{"日本語", false},
{"日本語.com", false},
{"abc.日本語.com", false},
{"a日本語a.com", false},
{"abc", true},
{"ABC", false},
{"ABC123", false},
{"ABC123.COM123", false},
{"1", true},
{"0.0", true},
{"1.2.3.4", true},
{"1.2.3.4.", false},
{"abc.", false},
{"abc.com", true},
{"abc.com.", false},
{"a.b.c.d.e.f", true},
{".abc", false},
{".abc.com", false},
{".abc.com", false},
}
for _, tc := range cases {
t.Run(tc.domain, func(t *testing.T) {
err := DomainName(tc.domain, false)
if tc.valid {
assert.NoError(t, err)
} else {
assert.Error(t, err)
}
})
}
} | explode_data.jsonl/56438 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
13636,
675,
50693,
583,
287,
1282,
14277,
34207,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
2698,
3121,
914,
198,
197,
56322,
220,
1807,
198,
197,
59403,
197,
197,
4913,
497,
895,
1583,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestOKExFuture_MarketCloseAllPosition(t *testing.T) {
t.Log(okex.OKExFuture.MarketCloseAllPosition(goex.BTC_USD, goex.THIS_WEEK_CONTRACT, goex.CLOSE_BUY))
} | explode_data.jsonl/3933 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
3925,
840,
24206,
1245,
54560,
7925,
2403,
3812,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
60207,
327,
15480,
840,
24206,
1321,
54560,
7925,
2403,
3812,
47415,
327,
1785,
7749,
13467,
35,
11,
728,
327,
56841,
1637,
76999,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestBuildContentLength_ZeroBody(t *testing.T) {
server := setupContentLengthTestServer(t, false, 0)
svc := s3.New(unit.Session, &aws.Config{
Endpoint: aws.String(server.URL),
S3ForcePathStyle: aws.Bool(true),
DisableSSL: aws.Bool(true),
})
_, err := svc.GetObject(&s3.GetObjectInput{
Bucket: aws.String("bucketname"),
Key: aws.String("keyname"),
})
assert.NoError(t, err)
} | explode_data.jsonl/57766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
11066,
2762,
4373,
97672,
5444,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
6505,
2762,
4373,
2271,
5475,
1155,
11,
895,
11,
220,
15,
692,
1903,
7362,
1669,
274,
18,
7121,
24144,
20674,
11,
609,
8635,
10753,
515,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHTMLTemplate_RenderError(t *testing.T) {
tpl := template.New("test")
_, err := tpl.Parse(`{{ define "foo" }}foo{{ .Foo.Bar }}bar{{ end }}`)
require.NoError(t, err)
htmlTemplate := NewHTMLTemplate(tpl, "foo")
assert.Equal(t, "foo", htmlTemplate.Render())
buf := &bytes.Buffer{}
assert.Error(t, htmlTemplate.RenderToWriter(buf))
assert.Equal(t, "foo", buf.String())
} | explode_data.jsonl/53385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
5835,
7275,
42102,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
500,
1669,
3811,
7121,
445,
1944,
1138,
197,
6878,
1848,
1669,
60979,
8937,
5809,
2979,
6979,
330,
7975,
1,
3869,
7975,
2979,
659,
40923,
40520,
3869,
2257,
2979,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCashout(t *testing.T) {
chequebookAddress := common.HexToAddress("abcd")
recipientAddress := common.HexToAddress("efff")
txHash := common.HexToHash("dddd")
totalPayout := big.NewInt(100)
cumulativePayout := big.NewInt(500)
cheque := &chequebook.SignedCheque{
Cheque: chequebook.Cheque{
Beneficiary: common.HexToAddress("aaaa"),
CumulativePayout: cumulativePayout,
Chequebook: chequebookAddress,
},
Signature: []byte{},
}
store := storemock.NewStateStore()
cashoutService := chequebook.NewCashoutService(
store,
backendmock.New(
backendmock.WithTransactionByHashFunc(func(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error) {
if hash != txHash {
t.Fatalf("fetching wrong transaction. wanted %v, got %v", txHash, hash)
}
return nil, false, nil
}),
backendmock.WithTransactionReceiptFunc(func(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
if hash != txHash {
t.Fatalf("fetching receipt for transaction. wanted %v, got %v", txHash, hash)
}
logData, err := chequeCashedEventType.Inputs.NonIndexed().Pack(totalPayout, cumulativePayout, big.NewInt(0))
if err != nil {
t.Fatal(err)
}
return &types.Receipt{
Status: types.ReceiptStatusSuccessful,
Logs: []*types.Log{
{
Address: chequebookAddress,
Topics: []common.Hash{chequeCashedEventType.ID, cheque.Beneficiary.Hash(), recipientAddress.Hash(), cheque.Beneficiary.Hash()},
Data: logData,
},
},
}, nil
}),
),
transactionmock.New(
transactionmock.WithSendFunc(func(c context.Context, request *transaction.TxRequest) (common.Hash, error) {
if request.To != nil && *request.To != chequebookAddress {
t.Fatalf("sending to wrong contract. wanted %x, got %x", chequebookAddress, request.To)
}
if request.Value.Cmp(big.NewInt(0)) != 0 {
t.Fatal("sending ether to chequebook contract")
}
return txHash, nil
}),
),
chequestoremock.NewChequeStore(
chequestoremock.WithLastChequeFunc(func(c common.Address) (*chequebook.SignedCheque, error) {
if c != chequebookAddress {
t.Fatalf("using wrong chequebook. wanted %v, got %v", chequebookAddress, c)
}
return cheque, nil
}),
),
)
returnedTxHash, err := cashoutService.CashCheque(context.Background(), chequebookAddress, recipientAddress)
if err != nil {
t.Fatal(err)
}
if returnedTxHash != txHash {
t.Fatalf("returned wrong transaction hash. wanted %v, got %v", txHash, returnedTxHash)
}
status, err := cashoutService.CashoutStatus(context.Background(), chequebookAddress)
if err != nil {
t.Fatal(err)
}
if status.Reverted {
t.Fatal("reported reverted transaction")
}
if status.TxHash != txHash {
t.Fatalf("wrong transaction hash. wanted %v, got %v", txHash, status.TxHash)
}
if !status.Cheque.Equal(cheque) {
t.Fatalf("wrong cheque in status. wanted %v, got %v", cheque, status.Cheque)
}
if status.Result == nil {
t.Fatal("missing result")
}
expectedResult := &chequebook.CashChequeResult{
Beneficiary: cheque.Beneficiary,
Recipient: recipientAddress,
Caller: cheque.Beneficiary,
TotalPayout: totalPayout,
CumulativePayout: cumulativePayout,
CallerPayout: big.NewInt(0),
Bounced: false,
}
if !status.Result.Equal(expectedResult) {
t.Fatalf("wrong result. wanted %v, got %v", expectedResult, status.Result)
}
} | explode_data.jsonl/17066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1413
} | [
2830,
3393,
47441,
411,
1155,
353,
8840,
836,
8,
341,
197,
1528,
591,
2190,
4286,
1669,
4185,
91538,
1249,
4286,
445,
68644,
1138,
197,
42610,
4286,
1669,
4185,
91538,
1249,
4286,
445,
6445,
69,
1138,
46237,
6370,
1669,
4185,
91538,
124... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveVolumeFromDeploymentConfig(t *testing.T) {
type args struct {
pvc string
dcName string
}
tests := []struct {
name string
dcBefore *appsv1.DeploymentConfig
args args
wantErr bool
}{
{
name: "Test case : 1",
dcBefore: &appsv1.DeploymentConfig{
Spec: appsv1.DeploymentConfigSpec{
Selector: map[string]string{
"deploymentconfig": "test",
},
Template: &corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "test",
VolumeMounts: []corev1.VolumeMount{
{
MountPath: "/tmp",
Name: "test-pvc",
},
},
},
},
Volumes: []corev1.Volume{
{
Name: "test-pvc",
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: "test-pvc",
},
},
},
},
},
},
},
},
args: args{
pvc: "test-pvc",
dcName: "test",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fakeClient, fakeClientSet := FakeNew()
fakeClientSet.AppsClientset.PrependReactor("get", "deploymentconfigs", func(action ktesting.Action) (bool, runtime.Object, error) {
return true, tt.dcBefore, nil
})
fakeClientSet.AppsClientset.PrependReactor("update", "deploymentconfigs", func(action ktesting.Action) (bool, runtime.Object, error) {
return true, nil, nil
})
err := fakeClient.RemoveVolumeFromDeploymentConfig(tt.args.pvc, tt.args.dcName)
// Checks for error in positive cases
if !tt.wantErr == (err != nil) {
t.Errorf(" client.RemoveVolumeFromDeploymentConfig(pvc, dcName) unexpected error %v, wantErr %v", err, tt.wantErr)
}
// Check for validating number of actions performed
if (len(fakeClientSet.AppsClientset.Actions()) != 2) && (tt.wantErr != true) {
t.Errorf("expected 2 actions in GetPVCFromName got: %v", fakeClientSet.Kubernetes.Actions())
}
updatedDc := fakeClientSet.AppsClientset.Actions()[1].(ktesting.UpdateAction).GetObject().(*appsv1.DeploymentConfig)
// validating volume got removed from dc
for _, volume := range updatedDc.Spec.Template.Spec.Volumes {
if volume.PersistentVolumeClaim.ClaimName == tt.args.pvc {
t.Errorf("expected volume with name : %v to be removed from dc", tt.args.pvc)
}
}
})
}
} | explode_data.jsonl/65141 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1134
} | [
2830,
3393,
13021,
18902,
3830,
75286,
2648,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
3223,
7362,
262,
914,
198,
197,
87249,
675,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
8724... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindColors10(t *testing.T) {
// .ico with 8-bit bmp, ColorsUsed=0
assertFindsRightColor(t, "icon10.ico.gz", "fe6d4c")
} | explode_data.jsonl/14304 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
9885,
13108,
16,
15,
1155,
353,
8840,
836,
8,
341,
197,
322,
659,
3955,
448,
220,
23,
15257,
43301,
11,
9526,
22743,
28,
15,
198,
6948,
37,
8673,
5979,
1636,
1155,
11,
330,
1924,
16,
15,
39186,
20963,
497,
330,
1859,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestConfigClients_Create_Success_Storage(t *testing.T) {
s, _, _, h, iss, err := setupHydraTest(false)
if err != nil {
t.Fatalf("setupHydraTest() failed: %v", err)
}
clientName := "new_client"
newClientID := "00000000-0000-0000-0000-100000000000"
cli := &cpb.Client{
RedirectUris: []string{"http://client.example.com"},
Ui: map[string]string{
"label": "l",
"description": "d",
},
}
pname := "admin"
h.CreateClientResp = &hydraapi.Client{
ClientID: newClientID,
Name: clientName,
Secret: "secret",
RedirectURIs: cli.RedirectUris,
Scope: defaultScope,
GrantTypes: defaultGrantTypes,
ResponseTypes: defaultResponseTypes,
}
resp := sendConfigClientsCreate(t, pname, clientName, "master", test.TestClientID, test.TestClientSecret, cli, s, iss)
if resp.StatusCode != http.StatusOK {
t.Errorf("status=%d, wants %d", resp.StatusCode, http.StatusOK)
}
conf, err := s.loadConfig(nil, "master")
if err != nil {
t.Fatalf("s.loadConfig() failed %v", err)
}
created, ok := conf.Clients[clientName]
if !ok {
t.Errorf("conf.Clients[%s] should exists in storage", clientName)
}
sec, err := s.loadSecrets(nil)
if err != nil {
t.Fatalf("s.loadSecrets() failed %v", err)
}
if sec.ClientSecrets[created.ClientId] != h.CreateClientResp.Secret {
t.Errorf("client secret in storage = %s, wants %s", sec.ClientSecrets[created.ClientId], h.CreateClientResp.Secret)
}
} | explode_data.jsonl/18517 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 588
} | [
2830,
3393,
2648,
47174,
34325,
87161,
62,
5793,
1155,
353,
8840,
836,
8,
341,
1903,
11,
8358,
8358,
305,
11,
2369,
11,
1848,
1669,
6505,
30816,
22248,
2271,
3576,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
15188,
30816,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestParseWriteMeta(t *testing.T) {
t.Parallel()
resp := &http.Response{
Header: make(map[string][]string),
}
resp.Header.Set("X-Nomad-Index", "12345")
wm := &WriteMeta{}
if err := parseWriteMeta(resp, wm); err != nil {
t.Fatalf("err: %v", err)
}
if wm.LastIndex != 12345 {
t.Fatalf("Bad: %v", wm)
}
} | explode_data.jsonl/65022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
14463,
7985,
12175,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
34653,
1669,
609,
1254,
12574,
515,
197,
197,
4047,
25,
1281,
9147,
14032,
45725,
917,
1326,
197,
532,
34653,
15753,
4202,
445,
55,
11250,
316,
329,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetIDErrorPaths(t *testing.T) {
testCases := []struct {
arn string
name string
}{
{"", "EmptyString"},
{"invalidArn", "InvalidARN"},
{"arn:aws:ecs:region:account-id:task:task-id", "IncorrectSections"},
{"arn:aws:ecs:region:account-id:task", "IncorrectResourceSections"},
}
task := Task{}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
task.Arn = tc.arn
taskID, err := task.GetID()
assert.Error(t, err, "GetID should return an error")
assert.Empty(t, taskID, "ID should be empty")
})
}
} | explode_data.jsonl/37219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
1949,
915,
1454,
26901,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
1885,
220,
914,
198,
197,
11609,
914,
198,
197,
59403,
197,
197,
4913,
497,
330,
3522,
703,
7115,
197,
197,
4913,
11808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAsset(t *testing.T) {
tt := test.Start(t)
defer tt.Finish()
action := makeTestAction()
ts := action.GetAsset("native_")
if tt.Assert.NoError(action.Err) {
tt.Assert.Equal(xdr.AssetTypeAssetTypeNative, ts.Type)
}
ts = action.GetAsset("4_")
if tt.Assert.NoError(action.Err) {
tt.Assert.Equal(xdr.AssetTypeAssetTypeCreditAlphanum4, ts.Type)
}
ts = action.GetAsset("12_")
if tt.Assert.NoError(action.Err) {
tt.Assert.Equal(xdr.AssetTypeAssetTypeCreditAlphanum12, ts.Type)
}
// bad path
action.GetAsset("cursor")
tt.Assert.Error(action.Err)
// regression #298: GetAsset panics when asset_code is longer than allowes
tt.Assert.NotPanics(func() {
action.Err = nil
action.GetAsset("long_4_")
})
tt.Assert.NotPanics(func() {
action.Err = nil
action.GetAsset("long_12_")
})
} | explode_data.jsonl/549 | {
"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,
1949,
16604,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
1273,
12101,
1155,
340,
16867,
17853,
991,
18176,
741,
38933,
1669,
1281,
2271,
2512,
2822,
57441,
1669,
1917,
2234,
16604,
445,
29738,
62,
1138,
743,
17853,
11711,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainerStopSignal(t *testing.T) {
c := &Container{
CommonContainer: CommonContainer{
Config: &runconfig.Config{},
},
}
def, err := signal.ParseSignal(signal.DefaultStopSignal)
if err != nil {
t.Fatal(err)
}
s := c.stopSignal()
if s != int(def) {
t.Fatalf("Expected %v, got %v", def, s)
}
c = &Container{
CommonContainer: CommonContainer{
Config: &runconfig.Config{StopSignal: "SIGKILL"},
},
}
s = c.stopSignal()
if s != 9 {
t.Fatalf("Expected 9, got %v", s)
}
} | explode_data.jsonl/21113 | {
"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,
4502,
10674,
26810,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
4502,
515,
197,
90580,
4502,
25,
7718,
4502,
515,
298,
66156,
25,
609,
6108,
1676,
10753,
38837,
197,
197,
1583,
197,
630,
7452,
11,
1848,
1669,
8286,
8937... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShopDownUp(t *testing.T) {
bsToken := getBusToken()
mSm := new(logics.SmLogic)
args := cards.ArgsShopDownUpSm{
BsToken: bsToken,
ShopSmIds: []int{1, 2, 3, 4, 5},
OptType: cards.OPT_DOWN,
}
logs.Info(mSm.ShopDownUpSm(context.Background(), &args))
} | explode_data.jsonl/35930 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
19795,
4454,
2324,
1155,
353,
8840,
836,
8,
341,
93801,
3323,
1669,
633,
15073,
3323,
741,
2109,
10673,
1669,
501,
12531,
1211,
92445,
26751,
340,
31215,
1669,
7411,
51015,
19795,
4454,
2324,
10673,
515,
197,
12791,
82,
3323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSmudgePassesInvalidData(t *testing.T) {
repo := NewRepository(t, "empty")
defer repo.Test()
cmd := repo.Command("smudge", "somefile")
cmd.Input = bytes.NewBufferString("this is not a pointer file\n")
cmd.Output = "this is not a pointer file"
} | explode_data.jsonl/8398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
10673,
19561,
12187,
288,
7928,
1043,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
1669,
1532,
4624,
1155,
11,
330,
3194,
1138,
16867,
15867,
8787,
2822,
25920,
1669,
15867,
12714,
445,
3563,
19561,
497,
330,
14689,
1192,
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 TestDecodeInstanceInfo(t *testing.T) {
response := `{"ID":"_azdev","UD":"0","FD":"99"}`
faultDomain, err := readFaultDomain(strings.NewReader(response))
if err != nil {
t.Error("Unexpected error in ReadFaultDomain")
}
if faultDomain == nil {
t.Error("Fault domain was unexpectedly nil")
}
if *faultDomain != "99" {
t.Error("got incorrect fault domain")
}
} | explode_data.jsonl/50416 | {
"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,
32564,
2523,
1731,
1155,
353,
8840,
836,
8,
341,
21735,
1669,
1565,
4913,
915,
3252,
62,
1370,
3583,
2198,
4656,
3252,
15,
2198,
14596,
3252,
24,
24,
1,
5541,
271,
1166,
945,
13636,
11,
1848,
1669,
1349,
58780,
13636,
5144... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAlterFuncMap_tplfunc(t *testing.T) {
c := &chart.Chart{
Metadata: &chart.Metadata{Name: "TplFunction"},
Templates: []*chart.File{
{Name: "templates/base", Data: []byte(`Evaluate tpl {{tpl "Value: {{ .Values.value | quote}}" .}}`)},
},
}
v := chartutil.Values{
"Values": chartutil.Values{
"value": "myvalue",
},
"Chart": c.Metadata,
"Release": chartutil.Values{
"Name": "TestRelease",
},
}
out, err := Render(c, v)
if err != nil {
t.Fatal(err)
}
expect := "Evaluate tpl Value: \"myvalue\""
if got := out["TplFunction/templates/base"]; got != expect {
t.Errorf("Expected %q, got %q (%v)", expect, got, out)
}
} | explode_data.jsonl/74711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
74290,
9626,
2227,
14107,
2830,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
15941,
42667,
515,
197,
9209,
7603,
25,
609,
15941,
46475,
63121,
25,
330,
87137,
5152,
7115,
197,
10261,
76793,
25,
29838,
15941,
8576,
515,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Validate_Networking_Flannel(t *testing.T) {
grid := []struct {
Input kops.FlannelNetworkingSpec
ExpectedErrors []string
}{
{
Input: kops.FlannelNetworkingSpec{
Backend: "udp",
},
},
{
Input: kops.FlannelNetworkingSpec{
Backend: "vxlan",
},
},
{
Input: kops.FlannelNetworkingSpec{
Backend: "",
},
ExpectedErrors: []string{"Required value::networking.flannel.backend"},
},
{
Input: kops.FlannelNetworkingSpec{
Backend: "nope",
},
ExpectedErrors: []string{"Unsupported value::networking.flannel.backend"},
},
}
for _, g := range grid {
networking := &kops.NetworkingSpec{}
networking.Flannel = &g.Input
cluster := &kops.Cluster{}
cluster.Spec.Networking = networking
errs := validateNetworking(cluster, networking, field.NewPath("networking"))
testErrors(t, g.Input, errs, g.ExpectedErrors)
}
} | explode_data.jsonl/61618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
62,
17926,
1604,
2349,
287,
1400,
75,
2594,
1155,
353,
8840,
836,
8,
1476,
49018,
1669,
3056,
1235,
341,
197,
66588,
688,
595,
3721,
73459,
2594,
78007,
8327,
198,
197,
197,
18896,
13877,
3056,
917,
198,
197,
59403,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.