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 TestReadFile(t *testing.T) {
viper.Reset()
defer viper.Reset()
workingDir := "/home/hugo"
viper.Set("workingDir", workingDir)
fs := &afero.MemMapFs{}
hugofs.InitFs(fs)
afero.WriteFile(fs, filepath.Join(workingDir, "/f/f1.txt"), []byte("f1-content"), 0755)
afero.WriteFile(fs, filepath.Join("/home", "f2.txt"), []byte("f2-content"), 0755)
for i, this := range []struct {
filename string
expect interface{}
}{
{"", false},
{"b", false},
{filepath.FromSlash("/f/f1.txt"), "f1-content"},
{filepath.FromSlash("f/f1.txt"), "f1-content"},
{filepath.FromSlash("../f2.txt"), false},
} {
result, err := readFileFromWorkingDir(this.filename)
if b, ok := this.expect.(bool); ok && !b {
if err == nil {
t.Errorf("[%d] readFile didn't return an expected error", i)
}
} else {
if err != nil {
t.Errorf("[%d] readFile failed: %s", i, err)
continue
}
if result != this.expect {
t.Errorf("[%d] readFile got %q but expected %q", i, result, this.expect)
}
}
}
} | explode_data.jsonl/9258 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 454
} | [
2830,
3393,
4418,
1703,
1155,
353,
8840,
836,
8,
341,
5195,
12858,
36660,
741,
16867,
95132,
36660,
2822,
197,
21152,
6184,
1669,
3521,
5117,
7530,
33501,
1837,
5195,
12858,
4202,
445,
21152,
6184,
497,
3238,
6184,
692,
53584,
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... | 7 |
func TestAccTest_create_default_test(t *testing.T) {
teamId := os.Getenv("RUNSCOPE_TEAM_ID")
bucketName := testAccRandomBucketName()
test := &runscope.Test{}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories,
CheckDestroy: testAccCheckTestDestroy,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccTestDefaultConfig, bucketName, teamId),
Check: resource.ComposeTestCheckFunc(
testAccCheckTestExists("runscope_test.test", test),
resource.TestCheckResourceAttr("runscope_test.test", "name", "runscope test"),
resource.TestCheckResourceAttr("runscope_test.test", "description", ""),
resource.TestCheckResourceAttrSet("runscope_test.test", "default_environment_id"),
resource.TestCheckResourceAttrSet("runscope_test.test", "created_at"),
resource.TestCheckResourceAttr("runscope_test.test", "created_by.#", "1"),
resource.TestCheckResourceAttrSet("runscope_test.test", "created_by.0.id"),
resource.TestCheckResourceAttrSet("runscope_test.test", "created_by.0.name"),
resource.TestCheckResourceAttrSet("runscope_test.test", "created_by.0.email"),
),
},
},
})
} | explode_data.jsonl/52175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 464
} | [
2830,
3393,
14603,
2271,
8657,
9993,
4452,
1155,
353,
8840,
836,
8,
341,
197,
9196,
764,
1669,
2643,
64883,
445,
47390,
76365,
1740,
71198,
3450,
1138,
2233,
11152,
675,
1669,
1273,
14603,
13999,
36018,
675,
741,
18185,
1669,
609,
6108,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClassifyFlowEmpty(t *testing.T) {
module := NewClassifierModule()
flow := types.NewFlow()
result := module.ClassifyFlow(flow)
if result.Protocol != types.Unknown || result.Source != types.NoSource {
t.Error("Protocol incorrectly detected:", result.Protocol)
}
} | explode_data.jsonl/61050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
1957,
1437,
18878,
3522,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
1532,
33895,
3332,
741,
1166,
10303,
1669,
4494,
7121,
18878,
741,
9559,
1669,
4688,
19331,
1437,
18878,
74637,
340,
743,
1102,
54096,
961,
4494,
69971,
1369,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppSave(t *testing.T) {
// clear the envs table when we're finished
defer truncate("123")
app := App{
EnvID: "123",
ID: "123_dev",
Name: "dev",
}
err := app.Save()
if err != nil {
t.Error(err)
}
// fetch the app
app2 := App{}
key := fmt.Sprintf("%s_%s", app.EnvID, app.Name)
if err = get(app.EnvID, key, &app2); err != nil {
t.Errorf("failed to fetch app: %s", err.Error())
}
if app2.EnvID != "123" {
t.Errorf("app doesn't match")
}
} | explode_data.jsonl/32898 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
2164,
8784,
1155,
353,
8840,
836,
8,
341,
197,
322,
2797,
279,
6105,
82,
1965,
979,
582,
2299,
8060,
198,
16867,
56772,
445,
16,
17,
18,
5130,
28236,
1669,
1845,
515,
197,
197,
14359,
915,
25,
330,
16,
17,
18,
756,
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 TestCheckPerms(t *testing.T) {
tdir := t.TempDir()
tfile := filepath.Join(tdir, "testconfig")
fh, err := os.OpenFile(tfile, os.O_CREATE|os.O_APPEND|os.O_RDWR, 0440)
if err != nil {
t.Errorf("Failed to create temp file: %s", err)
}
tconfig := settings.KubeConfig
settings.KubeConfig = tfile
defer func() { settings.KubeConfig = tconfig }()
text, err := checkPermsStderr()
if err != nil {
t.Fatalf("could not read from stderr: %s", err)
}
expectPrefix := "WARNING: Kubernetes configuration file is group-readable. This is insecure. Location:"
if !strings.HasPrefix(text, expectPrefix) {
t.Errorf("Expected to get a warning for group perms. Got %q", text)
}
if err := fh.Chmod(0404); err != nil {
t.Errorf("Could not change mode on file: %s", err)
}
text, err = checkPermsStderr()
if err != nil {
t.Fatalf("could not read from stderr: %s", err)
}
expectPrefix = "WARNING: Kubernetes configuration file is world-readable. This is insecure. Location:"
if !strings.HasPrefix(text, expectPrefix) {
t.Errorf("Expected to get a warning for world perms. Got %q", text)
}
} | explode_data.jsonl/9607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
3973,
3889,
1011,
1155,
353,
8840,
836,
8,
341,
76373,
404,
1669,
259,
65009,
6184,
741,
3244,
1192,
1669,
26054,
22363,
1155,
3741,
11,
330,
1944,
1676,
1138,
1166,
71,
11,
1848,
1669,
2643,
12953,
1703,
1155,
1192,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMaxExecutionTime(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("use test")
tk.MustExec("create table MaxExecTime( id int,name varchar(128),age int);")
tk.MustExec("begin")
tk.MustExec("insert into MaxExecTime (id,name,age) values (1,'john',18),(2,'lary',19),(3,'lily',18);")
tk.MustQuery("select /*+ MAX_EXECUTION_TIME(1000) MAX_EXECUTION_TIME(500) */ * FROM MaxExecTime;")
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1)
require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, "MAX_EXECUTION_TIME() is defined more than once, only the last definition takes effect: MAX_EXECUTION_TIME(500)")
require.True(t, tk.Session().GetSessionVars().StmtCtx.HasMaxExecutionTime)
require.Equal(t, uint64(500), tk.Session().GetSessionVars().StmtCtx.MaxExecutionTime)
tk.MustQuery("select @@MAX_EXECUTION_TIME;").Check(testkit.Rows("0"))
tk.MustQuery("select @@global.MAX_EXECUTION_TIME;").Check(testkit.Rows("0"))
tk.MustQuery("select /*+ MAX_EXECUTION_TIME(1000) */ * FROM MaxExecTime;")
tk.MustExec("set @@global.MAX_EXECUTION_TIME = 300;")
tk.MustQuery("select * FROM MaxExecTime;")
tk.MustExec("set @@MAX_EXECUTION_TIME = 150;")
tk.MustQuery("select * FROM MaxExecTime;")
tk.MustQuery("select @@global.MAX_EXECUTION_TIME;").Check(testkit.Rows("300"))
tk.MustQuery("select @@MAX_EXECUTION_TIME;").Check(testkit.Rows("150"))
tk.MustExec("set @@global.MAX_EXECUTION_TIME = 0;")
tk.MustExec("set @@MAX_EXECUTION_TIME = 0;")
tk.MustExec("commit")
tk.MustExec("drop table if exists MaxExecTime;")
} | explode_data.jsonl/5758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 641
} | [
2830,
3393,
5974,
20294,
1462,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScannerPaceInterval(t *testing.T) {
defer leaktest.AfterTest(t)
const count = 3
durations := []time.Duration{
30 * time.Millisecond,
60 * time.Millisecond,
500 * time.Millisecond,
}
// function logs an error when the actual value is not close
// to the expected value
logErrorWhenNotCloseTo := func(expected, actual time.Duration) {
delta := 1 * time.Millisecond
if actual < expected-delta || actual > expected+delta {
t.Errorf("Expected duration %s, got %s", expected, actual)
}
}
for _, duration := range durations {
startTime := time.Now()
iter := newTestIterator(count)
s := newRangeScanner(duration, 0, iter, nil)
interval := s.paceInterval(startTime, startTime)
logErrorWhenNotCloseTo(duration/count, interval)
// The iterator is empty
iter = newTestIterator(0)
s = newRangeScanner(duration, 0, iter, nil)
interval = s.paceInterval(startTime, startTime)
logErrorWhenNotCloseTo(duration, interval)
iter = newTestIterator(count)
s = newRangeScanner(duration, 0, iter, nil)
// Move the present to duration time into the future
interval = s.paceInterval(startTime, startTime.Add(duration))
logErrorWhenNotCloseTo(0, interval)
}
} | explode_data.jsonl/39876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
31002,
47,
578,
10256,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
4777,
1760,
284,
220,
18,
198,
2698,
21449,
1669,
3056,
1678,
33795,
515,
197,
197,
18,
15,
353,
882,
71482,
345,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInvalidType_Map(t *testing.T) {
var testVar map[string]int = map[string]int{"one": 1, "two": 2, "three": 3}
err := Scrub(testVar, []string{"owner"})
assert.Error(t, err)
err = Scrub(&testVar, []string{"owner"})
assert.Error(t, err)
} | explode_data.jsonl/9431 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
7928,
929,
56992,
1155,
353,
8840,
836,
8,
1476,
2405,
1273,
3962,
2415,
14032,
63025,
284,
2415,
14032,
63025,
4913,
603,
788,
220,
16,
11,
330,
19789,
788,
220,
17,
11,
330,
27856,
788,
220,
18,
630,
9859,
1669,
32134,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSummaryDataPoint_StartTime(t *testing.T) {
ms := NewSummaryDataPoint()
ms.InitEmpty()
assert.EqualValues(t, TimestampUnixNano(0), ms.StartTime())
testValStartTime := TimestampUnixNano(1234567890)
ms.SetStartTime(testValStartTime)
assert.EqualValues(t, testValStartTime, ms.StartTime())
} | explode_data.jsonl/19576 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
19237,
1043,
2609,
38056,
1462,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
19237,
1043,
2609,
741,
47691,
26849,
3522,
741,
6948,
12808,
6227,
1155,
11,
32758,
55832,
83819,
7,
15,
701,
9829,
12101,
1462,
2398,
18185,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenericResource(t *testing.T) {
c := qt.New(t)
spec := newTestResourceSpec(specDescriptor{c: c})
r := spec.newGenericResource(nil, nil, nil, "/a/foo.css", "foo.css", media.CSSType)
c.Assert(r.Permalink(), qt.Equals, "https://example.com/foo.css")
c.Assert(r.RelPermalink(), qt.Equals, "/foo.css")
c.Assert(r.ResourceType(), qt.Equals, "text")
} | explode_data.jsonl/75608 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
19964,
4783,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
38949,
7121,
1155,
340,
98100,
1669,
501,
2271,
4783,
8327,
38209,
11709,
90,
66,
25,
272,
8824,
7000,
1669,
1398,
4618,
19964,
4783,
27907,
11,
2092,
11,
2092,
11,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGenerateQuery(t *testing.T) {
tcases := []struct {
desc string
query string
bindVars map[string]*querypb.BindVariable
extras map[string]Encodable
output string
}{
{
desc: "no substitutions",
query: "select * from a where id = 2",
bindVars: map[string]*querypb.BindVariable{
"id": sqltypes.Int64BindVariable(1),
},
output: "select * from a where id = 2",
}, {
desc: "missing bind var",
query: "select * from a where id1 = :id1 and id2 = :id2",
bindVars: map[string]*querypb.BindVariable{
"id1": sqltypes.Int64BindVariable(1),
},
output: "missing bind var id2",
}, {
desc: "simple bindvar substitution",
query: "select * from a where id1 = :id1 and id2 = :id2",
bindVars: map[string]*querypb.BindVariable{
"id1": sqltypes.Int64BindVariable(1),
"id2": sqltypes.NullBindVariable,
},
output: "select * from a where id1 = 1 and id2 = null",
}, {
desc: "tuple *querypb.BindVariable",
query: "select * from a where id in ::vals",
bindVars: map[string]*querypb.BindVariable{
"vals": sqltypes.TestBindVariable([]interface{}{1, "aa"}),
},
output: "select * from a where id in (1, 'aa')",
}, {
desc: "list bind vars 0 arguments",
query: "select * from a where id in ::vals",
bindVars: map[string]*querypb.BindVariable{
"vals": sqltypes.TestBindVariable([]interface{}{}),
},
output: "empty list supplied for vals",
}, {
desc: "non-list bind var supplied",
query: "select * from a where id in ::vals",
bindVars: map[string]*querypb.BindVariable{
"vals": sqltypes.Int64BindVariable(1),
},
output: "unexpected list arg type (INT64) for key vals",
}, {
desc: "list bind var for non-list",
query: "select * from a where id = :vals",
bindVars: map[string]*querypb.BindVariable{
"vals": sqltypes.TestBindVariable([]interface{}{1}),
},
output: "unexpected arg type (TUPLE) for non-list key vals",
}, {
desc: "single column tuple equality",
query: "select * from a where b = :equality",
extras: map[string]Encodable{
"equality": &TupleEqualityList{
Columns: []ColIdent{NewColIdent("pk")},
Rows: [][]sqltypes.Value{
{sqltypes.NewInt64(1)},
{sqltypes.NewVarBinary("aa")},
},
},
},
output: "select * from a where b = pk in (1, 'aa')",
}, {
desc: "multi column tuple equality",
query: "select * from a where b = :equality",
extras: map[string]Encodable{
"equality": &TupleEqualityList{
Columns: []ColIdent{NewColIdent("pk1"), NewColIdent("pk2")},
Rows: [][]sqltypes.Value{
{
sqltypes.NewInt64(1),
sqltypes.NewVarBinary("aa"),
},
{
sqltypes.NewInt64(2),
sqltypes.NewVarBinary("bb"),
},
},
},
},
output: "select * from a where b = (pk1 = 1 and pk2 = 'aa') or (pk1 = 2 and pk2 = 'bb')",
},
}
for _, tcase := range tcases {
tree, err := Parse(tcase.query)
if err != nil {
t.Errorf("parse failed for %s: %v", tcase.desc, err)
continue
}
buf := NewTrackedBuffer(nil)
buf.Myprintf("%v", tree)
pq := buf.ParsedQuery()
bytes, err := pq.GenerateQuery(tcase.bindVars, tcase.extras)
var got string
if err != nil {
got = err.Error()
} else {
got = string(bytes)
}
if got != tcase.output {
t.Errorf("for test case: %s, got: '%s', want '%s'", tcase.desc, got, tcase.output)
}
}
} | explode_data.jsonl/12267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1508
} | [
2830,
3393,
31115,
2859,
1155,
353,
8840,
836,
8,
341,
3244,
23910,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
27274,
262,
914,
198,
197,
2233,
484,
28305,
2415,
14032,
8465,
1631,
16650,
32451,
7827,
198,
197,
8122,
13503,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPutReflect_alias(t *testing.T) {
var a1 aliasedInt = 42
expected := make([]byte, 8)
lex.PutInt(expected, int(a1))
actual := make([]byte, 8)
lex.PutReflect(actual, a1)
assert.True(t, bytes.Equal(expected, actual))
} | explode_data.jsonl/50146 | {
"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,
19103,
72789,
35947,
1155,
353,
8840,
836,
8,
341,
2405,
264,
16,
18991,
1475,
1072,
284,
220,
19,
17,
271,
42400,
1669,
1281,
10556,
3782,
11,
220,
23,
340,
197,
2571,
39825,
1072,
15253,
11,
526,
2877,
16,
4390,
88814,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInitCmd_CustomNamespace(t *testing.T) {
file := "deploy-kudo-ns.yaml"
fs := afero.NewMemMapFs()
out := &bytes.Buffer{}
initCmd := newInitCmd(fs, out)
Settings.AddFlags(initCmd.Flags())
flags := map[string]string{"dry-run": "true", "output": "yaml", "namespace": "foo"}
for flag, value := range flags {
if err := initCmd.Flags().Set(flag, value); err != nil {
t.Fatal(err)
}
}
if err := initCmd.RunE(initCmd, []string{}); err != nil {
t.Fatal(err)
}
gp := filepath.Join("testdata", file+".golden")
if *updateGolden {
t.Log("update golden file")
if err := ioutil.WriteFile(gp, out.Bytes(), 0644); err != nil {
t.Fatalf("failed to update golden file: %s", err)
}
}
g, err := ioutil.ReadFile(gp)
if err != nil {
t.Fatalf("failed reading .golden: %s", err)
}
if !bytes.Equal(out.Bytes(), g) {
t.Errorf("json does not match .golden file")
}
} | explode_data.jsonl/53642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
3803,
15613,
57402,
22699,
1155,
353,
8840,
836,
8,
341,
17661,
1669,
330,
35794,
12646,
7680,
12,
4412,
33406,
698,
53584,
1669,
264,
802,
78,
7121,
18816,
2227,
48300,
741,
13967,
1669,
609,
9651,
22622,
16094,
28248,
15613,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeLogDirs(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()),
"DescribeLogDirsRequest": NewMockDescribeLogDirsResponse(t).
SetLogDirs("/tmp/logs", map[string]int{"topic1": 2, "topic2": 2}),
})
config := NewTestConfig()
config.Version = V1_0_0_0
admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
if err != nil {
t.Fatal(err)
}
logDirsPerBroker, err := admin.DescribeLogDirs([]int32{seedBroker.BrokerID()})
if err != nil {
t.Fatal(err)
}
if len(logDirsPerBroker) != 1 {
t.Fatalf("Expected %v results, got %v", 1, len(logDirsPerBroker))
}
logDirs := logDirsPerBroker[seedBroker.BrokerID()]
if len(logDirs) != 1 {
t.Fatalf("Expected log dirs for broker %v to be returned, but it did not, got %v", seedBroker.BrokerID(), len(logDirs))
}
logDirsBroker := logDirs[0]
if logDirsBroker.ErrorCode != ErrNoError {
t.Fatalf("Expected no error for broker %v, but it was %v", seedBroker.BrokerID(), logDirsBroker.ErrorCode)
}
if logDirsBroker.Path != "/tmp/logs" {
t.Fatalf("Expected log dirs for broker %v to be '/tmp/logs', but it was %v", seedBroker.BrokerID(), logDirsBroker.Path)
}
if len(logDirsBroker.Topics) != 2 {
t.Fatalf("Expected log dirs for broker %v to have 2 topics, but it had %v", seedBroker.BrokerID(), len(logDirsBroker.Topics))
}
err = admin.Close()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/40811 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 658
} | [
2830,
3393,
74785,
2201,
97384,
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,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyBackendDeletion(t *testing.T) {
const (
backendName = "emptyBackend"
backendProtocol = config.File
)
orchestrator := getOrchestrator(t)
// Note that we don't care about the storage class here, but it's easier
// to reuse functionality.
addBackendStorageClass(t, orchestrator, backendName, "none", backendProtocol)
backend, errLookup := orchestrator.getBackendByBackendName(backendName)
if backend == nil || errLookup != nil {
t.Fatalf("Backend %s not stored in orchestrator", backendName)
}
err := orchestrator.DeleteBackend(ctx(), backendName)
if err != nil {
t.Fatalf("Unable to delete backend: %v", err)
}
if backend.Driver().Initialized() {
t.Errorf("Deleted backend %s is still initialized.", backendName)
}
_, err = orchestrator.storeClient.GetBackend(ctx(), backendName)
if err == nil {
t.Error("Empty backend remained on store client after offlining")
}
orchestrator.mutex.Lock()
missingBackend, _ := orchestrator.getBackendByBackendName(backendName)
if missingBackend != nil {
t.Error("Empty offlined backend not removed from memory.")
}
orchestrator.mutex.Unlock()
cleanup(t, orchestrator)
} | explode_data.jsonl/62720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 389
} | [
2830,
3393,
3522,
29699,
1912,
52625,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
197,
20942,
675,
257,
284,
330,
3194,
29699,
698,
197,
197,
20942,
20689,
284,
2193,
8576,
198,
197,
692,
197,
21584,
15111,
850,
1669,
633,
2195,
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... | 7 |
func Test_UnsafeIter(t *testing.T) {
a := NewThreadUnsafeSet()
a.Add("Z")
a.Add("Y")
a.Add("X")
a.Add("W")
b := NewThreadUnsafeSet()
for val := range a.Iter() {
b.Add(val)
}
if !a.Equal(b) {
t.Error("The sets are not equal after iterating (Iter) through the first set")
}
} | explode_data.jsonl/204 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
40687,
18675,
8537,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
6855,
78770,
1649,
2822,
11323,
1904,
445,
57,
1138,
11323,
1904,
445,
56,
1138,
11323,
1904,
445,
55,
1138,
11323,
1904,
445,
54,
5130,
2233,
1669,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJobLeaseCanBeRenewed(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
job := addLeasedJob(t, r, "queue1", "cluster1")
renewed, e := r.RenewLease("cluster1", []string{job.Id})
assert.Nil(t, e)
assert.Equal(t, 1, len(renewed))
assert.Equal(t, job.Id, renewed[0])
})
} | explode_data.jsonl/32037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
12245,
2304,
519,
69585,
34625,
92076,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
68577,
1669,
912,
2304,
1475,
12245,
1155,
11,
435,
11,
330,
4584,
16,
497,
330,
18855,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAminoJSON(t *testing.T) {
tx := legacytx.StdTx{}
var msg legacytx.LegacyMsg
blockTime := time.Date(1, 1, 1, 1, 1, 1, 1, time.UTC)
expiresAt := blockTime.Add(time.Hour)
msgSend := banktypes.MsgSend{FromAddress: "cosmos1ghi", ToAddress: "cosmos1jkl"}
typeURL := sdk.MsgTypeURL(&msgSend)
msgSendAny, err := cdctypes.NewAnyWithValue(&msgSend)
require.NoError(t, err)
grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt)
require.NoError(t, err)
sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), &expiresAt)
require.NoError(t, err)
valAddr, err := sdk.ValAddressFromBech32("cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq")
require.NoError(t, err)
stakingAuth, err := stakingtypes.NewStakeAuthorization([]sdk.ValAddress{valAddr}, nil, stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, &sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000)})
require.NoError(t, err)
delegateGrant, err := authz.NewGrant(blockTime, stakingAuth, nil)
require.NoError(t, err)
// Amino JSON encoding has changed in authz since v0.46.
// Before, it was outputting something like:
// `{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"grant":{"authorization":{"msg":"/cosmos.bank.v1beta1.MsgSend"},"expiration":"0001-01-01T02:01:01.000000001Z"},"grantee":"cosmos1def","granter":"cosmos1abc"}],"sequence":"1","timeout_height":"1"}`
//
// This was a bug. Now, it's as below, See how there's `type` & `value` fields.
// ref: https://github.com/cosmos/cosmos-sdk/issues/11190
// ref: https://github.com/cosmos/cosmjs/issues/1026
msg = &authz.MsgGrant{Granter: "cosmos1abc", Grantee: "cosmos1def", Grant: grant}
tx.Msgs = []sdk.Msg{msg}
require.Equal(t,
`{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"type":"cosmos-sdk/MsgGrant","value":{"grant":{"authorization":{"type":"cosmos-sdk/GenericAuthorization","value":{"msg":"/cosmos.bank.v1beta1.MsgSend"}},"expiration":"0001-01-01T02:01:01.000000001Z"},"grantee":"cosmos1def","granter":"cosmos1abc"}}],"sequence":"1","timeout_height":"1"}`,
string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{msg}, "memo", nil)),
)
msg = &authz.MsgGrant{Granter: "cosmos1abc", Grantee: "cosmos1def", Grant: sendGrant}
tx.Msgs = []sdk.Msg{msg}
require.Equal(t,
`{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"type":"cosmos-sdk/MsgGrant","value":{"grant":{"authorization":{"type":"cosmos-sdk/SendAuthorization","value":{"spend_limit":[{"amount":"1000","denom":"stake"}]}},"expiration":"0001-01-01T02:01:01.000000001Z"},"grantee":"cosmos1def","granter":"cosmos1abc"}}],"sequence":"1","timeout_height":"1"}`,
string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{msg}, "memo", nil)),
)
msg = &authz.MsgGrant{Granter: "cosmos1abc", Grantee: "cosmos1def", Grant: delegateGrant}
tx.Msgs = []sdk.Msg{msg}
require.Equal(t,
`{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"type":"cosmos-sdk/MsgGrant","value":{"grant":{"authorization":{"type":"cosmos-sdk/StakeAuthorization","value":{"Validators":{"type":"cosmos-sdk/StakeAuthorization/AllowList","value":{"allow_list":{"address":["cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq"]}}},"authorization_type":1,"max_tokens":{"amount":"1000","denom":"stake"}}}},"grantee":"cosmos1def","granter":"cosmos1abc"}}],"sequence":"1","timeout_height":"1"}`,
string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{msg}, "memo", nil)),
)
msg = &authz.MsgRevoke{Granter: "cosmos1abc", Grantee: "cosmos1def", MsgTypeUrl: typeURL}
tx.Msgs = []sdk.Msg{msg}
require.Equal(t,
`{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"type":"cosmos-sdk/MsgRevoke","value":{"grantee":"cosmos1def","granter":"cosmos1abc","msg_type_url":"/cosmos.bank.v1beta1.MsgSend"}}],"sequence":"1","timeout_height":"1"}`,
string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{msg}, "memo", nil)),
)
msg = &authz.MsgExec{Grantee: "cosmos1def", Msgs: []*cdctypes.Any{msgSendAny}}
tx.Msgs = []sdk.Msg{msg}
require.Equal(t,
`{"account_number":"1","chain_id":"foo","fee":{"amount":[],"gas":"0"},"memo":"memo","msgs":[{"type":"cosmos-sdk/MsgExec","value":{"grantee":"cosmos1def","msgs":[{"type":"cosmos-sdk/MsgSend","value":{"amount":[],"from_address":"cosmos1ghi","to_address":"cosmos1jkl"}}]}}],"sequence":"1","timeout_height":"1"}`,
string(legacytx.StdSignBytes("foo", 1, 1, 1, legacytx.StdFee{}, []sdk.Msg{msg}, "memo", nil)),
)
} | explode_data.jsonl/74942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1849
} | [
2830,
3393,
32,
31824,
5370,
1155,
353,
8840,
836,
8,
341,
46237,
1669,
19588,
3998,
36086,
31584,
16094,
2405,
3750,
19588,
3998,
1214,
791,
2757,
6611,
198,
47996,
1462,
1669,
882,
8518,
7,
16,
11,
220,
16,
11,
220,
16,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFlagSet_Register_Bool(t *testing.T) {
resetFlagSet()
Register(&BoolFlag{
Name: "watch",
Usage: "--watch",
Default: true,
Action: func(name string, fs *FlagSet) {},
})
err := Parse()
assert.NoError(t, err)
boolFlag, err := BoolE("watch")
assert.NoError(t, err)
assert.Equal(t, true, boolFlag)
os.Setenv("EGO_WATCH", "false")
defer os.Unsetenv("EGO_WATCH")
resetFlagSet()
Register(&BoolFlag{
Name: "watch",
Usage: "--watch",
Default: true,
EnvVar: "EGO_WATCH",
Action: func(name string, fs *FlagSet) {},
})
err = Parse()
assert.NoError(t, err)
boolFlag, err = BoolE("watch")
assert.NoError(t, err)
assert.Equal(t, false, boolFlag)
resetFlagSet()
Register(&BoolFlag{
Name: "watch",
Usage: "--watch",
Default: true,
Action: func(name string, fs *FlagSet) {},
})
err = Parse()
assert.NoError(t, err)
err = flag.Set("watch", "true")
assert.NoError(t, err)
boolFlag, err = BoolE("watch")
assert.NoError(t, err)
assert.Equal(t, true, boolFlag)
resetFlagSet()
Register(&BoolFlag{
Name: "watch",
Usage: "--watch",
Default: true,
Action: func(name string, fs *FlagSet) {},
})
err = Parse()
assert.NoError(t, err)
err = flag.Set("watch", "false")
assert.NoError(t, err)
boolFlag, err = BoolE("watch")
assert.NoError(t, err)
assert.Equal(t, false, boolFlag)
} | explode_data.jsonl/50981 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 591
} | [
2830,
3393,
12135,
1649,
73124,
79948,
1155,
353,
8840,
836,
8,
341,
70343,
12135,
1649,
741,
79096,
2099,
11233,
12135,
515,
197,
21297,
25,
262,
330,
14321,
756,
197,
197,
14783,
25,
256,
14482,
14321,
756,
197,
91084,
25,
830,
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 TestResolveFunc(t *testing.T) {
tests := []struct {
addr string
want error
}{
// TODO(yuxuanli): More false cases?
{"www.google.com", nil},
{"foo.bar:12345", nil},
{"127.0.0.1", nil},
{"127.0.0.1:12345", nil},
{"[::1]:80", nil},
{"[2001:db8:a0b:12f0::1]:21", nil},
{":80", nil},
{"127.0.0...1:12345", nil},
{"[fe80::1%lo0]:80", nil},
{"golang.org:http", nil},
{"[2001:db8::1]:http", nil},
{":", nil},
{"", errMissingAddr},
{"[2001:db8:a0b:12f0::1", fmt.Errorf("invalid target address %v", "[2001:db8:a0b:12f0::1")},
}
r, err := NewDNSResolver()
if err != nil {
t.Errorf("%v", err)
}
for _, v := range tests {
_, err := r.Resolve(v.addr)
if !reflect.DeepEqual(err, v.want) {
t.Errorf("Resolve(%q) = %v, want %v", v.addr, err, v.want)
}
}
} | explode_data.jsonl/22570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 406
} | [
2830,
3393,
56808,
9626,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
53183,
914,
198,
197,
50780,
1465,
198,
197,
59403,
197,
197,
322,
5343,
7021,
2200,
10386,
742,
1648,
4398,
895,
5048,
5267,
197,
197,
4913,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.ReplicaSet.Etcd)
test.TestUpdate(
// valid
validNewReplicaSet(),
// valid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Spec.Replicas = object.Spec.Replicas + 1
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.UID = "newUID"
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Name = ""
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Spec.Selector = &unversioned.LabelSelector{MatchLabels: map[string]string{}}
return object
},
)
} | explode_data.jsonl/14200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
4289,
1155,
353,
8840,
836,
8,
341,
197,
16172,
11,
3538,
1669,
501,
5793,
1155,
340,
16867,
3538,
836,
261,
34016,
1155,
340,
18185,
1669,
19424,
1944,
7121,
1155,
11,
5819,
2817,
79,
15317,
1649,
5142,
83,
4385,
340,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResultDecoder(t *testing.T) {
testCases := []TestCase{
{
name: "single table with defaults",
encoderConfig: csv.DefaultEncoderConfig(),
encoded: toCRLF(`#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double
#group,false,false,true,true,false,true,true,false
#default,_result,0,2018-04-17T00:00:00Z,2018-04-17T00:05:00Z,,cpu,A,
,result,table,_start,_stop,_time,_measurement,host,_value
,,,,,2018-04-17T00:00:00Z,cpu,A,42.0
,,,,,2018-04-17T00:00:01Z,cpu,A,43.0
`),
result: &executetest.Result{
Nm: "_result",
Tbls: []*executetest.Table{{
KeyCols: []string{"_start", "_stop", "_measurement", "host"},
ColMeta: []query.ColMeta{
{Label: "_start", Type: query.TTime},
{Label: "_stop", Type: query.TTime},
{Label: "_time", Type: query.TTime},
{Label: "_measurement", Type: query.TString},
{Label: "host", Type: query.TString},
{Label: "_value", Type: query.TFloat},
},
Data: [][]interface{}{
{
values.ConvertTime(time.Date(2018, 4, 17, 0, 0, 0, 0, time.UTC)),
values.ConvertTime(time.Date(2018, 4, 17, 0, 5, 0, 0, time.UTC)),
values.ConvertTime(time.Date(2018, 4, 17, 0, 0, 0, 0, time.UTC)),
"cpu",
"A",
42.0,
},
{
values.ConvertTime(time.Date(2018, 4, 17, 0, 0, 0, 0, time.UTC)),
values.ConvertTime(time.Date(2018, 4, 17, 0, 5, 0, 0, time.UTC)),
values.ConvertTime(time.Date(2018, 4, 17, 0, 0, 1, 0, time.UTC)),
"cpu",
"A",
43.0,
},
},
}},
},
},
}
testCases = append(testCases, symetricalTestCases...)
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if tc.skip {
t.Skip()
}
decoder := csv.NewResultDecoder(tc.decoderConfig)
result, err := decoder.Decode(bytes.NewReader(tc.encoded))
if err != nil {
t.Fatal(err)
}
got := &executetest.Result{
Nm: result.Name(),
}
if err := result.Tables().Do(func(tbl query.Table) error {
cb, err := executetest.ConvertTable(tbl)
if err != nil {
return err
}
got.Tbls = append(got.Tbls, cb)
return nil
}); err != nil {
t.Fatal(err)
}
got.Normalize()
tc.result.Normalize()
if !cmp.Equal(got, tc.result) {
t.Error("unexpected results -want/+got", cmp.Diff(tc.result, got))
}
})
}
} | explode_data.jsonl/54708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1199
} | [
2830,
3393,
2077,
20732,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
16458,
515,
197,
197,
515,
298,
11609,
25,
688,
330,
15338,
1965,
448,
16674,
756,
298,
197,
27008,
2648,
25,
13147,
13275,
19921,
2648,
3148,
298,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetConnectURLs(t *testing.T) {
opts := DefaultOptions()
opts.Port = 4222
var globalIP net.IP
checkGlobalConnectURLs := func() {
s := New(opts)
defer s.Shutdown()
s.mu.Lock()
urls := s.getClientConnectURLs()
s.mu.Unlock()
if len(urls) == 0 {
t.Fatalf("Expected to get a list of urls, got none for listen addr: %v", opts.Host)
}
for _, u := range urls {
tcpaddr, err := net.ResolveTCPAddr("tcp", u)
if err != nil {
t.Fatalf("Error resolving: %v", err)
}
ip := tcpaddr.IP
if !ip.IsGlobalUnicast() {
t.Fatalf("IP %v is not global", ip.String())
}
if ip.IsUnspecified() {
t.Fatalf("IP %v is unspecified", ip.String())
}
addr := strings.TrimSuffix(u, ":4222")
if addr == opts.Host {
t.Fatalf("Returned url is not right: %v", u)
}
if globalIP == nil {
globalIP = ip
}
}
}
listenAddrs := []string{"0.0.0.0", "::"}
for _, listenAddr := range listenAddrs {
opts.Host = listenAddr
checkGlobalConnectURLs()
}
checkConnectURLsHasOnlyOne := func() {
s := New(opts)
defer s.Shutdown()
s.mu.Lock()
urls := s.getClientConnectURLs()
s.mu.Unlock()
if len(urls) != 1 {
t.Fatalf("Expected one URL, got %v", urls)
}
tcpaddr, err := net.ResolveTCPAddr("tcp", urls[0])
if err != nil {
t.Fatalf("Error resolving: %v", err)
}
ip := tcpaddr.IP
if ip.String() != opts.Host {
t.Fatalf("Expected connect URL to be %v, got %v", opts.Host, ip.String())
}
}
singleConnectReturned := []string{"127.0.0.1", "::1"}
if globalIP != nil {
singleConnectReturned = append(singleConnectReturned, globalIP.String())
}
for _, listenAddr := range singleConnectReturned {
opts.Host = listenAddr
checkConnectURLsHasOnlyOne()
}
} | explode_data.jsonl/3601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 771
} | [
2830,
3393,
1949,
14611,
3144,
82,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
7899,
3798,
741,
64734,
43013,
284,
220,
19,
17,
17,
17,
271,
2405,
3644,
3298,
4179,
46917,
271,
25157,
11646,
14611,
3144,
82,
1669,
2915,
368,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestGetLatestSeq(t *testing.T) {
result := getLatestSeq([]string{"x", "0", "z", "a", "x", "1", "0"})
if result != "z" {
t.Errorf("Unexpected result %v", result)
}
} | explode_data.jsonl/45976 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
1949,
31992,
20183,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
633,
31992,
20183,
10556,
917,
4913,
87,
497,
330,
15,
497,
330,
89,
497,
330,
64,
497,
330,
87,
497,
330,
16,
497,
330,
15,
23625,
743,
1102,
961,
330,
89,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReplicationControllerConversion(t *testing.T) {
// If we start with a RC, we should always have round-trip fidelity.
inputs := []*v1.ReplicationController{
{
ObjectMeta: metav1.ObjectMeta{
Name: "name",
Namespace: "namespace",
},
Spec: v1.ReplicationControllerSpec{
Replicas: utilpointer.Int32Ptr(1),
MinReadySeconds: 32,
Selector: map[string]string{"foo": "bar", "bar": "foo"},
Template: &v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"foo": "bar", "bar": "foo"},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "container",
Image: "image",
},
},
},
},
},
Status: v1.ReplicationControllerStatus{
Replicas: 1,
FullyLabeledReplicas: 2,
ReadyReplicas: 3,
AvailableReplicas: 4,
ObservedGeneration: 5,
Conditions: []v1.ReplicationControllerCondition{
{
Type: v1.ReplicationControllerReplicaFailure,
Status: v1.ConditionTrue,
LastTransitionTime: metav1.NewTime(time.Unix(123456789, 0)),
Reason: "Reason",
Message: "Message",
},
},
},
},
}
// Add some fuzzed RCs.
apiObjectFuzzer := fuzzer.FuzzerFor(fuzzer.MergeFuzzerFuncs(metafuzzer.Funcs, corefuzzer.Funcs), rand.NewSource(152), legacyscheme.Codecs)
for i := 0; i < 100; i++ {
rc := &v1.ReplicationController{}
apiObjectFuzzer.Fuzz(rc)
// Sometimes the fuzzer decides to leave Spec.Template nil.
// We can't support that because Spec.Template is not a pointer in RS,
// so it will round-trip as non-nil but empty.
if rc.Spec.Template == nil {
rc.Spec.Template = &v1.PodTemplateSpec{}
}
// Sometimes the fuzzer decides to insert an empty label key.
// This doesn't round-trip properly because it's invalid.
if rc.Spec.Selector != nil {
delete(rc.Spec.Selector, "")
}
inputs = append(inputs, rc)
}
// Round-trip the input RCs before converting to RS.
for i := range inputs {
inputs[i] = roundTrip(t, inputs[i]).(*v1.ReplicationController)
}
for _, in := range inputs {
rs := &apps.ReplicaSet{}
// Use in.DeepCopy() to avoid sharing pointers with `in`.
if err := corev1.Convert_v1_ReplicationController_To_apps_ReplicaSet(in.DeepCopy(), rs, nil); err != nil {
t.Errorf("can't convert RC to RS: %v", err)
continue
}
// Round-trip RS before converting back to RC.
rs = roundTripRS(t, rs)
out := &v1.ReplicationController{}
if err := corev1.Convert_apps_ReplicaSet_To_v1_ReplicationController(rs, out, nil); err != nil {
t.Errorf("can't convert RS to RC: %v", err)
continue
}
if !apiequality.Semantic.DeepEqual(in, out) {
instr, _ := json.MarshalIndent(in, "", " ")
outstr, _ := json.MarshalIndent(out, "", " ")
t.Errorf("RC-RS conversion round-trip failed:\nin:\n%s\nout:\n%s", instr, outstr)
}
}
} | explode_data.jsonl/27250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1300
} | [
2830,
3393,
18327,
1693,
2051,
48237,
1155,
353,
8840,
836,
8,
341,
197,
322,
1416,
582,
1191,
448,
264,
21594,
11,
582,
1265,
2677,
614,
4778,
10188,
573,
82504,
624,
22427,
82,
1669,
29838,
85,
16,
2817,
79,
1693,
2051,
515,
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... | 9 |
func TestImageRef_HasAlpha__True(t *testing.T) {
Startup(nil)
img, err := NewImageFromFile(resources + "png-24bit+alpha.png")
require.NoError(t, err)
defer img.Close()
assert.True(t, img.HasAlpha())
} | explode_data.jsonl/38819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
1906,
3945,
2039,
300,
19384,
563,
2514,
1155,
353,
8840,
836,
8,
341,
197,
39076,
27907,
692,
39162,
11,
1848,
1669,
1532,
1906,
43633,
52607,
488,
330,
14066,
12,
17,
19,
4489,
10,
7141,
3508,
1138,
17957,
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 |
func TestDescribePostCommitHook(t *testing.T) {
tests := []struct {
hook buildv1.BuildPostCommitSpec
want string
}{
{
hook: buildv1.BuildPostCommitSpec{},
want: "",
},
{
hook: buildv1.BuildPostCommitSpec{
Script: "go test",
},
want: `"/bin/sh", "-ic", "go test"`,
},
{
hook: buildv1.BuildPostCommitSpec{
Command: []string{"go", "test"},
},
want: `"go", "test"`,
},
{
hook: buildv1.BuildPostCommitSpec{
Args: []string{"go", "test"},
},
want: `"<image-entrypoint>", "go", "test"`,
},
{
hook: buildv1.BuildPostCommitSpec{
Script: `go test "$@"`,
Args: []string{"-v", "-timeout", "2s"},
},
want: `"/bin/sh", "-ic", "go test \"$@\"", "/bin/sh", "-v", "-timeout", "2s"`,
},
{
hook: buildv1.BuildPostCommitSpec{
Command: []string{"go", "test"},
Args: []string{"-v", "-timeout", "2s"},
},
want: `"go", "test", "-v", "-timeout", "2s"`,
},
{
// Invalid hook: Script and Command are not allowed
// together. For printing, Script takes precedence.
hook: buildv1.BuildPostCommitSpec{
Script: "go test -v",
Command: []string{"go", "test"},
},
want: `"/bin/sh", "-ic", "go test -v"`,
},
}
for _, tt := range tests {
var b bytes.Buffer
out := tabwriter.NewWriter(&b, 0, 8, 0, '\t', 0)
describePostCommitHook(tt.hook, out)
if err := out.Flush(); err != nil {
t.Fatalf("%+v: flush error: %v", tt.hook, err)
}
var want string
if tt.want != "" {
want = fmt.Sprintf("Post Commit Hook:\t[%s]\n", tt.want)
}
if got := b.String(); got != want {
t.Errorf("describePostCommitHook(%+v, out) = %q, want %q", tt.hook, got, want)
}
}
} | explode_data.jsonl/6486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 789
} | [
2830,
3393,
74785,
4133,
33441,
31679,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
9598,
1941,
1936,
85,
16,
25212,
4133,
33441,
8327,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
9598,
1941,
25,
193... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodNormal(t *testing.T) {
t.Parallel()
ms, ctrl, pod, executor := setup(t)
defer ctrl.Finish()
// Expectations
ms.EXPECT().GetPodFlag(pod, events.PodCreatePodResponse).Return(scenario.ResponseNormal, nil)
ms.EXPECT().GetNodeFlag(events.NodeCreatePodResponse).Return(scenario.ResponseUnset, nil)
// Execute
out, err := executor(events.PodCreatePodResponse)
// Assert
assert.NoError(t, err)
assert.Equal(t, tStr, out)
} | explode_data.jsonl/35138 | {
"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,
23527,
12206,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
47691,
11,
23743,
11,
7509,
11,
31558,
1669,
6505,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
322,
32085,
804,
198,
47691,
22402,
7285,
1005,
1949,
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 TestHandleDebug(t *testing.T) {
t.Run("initialized with 0 request", func(t *testing.T) {
const expRequests = 0
s := &server.Server{}
r := httptest.NewRequest("", "/debug", nil)
testx.HTTPHandler(s).WithRequest(r).
Response(
checkStatusCode(200),
checkExactBody([]byte([]byte(strconv.Itoa(expRequests)))),
).
Run(t)
})
t.Run("count requests", func(t *testing.T) {
const expRequests = 42
s := &server.Server{}
regularRequest := httptest.NewRequest("", "/", nil)
for i := 0; i < expRequests; i++ {
s.ServeHTTP(nil, regularRequest)
}
debugRequest := httptest.NewRequest("", "/debug", nil)
testx.HTTPHandler(s).WithRequest(debugRequest).
Response(
checkStatusCode(200),
checkExactBody([]byte(strconv.Itoa(expRequests))),
).
Run(t)
})
} | explode_data.jsonl/41264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
6999,
7939,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
36161,
448,
220,
15,
1681,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
4777,
1343,
35295,
284,
220,
15,
271,
197,
1903,
1669,
609,
4030,
22997,
16094,
197,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPicturesService_Get(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
tcs := map[string]struct {
id string
want *Picture
}{
"ok": {"1", getPicture("1")},
}
for n, tc := range tcs {
t.Run(n, func(t *testing.T) {
mux.HandleFunc(fmt.Sprintf("/type/%s/%s", tc.id, picturesPath), func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, fmt.Sprintf(getPictureJSON(tc.id)))
})
got, err := client.Picture.Get(context.Background(), tc.id)
if err != nil {
t.Fatalf("Failed: %v", err)
}
if diff := cmp.Diff(got, tc.want); diff != "" {
t.Fatalf("Diff: %s(-got +want)", diff)
}
})
}
} | explode_data.jsonl/53569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
76646,
1860,
13614,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
3244,
4837,
1669,
2415,
14032,
60,
1235,
341,
197,
15710,
256,
914,
198,
197,
50780,
353,
24669,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTerragruntSetsAccessLoggingForTfSTateS3BuckeToADifferentBucketWithGivenTargetPrefix(t *testing.T) {
t.Parallel()
examplePath := filepath.Join(TEST_FIXTURE_REGRESSIONS, "accesslogging-bucket/with-target-prefix-input")
cleanupTerraformFolder(t, examplePath)
s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))
s3BucketLogsName := fmt.Sprintf("%s-tf-state-logs", s3BucketName)
s3BucketLogsTargetPrefix := "logs/"
lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(uniqueId()))
defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)
defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)
tmpTerragruntConfigPath := createTmpTerragruntConfig(
t,
examplePath,
s3BucketName,
lockTableName,
"remote_terragrunt.hcl",
)
runTerragrunt(t, fmt.Sprintf("terragrunt validate --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, examplePath))
targetLoggingBucket := terraws.GetS3BucketLoggingTarget(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)
targetLoggingBucketPrefix := terraws.GetS3BucketLoggingTargetPrefix(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)
assert.Equal(t, s3BucketLogsName, targetLoggingBucket)
assert.Equal(t, s3BucketLogsTargetPrefix, targetLoggingBucketPrefix)
} | explode_data.jsonl/10075 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 549
} | [
2830,
3393,
51402,
68305,
3850,
30175,
6054,
34575,
2461,
51,
69,
784,
349,
50,
18,
33,
1942,
68,
1249,
1808,
18277,
36018,
2354,
22043,
6397,
14335,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
8122,
1516,
1820,
1669,
26054,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWalletCreateTx(t *testing.T) {
chainID := ids.ID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
w, err := NewWallet(logging.NoLog{}, 12345, chainID, 0)
if err != nil {
t.Fatal(err)
}
assetID := ids.Empty.Prefix(0)
addr, err := w.GetAddress()
if err != nil {
t.Fatal(err)
}
utxo := &avax.UTXO{
UTXOID: avax.UTXOID{TxID: ids.Empty.Prefix(1)},
Asset: avax.Asset{ID: assetID},
Out: &secp256k1fx.TransferOutput{
Amt: 1000,
OutputOwners: secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{addr},
},
},
}
w.AddUTXO(utxo)
destAddr, err := w.CreateAddress()
if err != nil {
t.Fatal(err)
}
tx, err := w.CreateTx(assetID, 1000, destAddr)
if err != nil {
t.Fatal(err)
}
if balance := w.Balance(utxo.AssetID()); balance != 1000 {
t.Fatalf("expected balance to be 1000, was %d", balance)
}
for _, utxo := range tx.InputUTXOs() {
w.RemoveUTXO(utxo.InputID())
}
if balance := w.Balance(utxo.AssetID()); balance != 0 {
t.Fatalf("expected balance to be 0, was %d", balance)
}
} | explode_data.jsonl/41623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
38259,
4021,
31584,
1155,
353,
8840,
836,
8,
341,
197,
8819,
915,
1669,
14151,
9910,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
220,
21,
11,
220,
22,
11,
220,
23,
11,
220,
24,
11,
220,
16,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestNoFrom(t *testing.T) {
_, err := validate("", "redis://t", "*", false, false, 10000, 25000)
if err == nil {
t.Error("from should be required")
}
} | explode_data.jsonl/42983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
2753,
3830,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
9593,
19814,
330,
21748,
1110,
83,
497,
79936,
895,
11,
895,
11,
220,
16,
15,
15,
15,
15,
11,
220,
17,
20,
15,
15,
15,
340,
743,
1848,
621,
2092,
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
] | 2 |
func TestFastHTTPMiddleware(t *testing.T) {
requestBody := "fake_requestDaprBody"
responseBody := "fake_responseDaprBody"
testRequestCtx := fakeFastHTTPRequestCtx(requestBody)
fakeHandler := func(ctx *fasthttp.RequestCtx) {
time.Sleep(100 * time.Millisecond)
ctx.Response.SetBodyRaw([]byte(responseBody))
}
// create test httpMetrics
testHTTP := newHTTPMetrics()
testHTTP.Init("fakeID")
handler := testHTTP.FastHTTPMiddleware(fakeHandler)
// act
handler(testRequestCtx)
// assert
rows, err := view.RetrieveData("http/server/request_count")
assert.NoError(t, err)
assert.Equal(t, 1, len(rows))
assert.Equal(t, "app_id", rows[0].Tags[0].Key.Name())
assert.Equal(t, "fakeID", rows[0].Tags[0].Value)
assert.Equal(t, "method", rows[0].Tags[1].Key.Name())
assert.Equal(t, "POST", rows[0].Tags[1].Value)
assert.Equal(t, "path", rows[0].Tags[2].Key.Name())
assert.Equal(t, "/invoke/method/testmethod", rows[0].Tags[2].Value)
rows, err = view.RetrieveData("http/server/request_bytes")
assert.NoError(t, err)
assert.Equal(t, 1, len(rows))
assert.Equal(t, "app_id", rows[0].Tags[0].Key.Name())
assert.Equal(t, "fakeID", rows[0].Tags[0].Value)
assert.True(t, (rows[0].Data).(*view.DistributionData).Min == float64(len([]byte(requestBody))))
rows, err = view.RetrieveData("http/server/response_bytes")
assert.NoError(t, err)
assert.Equal(t, 1, len(rows))
assert.True(t, (rows[0].Data).(*view.DistributionData).Min == float64(len([]byte(responseBody))))
rows, err = view.RetrieveData("http/server/latency")
assert.NoError(t, err)
assert.Equal(t, 1, len(rows))
assert.True(t, (rows[0].Data).(*view.DistributionData).Min >= 100.0)
} | explode_data.jsonl/70162 | {
"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,
32174,
9230,
24684,
1155,
353,
8840,
836,
8,
341,
23555,
5444,
1669,
330,
30570,
7893,
35,
59817,
5444,
698,
21735,
5444,
1669,
330,
30570,
9655,
35,
59817,
5444,
1837,
18185,
1900,
23684,
1669,
12418,
32174,
63765,
23684,
487... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemittanceOriginatorAddressLineThreeAlphaNumeric(t *testing.T) {
ro := mockRemittanceOriginator()
ro.RemittanceData.AddressLineThree = "®"
err := ro.Validate()
require.EqualError(t, err, fieldError("AddressLineThree", ErrNonAlphanumeric, ro.RemittanceData.AddressLineThree).Error())
} | explode_data.jsonl/32934 | {
"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,
6590,
87191,
13298,
850,
4286,
2460,
19641,
19384,
36296,
1155,
353,
8840,
836,
8,
341,
197,
299,
1669,
7860,
6590,
87191,
13298,
850,
741,
197,
299,
11398,
87191,
1043,
26979,
2460,
19641,
284,
330,
11909,
1837,
9859,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUPCAWriter(t *testing.T) {
writer := NewUPCAWriter()
_, e := writer.EncodeWithoutHint("123456789012", gozxing.BarcodeFormat_EAN_13, 1, 1)
if e == nil {
t.Fatalf("Encode must be error")
}
expect, _ := gozxing.ParseStringToBitMatrix(""+
" # # ## # # ## #### # # ## ## # # #### # # # # # # ### # ### # ## ## ## ## # # \n"+
" # # ## # # ## #### # # ## ## # # #### # # # # # # ### # ### # ## ## ## ## # # \n",
"#", " ")
matrix, e := writer.Encode("12345678901", gozxing.BarcodeFormat_UPC_A, 1, 2, nil)
if e != nil {
t.Fatalf("Encode returns error, %v", e)
}
width := matrix.GetWidth()
height := matrix.GetHeight()
if w, h := expect.GetWidth(), expect.GetHeight(); width != w || height != h {
t.Fatalf("Encode matrix = %vx%v, expect %vx%v", width, height, w, h)
}
for j := 0; j < height; j++ {
for i := 0; i < width; i++ {
if m, e := matrix.Get(i, j), expect.Get(i, j); m != e {
t.Fatalf("Encode matrix[%v,%v] = %v, expect %v", i, j, m, e)
}
}
}
} | explode_data.jsonl/34714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
3124,
5049,
6492,
1155,
353,
8840,
836,
8,
341,
38959,
1669,
1532,
3124,
5049,
6492,
2822,
197,
6878,
384,
1669,
6916,
50217,
26040,
26987,
445,
16,
17,
18,
19,
20,
21,
22,
23,
24,
15,
16,
17,
497,
728,
66700,
287,
405... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShare(t *testing.T) {
registeredCodecNum := len(Codecs)
codec := MockCodec{}
mockCodecType := 127
RegisterCodec(protocol.SerializeType(mockCodecType), codec)
assert.Equal(t, registeredCodecNum + 1, len(Codecs))
} | explode_data.jsonl/47413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
12115,
1155,
353,
8840,
836,
8,
341,
29422,
291,
36913,
4651,
1669,
2422,
79321,
4837,
340,
43343,
66,
1669,
14563,
36913,
31483,
77333,
36913,
929,
1669,
220,
16,
17,
22,
198,
79096,
36913,
84356,
32859,
929,
30389,
36913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecoverDoublePendingConfig(t *testing.T) {
func() {
defer func() {
if err := recover(); err == nil {
t.Errorf("expect panic, but nothing happens")
}
}()
r := newRaft(1, []uint64{1, 2}, 10, 1, NewMemoryStorage(), 0)
r.appendEntry(pb.Entry{Type: pb.EntryConfChange})
r.appendEntry(pb.Entry{Type: pb.EntryConfChange})
r.becomeCandidate()
r.becomeLeader()
}()
} | explode_data.jsonl/67368 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
693,
3688,
7378,
32027,
2648,
1155,
353,
8840,
836,
8,
341,
29244,
368,
341,
197,
16867,
2915,
368,
341,
298,
743,
1848,
1669,
11731,
2129,
1848,
621,
2092,
341,
571,
3244,
13080,
445,
17119,
21975,
11,
714,
4302,
8573,
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 TestBaseParam_SetTable(t *testing.T) {
type args struct {
t Table
}
tests := []struct {
name string
b *BaseParam
args args
want Table
}{
{
name: "1",
b: NewBaseParam(nil, nil),
args: args{
t: newMockTable(NewBaseTable("db", "schema", "table")),
},
want: newMockTable(NewBaseTable("db", "schema", "table")),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.b.SetTable(tt.args.t)
if !reflect.DeepEqual(tt.b.Table(), tt.want) {
t.Errorf("got: %v want: %v", tt.b.Table(), tt.want)
}
})
}
} | explode_data.jsonl/20050 | {
"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,
3978,
2001,
14812,
2556,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
3244,
6633,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
2233,
262,
353,
3978,
2001,
198,
197,
31215,
2827,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMetadata(t *testing.T) {
var tests = map[string]struct {
options map[string]interface{}
mocks func(context.Context, *mocks.Client)
expectedResponse *types.ConstructionMetadataResponse
expectedError *types.Error
}{
"happy path: native currency with nonce": {
options: map[string]interface{}{
"from": metadataFrom,
"to": metadataTo,
"value": transferValueHex,
"nonce": transferNonceHex2,
},
expectedResponse: &types.ConstructionMetadataResponse{
Metadata: map[string]interface{}{
"to": metadataTo,
"value": transferValueHex,
"nonce": transferNonceHex2,
"gas_price": transferGasPriceHex,
"gas_limit": transferGasLimitHex,
},
SuggestedFee: []*types.Amount{
{
Value: fmt.Sprintf("%d", transferGasPrice*transferGasLimit),
Currency: polygon.Currency,
},
},
},
mocks: func(ctx context.Context, client *mocks.Client) {
var gasPrice *big.Int = nil
client.On("SuggestGasPrice", ctx, gasPrice).
Return(big.NewInt(int64(transferGasPrice)), nil)
},
},
"happy path: native currency without nonce": {
options: map[string]interface{}{
"from": metadataFrom,
"to": metadataTo,
"value": transferValueHex,
},
mocks: func(ctx context.Context, client *mocks.Client) {
var gasPrice *big.Int = nil
client.On("PendingNonceAt", ctx, common.HexToAddress(metadataFrom)).
Return(transferNonce, nil)
client.On("SuggestGasPrice", ctx, gasPrice).
Return(big.NewInt(int64(transferGasPrice)), nil)
},
expectedResponse: &types.ConstructionMetadataResponse{
Metadata: map[string]interface{}{
"to": metadataTo,
"value": transferValueHex,
"nonce": transferNonceHex,
"gas_price": transferGasPriceHex,
"gas_limit": transferGasLimitHex,
},
SuggestedFee: []*types.Amount{
{
Value: fmt.Sprintf("%d", transferGasPrice*transferGasLimit),
Currency: polygon.Currency,
},
},
},
},
"happy path: ERC20 currency with nonce": {
options: map[string]interface{}{
"from": metadataFrom,
"to": metadataTo,
"value": "0x0",
"nonce": transferNonceHex2,
"token_address": tokenContractAddress,
"data": metadataData,
},
mocks: func(ctx context.Context, client *mocks.Client) {
var gasPrice *big.Int = nil
to := common.HexToAddress(tokenContractAddress)
dataBytes, _ := hexutil.Decode(metadataData)
client.On("EstimateGas", ctx, ethereum.CallMsg{
From: common.HexToAddress(metadataFrom),
To: &to,
Data: dataBytes,
}).Return(transferGasLimitERC20, nil)
client.On("SuggestGasPrice", ctx, gasPrice).
Return(big.NewInt(int64(transferGasPrice)), nil)
},
expectedResponse: &types.ConstructionMetadataResponse{
Metadata: map[string]interface{}{
"to": tokenContractAddress,
"value": "0x0",
"nonce": transferNonceHex2,
"gas_price": transferGasPriceHex,
"gas_limit": transferGasLimitERC20Hex,
"data": metadataData,
},
SuggestedFee: []*types.Amount{
{
Value: fmt.Sprintf("%d", transferGasPrice*transferGasLimitERC20),
Currency: polygon.Currency,
},
},
},
},
"happy path: Generic contract call metadata": {
options: map[string]interface{}{
"from": metadataFrom,
"to": metadataTo,
"value": "0x0",
"nonce": transferNonceHex2,
"contract_address": tokenContractAddress,
"data": metadataGenericData,
"method_signature": "approve(address,uint256)",
"method_args": []string{"0xD10a72Cf054650931365Cc44D912a4FD75257058", "1000"},
},
mocks: func(ctx context.Context, client *mocks.Client) {
var gasPrice *big.Int = nil
to := common.HexToAddress(tokenContractAddress)
dataBytes, _ := hexutil.Decode(metadataGenericData)
client.On("EstimateGas", ctx, ethereum.CallMsg{
From: common.HexToAddress(metadataFrom),
To: &to,
Data: dataBytes,
}).Return(transferGasLimitERC20, nil)
client.On("SuggestGasPrice", ctx, gasPrice).
Return(big.NewInt(int64(transferGasPrice)), nil)
},
expectedResponse: &types.ConstructionMetadataResponse{
Metadata: map[string]interface{}{
"to": tokenContractAddress,
"value": "0x0",
"nonce": transferNonceHex2,
"gas_price": transferGasPriceHex,
"gas_limit": transferGasLimitERC20Hex,
"data": metadataGenericData,
"method_signature": "approve(address,uint256)",
"method_args": []interface{}{"0xD10a72Cf054650931365Cc44D912a4FD75257058", "1000"},
},
SuggestedFee: []*types.Amount{
{
Value: fmt.Sprintf("%d", transferGasPrice*transferGasLimitERC20),
Currency: polygon.Currency,
},
},
},
},
"error: missing source address": {
options: map[string]interface{}{
"to": metadataTo,
"nonce": transferNonceHex2,
"value": transferValueHex,
},
expectedResponse: nil,
expectedError: templateError(
errors.ErrInvalidAddress, "source address is not provided"),
},
"error: invalid source address": {
options: map[string]interface{}{
"from": "invalid_from",
"to": metadataTo,
"nonce": transferNonceHex2,
"value": transferValueHex,
},
expectedResponse: nil,
expectedError: templateError(
errors.ErrInvalidAddress, "invalid_from is not a valid address"),
},
"error: missing destination address": {
options: map[string]interface{}{
"from": metadataFrom,
"nonce": transferNonceHex,
"value": transferValueHex,
},
expectedResponse: nil,
expectedError: templateError(
errors.ErrInvalidAddress, "destination address is not provided"),
},
"error: invalid destination address": {
options: map[string]interface{}{
"from": metadataFrom,
"to": "invalid_to",
"nonce": transferNonceHex,
"value": transferValueHex,
},
expectedResponse: nil,
expectedError: templateError(
errors.ErrInvalidAddress, "invalid_to is not a valid address"),
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
mockClient := &mocks.Client{}
service := NewAPIService(
&configuration.Configuration{Mode: configuration.Online},
mockClient,
)
if test.mocks != nil {
test.mocks(context.Background(), mockClient)
}
resp, err := service.ConstructionMetadata(context.Background(), &types.ConstructionMetadataRequest{
NetworkIdentifier: networkIdentifier,
Options: test.options,
})
if err != nil {
assert.Equal(t, test.expectedError, err)
} else {
assert.Equal(t, test.expectedResponse, resp)
}
})
}
} | explode_data.jsonl/44645 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3029
} | [
2830,
3393,
14610,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
2415,
14032,
60,
1235,
341,
197,
35500,
688,
2415,
14032,
31344,
16094,
197,
2109,
25183,
310,
2915,
5378,
9328,
11,
353,
16712,
82,
11716,
340,
197,
42400,
2582,
353,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWork(t *testing.T) {
if !runIntegrationTests {
t.Skip("To run this test, use: go test -integration")
}
var wg sync.WaitGroup
worker.JobHandler = func(job Job) error {
t.Logf("%s", job.Data())
wg.Done()
return nil
}
if err := worker.Ready(); err != nil {
t.Error(err)
return
}
go worker.Work()
wg.Add(1)
worker.Echo([]byte("Hello"))
wg.Wait()
} | explode_data.jsonl/43515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
6776,
1155,
353,
8840,
836,
8,
341,
743,
753,
6108,
52464,
18200,
341,
197,
3244,
57776,
445,
1249,
1598,
419,
1273,
11,
990,
25,
728,
1273,
481,
60168,
1138,
197,
532,
2405,
63581,
12811,
28384,
2808,
198,
197,
21462,
452... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrefixMessage(t *testing.T) {
t.Run("without prefix", func(t *testing.T) {
assert.Equal(t, "type(name): ohno", plugin.PrefixMessage(facade, "ohno"))
})
t.Run("with old prefix", func(t *testing.T) {
assert.Equal(t, "type(name): ohno", plugin.PrefixMessage(facade, "name: ohno"))
})
t.Run("already prefixed", func(t *testing.T) {
assert.Equal(t, "type(name): ohno", plugin.PrefixMessage(facade, "type(name): ohno"))
})
} | explode_data.jsonl/30818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
14335,
2052,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
28996,
9252,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
12808,
1155,
11,
330,
1313,
3153,
1648,
14019,
2152,
497,
9006,
1069,
5060,
2052,
955,
580,
1021... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRandomPrepare(t *testing.T) {
trunk, root := prepareTruck()
defer closeTestCtx(root)
e := NewEbpTxExec(5, 5, 5, 10, &testcase.DumbSigner{})
e.SetContext(prepareCtx(trunk))
txs := prepareAccAndTx(e)
e.CollectTx(txs[0])
tx0, _ := gethtypes.NewTransaction(0, to1, big.NewInt(200), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx1, _ := gethtypes.NewTransaction(1, to1, big.NewInt(200), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx2, _ := gethtypes.NewTransaction(2, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx3, _ := gethtypes.NewTransaction(3, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx4, _ := gethtypes.NewTransaction(4, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx5, _ := gethtypes.NewTransaction(5, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx6, _ := gethtypes.NewTransaction(6, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx7, _ := gethtypes.NewTransaction(7, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx8, _ := gethtypes.NewTransaction(8, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx9, _ := gethtypes.NewTransaction(9, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx10, _ := gethtypes.NewTransaction(10, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
tx11, _ := gethtypes.NewTransaction(11, to1, big.NewInt(400), 100000, big.NewInt(1), nil).WithSignature(e.signer, from1.Bytes())
for i := 0; i < 2; i++ {
e.SetContext(prepareCtx(trunk))
e.CollectTx(tx0)
e.CollectTx(tx1)
e.CollectTx(tx2)
e.CollectTx(tx3)
e.CollectTx(tx4)
e.CollectTx(tx5)
e.CollectTx(tx6)
e.CollectTx(tx7)
e.CollectTx(tx8)
e.CollectTx(tx9)
e.CollectTx(tx10)
e.CollectTx(tx11)
e.Prepare(0, 0, DefaultTxGasLimit)
require.Equal(t, 12*i+12, e.StandbyQLen())
}
} | explode_data.jsonl/58976 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 933
} | [
2830,
3393,
13999,
50590,
1155,
353,
8840,
836,
8,
341,
25583,
3122,
11,
3704,
1669,
10549,
1282,
1942,
741,
16867,
3265,
2271,
23684,
9206,
340,
7727,
1669,
1532,
36,
17808,
31584,
10216,
7,
20,
11,
220,
20,
11,
220,
20,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBoundarySampler(t *testing.T) {
type triple struct {
id uint64
salt int64
rate float64
hasError bool
}
for input, sampled := range map[triple]bool{
{123, 456, 1.0, false}: true,
{123, 456, 999, true}: true,
{123, 456, 0.0, false}: false,
{123, 456, -42, true}: false,
{1229998, 0, 0.01, false}: false,
{1229999, 0, 0.01, false}: false,
{1230000, 0, 0.01, false}: true,
{1230001, 0, 0.01, false}: true,
{1230098, 0, 0.01, false}: true,
{1230099, 0, 0.01, false}: true,
{1230100, 0, 0.01, false}: false,
{1230101, 0, 0.01, false}: false,
{1, 9999999, 0.01, false}: false,
{999, 0, 0.99, false}: true,
{9999, 0, 0.99, false}: false,
} {
sampler, err := zipkin.NewBoundarySampler(input.rate, input.salt)
if want, have := input.hasError, (err != nil); want != have {
t.Fatalf("%#+v: want error %t, have error %t", input, want, have)
}
if input.hasError {
want := fmt.Errorf("rate should be 0.0 or between 0.0001 and 1: was %f", input.rate)
if have := err; have == nil || want.Error() != have.Error() {
t.Fatalf("%#+v: want error %+v, have error %+v", input, want, have)
}
continue
}
if want, have := sampled, sampler(input.id); want != have {
t.Errorf("%#+v: want %v, have %v", input, want, have)
}
}
} | explode_data.jsonl/74305 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 611
} | [
2830,
3393,
57977,
66048,
1155,
353,
8840,
836,
8,
341,
13158,
23725,
2036,
341,
197,
15710,
981,
2622,
21,
19,
198,
197,
1903,
3145,
257,
526,
21,
19,
198,
197,
7000,
349,
257,
2224,
21,
19,
198,
197,
63255,
1454,
1807,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestTransformBlackboxesToUptosByNil(t *testing.T) {
// given
bbs := map[string]*Upto{}
var m [][]string
// when
TransformBlackboxesToUptos(bbs, m, BBApplication)
// then
assert.Empty(t, bbs)
} | explode_data.jsonl/58728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
8963,
14417,
22204,
1249,
52,
417,
436,
1359,
19064,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
2233,
1279,
1669,
2415,
14032,
8465,
52,
57991,
16094,
2405,
296,
52931,
917,
271,
197,
322,
979,
198,
90291,
14417,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRecordExecutionStoppedAt(t *testing.T) {
testCases := []struct {
essential bool
status apicontainerstatus.ContainerStatus
executionStoppedAtSet bool
msg string
}{
{
essential: true,
status: apicontainerstatus.ContainerStopped,
executionStoppedAtSet: true,
msg: "essential container stopped should have executionStoppedAt set",
},
{
essential: false,
status: apicontainerstatus.ContainerStopped,
executionStoppedAtSet: false,
msg: "non essential container stopped should not cause executionStoppedAt set",
},
{
essential: true,
status: apicontainerstatus.ContainerRunning,
executionStoppedAtSet: false,
msg: "essential non-stop status change should not cause executionStoppedAt set",
},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("Container status: %s, essential: %v, executionStoppedAt should be set: %v", tc.status, tc.essential, tc.executionStoppedAtSet), func(t *testing.T) {
task := &Task{}
task.RecordExecutionStoppedAt(&apicontainer.Container{
Essential: tc.essential,
KnownStatusUnsafe: tc.status,
})
assert.Equal(t, !tc.executionStoppedAtSet, task.GetExecutionStoppedAt().IsZero(), tc.msg)
})
}
} | explode_data.jsonl/37231 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 625
} | [
2830,
3393,
6471,
20294,
59803,
1655,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
48482,
1797,
1807,
198,
197,
23847,
394,
1443,
51160,
1743,
2829,
33672,
2522,
198,
197,
67328,
1488,
59803,
1655,
1649,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidCheck(t *testing.T) {
cases := []struct {
name string
src influxdb.Check
err error
}{
{
name: "invalid check id",
src: &check.Deadman{},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Check ID is invalid",
},
},
{
name: "empty name",
src: &check.Threshold{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Check Name can't be empty",
},
},
{
name: "invalid owner id",
src: &check.Threshold{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Check OwnerID is invalid",
},
},
{
name: "invalid org id",
src: &check.Threshold{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
OwnerID: influxTesting.MustIDBase16(id2),
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Check OrgID is invalid",
},
},
{
name: "nil every",
src: &check.Deadman{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
OwnerID: influxTesting.MustIDBase16(id2),
OrgID: influxTesting.MustIDBase16(id3),
StatusMessageTemplate: "temp1",
Tags: []influxdb.Tag{{Key: "key1"}},
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Check Every must exist",
},
},
{
name: "offset greater then interval",
src: &check.Deadman{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
OwnerID: influxTesting.MustIDBase16(id2),
OrgID: influxTesting.MustIDBase16(id3),
Every: mustDuration("1m"),
Offset: mustDuration("2m"),
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "Offset should not be equal or greater than the interval",
},
},
{
name: "invalid tag",
src: &check.Deadman{
Base: check.Base{
ID: influxTesting.MustIDBase16(id1),
Name: "name1",
OwnerID: influxTesting.MustIDBase16(id2),
OrgID: influxTesting.MustIDBase16(id3),
StatusMessageTemplate: "temp1",
Every: mustDuration("1m"),
Tags: []influxdb.Tag{{Key: "key1"}},
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "tag must contain a key and a value",
},
},
{
name: "bad threshold",
src: &check.Threshold{
Base: goodBase,
Thresholds: []check.ThresholdConfig{
&check.Range{Min: 200, Max: 100},
},
},
err: &errors.Error{
Code: errors.EInvalid,
Msg: "range threshold min can't be larger than max",
},
},
}
for _, c := range cases {
got := c.src.Valid(fluxlang.DefaultService)
influxTesting.ErrorsEqual(t, got, c.err)
}
} | explode_data.jsonl/1914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1526
} | [
2830,
3393,
4088,
3973,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
41144,
220,
52852,
1999,
10600,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
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... | 2 |
func TestSnapshotWithReplacer(t *testing.T) {
if test.UpdateGoldenGlobal {
t.Skip()
}
randID, err := util.GenerateRandomBase64String(20)
require.NoError(t, err)
a := struct {
ID string
A string
B int
C bool
D *string
}{
ID: randID,
A: "foo",
B: 1,
C: true,
D: swag.String("bar"),
}
replacer := func(s string) string {
re, err := regexp.Compile(`ID:.*"(.*)",`)
require.NoError(t, err)
return re.ReplaceAllString(s, "ID: <redacted>,")
}
test.Snapshoter.Replacer(replacer).Save(t, a)
} | explode_data.jsonl/17626 | {
"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,
15009,
2354,
693,
90212,
1155,
353,
8840,
836,
8,
341,
743,
1273,
16689,
59790,
11646,
341,
197,
3244,
57776,
741,
197,
532,
7000,
437,
915,
11,
1848,
1669,
4094,
57582,
13999,
3978,
21,
19,
703,
7,
17,
15,
340,
17957,
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 TestBasic(t *testing.T) {
mysqld, err := NewMysqld(NewConfig())
if err != nil {
t.Errorf("Failed to start mysqld: %s", err)
return
}
defer mysqld.Stop()
dsn := mysqld.Datasource("test", "", "", 0)
wantdsn := fmt.Sprintf(
"root:@unix(%s)/test",
mysqld.Socket(),
)
if dsn != wantdsn {
t.Errorf("DSN does not match expected (got '%s', want '%s')", dsn, wantdsn)
return
}
_, err = sql.Open("mysql", dsn)
if err != nil {
t.Errorf("Failed to connect to database: %s", err)
return
}
// Got to wait for a bit till the log gets anything in it
time.Sleep(2 * time.Second)
buf, err := mysqld.ReadLog()
if err != nil {
t.Errorf("Failed to read log: %s", err)
return
}
if strings.Index(string(buf), "ready for connections") < 0 {
t.Errorf("Could not find 'ready for connections' in log: %s", buf)
return
}
} | explode_data.jsonl/77524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 359
} | [
2830,
3393,
15944,
1155,
353,
8840,
836,
8,
341,
2109,
1047,
80,
507,
11,
1848,
1669,
1532,
44,
1047,
80,
507,
35063,
2648,
2398,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
9408,
311,
1191,
9717,
80,
507,
25,
1018,
82,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnaryTracingInterceptor(t *testing.T) {
interceptor := UnaryTracingInterceptor("foo")
var run int32
var wg sync.WaitGroup
wg.Add(1)
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
FullMethod: "/",
}, func(ctx context.Context, req interface{}) (interface{}, error) {
defer wg.Done()
atomic.AddInt32(&run, 1)
return nil, nil
})
wg.Wait()
assert.Nil(t, err)
assert.Equal(t, int32(1), atomic.LoadInt32(&run))
} | explode_data.jsonl/27819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
94545,
1282,
4527,
32786,
1155,
353,
8840,
836,
8,
341,
58915,
15349,
1669,
86951,
1282,
4527,
32786,
445,
7975,
1138,
2405,
1598,
526,
18,
17,
198,
2405,
63581,
12811,
28384,
2808,
198,
72079,
1904,
7,
16,
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 |
func Test_buildSourceDeb(t *testing.T) {
pkg := deb.NewControlDefault("testpkg", "me", "me@a", "Dummy package for doing nothing", "testpkg is package ", true)
spkg := deb.NewSourcePackage(pkg)
err := buildOrigArchive(spkg) // it's up to you how to build this
if err != nil {
t.Fatalf("Error building source package: %v", err)
}
err = buildDebianArchive(spkg) // again - do it yourself
if err != nil {
t.Fatalf("Error building source package: %v", err)
}
err = buildDscFile(spkg) // yep, same again
if err != nil {
t.Fatalf("Error building source package: %v", err)
}
} | explode_data.jsonl/31834 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
20801,
3608,
1912,
65,
1155,
353,
8840,
836,
8,
341,
3223,
7351,
1669,
4222,
7121,
3273,
3675,
445,
1944,
30069,
497,
330,
2660,
497,
330,
2660,
89217,
497,
330,
43344,
6328,
369,
3730,
4302,
497,
330,
1944,
30069,
374,
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... | 4 |
func TestURLWithHeader(t *testing.T) {
pod := &v1.Pod{
TypeMeta: metav1.TypeMeta{
APIVersion: api.Registry.GroupOrDie(v1.GroupName).GroupVersion.String(),
Kind: "Pod",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
UID: "111",
Namespace: "mynamespace",
},
Spec: v1.PodSpec{
NodeName: "localhost",
Containers: []v1.Container{{Name: "1", Image: "foo", ImagePullPolicy: v1.PullAlways}},
},
}
data, err := json.Marshal(pod)
if err != nil {
t.Fatalf("Unexpected json marshalling error: %v", err)
}
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: string(data),
}
testServer := httptest.NewServer(&fakeHandler)
defer testServer.Close()
ch := make(chan interface{}, 1)
header := make(http.Header)
header.Set("Metadata-Flavor", "Google")
c := sourceURL{testServer.URL, header, "localhost", ch, nil, 0, http.DefaultClient}
if err := c.extractFromURL(); err != nil {
t.Fatalf("Unexpected error extracting from URL: %v", err)
}
update := (<-ch).(kubetypes.PodUpdate)
headerVal := fakeHandler.RequestReceived.Header["Metadata-Flavor"]
if len(headerVal) != 1 || headerVal[0] != "Google" {
t.Errorf("Header missing expected entry %v. Got %v", header, fakeHandler.RequestReceived.Header)
}
if len(update.Pods) != 1 {
t.Errorf("Received wrong number of pods, expected one: %v", update.Pods)
}
} | explode_data.jsonl/48251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 546
} | [
2830,
3393,
3144,
2354,
4047,
1155,
353,
8840,
836,
8,
341,
3223,
347,
1669,
609,
85,
16,
88823,
515,
197,
27725,
12175,
25,
77520,
16,
10184,
12175,
515,
298,
197,
7082,
5637,
25,
6330,
89142,
5407,
2195,
18175,
3747,
16,
5407,
675,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInspectServerBlocksWithAdjustedAddress(t *testing.T) {
Port = DefaultPort
Host = "example.com"
filename := "Testfile"
ctx := newContext(&caddy.Instance{Storage: make(map[interface{}]interface{})}).(*httpContext)
input := strings.NewReader("example.com {\n}\n:2015 {\n}")
sblocks, err := caddyfile.Parse(filename, input, nil)
if err != nil {
t.Fatalf("Expected no error setting up test, got: %v", err)
}
_, err = ctx.InspectServerBlocks(filename, sblocks)
if err == nil {
t.Fatalf("Expected an error because site definitions should overlap, got: %v", err)
}
} | explode_data.jsonl/26461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
58533,
5475,
4713,
16056,
98241,
4286,
1155,
353,
8840,
836,
8,
341,
98459,
284,
7899,
7084,
198,
197,
9296,
284,
330,
8687,
905,
698,
66434,
1669,
330,
2271,
1192,
698,
20985,
1669,
501,
1972,
2099,
66,
22478,
12688,
90,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_CheckStream(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
for i := 0; i < 1000; i++ {
randLen := rand.Int() % 10000
stream := NewStream()
bytes := []byte(base.GetRandString(randLen))
stream.PutBytes(bytes)
stream.BuildStreamCheck()
assert(stream.CheckStream()).IsTrue()
assert(int(stream.GetLength())).Equals(stream.GetWritePos())
stream.Release()
}
})
t.Run("bytes is change", func(t *testing.T) {
assert := base.NewAssert(t)
for i := 0; i < 1000; i++ {
randLen := rand.Int() % 10000
stream := NewStream()
bytes := []byte(base.GetRandString(randLen))
stream.PutBytes(bytes)
stream.BuildStreamCheck()
// rand change
changePos := rand.Int() % stream.GetWritePos()
changeSeg := changePos / streamBlockSize
changeIndex := changePos % streamBlockSize
(*stream.frames[changeSeg])[changeIndex]++
assert(stream.CheckStream()).IsFalse()
stream.Release()
}
})
} | explode_data.jsonl/21167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
3027,
28188,
3027,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAuthService_InviteUser_Forbidden(t *testing.T) {
var token = issueTestToken(user.ID, user.Username, createTestConfig().PrivKeyPath)
var email = "bojack@horseman.com"
dao := dao.MockUserDao{}
dao.On("GetByUsername", user.Username).Return(&st.User{ID: user.ID + 1}, nil)
s := AuthService{&mailer, &dao, createTestConfig()}
err := s.InviteUser(email, token)
assert.Equal(t, st.AuthError{Msg: "Available only for admin", Status: 403}, err)
dao.AssertExpectations(t)
} | explode_data.jsonl/18888 | {
"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,
90466,
62,
93540,
1474,
84368,
22108,
1155,
353,
8840,
836,
8,
341,
2405,
3950,
284,
4265,
2271,
3323,
4277,
9910,
11,
1196,
42777,
11,
1855,
2271,
2648,
1005,
32124,
1592,
1820,
340,
2405,
2551,
284,
330,
749,
27134,
31,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestService(t *testing.T) {
// waitgroup for server start
var wg sync.WaitGroup
// cancellation context
ctx, cancel := context.WithCancel(context.Background())
// start test server
service := testService(ctx, &wg, "test.service")
go func() {
// wait for service to start
wg.Wait()
// make a test call
if err := testRequest(ctx, service.Client(), "test.service"); err != nil {
t.Fatal(err)
}
// shutdown the service
testShutdown(&wg, cancel)
}()
// start service
if err := service.Run(); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/24492 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
1860,
1155,
353,
8840,
836,
8,
341,
197,
322,
3783,
4074,
369,
3538,
1191,
198,
2405,
63581,
12811,
28384,
2808,
271,
197,
322,
35835,
2266,
198,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
12367,
197,
322,
1191,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChange(t *testing.T) {
type args struct {
oldpass string
newpass string
id int
}
cases := []struct {
name string
args args
wantErr bool
udb *mockdb.User
rbac *mock.RBAC
sec *mock.Secure
}{
{
name: "Fail on EnforceUser",
args: args{id: 1},
rbac: &mock.RBAC{
EnforceUserFn: func(c echo.Context, id int) error {
return rest.ErrGeneric
}},
wantErr: true,
},
{
name: "Fail on ViewUser",
args: args{id: 1},
wantErr: true,
rbac: &mock.RBAC{
EnforceUserFn: func(c echo.Context, id int) error {
return nil
}},
udb: &mockdb.User{
ViewFn: func(db orm.DB, id int) (*rest.User, error) {
if id != 1 {
return nil, nil
}
return nil, rest.ErrGeneric
},
},
},
{
name: "Fail on PasswordMatch",
args: args{id: 1, oldpass: "hunter123"},
rbac: &mock.RBAC{
EnforceUserFn: func(c echo.Context, id int) error {
return nil
}},
wantErr: true,
udb: &mockdb.User{
ViewFn: func(db orm.DB, id int) (*rest.User, error) {
return &rest.User{
Password: "HashedPassword",
}, nil
},
},
sec: &mock.Secure{
HashMatchesPasswordFn: func(string, string) bool {
return false
},
},
},
{
name: "Fail on InsecurePassword",
args: args{id: 1, oldpass: "hunter123"},
rbac: &mock.RBAC{
EnforceUserFn: func(c echo.Context, id int) error {
return nil
}},
wantErr: true,
udb: &mockdb.User{
ViewFn: func(db orm.DB, id int) (*rest.User, error) {
return &rest.User{
Password: "HashedPassword",
}, nil
},
},
sec: &mock.Secure{
HashMatchesPasswordFn: func(string, string) bool {
return true
},
PasswordFn: func(string, ...string) bool {
return false
},
},
},
{
name: "Success",
args: args{id: 1, oldpass: "hunter123", newpass: "password"},
rbac: &mock.RBAC{
EnforceUserFn: func(c echo.Context, id int) error {
return nil
}},
udb: &mockdb.User{
ViewFn: func(db orm.DB, id int) (*rest.User, error) {
return &rest.User{
Password: "$2a$10$udRBroNGBeOYwSWCVzf6Lulg98uAoRCIi4t75VZg84xgw6EJbFNsG",
}, nil
},
UpdateFn: func(orm.DB, *rest.User) error {
return nil
},
},
sec: &mock.Secure{
HashMatchesPasswordFn: func(string, string) bool {
return true
},
PasswordFn: func(string, ...string) bool {
return true
},
HashFn: func(string) string {
return "hash3d"
},
},
},
}
for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
s := password.New(nil, tt.udb, tt.rbac, tt.sec)
err := s.Change(nil, tt.args.id, tt.args.oldpass, tt.args.newpass)
assert.Equal(t, tt.wantErr, err != nil)
// Check whether password was changed
})
}
} | explode_data.jsonl/69147 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1436
} | [
2830,
3393,
4072,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
61828,
6385,
914,
198,
197,
8638,
6385,
914,
198,
197,
15710,
414,
526,
198,
197,
532,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFetchIntoObjectPool_hooks(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
cfg.Git.HooksPath = testhelper.TempDir(t)
addr := runObjectPoolServer(t, cfg, config.NewLocator(cfg), testhelper.NewDiscardingLogger(t))
conn, err := grpc.Dial(addr, grpc.WithInsecure())
require.NoError(t, err)
defer testhelper.MustClose(t, conn)
client := gitalypb.NewObjectPoolServiceClient(conn)
ctx, cancel := testhelper.Context()
defer cancel()
pool := initObjectPool(t, cfg, cfg.Storages[0])
// Set up a custom reference-transaction hook which simply exits failure. This asserts that
// the RPC doesn't invoke any reference-transaction.
testhelper.WriteExecutable(t, filepath.Join(cfg.HooksPath(), "reference-transaction"), []byte("#!/bin/sh\nexit 1\n"))
req := &gitalypb.FetchIntoObjectPoolRequest{
ObjectPool: pool.ToProto(),
Origin: repo,
Repack: true,
}
_, err = client.FetchIntoObjectPool(ctx, req)
testhelper.RequireGrpcError(t, status.Error(codes.Internal, "fetch into object pool: exit status 128, stderr: \"fatal: ref updates aborted by hook\\n\""), err)
} | explode_data.jsonl/62525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
20714,
26591,
1190,
10551,
73113,
1155,
353,
8840,
836,
8,
341,
50286,
11,
15867,
11,
716,
1669,
1273,
14072,
25212,
2354,
25243,
1155,
340,
50286,
1224,
275,
3839,
14685,
1820,
284,
1273,
18764,
65009,
6184,
1155,
340,
53183,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseResponse(t *testing.T) {
creds := GetTestCreds()
type Person struct {
Name string `sql:"name"`
Age int32 `sql:"age"`
Mass float32 `sql:"mass"`
}
adam := Person{"Adam", 10, 242.0}
brad := Person{"Brad", 20, 199.9}
chad := Person{"Chad", 30, 206.9}
tests := []struct {
query string
wantPeople []Person
}{
{
`SELECT * FROM People WHERE name = 'Duke'`,
[]Person{},
}, {
`SELECT * FROM People WHERE name = 'Adam'`,
[]Person{adam},
}, {
`SELECT * FROM People WHERE age >= 20`,
[]Person{brad, chad},
},
}
// Create a suitable table in the test database.
conn, err := Connect(creds)
if err != nil {
t.Fatalf("Failed to connect to database: %v.", err)
}
if _, err := conn.exec(`CREATE TABLE People (name TEXT, age INT, mass FLOAT4);`); err != nil {
t.Fatalf("Failed to create table: %v.", err)
}
defer func() {
conn.exec(`DROP TABLE People;`)
conn.Close()
}()
// Add Adam, Brad, and Chad to the database.
for _, person := range []Person{adam, brad, chad} {
cmd := fmt.Sprintf("INSERT INTO People (name, age, mass) VALUES ('%s', %d, %f);", person.Name, person.Age, person.Mass)
if _, err := conn.exec(cmd); err != nil {
t.Fatalf("Failed to insert Person %q: %v.", person.Name, err)
}
}
for i, test := range tests {
rows, err := conn.query(test.query)
if err != nil {
t.Errorf("TestParseResponse()[%d] - failed to execute query: %v.", i, err)
continue
}
havePeople, err := parseResponse(rows, Person{})
if err != nil {
t.Errorf("TestParseResponse()[%d] - failed to parse response: %v.", i, err)
continue
}
if len(havePeople) != len(test.wantPeople) {
t.Errorf("TestParseResponse()[%d] = %d, want %d people.", i, len(havePeople), len(test.wantPeople))
continue
}
for j, havePerson := range havePeople {
wantPerson := test.wantPeople[j]
if !reflect.DeepEqual(havePerson, wantPerson) {
t.Errorf("TestParseResponse()[%d][%d] = %v, want Person %v.", i, j, havePerson, wantPerson)
}
}
}
} | explode_data.jsonl/6904 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 909
} | [
2830,
3393,
14463,
2582,
1155,
353,
8840,
836,
8,
972,
197,
85734,
1669,
2126,
2271,
34,
53369,
18005,
13158,
7357,
2036,
972,
197,
21297,
914,
220,
1565,
3544,
2974,
606,
39917,
319,
197,
197,
16749,
220,
526,
18,
17,
256,
1565,
3544... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResolveRevisionNegativeScenarios(t *testing.T) {
service := newService(".")
repo := &argoappv1.Repository{Repo: "https://github.com/argoproj/argo-cd"}
app := &argoappv1.Application{}
resolveRevisionResponse, err := service.ResolveRevision(context.Background(), &apiclient.ResolveRevisionRequest{
Repo: repo,
App: app,
AmbiguousRevision: "v2.a.2",
})
expectedResolveRevisionResponse := &apiclient.ResolveRevisionResponse{
Revision: "",
AmbiguousRevision: "",
}
assert.NotNil(t, resolveRevisionResponse.Revision)
assert.NotNil(t, err)
assert.Equal(t, expectedResolveRevisionResponse, resolveRevisionResponse)
} | explode_data.jsonl/5706 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
56808,
33602,
38489,
3326,
60494,
1155,
353,
8840,
836,
8,
1476,
52934,
1669,
501,
1860,
5680,
1138,
17200,
5368,
1669,
609,
12088,
676,
85,
16,
25170,
90,
25243,
25,
330,
2428,
1110,
5204,
905,
14,
858,
45926,
73,
14,
120... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateObjectStoreFailure(t *testing.T) {
clientFunc := func(client RookRestClient) (interface{}, error) {
return client.CreateObjectStore(model.ObjectStore{Name: "name"})
}
verifyFunc := getStringVerifyFunc(t)
ClientFailureHelperWithVerification(t, clientFunc, verifyFunc)
} | explode_data.jsonl/27861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
4021,
1190,
6093,
17507,
1155,
353,
8840,
836,
8,
341,
25291,
9626,
1669,
2915,
12805,
431,
1941,
12416,
2959,
8,
320,
4970,
22655,
1465,
8,
341,
197,
853,
2943,
7251,
1190,
6093,
7635,
8348,
6093,
63121,
25,
330,
606,
236... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadBackend(t *testing.T) {
const (
backendName = "load-backend-test"
)
// volumes must be nil in order to satisfy reflect.DeepEqual comparison. It isn't recommended to compare slices with deepEqual
var volumes []fake.Volume
orchestrator := getOrchestrator(t)
configJSON, err := fakedriver.NewFakeStorageDriverConfigJSON(
backendName,
config.File,
map[string]*fake.StoragePool{
"primary": {
Attrs: map[string]sa.Offer{
sa.Media: sa.NewStringOffer("hdd"),
sa.ProvisioningType: sa.NewStringOffer("thick", "thin"),
sa.TestingAttribute: sa.NewBoolOffer(true),
},
Bytes: 100 * 1024 * 1024 * 1024,
},
},
volumes,
)
originalBackend, err := orchestrator.AddBackend(ctx(), configJSON, "")
if err != nil {
t.Fatal("Unable to initially add backend: ", err)
}
persistentBackend, err := orchestrator.storeClient.GetBackend(ctx(), backendName)
if err != nil {
t.Fatal("Unable to retrieve backend from store client: ", err)
}
// Note that this will register as an update, but it should be close enough
newConfig, err := persistentBackend.MarshalConfig()
if err != nil {
t.Fatal("Unable to marshal config from stored backend: ", err)
}
newBackend, err := orchestrator.AddBackend(ctx(), newConfig, "")
if err != nil {
t.Error("Unable to update backend from config: ", err)
} else if !reflect.DeepEqual(newBackend, originalBackend) {
t.Error("Newly loaded backend differs.")
}
newOrchestrator := getOrchestrator(t)
if bootstrappedBackend, _ := newOrchestrator.GetBackend(ctx(), backendName); bootstrappedBackend == nil {
t.Error("Unable to find backend after bootstrapping.")
} else if !reflect.DeepEqual(bootstrappedBackend, originalBackend) {
t.Errorf("External backends differ.")
diffExternalBackends(t, originalBackend, bootstrappedBackend)
}
cleanup(t, orchestrator)
} | explode_data.jsonl/62725 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 663
} | [
2830,
3393,
5879,
29699,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
197,
20942,
675,
284,
330,
1078,
89987,
16839,
698,
197,
340,
197,
322,
26282,
1969,
387,
2092,
304,
1973,
311,
26553,
8708,
94750,
12313,
13,
1084,
4436,
944,
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... | 8 |
func TestCredentialRecord_SaveProfile(t *testing.T) {
t.Parallel()
t.Run("test save profile - success", func(t *testing.T) {
t.Parallel()
record, err := New(mem.NewProvider())
require.NoError(t, err)
require.NotNil(t, record)
value := &ProfileData{
ID: "profile1",
Name: "Issuer Profile 1",
SupportedVCContexts: []string{"https://w3id.org/citizenship/v3"},
URL: "http://issuer.example.com",
}
err = record.SaveProfile(value)
require.NoError(t, err)
k := getDBKey(value.ID)
v, err := record.store.Get(k)
require.NoError(t, err)
require.NotEmpty(t, v)
})
t.Run("test save profile - validation failure", func(t *testing.T) {
t.Parallel()
record, err := New(mem.NewProvider())
require.NoError(t, err)
require.NotNil(t, record)
value := &ProfileData{}
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "profile id mandatory")
value.ID = "profile1"
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "profile name mandatory")
value.Name = "Issuer Profile 1"
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "supported vc contexts mandatory")
value.SupportedVCContexts = []string{"https://w3id.org/citizenship/v3"}
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "issuer url is invalid")
})
t.Run("test save profile - profile already exists", func(t *testing.T) {
t.Parallel()
record, err := New(mem.NewProvider())
require.NoError(t, err)
require.NotNil(t, record)
value := &ProfileData{
ID: "profile1",
Name: "Issuer Profile 1",
SupportedVCContexts: []string{"https://w3id.org/citizenship/v3"},
URL: "http://issuer.example.com",
}
err = record.SaveProfile(value)
require.NoError(t, err)
// try to save again
err = record.SaveProfile(value)
require.Error(t, err)
require.Contains(t, err.Error(), "profile profile1 already exists")
})
} | explode_data.jsonl/53338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 877
} | [
2830,
3393,
48265,
6471,
78746,
8526,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3244,
16708,
445,
1944,
3581,
5526,
481,
2393,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
2822,
197,
71952,
11,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateGetDeleteRefreshTokenSession(t *testing.T) {
t.Parallel()
for k, m := range fositeStores {
t.Run(fmt.Sprintf("case=%s", k), TestHelperCreateGetDeleteRefreshTokenSession(m))
}
} | explode_data.jsonl/54418 | {
"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,
4021,
1949,
6435,
14567,
3323,
5283,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2023,
595,
11,
296,
1669,
2088,
48390,
632,
69026,
341,
197,
3244,
16708,
28197,
17305,
445,
5638,
7846,
82,
497,
595,
701,
3393,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestBuildServiceMapServiceUpdate(t *testing.T) {
ipt := iptablestest.NewFake()
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
fp := NewFakeProxier(ipt, ipvs, ipset, nil, nil, v1.IPv4Protocol)
servicev1 := makeTestService("somewhere", "some-service", func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeClusterIP
svc.Spec.ClusterIP = "172.16.55.4"
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "something", "UDP", 1234, 4321, 0)
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "somethingelse", "TCP", 1235, 5321, 0)
})
servicev2 := makeTestService("somewhere", "some-service", func(svc *v1.Service) {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
svc.Spec.ClusterIP = "172.16.55.4"
svc.Spec.LoadBalancerIP = "5.6.7.8"
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "something", "UDP", 1234, 4321, 7002)
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "somethingelse", "TCP", 1235, 5321, 7003)
svc.Status.LoadBalancer = v1.LoadBalancerStatus{
Ingress: []v1.LoadBalancerIngress{
{IP: "10.1.2.3"},
},
}
svc.Spec.ExternalTrafficPolicy = v1.ServiceExternalTrafficPolicyTypeLocal
svc.Spec.HealthCheckNodePort = 345
})
fp.OnServiceAdd(servicev1)
result := fp.serviceMap.Update(fp.serviceChanges)
if len(fp.serviceMap) != 2 {
t.Errorf("expected service map length 2, got %v", fp.serviceMap)
}
if len(result.HCServiceNodePorts) != 0 {
t.Errorf("expected healthcheck ports length 0, got %v", result.HCServiceNodePorts)
}
if len(result.UDPStaleClusterIP) != 0 {
// Services only added, so nothing stale yet
t.Errorf("expected stale UDP services length 0, got %d", len(result.UDPStaleClusterIP))
}
// Change service to load-balancer
fp.OnServiceUpdate(servicev1, servicev2)
result = fp.serviceMap.Update(fp.serviceChanges)
if len(fp.serviceMap) != 2 {
t.Errorf("expected service map length 2, got %v", fp.serviceMap)
}
if len(result.HCServiceNodePorts) != 1 {
t.Errorf("expected healthcheck ports length 1, got %v", result.HCServiceNodePorts)
}
if len(result.UDPStaleClusterIP) != 0 {
t.Errorf("expected stale UDP services length 0, got %v", result.UDPStaleClusterIP.List())
}
// No change; make sure the service map stays the same and there are
// no health-check changes
fp.OnServiceUpdate(servicev2, servicev2)
result = fp.serviceMap.Update(fp.serviceChanges)
if len(fp.serviceMap) != 2 {
t.Errorf("expected service map length 2, got %v", fp.serviceMap)
}
if len(result.HCServiceNodePorts) != 1 {
t.Errorf("expected healthcheck ports length 1, got %v", result.HCServiceNodePorts)
}
if len(result.UDPStaleClusterIP) != 0 {
t.Errorf("expected stale UDP services length 0, got %v", result.UDPStaleClusterIP.List())
}
// And back to ClusterIP
fp.OnServiceUpdate(servicev2, servicev1)
result = fp.serviceMap.Update(fp.serviceChanges)
if len(fp.serviceMap) != 2 {
t.Errorf("expected service map length 2, got %v", fp.serviceMap)
}
if len(result.HCServiceNodePorts) != 0 {
t.Errorf("expected healthcheck ports length 0, got %v", result.HCServiceNodePorts)
}
if len(result.UDPStaleClusterIP) != 0 {
// Services only added, so nothing stale yet
t.Errorf("expected stale UDP services length 0, got %d", len(result.UDPStaleClusterIP))
}
} | explode_data.jsonl/44366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1278
} | [
2830,
3393,
11066,
1860,
2227,
1860,
4289,
1155,
353,
8840,
836,
8,
341,
8230,
417,
1669,
66068,
480,
267,
477,
7121,
52317,
741,
46531,
11562,
1669,
45475,
267,
477,
7121,
52317,
741,
46531,
746,
1669,
5997,
746,
1944,
7121,
52317,
862... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInSegmentMatcher(t *testing.T) {
logger := logging.NewLogger(&logging.LoggerOptions{})
dto := &dtos.MatcherDTO{
MatcherType: "IN_SEGMENT",
UserDefinedSegment: &dtos.UserDefinedSegmentMatcherDataDTO{
SegmentName: "segmentito",
},
}
segmentKeys := set.NewSet()
segmentKeys.Add("item1", "item2")
segmentStorage := mutexmap.NewMMSegmentStorage()
segmentStorage.Put("segmentito", segmentKeys, 123)
ctx := injection.NewContext()
ctx.AddDependency("segmentStorage", segmentStorage)
matcher, err := BuildMatcher(dto, ctx, logger)
if err != nil {
t.Error("There should be no errors when building the matcher")
t.Error(err)
}
matcherType := reflect.TypeOf(matcher).String()
if matcherType != "*matchers.InSegmentMatcher" {
t.Errorf("Incorrect matcher constructed. Should be *matchers.InSegmentMatcher and was %s", matcherType)
}
if !matcher.Match("item1", nil, nil) {
t.Error("Should match a key present in the segment")
}
if matcher.Match("item7", nil, nil) {
t.Error("Should not match a key not present in the segment")
}
segmentStorage.Remove("segmentito")
if matcher.Match("item1", nil, nil) {
t.Error("Should return false for a nonexistent segment")
}
} | explode_data.jsonl/10812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
641,
21086,
37554,
1155,
353,
8840,
836,
8,
341,
17060,
1669,
8392,
7121,
7395,
2099,
25263,
12750,
3798,
37790,
98864,
1669,
609,
8047,
436,
76452,
14923,
515,
197,
197,
37554,
929,
25,
330,
687,
87354,
756,
197,
31672,
293... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetImageReferences(t *testing.T) {
references, err := getImageReferences("k8s.gcr.io/kube-apiserver:v1.23.0-alpha.3")
images := map[string]struct {
arch string
os string
}{
"k8s.gcr.io/kube-apiserver@sha256:a82ca097e824f99bfb2b5107aa9c427633f9afb82afd002d59204f39ef81ae70": {"amd64", "linux"},
"k8s.gcr.io/kube-apiserver@sha256:2a11e07f916b5982d9a6e3bbf5defd66ad50359c00b33862552063beb6981aec": {"arm", "linux"},
"k8s.gcr.io/kube-apiserver@sha256:18f97b8c1c9b7b35dea7ba122d86e23066ce347aa8bb75b7346fed3f79d0ea21": {"arm64", "linux"},
"k8s.gcr.io/kube-apiserver@sha256:1a61b61491042e2b1e659c4d57d426d01d9467fb381404bff029be4d00ead519": {"ppc64le", "linux"},
"k8s.gcr.io/kube-apiserver@sha256:3e98f1591a5052791eec71d3c5f5d0fa913140992cb9e1d19fd80a158305c2ff": {"s390x", "linux"},
}
require.NoError(t, err)
// This image should have 5 architectures
require.Len(t, references, 5)
for _, refData := range references {
_, ok := images[refData.Digest]
require.True(t, ok, fmt.Sprintf("Image not found %s", refData.Digest))
require.Equal(t, images[refData.Digest].os, refData.OS)
require.Equal(t, images[refData.Digest].arch, refData.Arch)
}
// Test a sha reference. This is the linux/ppc64le image
singleRef := "k8s.gcr.io/kube-apiserver@sha256:1a61b61491042e2b1e659c4d57d426d01d9467fb381404bff029be4d00ead519"
references, err = getImageReferences(singleRef)
require.NoError(t, err)
require.Len(t, references, 1)
require.Equal(t, singleRef, references[0].Digest)
// Tag with a single image. Image 1.0 is a single image
references, err = getImageReferences("k8s.gcr.io/pause:1.0")
require.NoError(t, err)
require.Len(t, references, 1)
require.Equal(t, "k8s.gcr.io/pause@sha256:a78c2d6208eff9b672de43f880093100050983047b7b0afe0217d3656e1b0d5f", references[0].Digest)
} | explode_data.jsonl/7741 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 849
} | [
2830,
3393,
1949,
1906,
31712,
1155,
353,
8840,
836,
8,
341,
17200,
4901,
11,
1848,
1669,
54561,
31712,
445,
74,
23,
82,
1302,
5082,
4245,
14109,
3760,
12,
13725,
2836,
52649,
16,
13,
17,
18,
13,
15,
64538,
13,
18,
1138,
197,
3642,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTable(t *testing.T) {
mt := "CREATE TABLE IF NOT EXISTS `aa`.`bb` ON CLUSTER bip_ck_cluster\n(\n`insert_id` UInt64 COMMENT '插入id unix timestamp nano second',\n \n `aa` int ,\n `ck_is_delete` UInt8 \tCOMMENT '用于记录删除状态 0为正常状态 1为删除状态'\n ) ENGINE=ReplicatedMergeTree('/clickhouse/tables/{layer}-{shard}/blackhole_aa.bb',\n\t\t\t '{replica}') PARTITION BY toYYYYMM(updateTime) ORDER BY(_id) SETTINGS index_granularity = 8192"
mv := "CREATEMATERIALIZEDVIEWIFNOTEXISTS`aa`.`bb_mv`ONCLUSTERbip_ck_cluster(`insert_id`UInt64COMMENT'插入idunixtimestampnanosecond',`aa`int,`ck_is_delete`UInt8COMMENT'用于记录删除状态0为正常状态1为删除状态')ENGINE=ReplicatedReplacingMergeTree('/clickhouse/tables/{layer}-{shard}/blackhole_aa.bb_mv','{replica}')PARTITIONBYtoYYYYMM(updateTime)ORDERBY_idSETTINGSindex_granularity=8192ASSELECT*FROMaa.bb\n"
mvNow := "CREATEVIEWIFNOTEXISTS`aa`.`bb_now`ONCLUSTERbip_ck_cluster(`insert_id`UInt64COMMENT'插入idunixtimestampnanosecond',`aa`int,`ck_is_delete`UInt8COMMENT'用于记录删除状态0为正常状态1为删除状态')ASSELECT*FROMaa.bb_mvFINALWHEREck_is_delete=0\n"
mvAll := "CREATETABLEIFNOTEXISTS`aa`.`bb_all`ONCLUSTERbip_ck_cluster(`insert_id`UInt64COMMENT'插入idunixtimestampnanosecond',`aa`int,`ck_is_delete`UInt8COMMENT'用于记录删除状态0为正常状态1为删除状态')ENGINE=Distributed('bip_ck_cluster','aa','bb_mv',sipHash64(_id))\n"
all := "CREATETABLEIFNOTEXISTS`aa`.`bb_full_all`ONCLUSTERbip_ck_cluster(`insert_id`UInt64COMMENT'插入idunixtimestampnanosecond',`aa`int,`ck_is_delete`UInt8COMMENT'用于记录删除状态0为正常状态1为删除状态')ENGINE=Distributed('bip_ck_cluster','aa','bb',sipHash64(_id))\n"
Columns := []Column{{"aa", "int", ""}}
d := &TableMeta{
QueryKey: "_id",
Columns: Columns,
DB: "aa",
Table: "bb",
CreateTime: "createTime",
UpdateTime: "updateTime",
Indexes: "_id",
M: nil,
}
cases := []struct {
target string
distribue bool
category int
}{
{target: mt, distribue: true, category: MTLocal},
{target: mv, distribue: true, category: MvLocal},
{target: mvAll, distribue: true, category: MvDistribute},
{target: mvNow, distribue: true, category: MvNow},
{target: all, distribue: true, category: Distribute},
}
for index, Case := range cases {
if removeNewLine(d.CreateTable(Case.category, Case.distribue)) != removeNewLine(Case.target) {
t.Log(removeNewLine(d.CreateTable(Case.category, Case.distribue)))
t.Log(removeNewLine(Case.target))
t.Fatalf("case %d failed", index)
}
}
} | explode_data.jsonl/31890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1280
} | [
2830,
3393,
2556,
1155,
353,
8840,
836,
8,
341,
2109,
83,
1669,
330,
22599,
14363,
11551,
4183,
34839,
1565,
5305,
28905,
6066,
63,
6197,
6976,
46009,
28878,
89236,
28441,
1699,
11520,
77,
63,
4208,
842,
63,
22275,
21,
19,
50505,
364,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplicationContext_UserDefinedTypeProperty(t *testing.T) {
type level int
var config struct {
Duration time.Duration `value:"${duration}"`
Level level `value:"${level}"`
Time time.Time `value:"${time}"`
Complex complex64 // `value:"${complex}"`
}
c := gs.New()
conf.Convert(func(v string) (level, error) {
if v == "debug" {
return 1, nil
}
return 0, errors.New("error level")
})
c.Property("time", "2018-12-20")
c.Property("duration", "1h")
c.Property("level", "debug")
c.Property("complex", "1+i")
c.Object(&config)
err := c.Refresh()
assert.Nil(t, err)
fmt.Printf("%+v\n", config)
} | explode_data.jsonl/17417 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
19736,
31339,
29361,
929,
3052,
1155,
353,
8840,
836,
8,
1476,
13158,
2188,
526,
271,
2405,
2193,
2036,
341,
197,
10957,
2017,
882,
33795,
1565,
957,
2974,
2365,
17021,
92,
8805,
197,
197,
4449,
262,
2188,
260,
1565,
957,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNew(t *testing.T) {
type args struct {
input string
}
tests := []struct {
name string
args args
want *Lexer
}{
{
name: "Setup Correctly",
args: args{
input: "some_identifier",
},
want: &Lexer{
buffer: []rune("some_identifier"),
ch: 's',
position: 0,
nextPosition: 1,
currentChar: 1,
currentLine: 0,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := New(tt.args.input); !reflect.DeepEqual(got, tt.want) {
t.Errorf("New() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/10026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22427,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
353,
92847,
198,
197,
59403,
197,
197,
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... | 2 |
func TestGenericArrayScanScannerArrayBytes(t *testing.T) {
src, expected, nsa := []byte(`{NULL,abc,"\""}`),
[3]sql.NullString{{}, {String: `abc`, Valid: true}, {String: `"`, Valid: true}},
[3]sql.NullString{{String: ``, Valid: true}, {}, {}}
if err := (GenericArray{&nsa}).Scan(src); err != nil {
t.Fatalf("Expected no error, got %v", err)
}
if !reflect.DeepEqual(nsa, expected) {
t.Errorf("Expected %v, got %v", expected, nsa)
}
} | explode_data.jsonl/5340 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
19964,
1857,
26570,
31002,
1857,
7078,
1155,
353,
8840,
836,
8,
341,
41144,
11,
3601,
11,
308,
9081,
1669,
3056,
3782,
5809,
90,
4576,
11,
13683,
1335,
57139,
5541,
1326,
197,
197,
58,
18,
60,
3544,
23979,
703,
2979,
2137,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCooperativeChannelClosure(t *testing.T) {
t.Run("tweakless", func(t *testing.T) {
testCoopClose(t, &coopCloseTestCase{
chanType: channeldb.SingleFunderTweaklessBit,
})
})
t.Run("anchors", func(t *testing.T) {
testCoopClose(t, &coopCloseTestCase{
chanType: channeldb.SingleFunderTweaklessBit |
channeldb.AnchorOutputsBit,
anchorAmt: anchorSize * 2,
})
})
} | explode_data.jsonl/72457 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
7339,
42619,
9629,
53854,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
83,
13150,
1717,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
18185,
7339,
453,
7925,
1155,
11,
609,
86857,
7925,
16458,
515,
298,
197,
5658,
929,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewSetEnvCmd(t *testing.T) {
cmd := NewSetEnvCmd(envFindSetterMock{}, inputTextMock{}, inputListMock{})
cmd.PersistentFlags().Bool("stdin", false, "input by stdin")
if cmd == nil {
t.Errorf("NewSetEnvCmd got %v", cmd)
}
if err := cmd.Execute(); err != nil {
t.Errorf("%s = %v, want %v", cmd.Use, err, nil)
}
} | explode_data.jsonl/14512 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 141
} | [
2830,
3393,
3564,
1649,
14359,
15613,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
1532,
1649,
14359,
15613,
16978,
9885,
44294,
11571,
22655,
1946,
1178,
11571,
22655,
1946,
852,
11571,
37790,
25920,
61655,
9195,
1005,
11233,
445,
51602,
497... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvalidCiid(t *testing.T) {
fileName := "test/iidtestsetInvalid.txt"
file, err := os.Open(fileName)
if err != nil {
t.Errorf("failed to open: %v", fileName)
}
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
i := 0
for scanner.Scan() {
i++
invalidIid := scanner.Text()
ttname := fmt.Sprintf("[%v:%v]", fileName, i)
// Filtering # comments and empty lines
if strings.HasPrefix(invalidIid, "#") || invalidIid == "" {
continue
}
t.Run(ttname, func(t *testing.T) {
m := NewStdCiid(invalidIid)
if got := m.String(); got != "" {
t.Errorf("Iid %v should not be parseble. Parsed to %v", invalidIid, got)
}
})
}
} | explode_data.jsonl/64802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
7928,
34,
54483,
1155,
353,
8840,
836,
8,
341,
17661,
675,
1669,
330,
1944,
16438,
307,
1944,
746,
7928,
3909,
698,
17661,
11,
1848,
1669,
2643,
12953,
23014,
692,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
16091,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSchemaAnnotations(test *testing.T) {
_, err := parseRDLString(`
//this is a schema annotation test
name foo;
version 1
x_something="23"
x_blah = "blah"
type Foo Struct {
String text
}
`)
if err != nil {
test.Errorf("cannot parse valid RDL: %v", err)
return
}
} | explode_data.jsonl/74358 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
8632,
21418,
8623,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
4715,
49,
16524,
703,
61528,
322,
574,
374,
264,
10802,
21223,
1273,
198,
606,
15229,
280,
4366,
220,
16,
198,
87,
643,
11532,
428,
17,
18,
698,
87,
13141... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPersistErrorWithoutLargeWfSupport(t *testing.T) {
defer makeMax()()
cancel, controller := newController()
defer cancel()
ctx := context.Background()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
wf := unmarshalWF(helloWorldWfPersist)
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
controller.offloadNodeStatusRepo, controller.hydrator = getMockDBCtx(errors.New("23324", "test"), false)
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
wf, err = wfcset.Get(ctx, wf.Name, metav1.GetOptions{})
assert.NoError(t, err)
assert.Equal(t, wfv1.NodeError, wf.Status.Phase)
} | explode_data.jsonl/45516 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
61267,
1454,
26040,
34253,
54,
69,
7916,
1155,
353,
8840,
836,
8,
341,
16867,
1281,
5974,
368,
741,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
2822,
20985,
1669,
2266,
19047,
741,
6692,
8316,
746,
1669,
6461,
1418,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_WriteString(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
testRange := getTestRange(streamPosBody, 3*streamBlockSize, 80, 80, 61)
for _, testData := range streamTestSuccessCollections["string"] {
for _, i := range testRange {
stream := NewStream()
stream.SetWritePos(i)
stream.WriteString(testData[0].(string))
assert(stream.GetBuffer()[i:]).Equals(testData[1])
assert(stream.GetWritePos()).
Equals(len(testData[1].([]byte)) + i)
stream.Release()
}
}
})
} | explode_data.jsonl/21209 | {
"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,
3027,
31825,
703,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
18185,
6046,
1669,
633,
2271,
6046,
20574,
4859,
5444,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDataSource_Iterators(t *testing.T) {
extractCoders := func(c *coder.Coder) (WindowEncoder, ElementEncoder, ElementEncoder) {
wc := MakeWindowEncoder(c.Window)
cc := coder.SkipW(c)
kc := MakeElementEncoder(cc.Components[0])
vc := MakeElementEncoder(cc.Components[1])
return wc, kc, vc
}
tests := []struct {
name string
keys, vals []interface{}
Coder *coder.Coder
driver func(c *coder.Coder, dmw io.WriteCloser, siwFn func() io.WriteCloser, ks, vs []interface{})
}{
{
name: "beam:coder:iterable:v1-singleChunk",
keys: []interface{}{int64(42), int64(53)},
vals: []interface{}{int64(1), int64(2), int64(3), int64(4), int64(5)},
Coder: coder.NewW(coder.NewCoGBK([]*coder.Coder{coder.NewVarInt(), coder.NewVarInt()}), coder.NewGlobalWindow()),
driver: func(c *coder.Coder, dmw io.WriteCloser, _ func() io.WriteCloser, ks, vs []interface{}) {
wc, kc, vc := extractCoders(c)
for _, k := range ks {
EncodeWindowedValueHeader(wc, window.SingleGlobalWindow, mtime.ZeroTimestamp, dmw)
kc.Encode(&FullValue{Elm: k}, dmw)
coder.EncodeInt32(int32(len(vs)), dmw) // Number of elements.
for _, v := range vs {
vc.Encode(&FullValue{Elm: v}, dmw)
}
}
dmw.Close()
},
},
{
name: "beam:coder:iterable:v1-multiChunk",
keys: []interface{}{int64(42), int64(53)},
vals: []interface{}{int64(1), int64(2), int64(3), int64(4), int64(5)},
Coder: coder.NewW(coder.NewCoGBK([]*coder.Coder{coder.NewVarInt(), coder.NewVarInt()}), coder.NewGlobalWindow()),
driver: func(c *coder.Coder, dmw io.WriteCloser, _ func() io.WriteCloser, ks, vs []interface{}) {
wc, kc, vc := extractCoders(c)
for _, k := range ks {
EncodeWindowedValueHeader(wc, window.SingleGlobalWindow, mtime.ZeroTimestamp, dmw)
kc.Encode(&FullValue{Elm: k}, dmw)
coder.EncodeInt32(-1, dmw) // Mark this as a multi-Chunk (though beam runner proto says to use 0)
for _, v := range vs {
coder.EncodeVarInt(1, dmw) // Number of elements in this chunk.
vc.Encode(&FullValue{Elm: v}, dmw)
}
coder.EncodeVarInt(0, dmw) // Terminate the multi-chunk for this key.
}
dmw.Close()
},
},
{
name: "beam:coder:state_backed_iterable:v1",
keys: []interface{}{int64(42), int64(53)},
vals: []interface{}{int64(1), int64(2), int64(3), int64(4), int64(5)},
Coder: coder.NewW(coder.NewCoGBK([]*coder.Coder{coder.NewVarInt(), coder.NewVarInt()}), coder.NewGlobalWindow()),
driver: func(c *coder.Coder, dmw io.WriteCloser, swFn func() io.WriteCloser, ks, vs []interface{}) {
wc, kc, vc := extractCoders(c)
for _, k := range ks {
EncodeWindowedValueHeader(wc, window.SingleGlobalWindow, mtime.ZeroTimestamp, dmw)
kc.Encode(&FullValue{Elm: k}, dmw)
coder.EncodeInt32(-1, dmw) // Mark as multi-chunk (though beam, runner says to use 0)
coder.EncodeVarInt(-1, dmw) // Mark subsequent chunks as "state backed"
token := []byte(tokenString)
coder.EncodeVarInt(int64(len(token)), dmw) // token.
dmw.Write(token)
// Each state stream needs to be a different writer, so get a new writer.
sw := swFn()
for _, v := range vs {
vc.Encode(&FullValue{Elm: v}, sw)
}
sw.Close()
}
dmw.Close()
},
},
// TODO: Test progress.
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
out := &IteratorCaptureNode{CaptureNode: CaptureNode{UID: 1}}
source := &DataSource{
UID: 2,
SID: StreamID{PtransformID: "myPTransform"},
Name: test.name,
Coder: test.Coder,
Out: out,
}
dmr, dmw := io.Pipe()
// Simulate individual state channels with pipes and a channel.
sRc := make(chan io.ReadCloser)
swFn := func() io.WriteCloser {
sr, sw := io.Pipe()
sRc <- sr
return sw
}
go test.driver(source.Coder, dmw, swFn, test.keys, test.vals)
constructAndExecutePlanWithContext(t, []Unit{out, source}, DataContext{
Data: &TestDataManager{R: dmr},
State: &TestStateReader{Rc: sRc},
})
if len(out.CapturedInputs) == 0 {
t.Fatal("did not capture source output")
}
expectedKeys := makeValues(test.keys...)
expectedValues := makeValuesNoWindowOrTime(test.vals...)
if got, want := len(out.CapturedInputs), len(expectedKeys); got != want {
t.Fatalf("lengths don't match: got %v, want %v", got, want)
}
var iVals []FullValue
for _, i := range out.CapturedInputs {
iVals = append(iVals, i.Key)
if got, want := i.Values, expectedValues; !equalList(got, want) {
t.Errorf("DataSource => key(%v) = %#v, want %#v", i.Key, extractValues(got...), extractValues(want...))
}
}
if got, want := iVals, expectedKeys; !equalList(got, want) {
t.Errorf("DataSource => %#v, want %#v", extractValues(got...), extractValues(want...))
}
})
}
} | explode_data.jsonl/12052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2222
} | [
2830,
3393,
17173,
7959,
465,
2973,
1155,
353,
8840,
836,
8,
341,
8122,
2144,
34,
52498,
1669,
2915,
1337,
353,
40170,
727,
4316,
8,
320,
4267,
19921,
11,
8543,
19921,
11,
8543,
19921,
8,
341,
197,
88858,
1669,
7405,
4267,
19921,
1337... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckNumPartitionsFn(t *testing.T) {
for _, tc := range []struct {
desc string
numPartitions int
wantPartitions int
wantErr bool
}{
{"same number of partitions",
5,
5,
false,
},
{"different number of partitions",
5,
6,
true,
},
{"got and want zero number of partitions",
0,
0,
false,
},
{"got zero number of partitions want non-zero number of partitions",
0,
5,
true,
},
} {
partitions := make([]int, tc.numPartitions)
p, s, col := ptest.CreateList(partitions)
CheckNumPartitions(s, col, tc.wantPartitions)
if err := ptest.Run(p); (err != nil) != tc.wantErr {
t.Errorf("With %s, got error=%v, wantErr=%t", tc.desc, err, tc.wantErr)
}
}
} | explode_data.jsonl/61195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
3973,
4651,
5800,
5930,
24911,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
41653,
1843,
914,
198,
197,
22431,
5800,
5930,
220,
526,
198,
197,
50780,
5800,
5930,
526,
198,
197,
50780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchema_relayBuiltinTypes(t *testing.T) {
tests := []struct {
name string
want string
}{
{
name: "relayBuiltinTypes",
want: `"""
Define a Relay Cursor type:
https://relay.dev/graphql/connections.htm#sec-Cursor
"""
scalar Cursor
"""
An object with an ID.
Follows the [Relay Global Object Identification Specification](https://relay.dev/graphql/objectidentification.htm)
"""
interface Node @goModel(model: "todo/ent.Noder") {
"""The id of the object."""
id: ID!
}
"""
Information about pagination in a connection.
https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo
"""
type PageInfo {
"""When paginating forwards, are there more items?"""
hasNextPage: Boolean!
"""When paginating backwards, are there more items?"""
hasPreviousPage: Boolean!
"""When paginating backwards, the cursor to continue."""
startCursor: Cursor
"""When paginating forwards, the cursor to continue."""
endCursor: Cursor
}
`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := relayBuiltinTypes("todo/ent")
s := &ast.Schema{}
s.AddTypes(got...)
gots := printSchema(s)
if !reflect.DeepEqual(gots, tt.want) {
t.Errorf("relayBuiltinTypes() = %v, want %v", gots, tt.want)
}
})
}
} | explode_data.jsonl/12086 | {
"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,
8632,
1288,
6651,
33,
25628,
4173,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
90891,
33,
25628,
4173,
756,
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... | 2 |
func TestModelInitializerConfigmap(t *testing.T) {
scenarios := map[string]struct {
original *appsv1.Deployment
expected *appsv1.Deployment
}{
"ModelInitializerConfig": {
original: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
constants.ModelInitializerSourceUriInternalAnnotationKey: "gs://foo",
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "user-container",
},
},
},
},
},
},
expected: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
constants.ModelInitializerSourceUriInternalAnnotationKey: "gs://foo",
},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "user-container",
VolumeMounts: []v1.VolumeMount{
{
Name: "kfserving-provision-location",
MountPath: constants.DefaultModelLocalMountPath,
ReadOnly: true,
},
},
},
},
InitContainers: []v1.Container{
{
Name: "model-initializer",
Image: "kfserving/model-initializer@sha256:xxx",
Args: []string{"gs://foo", constants.DefaultModelLocalMountPath},
VolumeMounts: []v1.VolumeMount{
{
Name: "kfserving-provision-location",
MountPath: constants.DefaultModelLocalMountPath,
},
},
},
},
Volumes: []v1.Volume{
{
Name: "kfserving-provision-location",
VolumeSource: v1.VolumeSource{
EmptyDir: &v1.EmptyDirVolumeSource{},
},
},
},
},
},
},
},
},
}
for name, scenario := range scenarios {
injector := &ModelInitializerInjector{
credentialBuilder: credentials.NewCredentialBulder(c, &v1.ConfigMap{
Data: map[string]string{},
}),
config: &ModelInitializerConfig{
Image: "kfserving/model-initializer@sha256:xxx",
},
}
if err := injector.InjectModelInitializer(scenario.original); err != nil {
t.Errorf("Test %q unexpected result: %s", name, err)
}
if diff := cmp.Diff(scenario.expected.Spec, scenario.original.Spec); diff != "" {
t.Errorf("Test %q unexpected result (-want +got): %v", name, diff)
}
}
} | explode_data.jsonl/14730 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1228
} | [
2830,
3393,
1712,
44251,
2648,
2186,
1155,
353,
8840,
836,
8,
341,
29928,
60494,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
9889,
353,
676,
3492,
16,
34848,
39130,
198,
197,
42400,
353,
676,
3492,
16,
34848,
39130,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestSyncer_verifyApp(t *testing.T) {
boom := errors.New("boom")
s := &snapshot{Height: 3, Format: 1, Chunks: 5, Hash: []byte{1, 2, 3}, trustedAppHash: []byte("app_hash")}
testcases := map[string]struct {
response *abci.ResponseInfo
err error
expectErr error
}{
"verified": {&abci.ResponseInfo{
LastBlockHeight: 3,
LastBlockAppHash: []byte("app_hash"),
AppVersion: 9,
}, nil, nil},
"invalid height": {&abci.ResponseInfo{
LastBlockHeight: 5,
LastBlockAppHash: []byte("app_hash"),
AppVersion: 9,
}, nil, errVerifyFailed},
"invalid hash": {&abci.ResponseInfo{
LastBlockHeight: 3,
LastBlockAppHash: []byte("xxx"),
AppVersion: 9,
}, nil, errVerifyFailed},
"error": {nil, boom, boom},
}
for name, tc := range testcases {
tc := tc
t.Run(name, func(t *testing.T) {
connQuery := &proxymocks.AppConnQuery{}
connSnapshot := &proxymocks.AppConnSnapshot{}
stateProvider := &mocks.StateProvider{}
syncer := newSyncer(log.NewNopLogger(), connSnapshot, connQuery, stateProvider, "")
connQuery.On("InfoSync", proxy.RequestInfo).Return(tc.response, tc.err)
version, err := syncer.verifyApp(s)
unwrapped := errors.Unwrap(err)
if unwrapped != nil {
err = unwrapped
}
assert.Equal(t, tc.expectErr, err)
if err == nil {
assert.Equal(t, tc.response.AppVersion, version)
}
})
}
} | explode_data.jsonl/46295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 602
} | [
2830,
3393,
12154,
261,
35638,
2164,
1155,
353,
8840,
836,
8,
341,
197,
95316,
1669,
5975,
7121,
445,
95316,
1138,
1903,
1669,
609,
35501,
90,
3640,
25,
220,
18,
11,
15042,
25,
220,
16,
11,
910,
15296,
25,
220,
20,
11,
6531,
25,
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... | 3 |
func TestGetFailure(t *testing.T) {
var want = ""
var got = Get("Gondor")
if got != want {
t.Errorf("Expected to get %v, got %v instead", want, got)
}
} | explode_data.jsonl/52092 | {
"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,
1949,
17507,
1155,
353,
8840,
836,
8,
341,
2405,
1366,
284,
8389,
2405,
2684,
284,
2126,
445,
38,
2111,
269,
5130,
743,
2684,
961,
1366,
341,
197,
3244,
13080,
445,
18896,
311,
633,
1018,
85,
11,
2684,
1018,
85,
4518,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckError(t *testing.T) {
assert.Panics(t, assert.PanicTestFunc(func() {
Check(errors.New("something"))
}))
assert.NotPanics(t, assert.PanicTestFunc(func() {
Check(nil)
}))
} | explode_data.jsonl/72 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
3973,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
1069,
276,
1211,
1155,
11,
2060,
1069,
31270,
2271,
9626,
18552,
368,
341,
197,
69472,
38881,
7121,
445,
33331,
5455,
197,
93596,
6948,
15000,
35693,
1211,
1155,
11,
2060,
1069... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAcls_CreateAclsSuccess(t *testing.T) {
mock := MockHttpClient{}
mk := MockKafkaClient{}
mock.DoRequestFn = func(method string, uri string, reqBody io.Reader) (responseBody []byte, statusCode int, status string, err error) {
assert.Equal(t, http.MethodPost, method, "Expected method 'POST', got %s", method)
assert.Equal(t, "/clusters/cluster-1/acls", uri)
return []byte(``), 201, "201", nil
}
clusterAdmin, _ := mk.NewSaramaClusterAdmin()
c := NewClient(&mock, &mk, clusterAdmin)
aclConfig := Acl{}
err := c.CreateAcl("cluster-1", &aclConfig)
assert.NoError(t, err)
} | explode_data.jsonl/10190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
32,
18074,
34325,
32,
18074,
7188,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
14563,
26316,
16094,
2109,
74,
1669,
14563,
42,
21883,
2959,
16094,
77333,
33596,
1900,
24911,
284,
2915,
17262,
914,
11,
13071,
914,
11,
4232,
54... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConsumer(t *testing.T) {
mt := mocktracer.Start()
defer mt.Stop()
broker := sarama.NewMockBroker(t, 0)
defer broker.Close()
broker.SetHandlerByMap(map[string]sarama.MockResponse{
"MetadataRequest": sarama.NewMockMetadataResponse(t).
SetBroker(broker.Addr(), broker.BrokerID()).
SetLeader("test-topic", 0, broker.BrokerID()),
"OffsetRequest": sarama.NewMockOffsetResponse(t).
SetOffset("test-topic", 0, sarama.OffsetOldest, 0).
SetOffset("test-topic", 0, sarama.OffsetNewest, 1),
"FetchRequest": sarama.NewMockFetchResponse(t, 1).
SetMessage("test-topic", 0, 0, sarama.StringEncoder("hello")).
SetMessage("test-topic", 0, 1, sarama.StringEncoder("world")),
})
cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
client, err := sarama.NewClient([]string{broker.Addr()}, cfg)
if err != nil {
t.Fatal(err)
}
defer client.Close()
consumer, err := sarama.NewConsumerFromClient(client)
if err != nil {
t.Fatal(err)
}
defer consumer.Close()
consumer = WrapConsumer(consumer)
partitionConsumer, err := consumer.ConsumePartition("test-topic", 0, 0)
if err != nil {
t.Fatal(err)
}
msg1 := <-partitionConsumer.Messages()
msg2 := <-partitionConsumer.Messages()
partitionConsumer.Close()
// wait for the channel to be closed
<-partitionConsumer.Messages()
spans := mt.FinishedSpans()
assert.Len(t, spans, 2)
{
s := spans[0]
spanctx, err := tracer.Extract(NewConsumerMessageCarrier(msg1))
assert.NoError(t, err)
assert.Equal(t, spanctx.TraceID(), s.TraceID(),
"span context should be injected into the consumer message headers")
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, int64(0), s.Tag("offset"))
assert.Equal(t, "kafka", s.Tag(ext.ServiceName))
assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName))
assert.Equal(t, "queue", s.Tag(ext.SpanType))
assert.Equal(t, "kafka.consume", s.OperationName())
}
{
s := spans[1]
spanctx, err := tracer.Extract(NewConsumerMessageCarrier(msg2))
assert.NoError(t, err)
assert.Equal(t, spanctx.TraceID(), s.TraceID(),
"span context should be injected into the consumer message headers")
assert.Equal(t, int32(0), s.Tag("partition"))
assert.Equal(t, int64(1), s.Tag("offset"))
assert.Equal(t, "kafka", s.Tag(ext.ServiceName))
assert.Equal(t, "Consume Topic test-topic", s.Tag(ext.ResourceName))
assert.Equal(t, "queue", s.Tag(ext.SpanType))
assert.Equal(t, "kafka.consume", s.OperationName())
}
} | explode_data.jsonl/28003 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 984
} | [
2830,
3393,
29968,
1155,
353,
8840,
836,
8,
341,
2109,
83,
1669,
7860,
94941,
12101,
741,
16867,
11965,
30213,
2822,
2233,
45985,
1669,
274,
637,
64,
7121,
11571,
65545,
1155,
11,
220,
15,
340,
16867,
22316,
10421,
2822,
2233,
45985,
42... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateKeyErrors(t *testing.T) {
invalidTables := []struct {
name string
key Key
err error
}{
{"empty key", Key{
KeyID: "",
KeyIDHashAlgorithms: nil,
KeyType: "",
KeyVal: KeyVal{},
Scheme: "",
}, ErrInvalidHexString},
{"keytype missing", Key{
KeyID: "bad",
KeyIDHashAlgorithms: []string{"sha256"},
KeyType: "",
KeyVal: KeyVal{
Private: "",
Public: "",
},
Scheme: "rsassa-psa-sha256",
}, ErrEmptyKeyField},
{"key scheme missing", Key{
KeyID: "bad",
KeyIDHashAlgorithms: []string{"sha256"},
KeyType: "ed25519",
KeyVal: KeyVal{
Private: "bad",
Public: "bad",
},
Scheme: "",
}, ErrEmptyKeyField},
{
name: "invalid key type",
key: Key{
KeyID: "bad",
KeyIDHashAlgorithms: []string{"sha256"},
KeyType: "invalid",
KeyVal: KeyVal{
Private: "invalid",
Public: "393e671b200f964c49083d34a867f5d989ec1c69df7b66758fe471c8591b139c",
},
Scheme: "ed25519",
},
err: ErrUnsupportedKeyType,
},
{
name: "keytype scheme mismatch",
key: Key{
KeyID: "be6371bc627318218191ce0780fd3183cce6c36da02938a477d2e4dfae1804a6",
KeyIDHashAlgorithms: []string{"sha256"},
KeyType: "ed25519",
KeyVal: KeyVal{
Private: "29ad59693fe94c9d623afbb66554b4f6bb248c47761689ada4875ebda94840ae393e671b200f964c49083d34a867f5d989ec1c69df7b66758fe471c8591b139c",
Public: "393e671b200f964c49083d34a867f5d989ec1c69df7b66758fe471c8591b139c",
},
Scheme: "rsassa-pss-sha256",
},
err: ErrSchemeKeyTypeMismatch,
},
{
name: "unsupported KeyIDHashAlgorithms",
key: Key{
KeyID: "be6371bc627318218191ce0780fd3183cce6c36da02938a477d2e4dfae1804a6",
KeyIDHashAlgorithms: []string{"sha128"},
KeyType: "ed25519",
KeyVal: KeyVal{
Private: "29ad59693fe94c9d623afbb66554b4f6bb248c47761689ada4875ebda94840ae393e671b200f964c49083d34a867f5d989ec1c69df7b66758fe471c8591b139c",
Public: "393e671b200f964c49083d34a867f5d989ec1c69df7b66758fe471c8591b139c",
},
Scheme: "ed25519",
},
err: ErrUnsupportedKeyIDHashAlgorithms,
},
}
for _, table := range invalidTables {
err := validateKey(table.key)
if !errors.Is(err, table.err) {
t.Errorf("test '%s' failed, expected error: '%s', got '%s'", table.name, table.err, err)
}
}
} | explode_data.jsonl/51772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1351
} | [
2830,
3393,
17926,
1592,
13877,
1155,
353,
8840,
836,
8,
341,
197,
11808,
21670,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
23634,
220,
5309,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
4913,
3194,
1376,
497,
5309,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMuxer_RemoteStreamCloseDuringRead(t *testing.T) {
r1, w1 := io.Pipe()
r2, w2 := io.Pipe()
alice := NewMuxer(NewReadWriteCloser(r1, w2), false)
defer func() { assert.NoError(t, alice.Close()) }()
bob := NewMuxer(NewReadWriteCloser(r2, w1), true)
defer func() { assert.NoError(t, bob.Close()) }()
id, as := alice.Serve()
bs := bob.Connect(id)
go func() {
as.Write([]byte("foo"))
as.Close()
}()
buf := make([]byte, 20)
n, err := bs.Read(buf)
assert.Equal(t, 3, n)
assert.Equal(t, "foo", string(buf[:n]))
n, err = bs.Read(buf)
assert.Equal(t, 0, n)
assert.Equal(t, io.EOF, err)
} | explode_data.jsonl/49634 | {
"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,
44,
2200,
261,
54551,
1272,
3027,
7925,
16014,
4418,
1155,
353,
8840,
836,
8,
341,
7000,
16,
11,
289,
16,
1669,
6399,
1069,
3444,
741,
7000,
17,
11,
289,
17,
1669,
6399,
1069,
3444,
2822,
197,
63195,
1669,
1532,
44,
2200... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEarlyTermNoTraversalString(t *testing.T) {
alpha := 2
vtxID := ids.ID{1}
vdr1 := ids.ShortID{1}
vdr2 := ids.ShortID{2} // k = 2
vdrs := ids.ShortBag{}
vdrs.Add(
vdr1,
vdr2,
)
factory := NewEarlyTermNoTraversalFactory(alpha)
poll := factory.New(vdrs)
poll.Vote(vdr1, vtxID)
expected := "waiting on Bag: (Size = 1)\n" +
" ID[BaMPFdqMUQ46BV8iRcwbVfsam55kMqcp]: Count = 1"
if result := poll.String(); expected != result {
t.Fatalf("Poll should have returned %s but returned %s", expected, result)
}
} | explode_data.jsonl/41156 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
41198,
17249,
2753,
76276,
703,
1155,
353,
8840,
836,
8,
341,
73063,
1669,
220,
17,
271,
5195,
3998,
915,
1669,
14151,
9910,
90,
16,
630,
5195,
3612,
16,
1669,
14151,
55958,
915,
90,
16,
532,
5195,
3612,
17,
1669,
14151,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestAbsPathJoins(t *testing.T) {
r := (&Request{baseURL: &url.URL{}}).AbsPath("foo/bar", "baz")
if s := r.URL().String(); s != "foo/bar/baz" {
t.Errorf("trailing slash should be preserved: %s", s)
}
} | explode_data.jsonl/13250 | {
"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,
1900,
27778,
1820,
22493,
1330,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
15899,
1900,
90,
3152,
3144,
25,
609,
1085,
20893,
90,
3417,
568,
27778,
1820,
445,
7975,
49513,
497,
330,
42573,
1138,
743,
274,
1669,
435,
20893,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportFromDisk(t *testing.T) {
RegisterTestingT(t)
unit := NewHoverflyWithConfiguration(&Configuration{})
err := unit.Import(hoverfly_io_simulation_path)
Expect(err).To(BeNil())
Expect(unit.Simulation.GetMatchingPairs()).To(HaveLen(2))
} | explode_data.jsonl/75446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
11511,
3830,
47583,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
81189,
1669,
1532,
34379,
21642,
2354,
7688,
2099,
7688,
6257,
692,
9859,
1669,
4982,
67275,
3203,
1975,
21642,
16939,
82487,
2638,
340,
35911,
396... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecover_startHandlerFunc_POST(t *testing.T) {
t.Parallel()
rec, storer, _ := testSetup()
storer.Users["john"] = authboss.Attributes{authboss.StoreUsername: "john", authboss.StoreEmail: "a@b.c"}
sentEmail := false
goRecoverEmail = func(_ *Recover, _ *authboss.Context, _, _ string) {
sentEmail = true
}
ctx, w, r, sessionStorer := testRequest(rec.Authboss, "POST", "username", "john", "confirm_username", "john")
if err := rec.startHandlerFunc(ctx, w, r); err != nil {
t.Error("Unexpected error:", err)
}
if !sentEmail {
t.Error("Expected email to have been sent")
}
if val, err := storer.Users["john"].StringErr(StoreRecoverToken); err != nil {
t.Error("Unexpected error:", err)
} else if len(val) <= 0 {
t.Error("Unexpected Recover Token to be set")
}
if val, err := storer.Users["john"].DateTimeErr(StoreRecoverTokenExpiry); err != nil {
t.Error("Unexpected error:", err)
} else if !val.After(time.Now()) {
t.Error("Expected recovery token expiry to be greater than now")
}
if w.Code != http.StatusFound {
t.Error("Unexpected status:", w.Code)
}
loc := w.Header().Get("Location")
if loc != rec.RecoverOKPath {
t.Error("Unexpected location:", loc)
}
if value, ok := sessionStorer.Get(authboss.FlashSuccessKey); !ok {
t.Error("Expected success flash message")
} else if value != recoverInitiateSuccessFlash {
t.Error("Unexpected success flash message")
}
} | explode_data.jsonl/61496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 515
} | [
2830,
3393,
693,
3688,
4906,
3050,
9626,
20506,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
67904,
11,
357,
14827,
11,
716,
1669,
1273,
21821,
2822,
18388,
14827,
36782,
1183,
47817,
1341,
284,
4166,
33314,
31384,
90,
3242,
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 TestSyncPodWithInitContainers(t *testing.T) {
fakeRuntime, _, m, err := createTestRuntimeManager()
assert.NoError(t, err)
initContainers := []v1.Container{
{
Name: "init1",
Image: "init",
ImagePullPolicy: v1.PullIfNotPresent,
},
}
containers := []v1.Container{
{
Name: "foo1",
Image: "busybox",
ImagePullPolicy: v1.PullIfNotPresent,
},
{
Name: "foo2",
Image: "alpine",
ImagePullPolicy: v1.PullIfNotPresent,
},
}
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "12345678",
Name: "foo",
Namespace: "new",
},
Spec: v1.PodSpec{
Containers: containers,
InitContainers: initContainers,
},
}
backOff := flowcontrol.NewBackOff(time.Second, time.Minute)
// 1. should only create the init container.
podStatus, err := m.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
assert.NoError(t, err)
result := m.SyncPod(pod, podStatus, []v1.Secret{}, backOff)
assert.NoError(t, result.Error())
expected := []*cRecord{
{name: initContainers[0].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_RUNNING},
}
verifyContainerStatuses(t, fakeRuntime, expected, "start only the init container")
// 2. should not create app container because init container is still running.
podStatus, err = m.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
assert.NoError(t, err)
result = m.SyncPod(pod, podStatus, []v1.Secret{}, backOff)
assert.NoError(t, result.Error())
verifyContainerStatuses(t, fakeRuntime, expected, "init container still running; do nothing")
// 3. should create all app containers because init container finished.
// Stop init container instance 0.
sandboxIDs, err := m.getSandboxIDByPodUID(pod.UID, nil)
require.NoError(t, err)
sandboxID := sandboxIDs[0]
initID0, err := fakeRuntime.GetContainerID(sandboxID, initContainers[0].Name, 0)
require.NoError(t, err)
fakeRuntime.StopContainer(initID0, 0)
// Sync again.
podStatus, err = m.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
assert.NoError(t, err)
result = m.SyncPod(pod, podStatus, []v1.Secret{}, backOff)
assert.NoError(t, result.Error())
expected = []*cRecord{
{name: initContainers[0].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{name: containers[0].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_RUNNING},
{name: containers[1].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_RUNNING},
}
verifyContainerStatuses(t, fakeRuntime, expected, "init container completed; all app containers should be running")
// 4. should restart the init container if needed to create a new podsandbox
// Stop the pod sandbox.
fakeRuntime.StopPodSandbox(sandboxID)
// Sync again.
podStatus, err = m.GetPodStatus(pod.UID, pod.Name, pod.Namespace)
assert.NoError(t, err)
result = m.SyncPod(pod, podStatus, []v1.Secret{}, backOff)
assert.NoError(t, result.Error())
expected = []*cRecord{
// The first init container instance is purged and no longer visible.
// The second (attempt == 1) instance has been started and is running.
{name: initContainers[0].Name, attempt: 1, state: runtimeapi.ContainerState_CONTAINER_RUNNING},
// All containers are killed.
{name: containers[0].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_EXITED},
{name: containers[1].Name, attempt: 0, state: runtimeapi.ContainerState_CONTAINER_EXITED},
}
verifyContainerStatuses(t, fakeRuntime, expected, "kill all app containers, purge the existing init container, and restart a new one")
} | explode_data.jsonl/13377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1318
} | [
2830,
3393,
12154,
23527,
2354,
3803,
74632,
1155,
353,
8840,
836,
8,
341,
1166,
726,
15123,
11,
8358,
296,
11,
1848,
1669,
1855,
2271,
15123,
2043,
741,
6948,
35699,
1155,
11,
1848,
692,
28248,
74632,
1669,
3056,
85,
16,
33672,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQuitShouldCloseCompletionsChannel(t *testing.T) {
worker := work.NewWorker(1, func(p work.Payload) interface{} {
return fmt.Sprintf("%s.", p.Data)
}, true)
worker.Quit()
_, ok := <-worker.Completions()
assert.Equal(t, false, ok, "The completions channel was not closed")
} | explode_data.jsonl/11917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
42856,
14996,
7925,
1092,
10819,
908,
9629,
1155,
353,
8840,
836,
8,
341,
197,
21462,
1669,
975,
7121,
21936,
7,
16,
11,
2915,
1295,
975,
86432,
8,
3749,
6257,
341,
197,
853,
8879,
17305,
4430,
82,
10465,
281,
3336,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFormatModulesRaw(t *testing.T) {
bundle1 := Bundle{
Modules: []ModuleFile{
{
URL: "/foo/corge/corge.rego",
Path: "/foo/corge/corge.rego",
Parsed: ast.MustParseModule(`package foo.corge`),
Raw: []byte("package foo.corge\n"),
},
},
}
bundle2 := Bundle{
Modules: []ModuleFile{
{
URL: "/foo/corge/corge.rego",
Path: "/foo/corge/corge.rego",
Parsed: ast.MustParseModule(`package foo.corge`),
Raw: []byte("package foo.corge"),
},
},
}
tests := map[string]struct {
bundle Bundle
exp bool
}{
"equal": {bundle: bundle1, exp: true},
"not_equal": {bundle: bundle2, exp: false},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
orig := tc.bundle.Modules[0].Raw
err := tc.bundle.FormatModules(false)
if err != nil {
t.Fatal("Unexpected error:", err)
}
actual := bytes.Equal(orig, tc.bundle.Modules[0].Raw)
if actual != tc.exp {
t.Fatalf("Expected result %v but got %v", tc.exp, actual)
}
})
}
} | explode_data.jsonl/55385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
4061,
28201,
20015,
1155,
353,
8840,
836,
8,
1476,
2233,
4206,
16,
1669,
13182,
515,
197,
197,
28201,
25,
3056,
3332,
1703,
515,
298,
197,
515,
571,
79055,
25,
262,
3521,
7975,
2899,
6670,
2899,
6670,
1327,
3346,
756,
571,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPopulateCluster_Default_NoError(t *testing.T) {
c := buildMinimalCluster()
cloud, err := BuildCloud(c)
if err != nil {
t.Fatalf("error from BuildCloud: %v", err)
}
err = PerformAssignments(c, cloud)
if err != nil {
t.Fatalf("error from PerformAssignments: %v", err)
}
_, err = mockedPopulateClusterSpec(c)
if err != nil {
t.Fatalf("Unexpected error from PopulateCluster: %v", err)
}
} | explode_data.jsonl/75030 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
11598,
6334,
28678,
60336,
36989,
1454,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
88328,
28678,
741,
197,
12361,
11,
1848,
1669,
7854,
16055,
1337,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
504,
7854,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPHandlerErrors(t *testing.T) {
testCases := []struct {
description string
mockSamplingResponse *sampling.SamplingStrategyResponse
mockBaggageResponse []*baggage.BaggageRestriction
url string
statusCode int
body string
metrics []mTestutils.ExpectedMetric
}{
{
description: "no service name",
url: "",
statusCode: http.StatusBadRequest,
body: "'service' parameter must be provided once\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "4xx"}, Value: 1},
},
},
{
description: "sampling endpoint too many service names",
url: "?service=Y&service=Y",
statusCode: http.StatusBadRequest,
body: "'service' parameter must be provided once\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "4xx"}, Value: 1},
},
},
{
description: "baggage endpoint too many service names",
url: "/baggageRestrictions?service=Y&service=Y",
statusCode: http.StatusBadRequest,
body: "'service' parameter must be provided once\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "4xx"}, Value: 1},
},
},
{
description: "sampler tcollector error",
url: "?service=Y",
statusCode: http.StatusInternalServerError,
body: "tcollector error: no mock response provided\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "5xx", "type": "tcollector-proxy"}, Value: 1},
},
},
{
description: "baggage tcollector error",
url: "/baggageRestrictions?service=Y",
statusCode: http.StatusInternalServerError,
body: "tcollector error: no mock response provided\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "5xx", "type": "tcollector-proxy"}, Value: 1},
},
},
{
description: "sampler marshalling error",
mockSamplingResponse: probabilistic(math.NaN()),
url: "?service=Y",
statusCode: http.StatusInternalServerError,
body: "Cannot marshall Thrift to JSON\n",
metrics: []mTestutils.ExpectedMetric{
{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "5xx", "type": "thrift"}, Value: 1},
},
},
}
for _, tc := range testCases {
testCase := tc // capture loop var
t.Run(testCase.description, func(t *testing.T) {
withServer(testCase.mockSamplingResponse, testCase.mockBaggageResponse, func(ts *testServer) {
resp, err := http.Get(ts.server.URL + testCase.url)
require.NoError(t, err)
assert.Equal(t, testCase.statusCode, resp.StatusCode)
if testCase.body != "" {
body, err := ioutil.ReadAll(resp.Body)
assert.NoError(t, err)
assert.Equal(t, testCase.body, string(body))
}
if len(testCase.metrics) > 0 {
mTestutils.AssertCounterMetrics(t, ts.metricsFactory, testCase.metrics...)
}
})
})
}
t.Run("failure to write a response", func(t *testing.T) {
withServer(probabilistic(0.001), restrictions("luggage", 10), func(ts *testServer) {
handler := newHTTPHandler(ts.mgr, ts.metricsFactory)
req := httptest.NewRequest("GET", "http://localhost:80/?service=X", nil)
w := &mockWriter{header: make(http.Header)}
handler.serveSamplingHTTP(w, req, false)
mTestutils.AssertCounterMetrics(t, ts.metricsFactory,
mTestutils.ExpectedMetric{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "5xx", "type": "write"}, Value: 1})
req = httptest.NewRequest("GET", "http://localhost:80/baggageRestrictions?service=X", nil)
handler.serveBaggageHTTP(w, req)
mTestutils.AssertCounterMetrics(t, ts.metricsFactory,
mTestutils.ExpectedMetric{Name: "http-server.requests", Tags: map[string]string{"result": "err", "status": "5xx", "type": "write"}, Value: 2})
})
})
} | explode_data.jsonl/58652 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1758
} | [
2830,
3393,
9230,
3050,
13877,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
42407,
688,
914,
198,
197,
77333,
98622,
2582,
353,
96959,
808,
29709,
19816,
2582,
198,
197,
77333,
12933,
14943,
2582,
220,
29838,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMqMsgStream_GetProduceChannels(t *testing.T) {
f := &fixture{t: t}
parameters := f.setup()
defer f.teardown()
factory := &ProtoUDFactory{}
for i := range parameters {
func(client mqclient.Client) {
m, err := NewMqMsgStream(context.Background(), 100, 100, client, factory.NewUnmarshalDispatcher())
assert.Nil(t, err)
// empty if not called AsProducer yet
chs := m.GetProduceChannels()
assert.Equal(t, 0, len(chs))
// not empty after AsProducer
m.AsProducer([]string{"a"})
chs = m.GetProduceChannels()
assert.Equal(t, 1, len(chs))
}(parameters[i].client)
}
} | explode_data.jsonl/55280 | {
"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,
44,
80,
6611,
3027,
13614,
1336,
13373,
35925,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
609,
59612,
90,
83,
25,
259,
532,
67543,
1669,
282,
25338,
741,
16867,
282,
31853,
37496,
2822,
1166,
2919,
1669,
609,
31549,
4656,
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... | 1 |
func TestIssue15986(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t0")
tk.MustExec("CREATE TABLE t0(c0 int)")
tk.MustExec("INSERT INTO t0 VALUES (0)")
tk.MustQuery("SELECT t0.c0 FROM t0 WHERE CHAR(204355900);").Check(testkit.Rows("0"))
tk.MustQuery("SELECT t0.c0 FROM t0 WHERE not CHAR(204355900);").Check(testkit.Rows())
tk.MustQuery("SELECT t0.c0 FROM t0 WHERE '.0';").Check(testkit.Rows())
tk.MustQuery("SELECT t0.c0 FROM t0 WHERE not '.0';").Check(testkit.Rows("0"))
// If the number does not exceed the range of float64 and its value is not 0, it will be converted to true.
tk.MustQuery("select * from t0 where '.000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000009';").Check(testkit.Rows("0"))
tk.MustQuery("select * from t0 where not '.000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"0000000000000000000000000000000000000000000000000000000000000000009';").Check(testkit.Rows())
// If the number is truncated beyond the range of float64, it will be converted to true when the truncated result is 0.
tk.MustQuery("select * from t0 where '.0000000000000000000000000000000000000000000000000000000" +
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000009';").Check(testkit.Rows())
tk.MustQuery("select * from t0 where not '.0000000000000000000000000000000000000000000000000000000" +
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000009';").Check(testkit.Rows("0"))
} | explode_data.jsonl/65518 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 570
} | [
2830,
3393,
42006,
16,
20,
24,
23,
21,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoDisplayImpInsertion(t *testing.T) {
data := interpolateImpressions(openrtb2.Bid{
AdM: sampleDisplayADM,
NURL: "https://example2.com/nurl",
}, amxBidExt{Himp: []string{"https://example.com/pixel.png"}})
assert.NotContains(t, data, "example2.com/nurl")
assert.NotContains(t, data, "example.com/pixel.png")
} | explode_data.jsonl/7175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
2753,
7020,
25216,
13780,
290,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
59457,
25216,
673,
908,
30981,
3342,
65,
17,
1785,
307,
515,
197,
197,
2589,
44,
25,
220,
6077,
7020,
50249,
345,
197,
18317,
3144,
25,
330,
2428,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.