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 TestStartExecutionSpanWithPayload(t *testing.T) {
defer reset()
testString := `a5a{"resource":"/users/create","path":"/users/create","httpMethod":"GET","headers":{"Accept":"*/*","Accept-Encoding":"gzip","x-datadog-parent-id":"1480558859903409531","x-datadog-sampling-priority":"1","x-datadog-trace-id":"5736943178450432258"}}0`
startTime := time.Now()
startExecutionSpan(startTime, testString, LambdaInvokeEventHeaders{})
assert.Equal(t, startTime, currentExecutionInfo.startTime)
assert.Equal(t, uint64(5736943178450432258), currentExecutionInfo.traceID)
assert.Equal(t, uint64(1480558859903409531), currentExecutionInfo.parentID)
assert.NotEqual(t, 0, currentExecutionInfo.spanID)
} | explode_data.jsonl/2345 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
3479,
20294,
12485,
2354,
29683,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
741,
18185,
703,
1669,
1565,
64,
20,
64,
4913,
9233,
58528,
4218,
25577,
2198,
2343,
58528,
4218,
25577,
2198,
1254,
3523,
3252,
3806,
2198,
7713,
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 TestImageStretch(t *testing.T) {
img0, _ := NewImage(16, 17, FilterDefault)
pix := make([]byte, 4*16*17)
for i := 0; i < 16*16; i++ {
pix[4*i] = 0xff
pix[4*i+3] = 0xff
}
for i := 0; i < 16; i++ {
pix[4*(16*16+i)+1] = 0xff
pix[4*(16*16+i)+3] = 0xff
}
img0.ReplacePixels(pix)
// TODO: 4096 doesn't pass on MacBook Pro (#611).
const h = 2048
img1, _ := NewImage(16, h, FilterDefault)
for i := 1; i < h; i++ {
img1.Clear()
op := &DrawImageOptions{}
op.GeoM.Scale(1, float64(i)/16)
r := image.Rect(0, 0, 16, 16)
op.SourceRect = &r
img1.DrawImage(img0, op)
for j := -1; j <= 1; j++ {
got := img1.At(0, i+j).(color.RGBA)
want := color.RGBA{}
if j < 0 {
want = color.RGBA{0xff, 0, 0, 0xff}
}
if got != want {
t.Errorf("At(%d, %d) (i=%d): got: %#v, want: %#v", 0, i+j, i, got, want)
}
}
}
} | explode_data.jsonl/10907 | {
"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,
1906,
53898,
1155,
353,
8840,
836,
8,
341,
39162,
15,
11,
716,
1669,
1532,
1906,
7,
16,
21,
11,
220,
16,
22,
11,
12339,
3675,
692,
3223,
941,
1669,
1281,
10556,
3782,
11,
220,
19,
9,
16,
21,
9,
16,
22,
340,
2023,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestApplyPatch(t *testing.T) {
config := `build:
artifacts:
- image: example
profiles:
- name: patches
patches:
- path: /build/artifacts/0/image
value: replacement
- op: add
path: /build/artifacts/0/docker
value:
dockerfile: Dockerfile.DEV
- op: add
path: /build/artifacts/-
value:
image: second
docker:
dockerfile: Dockerfile.second
`
tmp, cleanup := testutil.NewTempDir(t)
defer cleanup()
yaml := fmt.Sprintf("apiVersion: %s\nkind: Config\n%s", latest.Version, config)
tmp.Write("skaffold.yaml", yaml)
parsed, err := ParseConfig(tmp.Path("skaffold.yaml"), false)
testutil.CheckError(t, false, err)
skaffoldConfig := parsed.(*latest.SkaffoldConfig)
err = ApplyProfiles(skaffoldConfig, &cfg.SkaffoldOptions{
Profiles: []string{"patches"},
})
testutil.CheckError(t, false, err)
testutil.CheckDeepEqual(t, "replacement", skaffoldConfig.Build.Artifacts[0].ImageName)
testutil.CheckDeepEqual(t, "Dockerfile.DEV", skaffoldConfig.Build.Artifacts[0].DockerArtifact.DockerfilePath)
testutil.CheckDeepEqual(t, "Dockerfile.second", skaffoldConfig.Build.Artifacts[1].DockerArtifact.DockerfilePath)
} | explode_data.jsonl/32845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 447
} | [
2830,
3393,
28497,
43622,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1565,
5834,
510,
220,
35036,
510,
220,
481,
2168,
25,
3110,
198,
56195,
510,
12,
829,
25,
28660,
198,
220,
28660,
510,
220,
481,
1815,
25,
608,
5834,
55549,
26401,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPathHandling(t *testing.T) {
t.Run("Incoming Request", func(t *testing.T) {
path, err := NewPath(`/path/to/:something/$id<[0-9]+>/*foo`)
assert.NoError(t, err)
t.Run("Should properly parse request path's", func(t *testing.T) {
assert.NotNil(t, path)
var match = path.Match(`/path/to/something123/445566/foo/bar`)
assert.NotNil(t, match)
assert.Equal(t, "something123", match.Values["something"])
assert.Equal(t, "445566", match.Values["id"])
assert.Equal(t, "foo/bar", match.Values["foo"])
})
t.Run("Should properly render the path", func(t *testing.T) {
p, err := path.Render(map[string]string{
"something": "something123",
"id": "445566",
"foo": "foo/bar",
}, map[string]struct{}{})
assert.NoError(t, err)
assert.Equal(t, `/path/to/something123/445566/foo/bar`, p)
_, err = path.Render(map[string]string{
"something": "something123",
"id": "aaa",
"foo": "foo/bar",
}, map[string]struct{}{})
assert.EqualError(t, err, `param id in wrong format`)
})
})
t.Run("Fixed part matching", func(t *testing.T) {
path, err := NewPath(`/path/to/something`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/something`))
assert.Empty(t, path.Match(`/path/to/something`).Values)
assert.Nil(t, path.Match(`/pat/to/something`))
})
t.Run("Param part matching", func(t *testing.T) {
t.Run("Should match the different parameters", func(t *testing.T) {
path, err := NewPath(`/path/to/:something/:else/end`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/something/else/end`))
assert.Equal(t, "something", path.Match(`/path/to/something/else/end`).Values["something"])
assert.Equal(t, "else", path.Match(`/path/to/something/else/end`).Values["else"])
assert.Equal(t, "foo", path.Match(`/path/to/foo/bar/end`).Values["something"])
assert.Equal(t, "bar", path.Match(`/path/to/foo/bar/end`).Values["else"])
assert.Nil(t, path.Match(`/path/to/foo/bar`))
assert.Equal(t, "", path.Match(`/path/to///end`).Values["something"])
assert.Equal(t, "", path.Match(`/path/to///end`).Values["else"])
})
t.Run("Edge-case at the end", func(t *testing.T) {
path, err := NewPath(`/path/to/:something`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/something`))
assert.Equal(t, "something", path.Match(`/path/to/something`).Values["something"])
assert.Equal(t, "foo", path.Match(`/path/to/foo`).Values["something"])
assert.Nil(t, path.Match(`/path/to`))
assert.NotNil(t, path.Match(`/path/to/`))
assert.Equal(t, "", path.Match(`/path/to/`).Values["something"])
assert.Equal(t, "", path.Match(`/path/to//`).Values["something"])
assert.Nil(t, path.Match(`/path/to///`))
})
})
t.Run("Wildcard part matching", func(t *testing.T) {
path, err := NewPath(`/path/to/*something`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/foo/bar`))
assert.Equal(t, "foo/bar", path.Match(`/path/to/foo/bar`).Values["something"])
assert.NotNil(t, path.Match(`/path/to/`))
assert.Equal(t, "", path.Match(`/path/to/`).Values["something"])
assert.NotNil(t, path.Match(`/path/to/foo/bar/`))
assert.Equal(t, "foo/bar/", path.Match(`/path/to/foo/bar/`).Values["something"])
})
t.Run("Regex part matching", func(t *testing.T) {
t.Run("Should find the regexp's", func(t *testing.T) {
path, err := NewPath(`/path/to/$<[0-9]+>/$id<[0-9]+>`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/10/20`))
assert.Equal(t, "20", path.Match(`/path/to/10/20`).Values["id"])
assert.Len(t, path.Match(`/path/to/10/20`).Values, 1)
assert.Nil(t, path.Match(`/path/to/10/`))
assert.Nil(t, path.Match(`/path/to//`))
assert.Nil(t, path.Match(`/path/to//20`))
path, err = NewPath(`/path/to/$id<[0-9]+>/$id2<[0-9]+>`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/10/20`))
assert.Equal(t, "10", path.Match(`/path/to/10/20`).Values["id"])
assert.Equal(t, "20", path.Match(`/path/to/10/20`).Values["id2"])
assert.Len(t, path.Match(`/path/to/10/20`).Values, 2)
})
t.Run("Should match fullpath regex", func(t *testing.T) {
path, err := NewPath(`/path/to/$foo<.*>`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/path/to/10/20`))
assert.Equal(t, "10/20", path.Match(`/path/to/10/20`).Values["foo"])
assert.Equal(t, "bla", path.Match(`/path/to/bla`).Values["foo"])
assert.Equal(t, "", path.Match(`/path/to/`).Values["foo"])
})
})
t.Run("Edge cases", func(t *testing.T) {
path, err := NewPath(`/`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/`))
assert.Empty(t, path.Match(`/`).Values)
})
t.Run("Xml Sitemap Case", func(t *testing.T) {
path, err := NewPath(`/sitemap/$id<product-(\d+).xml>`)
assert.NoError(t, err)
assert.NotNil(t, path)
assert.NotNil(t, path.Match(`/sitemap/product-1.xml`))
assert.NotNil(t, path.Match(`/sitemap/product-2.xml`))
assert.NotNil(t, path.Match(`/sitemap/product-100.xml`))
assert.Nil(t, path.Match(`/sitemap/product-test.xml`))
assert.NotEmpty(t, path.Match(`/sitemap/product-1.xml`).Values)
values := path.Match(`/sitemap/product-1.xml`).Values
id := strings.TrimPrefix(strings.TrimSuffix(values["id"], ".xml"), "product-")
assert.Equal(t, id, "1")
})
} | explode_data.jsonl/1529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2572
} | [
2830,
3393,
1820,
38606,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
97564,
6145,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
26781,
11,
1848,
1669,
1532,
1820,
31813,
2343,
32429,
11315,
33331,
10749,
307,
66746,
15,
12,
24,
75... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPartialSuccess(t *testing.T) {
dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("TempDir: %v", err)
}
defer os.RemoveAll(dir)
opts := Options{
IndexDir: dir,
ShardMax: 1024,
SizeMax: 1 << 20,
Parallelism: 1,
}
opts.RepositoryDescription.Name = "repo"
opts.SetDefaults()
b, err := NewBuilder(opts)
if err != nil {
t.Fatalf("NewBuilder: %v", err)
}
for i := 0; i < 4; i++ {
nm := fmt.Sprintf("F%d", i)
// no error checking: the 2nd call will fail
_ = b.AddFile(nm, []byte(strings.Repeat("01234567\n", 128)))
if i == 1 {
// force writes to fail.
if err := os.Chmod(dir, 0o555); err != nil {
t.Fatalf("chmod(%s): %s", dir, err)
}
}
}
if err := os.Chmod(dir, 0o755); err != nil {
t.Fatalf("chmod(%s, writable): %s", dir, err)
}
// No error checking.
_ = b.Finish()
// Finish cleans up temporary files.
if fs, err := filepath.Glob(dir + "/*"); err != nil {
t.Errorf("glob(%s): %v", dir, err)
} else if len(fs) != 0 {
t.Errorf("got shards %v, want []", fs)
}
} | explode_data.jsonl/18267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 480
} | [
2830,
3393,
37314,
7188,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
12151,
6184,
25,
1018,
85,
497,
1848,
340,
197,
532,
16867,
2643,
84427,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFrom(t *testing.T) {
results := []struct {
Clauses []clause.Interface
Result string
Vars []interface{}
}{
{
[]clause.Interface{clause.Select{}, clause.From{}},
"SELECT * FROM `users`", nil,
},
{
[]clause.Interface{
clause.Select{}, clause.From{
Tables: []clause.Table{{Name: "users"}},
Joins: []clause.Join{
{
Type: clause.InnerJoin,
Table: clause.Table{Name: "articles"},
ON: clause.Where{
[]clause.Expression{clause.Eq{clause.Column{Table: "articles", Name: "id"}, clause.PrimaryColumn}},
},
},
},
},
},
"SELECT * FROM `users` INNER JOIN `articles` ON `articles`.`id` = `users`.`id`", nil,
},
{
[]clause.Interface{
clause.Select{}, clause.From{
Tables: []clause.Table{{Name: "users"}},
Joins: []clause.Join{
{
Type: clause.RightJoin,
Table: clause.Table{Name: "profiles"},
ON: clause.Where{
[]clause.Expression{clause.Eq{clause.Column{Table: "profiles", Name: "email"}, clause.Column{Table: clause.CurrentTable, Name: "email"}}},
},
},
},
}, clause.From{
Joins: []clause.Join{
{
Type: clause.InnerJoin,
Table: clause.Table{Name: "articles"},
ON: clause.Where{
[]clause.Expression{clause.Eq{clause.Column{Table: "articles", Name: "id"}, clause.PrimaryColumn}},
},
}, {
Type: clause.LeftJoin,
Table: clause.Table{Name: "companies"},
Using: []string{"company_name"},
},
},
},
},
"SELECT * FROM `users` INNER JOIN `articles` ON `articles`.`id` = `users`.`id` LEFT JOIN `companies` USING (`company_name`)", nil,
},
}
for idx, result := range results {
t.Run(fmt.Sprintf("case #%v", idx), func(t *testing.T) {
checkBuildClauses(t, result.Clauses, result.Result, result.Vars)
})
}
} | explode_data.jsonl/14327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 892
} | [
2830,
3393,
3830,
1155,
353,
8840,
836,
8,
341,
55497,
1669,
3056,
1235,
341,
197,
6258,
4260,
4776,
3056,
82082,
41065,
198,
197,
56503,
220,
914,
198,
197,
17446,
1561,
262,
3056,
4970,
16094,
197,
59403,
197,
197,
515,
298,
197,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFirstDropsAllButFirstNLinesOfInput(t *testing.T) {
t.Parallel()
input := "a\nb\nc\n"
want := "a\nb\n"
got, err := script.Echo(input).First(2).String()
if err != nil {
t.Fatal(err)
}
if want != got {
t.Error(cmp.Diff(want, got))
}
} | explode_data.jsonl/51477 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
5338,
35,
3702,
2403,
3983,
5338,
45,
16794,
2124,
2505,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22427,
1669,
330,
64,
1699,
65,
59,
1016,
1699,
698,
50780,
1669,
330,
64,
1699,
65,
1699,
698,
3174,
354,
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 TestCreateV2(t *testing.T) {
credentials := ec2tokens.AuthOptions{
Access: "a7f1e798b7c2417cba4a02de97dc3cdc",
Host: "localhost",
Path: "/",
Secret: "18f4f6761ada4e3795fa5273c30349b9",
Verb: "GET",
// this should be removed from JSON request
BodyHash: new(string),
// this should be removed from JSON request
Headers: map[string]string{
"Foo": "Bar",
},
Params: map[string]string{
"Action": "Test",
"SignatureMethod": "HmacSHA256",
"SignatureVersion": "2",
},
}
authTokenPost(t, credentials, `{
"credentials": {
"access": "a7f1e798b7c2417cba4a02de97dc3cdc",
"host": "localhost",
"params": {
"Action": "Test",
"SignatureMethod": "HmacSHA256",
"SignatureVersion": "2"
},
"path": "/",
"signature": "Up+MbVbbrvdR5FRkUz+n3nc+VW6xieuN50wh6ONEJ4w=",
"verb": "GET"
}
}`)
} | explode_data.jsonl/68579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 476
} | [
2830,
3393,
4021,
53,
17,
1155,
353,
8840,
836,
8,
341,
197,
32353,
1669,
11942,
17,
30566,
25233,
3798,
515,
197,
197,
6054,
25,
330,
64,
22,
69,
16,
68,
22,
24,
23,
65,
22,
66,
17,
19,
16,
22,
93829,
19,
64,
15,
17,
450,
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 Test_Kinds_Authorization(t *testing.T) {
type testCase struct {
methodName string
additionalArgs []interface{}
expectedVerb string
expectedResource string
}
tests := []testCase{
// single kind
{
methodName: "AddObject",
additionalArgs: []interface{}{(*models.Object)(nil)},
expectedVerb: "create",
expectedResource: "objects",
},
{
methodName: "ValidateObject",
additionalArgs: []interface{}{(*models.Object)(nil)},
expectedVerb: "validate",
expectedResource: "objects",
},
{
methodName: "GetObject",
additionalArgs: []interface{}{strfmt.UUID("foo"), additional.Properties{}},
expectedVerb: "get",
expectedResource: "objects/foo",
},
{
methodName: "DeleteObject",
additionalArgs: []interface{}{strfmt.UUID("foo")},
expectedVerb: "delete",
expectedResource: "objects/foo",
},
{
methodName: "UpdateObject",
additionalArgs: []interface{}{strfmt.UUID("foo"), (*models.Object)(nil)},
expectedVerb: "update",
expectedResource: "objects/foo",
},
{
methodName: "MergeObject",
additionalArgs: []interface{}{strfmt.UUID("foo"), (*models.Object)(nil)},
expectedVerb: "update",
expectedResource: "objects/foo",
},
{
methodName: "GetObjectsClass",
additionalArgs: []interface{}{strfmt.UUID("foo")},
expectedVerb: "get",
expectedResource: "objects/foo",
},
{
methodName: "HeadObject",
additionalArgs: []interface{}{strfmt.UUID("foo")},
expectedVerb: "head",
expectedResource: "objects/foo",
},
// list kinds
{
methodName: "GetObjects",
additionalArgs: []interface{}{(*int64)(nil), (*int64)(nil), additional.Properties{}},
expectedVerb: "list",
expectedResource: "objects",
},
// reference on kinds
{
methodName: "AddObjectReference",
additionalArgs: []interface{}{strfmt.UUID("foo"), "some prop", (*models.SingleRef)(nil)},
expectedVerb: "update",
expectedResource: "objects/foo",
},
{
methodName: "DeleteObjectReference",
additionalArgs: []interface{}{strfmt.UUID("foo"), "some prop", (*models.SingleRef)(nil)},
expectedVerb: "update",
expectedResource: "objects/foo",
},
{
methodName: "UpdateObjectReferences",
additionalArgs: []interface{}{strfmt.UUID("foo"), "some prop", (models.MultipleRef)(nil)},
expectedVerb: "update",
expectedResource: "objects/foo",
},
}
t.Run("verify that a test for every public method exists", func(t *testing.T) {
testedMethods := make([]string, len(tests))
for i, test := range tests {
testedMethods[i] = test.methodName
}
for _, method := range allExportedMethods(&Manager{}) {
assert.Contains(t, testedMethods, method)
}
})
t.Run("verify the tested methods require correct permissions from the authorizer", func(t *testing.T) {
principal := &models.Principal{}
logger, _ := test.NewNullLogger()
for _, test := range tests {
t.Run(test.methodName, func(t *testing.T) {
schemaManager := &fakeSchemaManager{}
locks := &fakeLocks{}
cfg := &config.WeaviateConfig{}
authorizer := &authDenier{}
vectorizer := &fakeVectorizer{}
vecProvider := &fakeVectorizerProvider{vectorizer}
vectorRepo := &fakeVectorRepo{}
manager := NewManager(locks, schemaManager,
cfg, logger, authorizer, vecProvider, vectorRepo, getFakeModulesProvider())
args := append([]interface{}{context.Background(), principal}, test.additionalArgs...)
out, _ := callFuncByName(manager, test.methodName, args...)
require.Len(t, authorizer.calls, 1, "authorizer must be called")
assert.Equal(t, errors.New("just a test fake"), out[len(out)-1].Interface(),
"execution must abort with authorizer error")
assert.Equal(t, authorizeCall{principal, test.expectedVerb, test.expectedResource},
authorizer.calls[0], "correct paramteres must have been used on authorizer")
})
}
})
} | explode_data.jsonl/43857 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1614
} | [
2830,
3393,
10102,
8673,
1566,
1553,
2022,
1155,
353,
8840,
836,
8,
341,
13158,
54452,
2036,
341,
197,
42257,
675,
981,
914,
198,
197,
12718,
3005,
4117,
256,
3056,
4970,
16094,
197,
42400,
66946,
257,
914,
198,
197,
42400,
4783,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRoaringPostingsListNotEqualWithOtherRoaring(t *testing.T) {
first := NewPostingsList()
first.Insert(42)
first.Insert(44)
first.Insert(51)
second := NewPostingsList()
second.Insert(42)
second.Insert(44)
second.Insert(51)
second.Insert(53)
require.False(t, first.Equal(second))
} | explode_data.jsonl/64023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
38872,
3249,
4133,
819,
852,
2623,
2993,
2354,
11409,
38872,
3249,
1155,
353,
8840,
836,
8,
341,
42190,
1669,
1532,
4133,
819,
852,
741,
42190,
23142,
7,
19,
17,
340,
42190,
23142,
7,
19,
19,
340,
42190,
23142,
7,
20,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSessionAffinity(t *testing.T) {
ipt := iptablestest.NewFake()
ipvs := ipvstest.NewFake()
ipset := ipsettest.NewFake(testIPSetVersion)
nodeIP := netutils.ParseIPSloppy("100.101.102.103")
fp := NewFakeProxier(ipt, ipvs, ipset, []net.IP{nodeIP}, nil, v1.IPv4Protocol)
svcIP := "10.20.30.41"
svcPort := 80
svcNodePort := 3001
svcExternalIPs := "50.60.70.81"
svcPortName := proxy.ServicePortName{
NamespacedName: makeNSN("ns1", "svc1"),
Port: "p80",
}
timeoutSeconds := v1.DefaultClientIPServiceAffinitySeconds
makeServiceMap(fp,
makeTestService(svcPortName.Namespace, svcPortName.Name, func(svc *v1.Service) {
svc.Spec.Type = "NodePort"
svc.Spec.ClusterIP = svcIP
svc.Spec.ExternalIPs = []string{svcExternalIPs}
svc.Spec.SessionAffinity = v1.ServiceAffinityClientIP
svc.Spec.SessionAffinityConfig = &v1.SessionAffinityConfig{
ClientIP: &v1.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
}
svc.Spec.Ports = []v1.ServicePort{{
Name: svcPortName.Port,
Port: int32(svcPort),
Protocol: v1.ProtocolTCP,
NodePort: int32(svcNodePort),
}}
}),
)
fp.syncProxyRules()
// check ipvs service and destinations
services, err := ipvs.GetVirtualServers()
if err != nil {
t.Errorf("Failed to get ipvs services, err: %v", err)
}
for _, svc := range services {
if svc.Timeout != uint32(v1.DefaultClientIPServiceAffinitySeconds) {
t.Errorf("Unexpected mismatch ipvs service session affinity timeout: %d, expected: %d", svc.Timeout, v1.DefaultClientIPServiceAffinitySeconds)
}
}
} | explode_data.jsonl/44367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 672
} | [
2830,
3393,
5283,
25841,
13489,
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,
8623,
3298,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContextRenderNoContentJSON(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
c.JSON(http.StatusNoContent, H{"foo": "bar"})
assert.Equal(t, http.StatusNoContent, w.Code)
assert.Empty(t, w.Body.String())
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
} | explode_data.jsonl/26772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
1972,
6750,
2753,
2762,
5370,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
54320,
70334,
7121,
47023,
741,
1444,
11,
716,
1669,
4230,
2271,
1972,
3622,
692,
1444,
18009,
19886,
10538,
2753,
2762,
11,
472,
4913,
7975,
788,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQueryLogicCalls(t *testing.T) {
input := CreateTestEnv(t)
ctx := input.Context
k := input.GravityKeeper
var (
logicContract = "0x510ab76899430424d209a6c9a5b9951fb8a6f47d"
payload = []byte("fake bytes")
tokenContract = "0x7580bfe88dd3d07947908fae12d95872a260f2d8"
invalidationId = []byte("GravityTesting")
invalidationNonce uint64 = 1
)
// seed with valset requests and eth addresses to make validators
// that we will later use to lookup calls to be signed
for i := 0; i < 6; i++ {
var validators []sdk.ValAddress
for j := 0; j <= i; j++ {
// add an validator each block
// TODO: replace with real SDK addresses
valAddr := bytes.Repeat([]byte{byte(j)}, sdk.AddrLen)
input.GravityKeeper.SetEthAddressForValidator(ctx, valAddr, gethcommon.BytesToAddress(bytes.Repeat([]byte{byte(j + 1)}, 20)).String())
validators = append(validators, valAddr)
}
input.GravityKeeper.StakingKeeper = NewStakingKeeperMock(validators...)
}
token := []*types.ERC20Token{{
Contract: tokenContract,
Amount: sdk.NewIntFromUint64(5000),
}}
call := types.OutgoingLogicCall{
Transfers: token,
Fees: token,
LogicContractAddress: logicContract,
Payload: payload,
Timeout: 10000,
InvalidationId: invalidationId,
InvalidationNonce: uint64(invalidationNonce),
}
k.SetOutgoingLogicCall(ctx, &call)
res := k.GetOutgoingLogicCall(ctx, invalidationId, invalidationNonce)
require.Equal(t, call, *res)
_, err := lastLogicCallRequests(ctx, k)
require.NoError(t, err)
var valAddr sdk.AccAddress = bytes.Repeat([]byte{byte(1)}, sdk.AddrLen)
_, err = lastPendingLogicCallRequest(ctx, valAddr.String(), k)
require.NoError(t, err)
require.NoError(t, err)
} | explode_data.jsonl/8799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 780
} | [
2830,
3393,
2859,
26751,
55292,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
14359,
1155,
340,
20985,
1669,
1946,
9328,
198,
16463,
1669,
1946,
96651,
77233,
198,
2405,
2399,
197,
6725,
292,
14067,
310,
284,
330,
15,
87,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_regexSafeLower(t *testing.T) {
a := assert.New(t)
a.Equal("blabla", regexSafeLower("BlaBLA"))
a.Equal("\\[injected\\]\\*", regexSafeLower("[injected]*"))
} | explode_data.jsonl/1137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
41832,
25663,
9053,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
340,
11323,
12808,
445,
2024,
370,
4260,
497,
20180,
25663,
9053,
445,
33,
4260,
9389,
32,
5455,
11323,
12808,
29710,
58,
258,
28303,
3422,
869... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestToSlice(t *testing.T) {
is := is.New(t)
m, err := NewMemtable(10000, "/tmp/memtable.log")
is.NoErr(err)
m.Put("key1", "value1")
m.Put("key2", "value2")
m.Put("key3", "old_value")
m.Delete("key2")
m.Put("key3", "new_value")
entries := m.ToSlice()
is.Equal(len(entries), 3)
sort.Slice(entries, func(i, j int) bool {
return entries[i].Key < entries[j].Key
})
is.Equal(entries[0].Key, "key1")
is.Equal(entries[0].Value, "value1")
is.Equal(entries[1].Key, "key2")
is.Equal(entries[1].Value, "")
is.Equal(entries[2].Key, "key3")
is.Equal(entries[2].Value, "new_value")
m.Clear()
} | explode_data.jsonl/56390 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
1249,
33236,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
340,
2109,
11,
1848,
1669,
1532,
18816,
2005,
7,
16,
15,
15,
15,
15,
11,
3521,
5173,
3183,
336,
2005,
1665,
1138,
19907,
16766,
7747,
3964,
692,
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... | 1 |
func TestRunParserGraphiteMsg(t *testing.T) {
var testmsg = []byte("cpu.load.graphite 12 1454780029")
listener, in := newTestTcpListener()
acc := testutil.Accumulator{}
listener.acc = &acc
defer close(listener.done)
listener.parser, _ = parsers.NewGraphiteParser("_", []string{}, nil)
listener.wg.Add(1)
go listener.tcpParser()
in <- testmsg
time.Sleep(time.Millisecond * 25)
listener.Gather(&acc)
acc.AssertContainsFields(t, "cpu_load_graphite",
map[string]interface{}{"value": float64(12)})
} | explode_data.jsonl/33007 | {
"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,
6727,
6570,
11212,
632,
6611,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
3236,
284,
3056,
3782,
445,
16475,
5104,
10763,
632,
220,
16,
17,
220,
16,
19,
20,
19,
22,
23,
15,
15,
17,
24,
5130,
14440,
798,
11,
304,
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 TestInvalidTransactions(t *testing.T) {
t.Parallel()
pool, key := setupTxPool()
defer pool.Stop()
tx := transaction(0, 100, key)
from, _ := deriveSender(tx)
pool.currentState.AddBalance(from, big.NewInt(1))
if err := pool.AddRemote(tx); err != ErrInsufficientFunds {
t.Error("expected", ErrInsufficientFunds)
}
balance := new(big.Int).Add(tx.Value(), new(big.Int).Mul(new(big.Int).SetUint64(tx.Gas()), tx.GasPrice()))
pool.currentState.AddBalance(from, balance)
if err := pool.AddRemote(tx); !errors.Is(err, ErrIntrinsicGas) {
t.Error("expected", ErrIntrinsicGas, "got", err)
}
pool.currentState.SetNonce(from, 1)
pool.currentState.AddBalance(from, big.NewInt(0xffffffffffffff))
tx = transaction(0, 100000, key)
if err := pool.AddRemote(tx); err != ErrNonceTooLow {
t.Error("expected", ErrNonceTooLow)
}
tx = transaction(1, 100000, key)
pool.gasPrice = big.NewInt(1000)
if err := pool.AddRemote(tx); err != ErrUnderpriced {
t.Error("expected", ErrUnderpriced, "got", err)
}
if err := pool.AddLocal(tx); err != nil {
t.Error("expected", nil, "got", err)
}
} | explode_data.jsonl/7855 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
7928,
48761,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
85273,
11,
1376,
1669,
6505,
31584,
10551,
741,
16867,
7314,
30213,
2822,
46237,
1669,
7745,
7,
15,
11,
220,
16,
15,
15,
11,
1376,
340,
42727,
11,
716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccIpTcp_create(t *testing.T) {
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: TEST_IP_TCP_RESOURCE,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("thunder_ip_tcp.Iptcp", "syn_cookie.0.threshold", "4"),
),
},
},
})
} | explode_data.jsonl/80137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
14603,
23378,
77536,
8657,
1155,
353,
8840,
836,
8,
341,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
37351,
25,
1273,
14603,
37351,
345,
197,
197,
33951,
25,
3056,
9233,
8787,
8304,
515,
298,
197,
515,
571,
66156,
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 TestStrArray_Shuffle(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []string{"0", "1", "2", "3", "4", "5", "6"}
array1 := garray.NewStrArrayFrom(a1)
t.Assert(array1.Shuffle().Len(), 7)
})
} | explode_data.jsonl/53098 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
2580,
1857,
36578,
13208,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
917,
4913,
15,
497,
330,
16,
497,
330,
17,
497,
330,
18,
497,
330,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExportIntegerValuesFromScript(t *testing.T) {
t.Parallel()
test := func(integerType sema.Type) {
t.Run(integerType.String(), func(t *testing.T) {
t.Parallel()
script := fmt.Sprintf(
`
pub fun main(): %s {
return 42
}
`,
integerType,
)
assert.NotPanics(t, func() {
exportValueFromScript(t, script)
})
})
}
for _, integerType := range sema.AllIntegerTypes {
test(integerType)
}
} | explode_data.jsonl/4621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
16894,
3486,
6227,
3830,
5910,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
18185,
1669,
2915,
87414,
929,
5234,
64,
10184,
8,
1476,
197,
3244,
16708,
87414,
929,
6431,
1507,
2915,
1155,
353,
8840,
836,
8,
1476,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokenRefreshRequest(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.String() == "/somethingelse" {
return
}
if r.URL.String() != "/token" {
t.Errorf("Unexpected token refresh request URL, %v is found.", r.URL)
}
headerContentType := r.Header.Get("Content-Type")
if headerContentType != "application/x-www-form-urlencoded" {
t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
}
body, _ := ioutil.ReadAll(r.Body)
if string(body) != "client_id=CLIENT_ID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN" {
t.Errorf("Unexpected refresh token payload, %v is found.", string(body))
}
}))
defer ts.Close()
conf := newConf(ts.URL)
c := conf.Client(NoContext, &Token{RefreshToken: "REFRESH_TOKEN"})
c.Get(ts.URL + "/somethingelse")
} | explode_data.jsonl/25892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
3323,
14567,
1900,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20893,
6431,
368,
621,
3521,
33331,
1503,
1,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInboxCacheOnLogout(t *testing.T) {
uid := keybase1.MakeTestUID(3)
inboxMemCache.Put(gregor1.UID(uid), &inboxDiskData{})
require.NotEmpty(t, len(inboxMemCache.datMap))
err := inboxMemCache.OnLogout()
require.NoError(t, err)
require.Nil(t, inboxMemCache.Get(gregor1.UID(uid)))
require.Empty(t, len(inboxMemCache.datMap))
} | explode_data.jsonl/16812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
641,
2011,
8233,
1925,
27958,
1155,
353,
8840,
836,
8,
341,
197,
2423,
1669,
1376,
3152,
16,
50133,
2271,
6463,
7,
18,
340,
17430,
2011,
18816,
8233,
39825,
3268,
65921,
16,
5255,
915,
37048,
701,
609,
84699,
47583,
1043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIs(t *testing.T) {
tests := []struct {
name string
e *Error
err error
want bool
}{
{
name: "true",
e: New(404, "test", ""),
err: New(http.StatusNotFound, "test", ""),
want: true,
},
{
name: "false",
e: New(0, "test", ""),
err: errors.New("test"),
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if ok := tt.e.Is(tt.err); ok != tt.want {
t.Errorf("Error.Error() = %v, want %v", ok, tt.want)
}
})
}
} | explode_data.jsonl/15375 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
3872,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
353,
1454,
198,
197,
9859,
220,
1465,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConfigurationSpec(t *testing.T) {
s := createService()
s.Annotations = kmeta.UnionMaps(s.Annotations,
map[string]string{
serving.RolloutDurationKey: "2021s",
},
)
c := MakeConfiguration(s)
if got, want := c.Name, testServiceName; got != want {
t.Errorf("Service name = %q; want: %q", got, want)
}
if got, want := c.Namespace, testServiceNamespace; got != want {
t.Errorf("Service namespace = %q; want: %q", got, want)
}
if got, want := c.Spec.GetTemplate().Spec.GetContainer().Name, testContainerName; got != want {
t.Errorf("Container name = %q; want: %q", got, want)
}
expectOwnerReferencesSetCorrectly(t, c.OwnerReferences)
if got, want := c.Labels, map[string]string{
serving.ServiceLabelKey: testServiceName,
serving.ServiceUIDLabelKey: "cccccccc-cccc-cccc-cccc-cccccccccccc",
}; !cmp.Equal(got, want) {
t.Errorf("Labels mismatch: diff(-want,+got):\n%s", cmp.Diff(want, got))
}
if got, want := c.Annotations, map[string]string{
serving.RoutesAnnotationKey: testServiceName,
}; !cmp.Equal(got, want) {
t.Errorf("Annotations mismatch: diff(-want,+got):\n%s", cmp.Diff(want, got))
}
// Create the configuration based on the same existing configuration.
c = MakeConfigurationFromExisting(s, c)
if got, want := c.Annotations, map[string]string{
serving.RoutesAnnotationKey: testServiceName,
}; !cmp.Equal(got, want) {
t.Errorf("Annotations mismatch: diff(-want,+got):\n%s", cmp.Diff(want, got))
}
// Create the configuration based on the configuration with a different value for the
// annotation key serving.RoutesAnnotationKey.
const secTestServiceName = "second-test-service"
secondConfig := MakeConfigurationFromExisting(
createServiceWithName(secTestServiceName), c)
// MakeConfigurationFromExisting employs maps in process, so order is
// not guaranteed.
annoValue := secondConfig.Annotations[serving.RoutesAnnotationKey]
got := strings.Split(annoValue, ",")
sort.Strings(got)
want := []string{secTestServiceName, testServiceName}
if !cmp.Equal(got, want) {
t.Errorf("Annotations = %v, want: %v", got, want)
}
} | explode_data.jsonl/45490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 749
} | [
2830,
3393,
7688,
8327,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1855,
1860,
741,
1903,
91172,
284,
595,
5490,
10616,
290,
36562,
1141,
91172,
345,
197,
19567,
14032,
30953,
515,
298,
1903,
19505,
71212,
411,
12945,
1592,
25,
330,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestGetAvailableUpdateForDeviceWhenDeviceIsNotFound(t *testing.T) {
// Given
req, err := http.NewRequest("GET", "/", nil)
if err != nil {
t.Fatal(err)
}
dc := DeviceContext{
DeviceUUID: faker.UUIDHyphenated(),
}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockDeviceService := mock_services.NewMockDeviceServiceInterface(ctrl)
mockDeviceService.EXPECT().GetDeviceByUUID(gomock.Eq(dc.DeviceUUID)).Return(&models.Device{UUID: dc.DeviceUUID}, nil)
mockDeviceService.EXPECT().GetUpdateAvailableForDeviceByUUID(gomock.Eq(dc.DeviceUUID)).Return(nil, new(services.DeviceNotFoundError))
ctx := context.WithValue(req.Context(), DeviceContextKey, dc)
ctx = dependencies.ContextWithServices(ctx, &dependencies.EdgeAPIServices{
DeviceService: mockDeviceService,
Log: log.NewEntry(log.StandardLogger()),
})
req = req.WithContext(ctx)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(GetUpdateAvailableForDevice)
// When
handler.ServeHTTP(rr, req.WithContext(ctx))
// Then
if status := rr.Code; status != http.StatusNotFound {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusNotFound)
return
}
} | explode_data.jsonl/58630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 423
} | [
2830,
3393,
1949,
16485,
4289,
2461,
6985,
4498,
6985,
3872,
10372,
1155,
353,
8840,
836,
8,
341,
197,
322,
16246,
198,
24395,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
64657,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetEnvAsBool(t *testing.T) {
t.Parallel()
testVarKey := "TEST_ONLY_FOR_UNIT_TEST_BOOL"
res := util.GetEnvAsBool(testVarKey, true)
assert.Equal(t, true, res)
os.Setenv(testVarKey, "f")
defer os.Unsetenv(testVarKey)
res = util.GetEnvAsBool(testVarKey, true)
assert.Equal(t, false, res)
os.Setenv(testVarKey, "0")
res = util.GetEnvAsBool(testVarKey, true)
assert.Equal(t, false, res)
os.Setenv(testVarKey, "false")
res = util.GetEnvAsBool(testVarKey, true)
assert.Equal(t, false, res)
os.Setenv(testVarKey, "3x")
res = util.GetEnvAsBool(testVarKey, true)
assert.Equal(t, true, res)
} | explode_data.jsonl/6087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
1949,
14359,
2121,
11233,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
3962,
1592,
1669,
330,
10033,
31263,
14516,
31718,
11641,
32491,
698,
10202,
1669,
4094,
2234,
14359,
2121,
11233,
8623,
3962,
1592,
11,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQueryGetChainInfo(t *testing.T) {
chainid := "mytestchainid1"
path := tempDir(t, "test1")
defer os.RemoveAll(path)
stub, err := setupTestLedger(chainid, path)
if err != nil {
t.Fatalf(err.Error())
}
args := [][]byte{[]byte(GetChainInfo), []byte(chainid)}
prop := resetProvider(resources.Qscc_GetChainInfo, chainid, &peer2.SignedProposal{}, nil)
res := stub.MockInvokeWithSignedProposal("1", args, prop)
assert.Equal(t, int32(shim.OK), res.Status, "GetChainInfo failed with err: %s", res.Message)
args = [][]byte{[]byte(GetChainInfo)}
res = stub.MockInvoke("2", args)
assert.Equal(t, int32(shim.ERROR), res.Status, "GetChainInfo should have failed because no channel id was provided")
args = [][]byte{[]byte(GetChainInfo), []byte("fakechainid")}
res = stub.MockInvoke("3", args)
assert.Equal(t, int32(shim.ERROR), res.Status, "GetChainInfo should have failed because the channel id does not exist")
} | explode_data.jsonl/18828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
2859,
1949,
18837,
1731,
1155,
353,
8840,
836,
8,
341,
197,
8819,
307,
1669,
330,
2408,
1944,
8819,
307,
16,
698,
26781,
1669,
2730,
6184,
1155,
11,
330,
1944,
16,
1138,
16867,
2643,
84427,
5581,
692,
18388,
392,
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... | 2 |
func TestPutMissingLocalFileReturnsError(t *testing.T) {
beforeTest(t)
conn := _getConnection(t)
defer conn.Close()
client := agaveproto.NewSftpRelayClient(conn)
// construct a missing local path
tmpMissingTestFilePath := filepath.Join(CurrentBaseTestDirPath, uuid.New().String(), uuid.New().String())
resolvedTmpMissingTestFilePath := _resolveTestPath(tmpMissingTestFilePath, LocalSharedTestDir)
// create a path for the target of our put
tmpRemoteTestDirPath := filepath.Join(CurrentBaseTestDirPath, uuid.New().String())
resolvedRemoteTestDirPath := _resolveTestPath(tmpRemoteTestDirPath, SFTP_SHARED_TEST_DIR)
req := &agaveproto.SrvPutRequest{
SystemConfig: _createRemoteSystemConfig(),
LocalPath: resolvedTmpMissingTestFilePath,
RemotePath: resolvedRemoteTestDirPath,
Force: true,
Append: false,
}
grpcResponse, err := client.Put(context.Background(), req)
if err != nil {
assert.Nilf(t, err, "Error while invoking remote service: %v", err)
} else {
// get the test directory stat in the local shared directory
resolvedLocalTestDirPath := _resolveTestPath(tmpRemoteTestDirPath, LocalSharedTestDir)
_, err := os.Stat(resolvedLocalTestDirPath)
if err == nil {
assert.FailNowf(t, "Missing target file should not be created", "Missing target file, %s, should not be present after attempting to put a missing file", resolvedLocalTestDirPath)
}
assert.Contains(t, strings.ToLower(grpcResponse.Error), "no such file or directory", "Error message in response should state no such file or directory")
assert.Nil(t, grpcResponse.RemoteFileInfo, "Returned file info should be nil on error")
}
afterTest(t)
} | explode_data.jsonl/32555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 547
} | [
2830,
3393,
19103,
25080,
7319,
1703,
16446,
1454,
1155,
353,
8840,
836,
8,
341,
63234,
2271,
1155,
692,
32917,
1669,
716,
52414,
1155,
340,
16867,
4534,
10421,
2822,
25291,
1669,
933,
523,
15110,
7121,
50,
25068,
6740,
352,
2959,
20571,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewCollector(t *testing.T) {
c, err := NewCollector(14, "../model/test.db")
if err != nil {
t.Errorf(`err should be nil, got: %v`, err)
}
if c == nil {
t.Error(`c should not be nil`)
}
} | explode_data.jsonl/13475 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
3564,
53694,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
53694,
7,
16,
19,
11,
7005,
2528,
12697,
7076,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
5809,
615,
1265,
387,
2092,
11,
2684,
25,
1018,
85,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFormatterUserError(test *testing.T) {
defer func() {
formatter.Current = user.Current
}()
formatter.Current = func() (*user.User, error) {
return nil, Error("error")
}
formatted, err := formatter.Format("{user}")
assert.NoError(test, err)
assert.Empty(test, formatted)
} | explode_data.jsonl/39786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
14183,
1474,
1454,
8623,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
197,
32941,
11517,
284,
1196,
11517,
198,
197,
66816,
197,
32941,
11517,
284,
2915,
368,
4609,
872,
7344,
11,
1465,
8,
341,
197,
853,
2092,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCallPrintln(t *testing.T) {
gopClTest(t, `
print
print "hello"
print("hello")
println
println "hello"
println("hello")
`, `package main
import fmt "fmt"
func main() {
fmt.Print()
fmt.Print("hello")
fmt.Print("hello")
fmt.Println()
fmt.Println("hello")
fmt.Println("hello")
}
`)
} | explode_data.jsonl/73710 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
7220,
8994,
2261,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
1350,
198,
1350,
330,
14990,
698,
1350,
445,
14990,
1138,
33655,
198,
33655,
330,
14990,
698,
33655,
445,
14990,
1138,
7808,
1565,
1722,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVariadicMatching(t *testing.T) {
rep, ctrl := createFixtures(t)
defer rep.recoverUnexpectedFatal()
s := new(Subject)
ctrl.RecordCall(s, "VariadicMethod", 0, "1", "2")
ctrl.Call(s, "VariadicMethod", 0, "1", "2")
ctrl.Finish()
rep.assertPass("variadic matching works")
} | explode_data.jsonl/17295 | {
"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,
56135,
36214,
64430,
1155,
353,
8840,
836,
8,
341,
73731,
11,
23743,
1669,
1855,
25958,
18513,
1155,
340,
16867,
2064,
1327,
3688,
29430,
62396,
2822,
1903,
1669,
501,
7,
13019,
340,
84381,
49959,
7220,
1141,
11,
330,
56135,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNegativeRead(t *testing.T) {
// should panic with a description pointing at the reader, not at itself.
// (should NOT panic with slice index error, for example.)
b := NewReader(new(negativeReader))
defer func() {
switch err := recover().(type) {
case nil:
t.Fatal("read did not panic")
case error:
if !strings.Contains(err.Error(), "reader returned negative count from Read") {
t.Fatalf("wrong panic: %v", err)
}
default:
t.Fatalf("unexpected panic value: %T(%v)", err, err)
}
}()
_, _ = b.Read(make([]byte, 100))
} | explode_data.jsonl/2892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
38489,
4418,
1155,
353,
8840,
836,
8,
341,
197,
322,
1265,
21975,
448,
264,
4008,
21633,
518,
279,
6604,
11,
537,
518,
5086,
624,
197,
322,
320,
5445,
4183,
21975,
448,
15983,
1922,
1465,
11,
369,
3110,
28175,
2233,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestWorkflowTemplateServer_CreateClusterWorkflowTemplate(t *testing.T) {
server, ctx := getClusterWorkflowTemplateServer()
t.Run("Without parameter values", func(t *testing.T) {
tmpl := unlabelled.DeepCopy()
tmpl.Name = "foo-without-param-values"
tmpl.Spec.Arguments.Parameters[0].Value = nil
req := clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{
Template: tmpl,
}
resp, err := server.CreateClusterWorkflowTemplate(ctx, &req)
if assert.NoError(t, err) {
assert.Equal(t, "message", resp.Spec.Arguments.Parameters[0].Name)
assert.Nil(t, resp.Spec.Arguments.Parameters[0].Value)
}
})
t.Run("With parameter values", func(t *testing.T) {
cwftReq := clusterwftmplpkg.ClusterWorkflowTemplateCreateRequest{
Template: unlabelled.DeepCopy(),
}
cwftReq.Template.Name = "foo-with-param-values"
assert.NotContains(t, cwftReq.Template.Labels, common.LabelKeyControllerInstanceID)
cwftRsp, err := server.CreateClusterWorkflowTemplate(ctx, &cwftReq)
if assert.NoError(t, err) {
assert.NotNil(t, cwftRsp)
// ensure the label is added
assert.Contains(t, cwftRsp.Labels, common.LabelKeyControllerInstanceID)
assert.Contains(t, cwftRsp.Labels, common.LabelKeyCreator)
}
})
} | explode_data.jsonl/48136 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 477
} | [
2830,
3393,
62768,
7275,
5475,
34325,
28678,
62768,
7275,
1155,
353,
8840,
836,
8,
341,
41057,
11,
5635,
1669,
633,
28678,
62768,
7275,
5475,
741,
3244,
16708,
445,
26040,
5733,
2750,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCaptiveGetLedgerCacheLatestLedger(t *testing.T) {
tt := assert.New(t)
metaChan := make(chan metaResult, 300)
for i := 2; i <= 67; i++ {
meta := buildLedgerCloseMeta(testLedgerHeader{sequence: uint32(i)})
metaChan <- metaResult{
LedgerCloseMeta: &meta,
}
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mockRunner := &stellarCoreRunnerMock{}
mockRunner.On("runFrom", uint32(65), "0101010100000000000000000000000000000000000000000000000000000000").Return(nil).Once()
mockRunner.On("getMetaPipe").Return((<-chan metaResult)(metaChan))
mockRunner.On("context").Return(ctx)
mockArchive := &historyarchive.MockArchive{}
mockArchive.
On("GetRootHAS").
Return(historyarchive.HistoryArchiveState{
CurrentLedger: uint32(200),
}, nil)
mockArchive.
On("GetLedgerHeader", uint32(66)).
Return(xdr.LedgerHeaderHistoryEntry{
Header: xdr.LedgerHeader{
PreviousLedgerHash: xdr.Hash{1, 1, 1, 1},
},
}, nil).Once()
captiveBackend := CaptiveStellarCore{
archive: mockArchive,
stellarCoreRunnerFactory: func(_ stellarCoreRunnerMode) (stellarCoreRunnerInterface, error) {
return mockRunner, nil
},
checkpointManager: historyarchive.NewCheckpointManager(64),
}
err := captiveBackend.PrepareRange(ctx, UnboundedRange(66))
assert.NoError(t, err)
// found, _, err := captiveBackend.GetLedger(ctx, 68)
// tt.NoError(err)
// tt.False(found)
// tt.Equal(uint32(67), captiveBackend.cachedMeta.LedgerSequence())
// tt.Equal(uint32(68), captiveBackend.nextLedger)
meta, err := captiveBackend.GetLedger(ctx, 67)
tt.NoError(err)
tt.Equal(uint32(67), meta.LedgerSequence())
mockArchive.AssertExpectations(t)
mockRunner.AssertExpectations(t)
} | explode_data.jsonl/7324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 645
} | [
2830,
3393,
34,
27781,
1949,
60850,
1389,
8233,
31992,
60850,
1389,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
2060,
7121,
1155,
340,
84004,
46019,
1669,
1281,
35190,
8823,
2077,
11,
220,
18,
15,
15,
692,
2023,
600,
1669,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDERToX509Certificate(t *testing.T) {
testExtKeyUsage := []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}
testUnknownExtKeyUsage := []asn1.ObjectIdentifier{[]int{1, 2, 3}, []int{2, 59, 1}}
extraExtensionData := []byte("extra extension")
commonName := "test.example.com"
template := x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{
CommonName: commonName,
Organization: []string{"Σ Acme Co"},
Country: []string{"US"},
ExtraNames: []pkix.AttributeTypeAndValue{
{
Type: []int{2, 5, 4, 42},
Value: "Gopher",
},
// This should override the Country, above.
{
Type: []int{2, 5, 4, 6},
Value: "NL",
},
},
},
NotBefore: time.Now().Add(-1 * time.Hour),
NotAfter: time.Now().Add(1 * time.Hour),
//SignatureAlgorithm: x509.ECDSAWithSHA256,
SignatureAlgorithm: x509.SM2WithSM3,
SubjectKeyId: []byte{1, 2, 3, 4},
KeyUsage: x509.KeyUsageCertSign,
ExtKeyUsage: testExtKeyUsage,
UnknownExtKeyUsage: testUnknownExtKeyUsage,
BasicConstraintsValid: true,
IsCA: true,
OCSPServer: []string{"http://ocurrentBCCSP.example.com"},
IssuingCertificateURL: []string{"http://crt.example.com/ca1.crt"},
DNSNames: []string{"test.example.com"},
EmailAddresses: []string{"gopher@golang.org"},
IPAddresses: []net.IP{net.IPv4(127, 0, 0, 1).To4(), net.ParseIP("2001:4860:0:2001::68")},
PolicyIdentifiers: []asn1.ObjectIdentifier{[]int{1, 2, 3}},
PermittedDNSDomains: []string{".example.com", "example.com"},
CRLDistributionPoints: []string{"http://crl1.example.com/ca1.crl", "http://crl2.example.com/ca1.crl"},
ExtraExtensions: []pkix.Extension{
{
Id: []int{1, 2, 3, 4},
Value: extraExtensionData,
},
},
}
key, err := sm2.GenerateKey(rand.Reader)
assert.NoError(t, err)
certRaw, err := x509.CreateCertificate(rand.Reader, &template, &template,key.Public(),key)
assert.NoError(t, err)
cert, err := DERToX509Certificate(certRaw)
assert.NoError(t, err)
assert.NotNil(t, cert)
assert.Equal(t, cert.Raw, certRaw)
} | explode_data.jsonl/2461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 932
} | [
2830,
3393,
11391,
1249,
55,
20,
15,
24,
33202,
1155,
353,
8840,
836,
8,
341,
18185,
6756,
1592,
14783,
1669,
3056,
87,
20,
15,
24,
16146,
1592,
14783,
45340,
20,
15,
24,
16146,
1592,
14783,
2959,
5087,
11,
856,
20,
15,
24,
16146,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWalkSkipDir(t *testing.T) {
initOverlay(t, `
{
"Replace": {
"dir/skip/file.go": "dummy.txt",
"dir/dontskip/file.go": "dummy.txt",
"dir/dontskip/skip/file.go": "dummy.txt"
}
}
-- dummy.txt --
`)
var seen []string
Walk("dir", func(path string, info fs.FileInfo, err error) error {
seen = append(seen, filepath.ToSlash(path))
if info.Name() == "skip" {
return filepath.SkipDir
}
return nil
})
wantSeen := []string{"dir", "dir/dontskip", "dir/dontskip/file.go", "dir/dontskip/skip", "dir/skip"}
if len(seen) != len(wantSeen) {
t.Errorf("paths seen in walk: got %v entries; want %v entries", len(seen), len(wantSeen))
}
for i := 0; i < len(seen) && i < len(wantSeen); i++ {
if seen[i] != wantSeen[i] {
t.Errorf("path #%v seen walking tree: want %q, got %q", i, seen[i], wantSeen[i])
}
}
} | explode_data.jsonl/56053 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 368
} | [
2830,
3393,
48849,
35134,
6184,
1155,
353,
8840,
836,
8,
341,
28248,
32755,
1155,
11,
22074,
515,
197,
1,
23107,
788,
341,
197,
197,
1,
3741,
2687,
13389,
23903,
18002,
788,
330,
31390,
3909,
756,
197,
197,
1,
3741,
3446,
544,
20599,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGocloak_DecodeAccessToken(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)
token := GetClientToken(t, client)
resultToken, claims, err := client.DecodeAccessToken(
token.AccessToken,
cfg.GoCloak.Realm)
t.Log(resultToken)
t.Log(claims)
FailIfErr(t, err, "DecodeAccessToken")
} | explode_data.jsonl/79512 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
38,
509,
385,
585,
78668,
534,
37649,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
1669,
2126,
2648,
1155,
340,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
43947,
1669,
2126,
2959,
3323,
1155,
11,
2943,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateDeveloperHeaderEmpty(t *testing.T) {
testServer(func(s *core.Server) {
res, err := testHTTPRequest("POST", "/api/v1/developers/", `{"name":"adnaan","email":"badr.adnaan@gmail.com","password":"mypassword"}`)
if err != nil {
t.Fatalf("Unable to create developer: %v", err)
} else {
body, _ := ioutil.ReadAll(res.Body)
if res.StatusCode == 200 {
t.Fatalf("able to create developer: %v", string(body))
}
}
})
} | explode_data.jsonl/42204 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
4021,
44911,
4047,
3522,
1155,
353,
8840,
836,
8,
341,
18185,
5475,
18552,
1141,
353,
2153,
22997,
8,
341,
197,
10202,
11,
1848,
1669,
1273,
63765,
445,
2946,
497,
3521,
2068,
5457,
16,
14,
64305,
28105,
1565,
4913,
606,
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 TestConfigEmptyClusterMetadata(t *testing.T) {
cfg := &Config{
Persistence: Persistence{
DefaultStore: "default",
VisibilityStore: "cass",
DataStores: map[string]DataStore{
"default": {
SQL: &SQL{
PluginName: "fake",
ConnectProtocol: "tcp",
ConnectAddr: "192.168.0.1:3306",
DatabaseName: "db1",
NumShards: 0, // default value, should be changed
},
},
"cass": {
Cassandra: &NoSQL{
Hosts: "127.0.0.1",
},
// no sql or nosql, should be populated from cassandra
},
},
},
}
err := cfg.ValidateAndFillDefaults()
require.Error(t, err)
} | explode_data.jsonl/46571 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
2648,
3522,
28678,
14610,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
609,
2648,
515,
197,
10025,
8026,
25,
64236,
515,
298,
91084,
6093,
25,
262,
330,
2258,
756,
298,
197,
11432,
6093,
25,
330,
66,
395,
756,
298,
40927,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClose(t *testing.T) {
fixture := &testFixture{}
kc := getDefaultKubeClient(fixture, nil, t)
mm, err := kc.GetMetricsClient("myNamespace")
require.NoError(t, err)
require.NotNil(t, mm)
// Check that KubeClientInterface.Close invokes MetricsInterface.Close
kc.Close()
require.True(t, fixture.metrics.closed, "Metrics client not closed")
} | explode_data.jsonl/41267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
7925,
1155,
353,
8840,
836,
8,
341,
1166,
12735,
1669,
609,
1944,
18930,
16094,
16463,
66,
1669,
69106,
42,
3760,
2959,
94886,
11,
2092,
11,
259,
692,
2109,
76,
11,
1848,
1669,
87518,
2234,
27328,
2959,
445,
2408,
22699,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRateLimits(t *testing.T) {
for _, tt := range []struct {
name string
method string
prepareCtx func(context.Context) context.Context
rateLimitCount int
returnErr error
downstreamErr error
expectLogs []spiretest.LogEntry
expectCode codes.Code
expectMsg string
}{
{
name: "RPC fails if method not configured for rate limiting",
method: "/fake.Service/Whoopsie",
expectCode: codes.Internal,
expectMsg: `rate limiting misconfigured for "/fake.Service/Whoopsie"`,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Rate limiting misconfigured; this is a bug",
},
},
},
{
name: "logs when rate limiter not used by handler",
method: "/fake.Service/WithLimit",
expectCode: codes.OK,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Rate limiter went unused; this is a bug",
},
},
},
{
name: "does not log if handler returns invalid argument",
method: "/fake.Service/WithLimit",
returnErr: status.Error(codes.InvalidArgument, "ohno!"),
expectCode: codes.InvalidArgument,
expectMsg: `ohno!`,
},
{
name: "does not log if handler was never invoked",
method: "/fake.Service/WithLimit",
downstreamErr: status.Error(codes.PermissionDenied, "permission denied"),
expectCode: codes.PermissionDenied,
expectMsg: `permission denied`,
},
{
name: "logs when handler with no limit tries to rate limit",
method: "/fake.Service/NoLimit",
rateLimitCount: 1,
expectCode: codes.OK,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Rate limiter used unexpectedly; this is a bug",
},
},
},
{
name: "does not log when handler with disabled limit tries to rate limit",
method: "/fake.Service/DisabledLimit",
rateLimitCount: 1,
expectCode: codes.OK,
},
{
name: "logs when handler with disabled limit does not rate limit",
method: "/fake.Service/DisabledLimit",
expectCode: codes.OK,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Disabled rate limiter went unused; this is a bug",
},
},
},
{
name: "does not log when rate limiter not used by unlimited handler",
method: "/fake.Service/NoLimit",
expectCode: codes.OK,
},
{
name: "does not log when rate limiter used by limited handler",
method: "/fake.Service/WithLimit",
rateLimitCount: 1,
},
{
name: "returns resource exhausted when rate limiting fails",
method: "/fake.Service/WithLimit",
rateLimitCount: 3,
expectCode: codes.ResourceExhausted,
expectMsg: "rate (3) exceeds burst size (2)",
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
log, hook := test.NewNullLogger()
ctx := rpccontext.WithLogger(context.Background(), log)
if tt.prepareCtx != nil {
ctx = tt.prepareCtx(ctx)
}
serverInfo := &grpc.UnaryServerInfo{FullMethod: tt.method}
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
if tt.rateLimitCount > 0 {
if err := rpccontext.RateLimit(ctx, tt.rateLimitCount); err != nil {
return nil, err
}
}
if tt.returnErr != nil {
return nil, tt.returnErr
}
return struct{}{}, nil
}
unaryInterceptor := UnaryInterceptor(Chain(
WithRateLimits(
map[string]api.RateLimiter{
"/fake.Service/NoLimit": NoLimit(),
"/fake.Service/DisabledLimit": DisabledLimit(),
"/fake.Service/WithLimit": PerCallLimit(2),
},
),
// Install a middleware downstream so that we can test what
// happens in postprocess if the handler is never invoked.
Preprocess(func(ctx context.Context, fullMethod string) (context.Context, error) {
return ctx, tt.downstreamErr
}),
))
resp, err := unaryInterceptor(ctx, struct{}{}, serverInfo, handler)
spiretest.AssertGRPCStatus(t, err, tt.expectCode, tt.expectMsg)
if err == nil {
assert.NotNil(t, resp)
} else {
assert.Nil(t, resp)
}
spiretest.AssertLogs(t, hook.AllEntries(), tt.expectLogs)
})
}
} | explode_data.jsonl/5209 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1907
} | [
2830,
3393,
11564,
94588,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
42257,
260,
914,
198,
197,
197,
13609,
23684,
257,
2915,
5378,
9328,
8,
2266,
9328,
198,
197,
700... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMetaData(t *testing.T) {
efs := ipfs.NewExoFS(shellURL)
is := is.New(t)
metaDest := paths.MetaPath(testDir)
md, err := efs.GetMetaData(metaSrc, metaDest)
is.NoErr(err) // get metadata returns error
is.True(len(md) > 0) // metadata should not be empty
} | explode_data.jsonl/49333 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
1949,
37307,
1155,
353,
8840,
836,
8,
341,
197,
43962,
1669,
5997,
3848,
7121,
840,
78,
8485,
93558,
3144,
340,
19907,
1669,
374,
7121,
1155,
692,
84004,
34830,
1669,
12716,
58806,
1820,
8623,
6184,
692,
84374,
11,
1848,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetMentionsEnabledFields(t *testing.T) {
attachmentWithTextAndPreText := model.SlackAttachment{
Text: "@here with mentions",
Pretext: "@Channel some comment for the channel",
}
attachmentWithOutPreText := model.SlackAttachment{
Text: "some text",
}
attachments := []*model.SlackAttachment{
&attachmentWithTextAndPreText,
&attachmentWithOutPreText,
}
post := &model.Post{
Message: "This is the message",
Props: model.StringInterface{
"attachments": attachments,
},
}
expectedFields := []string{
"This is the message",
"@Channel some comment for the channel",
"@here with mentions",
"some text"}
mentionEnabledFields := GetMentionsEnabledFields(post)
assert.EqualValues(t, 4, len(mentionEnabledFields))
assert.EqualValues(t, expectedFields, mentionEnabledFields)
} | explode_data.jsonl/28309 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
1949,
44,
63701,
5462,
8941,
1155,
353,
8840,
836,
8,
1476,
197,
21981,
2354,
1178,
3036,
4703,
1178,
1669,
1614,
808,
75,
473,
33569,
515,
197,
49635,
25,
262,
8428,
6739,
448,
33845,
756,
197,
197,
4703,
1318,
25,
8428,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsertBetweenIdx(t *testing.T) {
type args struct {
original []string
start int
stop int
toInsert []string
}
tests := []struct {
name string
args args
want []string
err string
}{
{
name: "simple",
args: args{
original: []string{"a", "b", "c", "d", "e", "f"},
start: 1,
stop: 2,
toInsert: []string{"x", "y"},
},
want: []string{"a", "x", "y", "d", "e", "f"},
},
{
name: "small original",
args: args{
original: []string{"a", "b", "c"},
start: 0,
stop: 1,
toInsert: []string{"x", "y", "z"},
},
want: []string{"x", "y", "z", "c"},
},
{
name: "negative start",
args: args{
original: []string{"a", "b", "c"},
start: -1,
stop: 1,
toInsert: []string{"x", "y", "z"},
},
err: "unable insert, invalid start: -1 or stop: 1",
},
{
name: "oob start",
args: args{
original: []string{"a", "b", "c"},
start: 3,
stop: 4,
toInsert: []string{"x", "y", "z"},
},
err: "unable insert, invalid start: 3 or stop: 4",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := insertBetweenIdx(tt.args.original, tt.args.start, tt.args.stop, tt.args.toInsert)
require := require.New(t)
if tt.err != "" {
require.EqualError(err, tt.err)
} else {
require.NoError(err)
require.Equal(tt.want, got)
}
})
}
} | explode_data.jsonl/6195 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 717
} | [
2830,
3393,
13780,
25477,
11420,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
9889,
3056,
917,
198,
197,
21375,
262,
526,
198,
197,
62644,
257,
526,
198,
197,
31709,
13780,
3056,
917,
198,
197,
532,
78216,
1669,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdCreateControllerAlreadyExisting(t *testing.T) {
ctx := api.NewDefaultContext()
fakeClient := tools.NewFakeEtcdClient(t)
key, _ := makeControllerKey(ctx, "foo")
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.ReplicationController{TypeMeta: api.TypeMeta{ID: "foo"}}), 0)
registry := NewTestEtcdRegistry(fakeClient)
err := registry.CreateController(ctx, &api.ReplicationController{
TypeMeta: api.TypeMeta{
ID: "foo",
},
})
if !errors.IsAlreadyExists(err) {
t.Errorf("expected already exists err, got %#v", err)
}
} | explode_data.jsonl/8162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
31860,
4385,
4021,
2051,
38370,
53067,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6330,
7121,
3675,
1972,
741,
1166,
726,
2959,
1669,
7375,
7121,
52317,
31860,
4385,
2959,
1155,
340,
23634,
11,
716,
1669,
1281,
2051,
1592,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestVirtualColumnDDL(t *testing.T) {
store, clean := testkit.CreateMockStoreWithSchemaLease(t, columnModifyLease)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`create global temporary table test_gv_ddl(a int, b int as (a+8) virtual, c int as (b + 2) stored) on commit delete rows;`)
is := tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
tbl, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_gv_ddl"))
require.NoError(t, err)
testCases := []struct {
generatedExprString string
generatedStored bool
}{
{"", false},
{"`a` + 8", false},
{"`b` + 2", true},
}
for i, column := range tbl.Meta().Columns {
require.Equal(t, testCases[i].generatedExprString, column.GeneratedExprString)
require.Equal(t, testCases[i].generatedStored, column.GeneratedStored)
}
result := tk.MustQuery(`DESC test_gv_ddl`)
result.Check(testkit.Rows(`a int(11) YES <nil> `, `b int(11) YES <nil> VIRTUAL GENERATED`, `c int(11) YES <nil> STORED GENERATED`))
tk.MustExec("begin;")
tk.MustExec("insert into test_gv_ddl values (1, default, default)")
tk.MustQuery("select * from test_gv_ddl").Check(testkit.Rows("1 9 11"))
tk.MustExec("commit")
// for local temporary table
tk.MustExec(`create temporary table test_local_gv_ddl(a int, b int as (a+8) virtual, c int as (b + 2) stored);`)
is = tk.Session().(sessionctx.Context).GetInfoSchema().(infoschema.InfoSchema)
tbl, err = is.TableByName(model.NewCIStr("test"), model.NewCIStr("test_local_gv_ddl"))
require.NoError(t, err)
for i, column := range tbl.Meta().Columns {
require.Equal(t, testCases[i].generatedExprString, column.GeneratedExprString)
require.Equal(t, testCases[i].generatedStored, column.GeneratedStored)
}
result = tk.MustQuery(`DESC test_local_gv_ddl`)
result.Check(testkit.Rows(`a int(11) YES <nil> `, `b int(11) YES <nil> VIRTUAL GENERATED`, `c int(11) YES <nil> STORED GENERATED`))
tk.MustExec("begin;")
tk.MustExec("insert into test_local_gv_ddl values (1, default, default)")
tk.MustQuery("select * from test_local_gv_ddl").Check(testkit.Rows("1 9 11"))
tk.MustExec("commit")
tk.MustQuery("select * from test_local_gv_ddl").Check(testkit.Rows("1 9 11"))
} | explode_data.jsonl/51312 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 898
} | [
2830,
3393,
33026,
2933,
58781,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
2354,
8632,
2304,
519,
1155,
11,
3250,
44427,
2304,
519,
340,
16867,
4240,
741,
3244,
74,
1669,
1273,
8226,
7121,
2271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExportImportPubKeyKeyRing(t *testing.T) {
kb, err := New("keybasename", "test", t.TempDir(), nil)
require.NoError(t, err)
algo := hd.Secp256k1
// CreateMnemonic a private-public key pair and ensure consistency
info, _, err := kb.NewMnemonic("john", English, sdk.FullFundraiserPath, algo)
require.Nil(t, err)
require.NotEqual(t, info, "")
require.Equal(t, info.GetName(), "john")
addr := info.GetPubKey().Address()
john, err := kb.Key("john")
require.NoError(t, err)
require.Equal(t, john.GetName(), "john")
require.Equal(t, john.GetPubKey().Address(), addr)
// Export the public key only
armor, err := kb.ExportPubKeyArmor("john")
require.NoError(t, err)
err = kb.Delete("john")
require.NoError(t, err)
// Import it under a different name
err = kb.ImportPubKey("john-pubkey-only", armor)
require.NoError(t, err)
// Ensure consistency
john2, err := kb.Key("john-pubkey-only")
require.NoError(t, err)
// Compare the public keys
require.True(t, john.GetPubKey().Equals(john2.GetPubKey()))
// Ensure keys cannot be overwritten
err = kb.ImportPubKey("john-pubkey-only", armor)
require.NotNil(t, err)
} | explode_data.jsonl/73437 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
16894,
11511,
29162,
1592,
1592,
43466,
1155,
353,
8840,
836,
8,
341,
16463,
65,
11,
1848,
1669,
1532,
445,
792,
42953,
497,
330,
1944,
497,
259,
65009,
6184,
1507,
2092,
340,
17957,
35699,
1155,
11,
1848,
340,
69571,
3346,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStyledText(t *testing.T) {
Test(t,
That("print (styled (styled abc red) blue)").
Prints("\033[34mabc\033[m"),
That("print (styled (styled abc italic) red)").
Prints("\033[3;31mabc\033[m"),
That("print (styled (styled abc inverse) inverse)").
Prints("\033[7mabc\033[m"),
That("print (styled (styled abc inverse) no-inverse)").Prints("abc"),
That("print (styled (styled abc inverse) toggle-inverse)").Prints("abc"),
That("print (styled (styled abc inverse) toggle-inverse toggle-inverse)").Prints("\033[7mabc\033[m"),
)
} | explode_data.jsonl/6983 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
34180,
1178,
1155,
353,
8840,
836,
8,
341,
73866,
1155,
345,
197,
197,
4792,
445,
1350,
320,
22849,
320,
22849,
39022,
2518,
8,
6303,
8,
38609,
298,
58702,
82,
4921,
15,
18,
18,
58,
18,
19,
76,
13683,
59,
15,
18,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValSetUpdatesOrderIndependenceTestsExecute(t *testing.T) {
// startVals - initial validators to create the set with
// updateVals - a sequence of updates to be applied to the set.
// updateVals is shuffled a number of times during testing to check for same resulting validator set.
valSetUpdatesOrderTests := []struct {
startVals []testVal
updateVals []testVal
}{
0: { // order of changes should not matter, the final validator sets should be the same
[]testVal{{"v1", 10}, {"v2", 10}, {"v3", 30}, {"v4", 40}},
[]testVal{{"v1", 11}, {"v2", 22}, {"v3", 33}, {"v4", 44}}},
1: { // order of additions should not matter
[]testVal{{"v1", 10}, {"v2", 20}},
[]testVal{{"v3", 30}, {"v4", 40}, {"v5", 50}, {"v6", 60}}},
2: { // order of removals should not matter
[]testVal{{"v1", 10}, {"v2", 20}, {"v3", 30}, {"v4", 40}},
[]testVal{{"v1", 0}, {"v3", 0}, {"v4", 0}}},
3: { // order of mixed operations should not matter
[]testVal{{"v1", 10}, {"v2", 20}, {"v3", 30}, {"v4", 40}},
[]testVal{{"v1", 0}, {"v3", 0}, {"v2", 22}, {"v5", 50}, {"v4", 44}}},
}
for i, tt := range valSetUpdatesOrderTests {
// create a new set and apply updates
valSet := createNewValidatorSet(tt.startVals)
valSetCopy := valSet.Copy()
valList := createNewValidatorList(tt.updateVals)
assert.NoError(t, valSetCopy.UpdateWithChangeSet(valList))
// save the result as expected for next updates
valSetExp := valSetCopy.Copy()
// perform at most 20 permutations on the updates and call UpdateWithChangeSet()
n := len(tt.updateVals)
maxNumPerms := cmn.MinInt(20, n*n)
for j := 0; j < maxNumPerms; j++ {
// create a copy of original set and apply a random permutation of updates
valSetCopy := valSet.Copy()
valList := createNewValidatorList(permutation(tt.updateVals))
// check there was no error and the set is properly scaled and centered.
assert.NoError(t, valSetCopy.UpdateWithChangeSet(valList),
"test %v failed for permutation %v", i, valList)
verifyValidatorSet(t, valSetCopy)
// verify the resulting test is same as the expected
assert.Equal(t, valSetCopy, valSetExp,
"test %v failed for permutation %v", i, valList)
}
}
} | explode_data.jsonl/28332 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 823
} | [
2830,
3393,
2208,
1649,
37091,
4431,
63399,
763,
18200,
17174,
1155,
353,
8840,
836,
8,
341,
197,
322,
1191,
52452,
481,
2856,
38588,
311,
1855,
279,
738,
448,
198,
197,
322,
2647,
52452,
481,
264,
8500,
315,
8837,
311,
387,
9251,
311... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateProject(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleCreateProjectSuccessfully(t)
createOpts := projects.CreateOpts{
Name: "Red Team",
Description: "The team that is red",
Tags: []string{"Red", "Team"},
Extra: map[string]interface{}{"test": "old"},
}
actual, err := projects.Create(client.ServiceClient(), createOpts).Extract()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, RedTeam, *actual)
} | explode_data.jsonl/49970 | {
"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,
4021,
7849,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
197,
6999,
4021,
7849,
35959,
1155,
692,
39263,
43451,
1669,
7079,
7251,
43451,
515,
197,
21297,
25,
286,
330,
6033,
790... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRpc_CreateTransaction(t *testing.T) {
err := client.Connect()
if err != nil {
t.Fatalf("error %s", err.Error())
}
ti := uint64(time.Now().Unix())
resp, err := client.Gc.CreateTransaction(context.Background(), &TransactionReq{
From: "FMejc9bjiTeQzKQG9fSDPGdsRzzEdEQe6se",
To: "FMegukTco2m1S9Y4ebXM9kVpQ6jqGGZBwWv",
Token: "FM",
Amount: 1000000000,
Fees: 1000000,
Nonce: 8,
Timestamp: ti,
})
fmt.Println(string(resp.Result))
var h *respHash
err = json.Unmarshal(resp.Result, &h)
if err != nil {
t.Fatalf("error %s", err.Error())
}
si, err := message.Sign("68d01d8fe1d512f9038040f0e1d3b26a599513a2e6595322aae07060afae698c", h.Header.Hash)
if err != nil {
t.Fatalf("error %s", err.Error())
}
resp, err = client.Gc.SendTransaction(context.Background(), &TransactionReq{
From: "FMejc9bjiTeQzKQG9fSDPGdsRzzEdEQe6se",
To: "FMegukTco2m1S9Y4ebXM9kVpQ6jqGGZBwWv",
Token: "FM",
Amount: 1000000000,
Fees: 1000000,
Nonce: 8,
Timestamp: ti,
Signature: si.SignatureString(),
Publickey: si.PubKeyString(),
})
fmt.Println(resp, err)
} | explode_data.jsonl/35237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 574
} | [
2830,
3393,
60248,
34325,
8070,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
2943,
43851,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
1018,
82,
497,
1848,
6141,
2398,
197,
532,
72859,
1669,
2622,
21,
19,
9730,
13244,
1005... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestConnBitfieldThenHaveBombardism(t *testing.T) {
w, r := net.Pipe()
cl, err := NewClient(testingConfig())
require.NoError(t, err)
tr := newTorrent(cl)
cn := newConn(tr, r, Peer{}, peer_wire.Reserved{})
go cn.mainLoop()
numPieces := 100
bf := peer_wire.NewBitField(numPieces)
bf.SetPiece(7)
bf.SetPiece(91)
w.Write((&peer_wire.Msg{
Kind: peer_wire.Bitfield,
Bf: bf,
}).Encode())
//get events from eventCH
e := <-cn.sendC
bm := e.(bitmap.Bitmap)
assert.Equal(t, 2, bm.Len())
assert.Equal(t, bm.Get(7), true)
assert.Equal(t, bm.Get(91), true)
for i := 0; i < 30*2; i += 2 {
w.Write((&peer_wire.Msg{
Kind: peer_wire.Have,
Index: uint32(i),
}).Encode())
}
for i := 0; i < 30*2; i += 2 {
e := <-cn.sendC
msg := e.(*peer_wire.Msg)
assert.Equal(t, peer_wire.Have, msg.Kind)
assert.EqualValues(t, i, msg.Index)
}
assert.Equal(t, 30+2, cn.peerBf.Len())
} | explode_data.jsonl/43527 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
9701,
8344,
2566,
12209,
12116,
91726,
567,
2142,
1155,
353,
8840,
836,
8,
341,
6692,
11,
435,
1669,
4179,
1069,
3444,
741,
39407,
11,
1848,
1669,
1532,
2959,
8623,
287,
2648,
2398,
17957,
35699,
1155,
11,
1848,
340,
25583,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddonsIndexByName(t *testing.T) {
addonName := "testaddon"
addons := []KubernetesAddon{
getMockAddon(addonName),
}
i := getAddonsIndexByName(addons, addonName)
if i != 0 {
t.Fatalf("addonsIndexByName() did not return the expected index value 0, instead returned: %d", i)
}
i = getAddonsIndexByName(addons, "nonExistentAddonName")
if i != -1 {
t.Fatalf("addonsIndexByName() did not return -1 for a non-existent addon, instead returned: %d", i)
}
} | explode_data.jsonl/33862 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
2212,
2382,
1552,
16898,
1155,
353,
8840,
836,
8,
341,
12718,
263,
675,
1669,
330,
1944,
51099,
698,
12718,
2382,
1669,
3056,
42,
29827,
84312,
515,
197,
10366,
11571,
84312,
25906,
263,
675,
1326,
197,
532,
8230,
1669,
633,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSearch__fedwireRoutingNumberOnlySearchRequest(t *testing.T) {
u, _ := url.Parse("https://moov.io/fed/wire/search?routingNumber=091905114")
req := readFEDSearchRequest(u)
if req.RoutingNumber != "091905114" {
t.Errorf("req.RoutingNUmber=%s", req.RoutingNumber)
}
if !req.routingNumberOnly() {
t.Errorf("req is not routing number only")
}
} | explode_data.jsonl/71098 | {
"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,
5890,
563,
51123,
35531,
24701,
2833,
7308,
5890,
1900,
1155,
353,
8840,
836,
8,
341,
10676,
11,
716,
1669,
2515,
8937,
445,
2428,
1110,
6355,
859,
4245,
6663,
291,
6324,
554,
23167,
30,
73320,
2833,
28,
15,
24,
16,
24,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServer_Request_Post_Body_ImmediateEOF(t *testing.T) {
testBodyContents(t, -1, "", func(st *serverTester) {
st.writeHeaders(HeadersFrameParam{
StreamID: 1, // clients send odd numbers
BlockFragment: st.encodeHeader(":method", "POST"),
EndStream: false, // to say DATA frames are coming
EndHeaders: true,
})
st.writeData(1, true, nil) // just kidding. empty body.
})
} | explode_data.jsonl/71608 | {
"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,
5475,
44024,
66726,
1668,
1076,
62,
52734,
23483,
1155,
353,
8840,
836,
8,
341,
18185,
5444,
14803,
1155,
11,
481,
16,
11,
7342,
2915,
5895,
353,
4030,
58699,
8,
341,
197,
18388,
3836,
10574,
7,
10574,
4369,
2001,
515,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddItemEmptyTitleDescription(t *testing.T) {
t.Parallel()
// arrange
p := podcast.New("title", "link", "description", nil, nil)
i := podcast.Item{}
// act
added, err := p.AddItem(i)
// assert
assert.EqualValues(t, 0, added)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Title")
assert.Contains(t, err.Error(), "Description")
assert.Contains(t, err.Error(), "required")
} | explode_data.jsonl/73073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
2212,
1234,
3522,
3851,
5009,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
30893,
198,
3223,
1669,
17711,
7121,
445,
2102,
497,
330,
2080,
497,
330,
4684,
497,
2092,
11,
2092,
340,
8230,
1669,
17711,
93... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserUnicodeNames(t *testing.T) {
th := Setup(t)
defer th.TearDown()
client := th.Client
t.Run("create user unicode", func(t *testing.T) {
user := model.User{
Email: th.GenerateTestEmail(),
FirstName: "Andrew\u202e",
LastName: "\ufeffWiggin",
Nickname: "Ender\u2028 Wiggin",
Password: "hello1",
Username: "\ufeffwiggin77",
Roles: model.SystemAdminRoleId + " " + model.SystemUserRoleId}
ruser, resp, err := client.CreateUser(&user)
require.NoError(t, err)
CheckCreatedStatus(t, resp)
_, _, _ = client.Login(user.Email, user.Password)
require.Equal(t, "wiggin77", ruser.Username, "Bad Unicode not filtered from username")
require.Equal(t, "Andrew Wiggin", ruser.GetDisplayName(model.ShowFullName), "Bad Unicode not filtered from displayname")
require.Equal(t, "Ender Wiggin", ruser.Nickname, "Bad Unicode not filtered from nickname")
})
t.Run("update user unicode", func(t *testing.T) {
user := th.CreateUser()
client.Login(user.Email, user.Password)
user.Username = "wiggin\ufff9"
user.Nickname = "Ender\u0340 \ufffcWiggin"
user.FirstName = "Andrew\ufff9"
user.LastName = "Wig\u206fgin"
ruser, _, err := client.UpdateUser(user)
require.NoError(t, err)
require.Equal(t, "wiggin", ruser.Username, "bad unicode should be filtered from username")
require.Equal(t, "Ender Wiggin", ruser.Nickname, "bad unicode should be filtered from nickname")
require.Equal(t, "Andrew Wiggin", ruser.GetDisplayName(model.ShowFullName), "bad unicode should be filtered from display name")
})
t.Run("patch user unicode", func(t *testing.T) {
user := th.CreateUser()
client.Login(user.Email, user.Password)
patch := &model.UserPatch{}
patch.Nickname = model.NewString("\U000E0000Ender\u206d Wiggin\U000E007F")
patch.FirstName = model.NewString("\U0001d173Andrew\U0001d17a")
patch.LastName = model.NewString("\u2028Wiggin\u2029")
ruser, _, err := client.PatchUser(user.Id, patch)
require.NoError(t, err)
CheckUserSanitization(t, ruser)
require.Equal(t, "Ender Wiggin", ruser.Nickname, "Bad unicode should be filtered from nickname")
require.Equal(t, "Andrew", ruser.FirstName, "Bad unicode should be filtered from first name")
require.Equal(t, "Wiggin", ruser.LastName, "Bad unicode should be filtered from last name")
require.Equal(t, "Andrew Wiggin", ruser.GetDisplayName(model.ShowFullName), "Bad unicode should be filtered from display name")
})
} | explode_data.jsonl/47507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 929
} | [
2830,
3393,
1474,
33920,
7980,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
340,
16867,
270,
836,
682,
4454,
741,
25291,
1669,
270,
11716,
271,
3244,
16708,
445,
3182,
1196,
26077,
497,
2915,
1155,
353,
8840,
836,
8,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetFileSize(t *testing.T) {
size, err := GetFileSize(gogputils)
if err != nil {
t.Fail()
}
kbSize := size / 1024
t.Log(helper.ByteCountIEC(size))
t.Log(helper.ByteCountSI(size))
t.Log(size)
t.Log(kbSize, "K")
} | explode_data.jsonl/24017 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
1949,
67649,
1155,
353,
8840,
836,
8,
341,
13832,
11,
1848,
1669,
2126,
67649,
3268,
538,
628,
8669,
340,
743,
1848,
961,
2092,
341,
197,
3244,
57243,
741,
197,
630,
16463,
65,
1695,
1669,
1379,
608,
220,
16,
15,
17,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClient_Stat(t *testing.T) {
if !isTestManual {
t.Skipf("%s not set", envNameTestManual)
}
remoteFile := "/etc/hosts"
fh, err := testClient.Open(remoteFile)
if err != nil {
t.Fatal(err)
}
fa, err := testClient.Fstat(fh)
if err != nil {
t.Fatal(err)
}
t.Logf("Stat: %s: %+v", remoteFile, fa)
} | explode_data.jsonl/66420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
2959,
62,
15878,
1155,
353,
8840,
836,
8,
341,
743,
753,
285,
2271,
52092,
341,
197,
3244,
57776,
69,
4430,
82,
537,
738,
497,
6105,
675,
2271,
52092,
340,
197,
630,
197,
18147,
1703,
1669,
3521,
12107,
14,
44692,
698,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRevokeSessions(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
user := th.BasicUser
Client.Login(user.Email, user.Password)
sessions, _ := Client.GetSessions(user.Id, "")
if len(sessions) == 0 {
t.Fatal("sessions should exist")
}
for _, session := range sessions {
if session.UserId != user.Id {
t.Fatal("user id does not match session user id")
}
}
session := sessions[0]
_, resp := Client.RevokeSession(user.Id, model.NewId())
CheckBadRequestStatus(t, resp)
_, resp = Client.RevokeSession(th.BasicUser2.Id, model.NewId())
CheckForbiddenStatus(t, resp)
_, resp = Client.RevokeSession("junk", model.NewId())
CheckBadRequestStatus(t, resp)
status, resp := Client.RevokeSession(user.Id, session.Id)
if !status {
t.Fatal("user session revoke unsuccessful")
}
CheckNoError(t, resp)
th.LoginBasic()
sessions, _ = th.App.GetSessions(th.SystemAdminUser.Id)
session = sessions[0]
_, resp = Client.RevokeSession(user.Id, session.Id)
CheckBadRequestStatus(t, resp)
Client.Logout()
_, resp = Client.RevokeSession(user.Id, model.NewId())
CheckUnauthorizedStatus(t, resp)
_, resp = th.SystemAdminClient.RevokeSession(user.Id, model.NewId())
CheckBadRequestStatus(t, resp)
sessions, _ = th.SystemAdminClient.GetSessions(th.SystemAdminUser.Id, "")
if len(sessions) == 0 {
t.Fatal("sessions should exist")
}
for _, session := range sessions {
if session.UserId != th.SystemAdminUser.Id {
t.Fatal("user id does not match session user id")
}
}
session = sessions[0]
_, resp = th.SystemAdminClient.RevokeSession(th.SystemAdminUser.Id, session.Id)
CheckNoError(t, resp)
} | explode_data.jsonl/21548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 619
} | [
2830,
3393,
693,
7621,
59062,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
19060,
1669,
270,
48868,
1474,
198,
71724,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAzureDevOpsProject_ProjectRead_UsesNameIfIdNotSet(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
coreClient := azdosdkmocks.NewMockCoreClient(ctrl)
clients := &config.AggregatedClient{
CoreClient: coreClient,
Ctx: context.Background(),
}
id := ""
name := "name"
coreClient.
EXPECT().
GetProject(clients.Ctx, core.GetProjectArgs{
ProjectId: &name,
IncludeCapabilities: converter.Bool(true),
IncludeHistory: converter.Bool(false),
}).
Times(1)
projectRead(clients, id, name)
} | explode_data.jsonl/3735 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
78107,
14592,
38904,
7849,
64659,
4418,
62,
68965,
675,
2679,
764,
2623,
1649,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
71882,
2959,
1669,
12376,
40525,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoutesFromRules(t *testing.T) {
assert := tassert.New(t)
mc := MeshCatalog{meshSpec: smi.NewFakeMeshSpecClient()}
testCases := []struct {
name string
rules []access.TrafficTargetRule
namespace string
expectedRoutes []trafficpolicy.HTTPRouteMatch
}{
{
name: "http route group and match name exist",
rules: []access.TrafficTargetRule{
{
Kind: "HTTPRouteGroup",
Name: tests.RouteGroupName,
Matches: []string{tests.BuyBooksMatchName},
},
},
namespace: tests.Namespace,
expectedRoutes: []trafficpolicy.HTTPRouteMatch{tests.BookstoreBuyHTTPRoute},
},
{
name: "http route group and match name do not exist",
rules: []access.TrafficTargetRule{
{
Kind: "HTTPRouteGroup",
Name: "DoesNotExist",
Matches: []string{"hello"},
},
},
namespace: tests.Namespace,
expectedRoutes: []trafficpolicy.HTTPRouteMatch{},
},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("Testing routesFromRules where %s", tc.name), func(t *testing.T) {
routes, err := mc.routesFromRules(tc.rules, tc.namespace)
assert.Nil(err)
assert.EqualValues(tc.expectedRoutes, routes)
})
}
} | explode_data.jsonl/69748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
26653,
3830,
26008,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
259,
2207,
7121,
1155,
340,
97662,
1669,
25122,
41606,
90,
23506,
8327,
25,
1525,
72,
7121,
52317,
14194,
8327,
2959,
368,
630,
18185,
37302,
1669,
3056,
1235,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAlphaHugePagesIsolation(t *testing.T) {
successCases := []core.Pod{
{ // Basic fields.
ObjectMeta: metav1.ObjectMeta{Name: "123", Namespace: "ns"},
Spec: core.PodSpec{
Containers: []core.Container{
{
Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
},
Limits: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
},
},
},
},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
},
},
}
failureCases := []core.Pod{
{ // Basic fields.
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-requireCpuOrMemory", Namespace: "ns"},
Spec: core.PodSpec{
Containers: []core.Container{
{
Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
},
Limits: core.ResourceList{
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
},
},
},
},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
},
},
{ // Basic fields.
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-shared", Namespace: "ns"},
Spec: core.PodSpec{
Containers: []core.Container{
{
Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
},
Limits: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-2Mi"): resource.MustParse("2Gi"),
},
},
},
},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
},
},
{ // Basic fields.
ObjectMeta: metav1.ObjectMeta{Name: "hugepages-multiple", Namespace: "ns"},
Spec: core.PodSpec{
Containers: []core.Container{
{
Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File",
Resources: core.ResourceRequirements{
Requests: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-1Gi"): resource.MustParse("2Gi"),
},
Limits: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
core.ResourceName("hugepages-2Mi"): resource.MustParse("1Gi"),
core.ResourceName("hugepages-1Gi"): resource.MustParse("2Gi"),
},
},
},
},
RestartPolicy: core.RestartPolicyAlways,
DNSPolicy: core.DNSClusterFirst,
},
},
}
// Enable feature HugePages
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.HugePages, true)()
for i := range successCases {
pod := &successCases[i]
if errs := ValidatePod(pod); len(errs) != 0 {
t.Errorf("Unexpected error for case[%d], err: %v", i, errs)
}
}
for i := range failureCases {
pod := &failureCases[i]
if errs := ValidatePod(pod); len(errs) == 0 {
t.Errorf("Expected error for case[%d], pod: %v", i, pod.Name)
}
}
// Disable feature HugePages
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.HugePages, false)()
// Disable feature HugePages and ensure all success cases fail
for i := range successCases {
pod := &successCases[i]
if errs := ValidatePod(pod); len(errs) == 0 {
t.Errorf("Expected error for case[%d], pod: %v", i, pod.Name)
}
}
} | explode_data.jsonl/1006 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1950
} | [
2830,
3393,
19384,
39,
4733,
17713,
3872,
34962,
1155,
353,
8840,
836,
8,
341,
30553,
37302,
1669,
3056,
2153,
88823,
515,
197,
197,
90,
442,
14625,
5043,
624,
298,
23816,
12175,
25,
77520,
16,
80222,
63121,
25,
330,
16,
17,
18,
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... | 7 |
func TestErrorCodes(t *testing.T) {
assert.True(t, IsBadRequestError(yarpcerrors.Newf(yarpcerrors.CodeInvalidArgument, "")))
assert.True(t, IsUnexpectedError(yarpcerrors.Newf(yarpcerrors.CodeInternal, "")))
assert.True(t, IsTimeoutError(yarpcerrors.Newf(yarpcerrors.CodeDeadlineExceeded, "")))
} | explode_data.jsonl/16196 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
1454,
20871,
1155,
353,
8840,
836,
8,
341,
6948,
32443,
1155,
11,
2160,
46015,
1454,
7021,
277,
3992,
7650,
7121,
69,
7021,
277,
3992,
7650,
20274,
7928,
9171,
11,
1591,
5929,
6948,
32443,
1155,
11,
2160,
29430,
1454,
7021,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestZoneInitialized(t *testing.T) {
fnh := &testutil.FakeNodeHandler{
Existing: []*v1.Node{
{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC),
Labels: map[string]string{},
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{
Type: v1.NodeReady,
Status: v1.ConditionUnknown,
LastHeartbeatTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
LastTransitionTime: metav1.Date(2015, 1, 1, 12, 0, 0, 0, time.UTC),
},
},
},
Spec: v1.NodeSpec{
Taints: []v1.Taint{
{
Key: schedulerapi.TaintExternalCloudProvider,
Value: "true",
Effect: v1.TaintEffectNoSchedule,
},
},
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{}),
DeleteWaitChan: make(chan struct{}),
}
factory := informers.NewSharedInformerFactory(fnh, 0)
fakeCloud := &fakecloud.Cloud{
InstanceTypes: map[types.NodeName]string{
types.NodeName("node0"): "t1.micro",
},
Addresses: []v1.NodeAddress{
{
Type: v1.NodeHostName,
Address: "node0.cloud.internal",
},
{
Type: v1.NodeInternalIP,
Address: "10.0.0.1",
},
{
Type: v1.NodeExternalIP,
Address: "132.143.154.163",
},
},
Provider: "aws",
Zone: cloudprovider.Zone{
FailureDomain: "us-west-1a",
Region: "us-west",
},
Err: nil,
}
eventBroadcaster := record.NewBroadcaster()
cloudNodeController := &CloudNodeController{
kubeClient: fnh,
nodeInformer: factory.Core().V1().Nodes(),
cloud: fakeCloud,
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "cloud-node-controller"}),
}
eventBroadcaster.StartLogging(klog.Infof)
cloudNodeController.AddCloudNode(context.TODO(), fnh.Existing[0])
assert.Equal(t, 1, len(fnh.UpdatedNodes), "Node was not updated")
assert.Equal(t, "node0", fnh.UpdatedNodes[0].Name, "Node was not updated")
assert.Equal(t, 4, len(fnh.UpdatedNodes[0].ObjectMeta.Labels),
"Node label for Region and Zone were not set")
assert.Equal(t, "us-west", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneRegionStable],
"Node Region not correctly updated")
assert.Equal(t, "us-west-1a", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneFailureDomainStable],
"Node FailureDomain not correctly updated")
assert.Equal(t, "us-west", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneRegion],
"Node Region not correctly updated")
assert.Equal(t, "us-west-1a", fnh.UpdatedNodes[0].ObjectMeta.Labels[v1.LabelZoneFailureDomain],
"Node FailureDomain not correctly updated")
} | explode_data.jsonl/13628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1240
} | [
2830,
3393,
15363,
22495,
1155,
353,
8840,
836,
8,
341,
1166,
16719,
1669,
609,
1944,
1314,
991,
726,
1955,
3050,
515,
197,
197,
53067,
25,
29838,
85,
16,
21714,
515,
298,
197,
515,
571,
23816,
12175,
25,
77520,
16,
80222,
515,
464,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidArgsFuncAndCmdCompletionInGo(t *testing.T) {
rootCmd := &Command{
Use: "root",
ValidArgsFunction: validArgsFunc,
Run: emptyRun,
}
childCmd := &Command{
Use: "thechild",
Short: "The child command",
Run: emptyRun,
}
rootCmd.AddCommand(childCmd)
// Test that both sub-commands and validArgsFunction are completed
output, err := executeCommand(rootCmd, ShellCompNoDescRequestCmd, "")
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
expected := strings.Join([]string{
"completion",
"help",
"thechild",
"one",
"two",
":0",
"Completion ended with directive: ShellCompDirectiveDefault", ""}, "\n")
if output != expected {
t.Errorf("expected: %q, got: %q", expected, output)
}
// Test that both sub-commands and validArgs are completed with prefix
output, err = executeCommand(rootCmd, ShellCompNoDescRequestCmd, "t")
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
expected = strings.Join([]string{
"thechild",
"two",
":0",
"Completion ended with directive: ShellCompDirectiveDefault", ""}, "\n")
if output != expected {
t.Errorf("expected: %q, got: %q", expected, output)
}
// Test that both sub-commands and validArgs are completed with description
output, err = executeCommand(rootCmd, ShellCompRequestCmd, "t")
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
expected = strings.Join([]string{
"thechild\tThe child command",
"two\tThe second",
":0",
"Completion ended with directive: ShellCompDirectiveDefault", ""}, "\n")
if output != expected {
t.Errorf("expected: %q, got: %q", expected, output)
}
} | explode_data.jsonl/43739 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 613
} | [
2830,
3393,
4088,
4117,
9626,
3036,
15613,
33190,
641,
10850,
1155,
353,
8840,
836,
8,
341,
33698,
15613,
1669,
609,
4062,
515,
197,
95023,
25,
2290,
330,
2888,
756,
197,
197,
4088,
4117,
5152,
25,
2697,
4117,
9626,
345,
197,
85952,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestParser_SeparateSubDocuments(t *testing.T) {
tests := []struct {
name string
data []byte
want [][]byte
}{
{
name: "happy path",
data: []byte(`kind: Pod
---
kind: Service`),
want: [][]byte{
[]byte(`kind: Pod`),
[]byte(`kind: Service`),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := &yaml.Parser{}
got := p.SeparateSubDocuments(tt.data)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/1273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
6570,
1098,
11584,
349,
3136,
27143,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
8924,
3056,
3782,
198,
197,
50780,
52931,
3782,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAcquireBuildLock_waitLowerExpired(t *testing.T) {
// wait for a lock to expire
client := buildLock_Client(t)
counter := buildLock_CountWatch(client)
old := buildLock_Lock(t, client, "my-namespace", "my-owner", "my-repository", "my-branch", "11", 11, time.Duration(2)*time.Second)
// should update the lock
pod := buildLock_Pod(t, client, "my-owner", "my-repository", "my-branch", "13")
clean, channel := buildLock_AcquireFromPod(t, client, "my-namespace", pod, false)
defer clean()
// wait for AcquireBuildLock to be waiting
for {
count := 0
select {
case count = <-counter:
case callback := <-channel:
require.NotNil(t, callback, "timeout")
assert.Fail(t, "TestAcquireBuildLock returned")
callback()
return
}
if count == 1 {
break
}
}
// check the lock
lock, err := client.CoreV1().ConfigMaps("jx").Get(old.Name, metav1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, old.ObjectMeta, lock.ObjectMeta)
assert.Equal(t, "my-namespace", lock.Data["namespace"])
assert.Equal(t, "my-owner", lock.Data["owner"])
assert.Equal(t, "my-repository", lock.Data["repository"])
assert.Equal(t, "my-branch", lock.Data["branch"])
assert.Equal(t, "13", lock.Data["build"])
assert.Equal(t, pod.Name, lock.Data["pod"])
assert.Equal(t, old.Data["timestamp"], lock.Data["timestamp"])
// should acquire the lock after 2 seconds
callback := <-channel
require.NotNil(t, callback, "timeout")
buildLock_AssertLockFromPod(t, client, "my-namespace", pod)
callback()
buildLock_AssertNoLock(t, client, "my-namespace")
} | explode_data.jsonl/28232 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 596
} | [
2830,
3393,
11654,
984,
11066,
11989,
18760,
9053,
54349,
1155,
353,
8840,
836,
8,
341,
197,
322,
3783,
369,
264,
5296,
311,
32563,
198,
25291,
1669,
1936,
11989,
46102,
1155,
340,
58261,
1669,
1936,
11989,
50775,
14247,
12805,
340,
61828... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnforceNilClaims(t *testing.T) {
kubeclientset := fake.NewSimpleClientset(test.NewFakeConfigMap())
enf := rbac.NewEnforcer(kubeclientset, test.FakeArgoCDNamespace, common.ArgoCDConfigMapName, nil)
_ = enf.SetBuiltinPolicy(assets.BuiltinPolicyCSV)
rbacEnf := rbacpolicy.NewRBACPolicyEnforcer(enf, test.NewFakeProjLister())
enf.SetClaimsEnforcerFunc(rbacEnf.EnforceClaims)
assert.False(t, enf.Enforce(nil, "applications", "get", "foo/obj"))
enf.SetDefaultRole("role:readonly")
assert.True(t, enf.Enforce(nil, "applications", "get", "foo/obj"))
} | explode_data.jsonl/38035 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
1702,
8833,
19064,
51133,
1155,
353,
8840,
836,
8,
341,
16463,
3760,
2972,
746,
1669,
12418,
7121,
16374,
2959,
746,
8623,
7121,
52317,
2648,
2227,
2398,
81848,
69,
1669,
18717,
580,
7121,
1702,
82010,
5969,
3760,
2972,
746,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackend_CertWrites(t *testing.T) {
// CA cert
ca1, err := ioutil.ReadFile("test-fixtures/root/rootcacert.pem")
if err != nil {
t.Fatalf("err: %v", err)
}
// Non CA Cert
ca2, err := ioutil.ReadFile("test-fixtures/keys/cert.pem")
if err != nil {
t.Fatalf("err: %v", err)
}
// Non CA cert without TLS web client authentication
ca3, err := ioutil.ReadFile("test-fixtures/noclientauthcert.pem")
if err != nil {
t.Fatalf("err: %v", err)
}
tc := logicaltest.TestCase{
AcceptanceTest: true,
Backend: testFactory(t),
Steps: []logicaltest.TestStep{
testAccStepCert(t, "aaa", ca1, "foo", false),
testAccStepCert(t, "bbb", ca2, "foo", false),
testAccStepCert(t, "ccc", ca3, "foo", true),
},
}
tc.Steps = append(tc.Steps, testAccStepListCerts(t, []string{"aaa", "bbb"})...)
logicaltest.Test(t, tc)
} | explode_data.jsonl/68942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
29699,
920,
529,
93638,
1155,
353,
8840,
836,
8,
341,
197,
322,
9183,
2777,
198,
197,
924,
16,
11,
1848,
1669,
43144,
78976,
445,
1944,
70913,
18513,
72074,
72074,
83110,
529,
49373,
1138,
743,
1848,
961,
2092,
341,
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... | 4 |
func TestDockerImageReferenceEquality(t *testing.T) {
equalityTests := []struct {
a, b DockerImageReference
isEqual bool
}{
{
a: DockerImageReference{},
b: DockerImageReference{},
isEqual: true,
},
{
a: DockerImageReference{
Name: "openshift",
},
b: DockerImageReference{
Name: "openshift",
},
isEqual: true,
},
{
a: DockerImageReference{
Name: "openshift",
},
b: DockerImageReference{
Name: "openshift3",
},
isEqual: false,
},
{
a: DockerImageReference{
Name: "openshift",
},
b: DockerImageReference{
Registry: DockerDefaultRegistry,
Namespace: DockerDefaultNamespace,
Name: "openshift",
Tag: DefaultImageTag,
},
isEqual: true,
},
{
a: DockerImageReference{
Name: "openshift",
},
b: DockerImageReference{
Registry: DockerDefaultRegistry,
Namespace: DockerDefaultNamespace,
Name: "openshift",
Tag: "v1.0",
},
isEqual: false,
},
{
a: DockerImageReference{
Name: "openshift",
},
b: DockerImageReference{
Registry: DockerDefaultRegistry,
Namespace: DockerDefaultNamespace,
Name: "openshift",
Tag: DefaultImageTag,
ID: "d0a28ab59a",
},
isEqual: false,
},
}
for i, test := range equalityTests {
if isEqual := test.a.Equal(test.b); isEqual != test.isEqual {
t.Errorf("test %d: %#v.Equal(%#v) = %t; want %t",
i, test.a, test.b, isEqual, test.isEqual)
}
// commutativeness sanity check
if x, y := test.a.Equal(test.b), test.b.Equal(test.a); x != y {
t.Errorf("test %[1]d: %[2]q.Equal(%[3]q) = %[4]t != %[3]q.Equal(%[2]q) = %[5]t",
i, test.a, test.b, x, y)
}
}
} | explode_data.jsonl/40835 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 859
} | [
2830,
3393,
35,
13659,
1906,
8856,
50745,
1155,
353,
8840,
836,
8,
341,
7727,
10473,
18200,
1669,
3056,
1235,
341,
197,
11323,
11,
293,
262,
40549,
1906,
8856,
198,
197,
19907,
2993,
1807,
198,
197,
59403,
197,
197,
515,
298,
11323,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestValueAssignment_UnmarshalJSON(t *testing.T) {
tests := []struct {
name string
jsonVal string
wantType ValueAssignmentType
wantValue interface{}
}{
{"IntLiteral", `{"type":0, "value":1.10}`, ValueAssignmentLiteral, 1.10},
{"StringLiteral", `{"type":0, "value":"abc"}`, ValueAssignmentLiteral, "abc"},
{"List", `{"type":2, "value":["1", "two"]}`, ValueAssignmentList, []interface{}{"1", "two"}},
{"Map", `{"type":3, "value":{"one":"val1","two":"val2"}}`, ValueAssignmentMap,
map[string]interface{}{"one": "val1", "two": "val2"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var v ValueAssignment
err := json.Unmarshal([]byte(tt.jsonVal), &v)
if err != nil {
t.Errorf("ValueAssignment.UnmarshalJSON() error = %v", err)
} else {
assert.Equal(t, tt.wantType.String(), v.Type.String(),
"Unexpected type error unmarshalling %s", tt.jsonVal)
assert.Equal(t, tt.wantValue, v.Value,
"Unexpected value error unmarshalling %s (%t)", tt.jsonVal, v.Value)
}
})
}
} | explode_data.jsonl/64273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
1130,
41613,
40687,
27121,
5370,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
30847,
2208,
256,
914,
198,
197,
50780,
929,
220,
5162,
41613,
929,
198,
197,
50780,
1130,
3749,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFillPortPlaceholders(t *testing.T) {
fillPortPlaceholdersTests := []struct {
name string
wrapper *prometheusExecReceiver
newPort int
want *subprocessmanager.SubprocessConfig
}{
{
name: "port is defined by user",
wrapper: &prometheusExecReceiver{
port: 10500,
config: &Config{
ScrapeTimeout: 10 * time.Second,
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "apache_exporter --port:{{port}}",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:{{port}})/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "{{port}}",
},
},
},
},
subprocessConfig: &subprocessmanager.SubprocessConfig{
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
},
{
Name: "SECONDARY_PORT",
},
},
},
},
newPort: 10500,
want: &subprocessmanager.SubprocessConfig{
Command: "apache_exporter --port:10500",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:10500)/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "10500",
},
},
},
},
{
name: "no string templating",
wrapper: &prometheusExecReceiver{
config: &Config{
ScrapeTimeout: 10 * time.Second,
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "apache_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:port)/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "1234",
},
},
},
},
subprocessConfig: &subprocessmanager.SubprocessConfig{
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
},
{
Name: "SECONDARY_PORT",
},
},
},
},
newPort: 0,
want: &subprocessmanager.SubprocessConfig{
Command: "apache_exporter",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:port)/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "1234",
},
},
},
},
{
name: "no port defined",
wrapper: &prometheusExecReceiver{
config: &Config{
SubprocessConfig: subprocessmanager.SubprocessConfig{
Command: "apache_exporter --port={{port}}",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:{{port}})/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "{{port}}",
},
},
},
},
subprocessConfig: &subprocessmanager.SubprocessConfig{
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
},
{
Name: "SECONDARY_PORT",
},
},
},
},
newPort: 10111,
want: &subprocessmanager.SubprocessConfig{
Command: "apache_exporter --port=10111",
Env: []subprocessmanager.EnvConfig{
{
Name: "DATA_SOURCE_NAME",
Value: "user:password@(hostname:10111)/dbname",
},
{
Name: "SECONDARY_PORT",
Value: "10111",
},
},
},
},
}
for _, test := range fillPortPlaceholdersTests {
t.Run(test.name, func(t *testing.T) {
got := test.wrapper.fillPortPlaceholders(test.newPort)
assert.Equal(t, test.want.Command, got.Command)
assert.Equal(t, test.want.Env, got.Env)
})
}
} | explode_data.jsonl/1741 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1793
} | [
2830,
3393,
14449,
7084,
17371,
16662,
1155,
353,
8840,
836,
8,
341,
65848,
7084,
17371,
16662,
18200,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
6692,
5518,
353,
24468,
39705,
10216,
25436,
198,
197,
8638,
7084,
526,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCloseRemovesDiagMsgListener(t *testing.T) {
assert := assert.New(t)
transmitter := new(mocks.Transmitter)
transmitter.On("Close").Return(closed)
diagMsgListener := new(mocks.DiagnosticsMessageListener)
diagMsgListener.On("Remove")
diagMsgSubscriber := new(mocks.DiagnosticsMessageSubscriber)
diagMsgSubscriber.
On("Subscribe", mock.AnythingOfType("appinsights.DiagnosticsMessageHandler")).
Return(diagMsgListener)
ai := ApplicationInsights{
transmitter: transmitter,
Timeout: internal.Duration{Duration: time.Hour},
EnableDiagnosticLogging: true,
diagMsgSubscriber: diagMsgSubscriber,
InstrumentationKey: "1234", // Fake, but necessary to enable tracking
}
err := ai.Connect()
assert.NoError(err)
diagMsgSubscriber.AssertCalled(t, "Subscribe", mock.AnythingOfType("appinsights.DiagnosticsMessageHandler"))
err = ai.Close()
assert.NoError(err)
transmitter.AssertCalled(t, "Close")
diagMsgListener.AssertCalled(t, "Remove")
} | explode_data.jsonl/50940 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 410
} | [
2830,
3393,
7925,
6590,
10088,
21685,
351,
6611,
2743,
1155,
353,
8840,
836,
8,
972,
6948,
1669,
2060,
7121,
1155,
7229,
72453,
16126,
1669,
501,
1255,
25183,
11815,
16126,
1218,
72453,
16126,
8071,
445,
7925,
1827,
5598,
1337,
9259,
7229... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDemoValidationError(t *testing.T) {
host := newDefaultNamedHost(demo.ValidationErrorHost, t)
host.Spec.Image = &metalkubev1alpha1.Image{
URL: "a-url",
Checksum: "a-checksum",
}
host.Spec.Online = true
r := newDemoReconciler(host)
tryReconcile(t, r, host,
func(host *metalkubev1alpha1.BareMetalHost, result reconcile.Result) bool {
t.Logf("Status: %q State: %q ErrorMessage: %q",
host.OperationalStatus(),
host.Status.Provisioning.State,
host.Status.ErrorMessage,
)
return host.HasError()
},
)
} | explode_data.jsonl/9499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
37413,
80553,
1155,
353,
8840,
836,
8,
341,
63104,
1669,
501,
3675,
15810,
9296,
1500,
6726,
82714,
9296,
11,
259,
340,
63104,
36473,
7528,
284,
609,
4059,
1692,
3760,
85,
16,
7141,
16,
7528,
515,
197,
79055,
25,
414,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBadTLS(t *testing.T) {
for _, test := range badTLS {
_, err := TLS(test.host, test.port, 1)
if err == nil {
t.Log("Expected error for", test)
t.Fail()
continue
}
if err.Error() != test.exp {
t.Logf("Expected error \"%v\" got \"%v\"", test.exp, err.Error())
t.Logf(" for, %s", test.host)
t.Fail()
}
}
} | explode_data.jsonl/25873 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
17082,
45439,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3873,
45439,
341,
197,
197,
6878,
1848,
1669,
41654,
8623,
17840,
11,
1273,
14598,
11,
220,
16,
340,
197,
743,
1848,
621,
2092,
341,
298,
3244,
5247... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenesisTxHash(t *testing.T) {
// Mainnet
genesisTxHash := GenesisTxHash(&chaincfg.MainNetParams).String()
if genesisTxHash == "" {
t.Errorf("Failed to get genesis transaction hash for mainnet.")
}
t.Logf("Genesis transaction hash (mainnet): %s", genesisTxHash)
mainnetExpectedTxHash := "e7dfbceac9fccd6025c70a1dfa9302b3e7b5aa22fa51c98a69164ad403d60a2c"
if genesisTxHash != mainnetExpectedTxHash {
t.Errorf("Incorrect genesis transaction hash (mainnet). Expected %s, got %s",
mainnetExpectedTxHash, genesisTxHash)
}
// Simnet
genesisTxHash = GenesisTxHash(&chaincfg.SimNetParams).String()
if genesisTxHash == "" {
t.Errorf("Failed to get genesis transaction hash for simnet.")
}
t.Logf("Genesis transaction hash (mainnet): %s", genesisTxHash)
simnetExpectedTxHash := "a216ea043f0d481a072424af646787794c32bcefd3ed181a090319bbf8a37105"
if genesisTxHash != simnetExpectedTxHash {
t.Errorf("Incorrect genesis transaction hash (simnet). Expected %s, got %s",
mainnetExpectedTxHash, genesisTxHash)
}
} | explode_data.jsonl/54132 | {
"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,
84652,
31584,
6370,
1155,
353,
8840,
836,
8,
341,
197,
322,
4697,
4711,
198,
82281,
13774,
31584,
6370,
1669,
40788,
31584,
6370,
2099,
8819,
14072,
23873,
6954,
4870,
568,
703,
741,
743,
59366,
31584,
6370,
621,
1591,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_Pagination_PrevNext_PopularBadLinks(t *testing.T) {
doc := testutil.CreateHTML()
body := dom.QuerySelector(doc, "body")
root := testutil.CreateDiv(0)
dom.AppendChild(body, root)
nextAnchor := testutil.CreateAnchor("page2", "next page")
dom.AppendChild(root, nextAnchor)
// If the same bad URL can get scores accumulated across links,
// it would wrongly get selected.
bad1 := testutil.CreateAnchor("not-page1", "not")
bad2 := testutil.CreateAnchor("not-page1", "not")
bad3 := testutil.CreateAnchor("not-page1", "not")
bad4 := testutil.CreateAnchor("not-page1", "not")
bad5 := testutil.CreateAnchor("not-page1", "not")
dom.AppendChild(root, bad1)
dom.AppendChild(root, bad2)
dom.AppendChild(root, bad3)
dom.AppendChild(root, bad4)
dom.AppendChild(root, bad5)
assertDefaultDocumenOutlink(t, doc, nil, nextAnchor)
} | explode_data.jsonl/10830 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
1088,
10353,
1088,
7282,
5847,
1088,
453,
1276,
17082,
24089,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
1273,
1314,
7251,
5835,
741,
35402,
1669,
4719,
15685,
5877,
19153,
11,
330,
2599,
5130,
33698,
1669,
1273,
1314,
7251,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHref(t *testing.T) {
assert := assert.New(t)
sp, _ := ForDatabase("aws://table/foo/bar/baz")
assert.Equal("aws://table/foo/bar/baz", sp.Href())
sp, _ = ForDataset("aws://[table:bucket]/foo/bar/baz::myds")
assert.Equal("aws://[table:bucket]/foo/bar/baz", sp.Href())
sp, _ = ForPath("aws://[table:bucket]/foo/bar/baz::myds.my.path")
assert.Equal("aws://[table:bucket]/foo/bar/baz", sp.Href())
sp, err := ForPath("mem::myds.my.path")
assert.NoError(err)
assert.Equal("", sp.Href())
} | explode_data.jsonl/49592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
64919,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
41378,
11,
716,
1669,
1752,
5988,
445,
8635,
1110,
2005,
60555,
49513,
3470,
1370,
1138,
6948,
12808,
445,
8635,
1110,
2005,
60555,
49513,
3470,
1370,
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 TestTransactionDoubleNonce(t *testing.T) {
t.Parallel()
pool, key := setupTxPool()
defer pool.Stop()
addr := crypto.PubkeyToAddress(key.PublicKey)
resetState := func() {
statedb, _ := state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
statedb.AddBalance(addr, big.NewInt(100000000000000))
pool.chain = &testBlockChain{statedb, 1000000, new(notify.Feed)}
<-pool.requestReset(nil, nil)
}
resetState()
signer := types.HomesteadSigner{}
tx1, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 100000, big.NewInt(1), nil), signer, key)
tx2, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, big.NewInt(2), nil), signer, key)
tx3, _ := types.SignTx(types.NewTransaction(0, common.Address{}, big.NewInt(100), 1000000, big.NewInt(1), nil), signer, key)
// Add the first two transaction, ensure higher priced stays only
if replace, err := pool.add(tx1, false); err != nil || replace {
t.Errorf("first transaction insert failed (%v) or reported replacement (%v)", err, replace)
}
if replace, err := pool.add(tx2, false); err != nil || !replace {
t.Errorf("second transaction insert failed (%v) or not reported replacement (%v)", err, replace)
}
<-pool.requestPromoteExecutables(newAccountSet(signer, addr))
if pool.pending[addr].Len() != 1 {
t.Error("expected 1 pending transactions, got", pool.pending[addr].Len())
}
if tx := pool.pending[addr].txs.items[0]; tx.Hash() != tx2.Hash() {
t.Errorf("transaction mismatch: have %x, want %x", tx.Hash(), tx2.Hash())
}
// Add the third transaction and ensure it's not saved (smaller price)
pool.add(tx3, false)
<-pool.requestPromoteExecutables(newAccountSet(signer, addr))
if pool.pending[addr].Len() != 1 {
t.Error("expected 1 pending transactions, got", pool.pending[addr].Len())
}
if tx := pool.pending[addr].txs.items[0]; tx.Hash() != tx2.Hash() {
t.Errorf("transaction mismatch: have %x, want %x", tx.Hash(), tx2.Hash())
}
// Ensure the total transaction count is correct
if pool.all.Count() != 1 {
t.Error("expected 1 total transactions, got", pool.all.Count())
}
} | explode_data.jsonl/7860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 762
} | [
2830,
3393,
8070,
7378,
90528,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
85273,
11,
1376,
1669,
6505,
31584,
10551,
741,
16867,
7314,
30213,
2822,
53183,
1669,
19028,
1069,
392,
792,
1249,
4286,
4857,
49139,
1592,
340,
70343,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApp_SetStdout(t *testing.T) {
w := &mockWriter{}
app := &App{
Name: "test",
Writer: w,
}
err := app.Run([]string{"help"})
if err != nil {
t.Fatalf("Run error: %s", err)
}
if len(w.written) == 0 {
t.Error("App did not write output to desired writer.")
}
} | explode_data.jsonl/52575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
2164,
14812,
22748,
411,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
609,
16712,
6492,
31483,
28236,
1669,
609,
2164,
515,
197,
21297,
25,
256,
330,
1944,
756,
197,
197,
6492,
25,
289,
345,
197,
630,
9859,
1669,
906,
16708,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyRead(t *testing.T) {
ctx := context.Background()
flags.Set(t, "auth.enable_anonymous_usage", "true")
te := getTestEnv(t, emptyUserMap)
ctx, err := prefix.AttachUserPrefixToContext(ctx, te)
if err != nil {
t.Errorf("error attaching user prefix: %v", err)
}
peer := fmt.Sprintf("localhost:%d", app.FreePort(t))
c := cacheproxy.NewCacheProxy(te, te.GetCache(), peer)
if err := c.StartListening(); err != nil {
t.Fatalf("Error setting up cacheproxy: %s", err)
}
waitUntilServerIsAlive(peer)
remoteInstanceName := "null"
isolation := &dcpb.Isolation{CacheType: dcpb.Isolation_CAS_CACHE, RemoteInstanceName: remoteInstanceName}
d := &repb.Digest{
Hash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
SizeBytes: 0,
}
cache, err := te.GetCache().WithIsolation(ctx, interfaces.CASCacheType, remoteInstanceName)
require.NoError(t, err)
err = cache.Set(ctx, d, []byte{})
if err != nil {
t.Fatal(err)
}
r, err := c.RemoteReader(ctx, peer, isolation, d, 0)
if err != nil {
t.Fatal(err)
}
_, err = r.Read(nil)
if err != io.EOF {
t.Fatal(err)
}
} | explode_data.jsonl/69648 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 465
} | [
2830,
3393,
3522,
4418,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
59516,
4202,
1155,
11,
330,
3242,
28697,
12008,
9757,
31507,
497,
330,
1866,
1138,
197,
665,
1669,
633,
2271,
14359,
1155,
11,
4287,
1474,
2227,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestManifestGeneratePilot(t *testing.T) {
runTestGroup(t, testGroup{
{
desc: "pilot_default",
// TODO: remove istio ConfigMap (istio/istio#16828)
diffIgnore: "CustomResourceDefinition:*:*,ConfigMap:*:istio",
},
{
desc: "pilot_k8s_settings",
diffIgnore: "CustomResourceDefinition:*:*,ConfigMap:*:istio",
},
{
desc: "pilot_override_values",
diffSelect: "Deployment:*:istiod",
},
{
desc: "pilot_override_kubernetes",
diffSelect: "Deployment:*:istiod, Service:*:istio-pilot",
},
{
desc: "pilot_merge_meshconfig",
diffSelect: "ConfigMap:*:istio$",
},
})
} | explode_data.jsonl/55972 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
38495,
31115,
47,
23958,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
2808,
1155,
11,
1273,
2808,
515,
197,
197,
515,
298,
41653,
25,
330,
79,
23958,
9993,
756,
298,
197,
322,
5343,
25,
4057,
5999,
815,
5532,
2227,
320,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReceiverNameIsUnique(t *testing.T) {
in := `
route:
receiver: team-X
receivers:
- name: 'team-X'
- name: 'team-X'
`
_, err := Load(in)
expected := "notification config name \"team-X\" is not unique"
if err == nil {
t.Fatalf("no error returned, expected:\n%q", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%q\ngot:\n%q", expected, err.Error())
}
} | explode_data.jsonl/72894 | {
"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,
25436,
675,
3872,
22811,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
22074,
8966,
510,
262,
13964,
25,
2083,
30550,
271,
53387,
1945,
510,
12,
829,
25,
364,
9196,
30550,
1248,
12,
829,
25,
364,
9196,
30550,
1248,
3989,
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 TestHashable(t *testing.T) {
table := make(map[fs.Node]int)
table[root(0)] = 42
table[directory{}] = 57
table[file{}] = 12
} | explode_data.jsonl/25782 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
6370,
480,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
1281,
9147,
58,
3848,
21714,
63025,
692,
26481,
79444,
7,
15,
7252,
284,
220,
19,
17,
198,
26481,
21427,
4758,
78134,
284,
220,
20,
22,
198,
26481,
70098,
78134,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStartReplicationPhysical(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*50)
defer cancel()
conn, err := pgconn.Connect(ctx, os.Getenv("PGLOGREPL_TEST_CONN_STRING"))
require.NoError(t, err)
defer closeConn(t, conn)
sysident, err := pglogrepl.IdentifySystem(ctx, conn)
require.NoError(t, err)
_, err = pglogrepl.CreateReplicationSlot(ctx, conn, slotName, "", pglogrepl.CreateReplicationSlotOptions{Temporary: true, Mode: pglogrepl.PhysicalReplication})
require.NoError(t, err)
err = pglogrepl.StartReplication(ctx, conn, slotName, sysident.XLogPos, pglogrepl.StartReplicationOptions{Mode: pglogrepl.PhysicalReplication})
require.NoError(t, err)
go func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
config, err := pgconn.ParseConfig(os.Getenv("PGLOGREPL_TEST_CONN_STRING"))
require.NoError(t, err)
delete(config.RuntimeParams, "replication")
conn, err := pgconn.ConnectConfig(ctx, config)
require.NoError(t, err)
defer closeConn(t, conn)
_, err = conn.Exec(ctx, `
create table mytable(id int primary key, name text);
drop table mytable;
`).ReadAll()
require.NoError(t, err)
}()
_ = func() pglogrepl.PrimaryKeepaliveMessage {
msg, err := conn.ReceiveMessage(ctx)
require.NoError(t, err)
cdMsg, ok := msg.(*pgproto3.CopyData)
require.True(t, ok)
require.Equal(t, byte(pglogrepl.PrimaryKeepaliveMessageByteID), cdMsg.Data[0])
pkm, err := pglogrepl.ParsePrimaryKeepaliveMessage(cdMsg.Data[1:])
require.NoError(t, err)
return pkm
}
rxXLogData := func() pglogrepl.XLogData {
msg, err := conn.ReceiveMessage(ctx)
require.NoError(t, err)
cdMsg, ok := msg.(*pgproto3.CopyData)
require.True(t, ok)
require.Equal(t, byte(pglogrepl.XLogDataByteID), cdMsg.Data[0])
xld, err := pglogrepl.ParseXLogData(cdMsg.Data[1:])
require.NoError(t, err)
return xld
}
xld := rxXLogData()
assert.Contains(t, string(xld.WALData), "mytable")
copyDoneResult, err := pglogrepl.SendStandbyCopyDone(ctx, conn)
require.NoError(t, err)
assert.Nil(t, copyDoneResult)
} | explode_data.jsonl/45907 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 831
} | [
2830,
3393,
3479,
18327,
1693,
39253,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
882,
32435,
9,
20,
15,
340,
16867,
9121,
2822,
32917,
11,
1848,
1669,
17495,
5148,
43851,
7502,
11,
2643,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_bot_onChannelMessage(t *testing.T) {
cfg := fakeCfg{}
prc := &fakeProcessor{}
discord := &FakeDiscordClientSpy{}
discord.failOnClose = true
b := &bot{
cfg: cfg,
discord: discord,
prc: prc,
}
botUser := &discordgo.User{ID: "123"}
sta := discordgo.NewState()
sta.User = botUser
ses := &discordgo.Session{State: sta}
m := &discordgo.MessageCreate{
Message: &discordgo.Message{
ChannelID: "chanel1",
Author: &discordgo.User{ID: "456"},
Content: "<@123> this is a message",
Mentions: []*discordgo.User{botUser},
},
}
b.onChannelMessage(ses, m)
wantChannel := "chanel1"
gotChannel := discord.lastChannelTo
if wantChannel != gotChannel {
t.Errorf("want message reply to %q, got %q", wantChannel, gotChannel)
}
wantMessage := "<@456> 456 told me : this is a message"
gotMessage := discord.lastMessage
if wantMessage != gotMessage {
t.Errorf("want message %q, got %q", wantMessage, gotMessage)
}
} | explode_data.jsonl/2145 | {
"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,
38883,
4470,
9629,
2052,
1155,
353,
8840,
836,
8,
1476,
50286,
1669,
12418,
42467,
16094,
25653,
66,
1669,
609,
30570,
22946,
31483,
2698,
3427,
539,
1669,
609,
52317,
23477,
539,
2959,
44027,
16094,
2698,
3427,
539,
26738,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMemberNotFound_Error(t *testing.T) {
mnf := &callbacks.MemberNotFound{}
expectedErrMsg := callbacks.MemberNotFoundMessage
if mnf.Error() != expectedErrMsg {
t.Errorf(
"Unexpected error message. Got %s, Expected: %s",
mnf.Error(),
expectedErrMsg,
)
}
mnf.Err = fmt.Errorf(wrapMsg)
expectedErrMsg = fmt.Sprintf("%s: %s", expectedErrMsg, wrapMsg)
if mnf.Error() != expectedErrMsg {
t.Errorf(
"Unexpected error message. Got %s, Expected: %s",
mnf.Error(),
expectedErrMsg,
)
}
} | explode_data.jsonl/56079 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
9366,
10372,
28651,
1155,
353,
8840,
836,
8,
341,
2109,
31737,
1669,
609,
68311,
46404,
10372,
16094,
42400,
75449,
1669,
26679,
46404,
10372,
2052,
271,
743,
27938,
69,
6141,
368,
961,
3601,
75449,
341,
197,
3244,
13080,
1006... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostgres(t *testing.T) {
for version, port := range map[string]int{"10": 5430, "11": 5431, "12": 5433} {
t.Run(version, func(t *testing.T) {
client := enttest.Open(t, dialect.Postgres, fmt.Sprintf("host=localhost port=%d user=postgres dbname=test password=pass sslmode=disable", port), opts)
defer client.Close()
for _, tt := range tests {
name := runtime.FuncForPC(reflect.ValueOf(tt).Pointer()).Name()
t.Run(name[strings.LastIndex(name, ".")+1:], func(t *testing.T) {
drop(t, client)
tt(t, client)
})
}
})
}
} | explode_data.jsonl/45700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
4133,
17818,
1155,
353,
8840,
836,
8,
341,
2023,
2319,
11,
2635,
1669,
2088,
2415,
14032,
63025,
4913,
16,
15,
788,
220,
20,
19,
18,
15,
11,
330,
16,
16,
788,
220,
20,
19,
18,
16,
11,
330,
16,
17,
788,
220,
20,
19,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLastBatchesRequest(t *testing.T) {
input := CreateTestEnv(t)
ctx := input.Context
createTestBatch(t, input)
createTestBatch(t, input)
lastBatches, err := lastBatchesRequest(ctx, input.GravityKeeper)
require.NoError(t, err)
expectedJSON := []byte(`[
{
"transactions": [
{
"erc20_fee": {
"amount": "3",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"dest_address": "0x320915BD0F1bad11cBf06e85D5199DBcAC4E9934",
"erc20_token": {
"amount": "101",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"sender": "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du",
"id": "6"
},
{
"erc20_fee": {
"amount": "2",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"dest_address": "0x320915BD0F1bad11cBf06e85D5199DBcAC4E9934",
"erc20_token": {
"amount": "102",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"sender": "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du",
"id": "7"
}
],
"batch_nonce": "2",
"block": "1234567",
"token_contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
{
"transactions": [
{
"erc20_fee": {
"amount": "3",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"dest_address": "0x320915BD0F1bad11cBf06e85D5199DBcAC4E9934",
"erc20_token": {
"amount": "101",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"sender": "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du",
"id": "2"
},
{
"erc20_fee": {
"amount": "2",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"dest_address": "0x320915BD0F1bad11cBf06e85D5199DBcAC4E9934",
"erc20_token": {
"amount": "102",
"contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
},
"sender": "cosmos1qyqszqgpqyqszqgpqyqszqgpqyqszqgpjnp7du",
"id": "3"
}
],
"batch_nonce": "1",
"block": "1234567",
"token_contract": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"
}
]
`)
assert.JSONEq(t, string(expectedJSON), string(lastBatches), "json is equal")
} | explode_data.jsonl/8802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1246
} | [
2830,
3393,
5842,
33,
9118,
1900,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
14359,
1155,
340,
20985,
1669,
1946,
9328,
271,
39263,
2271,
21074,
1155,
11,
1946,
340,
39263,
2271,
21074,
1155,
11,
1946,
692,
33096,
33,
9118,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetServiceInfo(t *testing.T) {
defer leakcheck.Check(t)
testSd := ServiceDesc{
ServiceName: "grpc.testing.EmptyService",
HandlerType: (*emptyServiceServer)(nil),
Methods: []MethodDesc{
{
MethodName: "EmptyCall",
Handler: nil,
},
},
Streams: []StreamDesc{
{
StreamName: "EmptyStream",
Handler: nil,
ServerStreams: false,
ClientStreams: true,
},
},
Metadata: []int{0, 2, 1, 3},
}
server := NewServer()
server.RegisterService(&testSd, &testServer{})
info := server.GetServiceInfo()
want := map[string]ServiceInfo{
"grpc.testing.EmptyService": {
Methods: []MethodInfo{
{
Name: "EmptyCall",
IsClientStream: false,
IsServerStream: false,
},
{
Name: "EmptyStream",
IsClientStream: true,
IsServerStream: false,
}},
Metadata: []int{0, 2, 1, 3},
},
}
if !reflect.DeepEqual(info, want) {
t.Errorf("GetServiceInfo() = %+v, want %+v", info, want)
}
} | explode_data.jsonl/74372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
1949,
1860,
1731,
1155,
353,
8840,
836,
8,
972,
16867,
23352,
2028,
10600,
1155,
1218,
18185,
50,
67,
1669,
5362,
11065,
1666,
197,
91619,
675,
25,
330,
56585,
45056,
11180,
1860,
4723,
197,
197,
3050,
929,
25,
4609,
3194,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultipleURLsInCRLDP(t *testing.T) {
block, _ := pem.Decode([]byte(multipleURLsInCRLDPPEM))
cert, err := ParseCertificate(block.Bytes)
if err != nil {
t.Fatalf("failed to parse certificate: %s", err)
}
want := []string{
"http://epscd.catcert.net/crl/ec-acc.crl",
"http://epscd2.catcert.net/crl/ec-acc.crl",
}
if got := cert.CRLDistributionPoints; !reflect.DeepEqual(got, want) {
t.Errorf("CRL distribution points = %#v, want #%v", got, want)
}
} | explode_data.jsonl/68022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
32089,
3144,
82,
641,
34,
4728,
10298,
1155,
353,
8840,
836,
8,
341,
47996,
11,
716,
1669,
54184,
56372,
10556,
3782,
1255,
12229,
3144,
82,
641,
34,
4728,
10298,
1740,
44,
1171,
1444,
529,
11,
1848,
1669,
14775,
33202,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetConfigurationReturnsCorrectMaxConnConfiguration(t *testing.T) {
templateFile, err := ioutil.TempFile("", "provider-configuration")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(templateFile.Name())
data := []byte(`[backends]
[backends.backend1]
[backends.backend1.maxconn]
amount = 10
extractorFunc = "request.host"`)
err = ioutil.WriteFile(templateFile.Name(), data, 0700)
if err != nil {
t.Fatal(err)
}
provider := &myProvider{
BaseProvider{
Filename: templateFile.Name(),
},
nil,
}
configuration, err := provider.getConfiguration(templateFile.Name(), nil, nil)
if err != nil {
t.Fatalf("Shouldn't have error out, got %v", err)
}
if configuration == nil {
t.Fatalf("Configuration should not be nil, but was")
}
if configuration.Backends["backend1"].MaxConn.Amount != 10 {
t.Fatalf("Configuration did not parse MaxConn.Amount properly")
}
if configuration.Backends["backend1"].MaxConn.ExtractorFunc != "request.host" {
t.Fatalf("Configuration did not parse MaxConn.ExtractorFunc properly")
}
} | explode_data.jsonl/64890 | {
"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,
1949,
7688,
16446,
33092,
5974,
9701,
7688,
1155,
353,
8840,
836,
8,
341,
22832,
1703,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
19979,
12,
21138,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAddMaterialByURL(t *testing.T) {
resp := &http.Response{
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewReader([]byte(`{
"errcode": 0,
"errmsg": "ok",
"media_id": "MEDIA_ID",
"url": "URL"
}`))),
}
ctrl := gomock.NewController(t)
defer ctrl.Finish()
client := mock.NewMockHTTPClient(ctrl)
client.EXPECT().Upload(gomock.AssignableToTypeOf(context.TODO()), "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=image", gomock.AssignableToTypeOf(yiigo.NewUploadForm())).Return(resp, nil)
oa := New("APPID", "APPSECRET")
oa.SetClient(wx.WithHTTPClient(client))
result := new(ResultMaterialAdd)
err := oa.Do(context.TODO(), "ACCESS_TOKEN", AddMaterialByURL(MediaImage, "test.png", "https://golang.google.cn/doc/gopher/pkg.png", result))
assert.Nil(t, err)
assert.Equal(t, &ResultMaterialAdd{
MediaID: "MEDIA_ID",
URL: "URL",
}, result)
} | explode_data.jsonl/20865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
2212,
13415,
1359,
3144,
1155,
353,
8840,
836,
8,
341,
34653,
1669,
609,
1254,
12574,
515,
197,
197,
15872,
25,
1758,
52989,
345,
197,
197,
5444,
25,
6399,
2067,
453,
51236,
799,
23158,
68587,
10556,
3782,
5809,
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... | 1 |
func TestInt32_HasAll(t *testing.T) {
testcases := []struct {
name string
s Int32
input []int32
expect bool
}{
{
name: "test Int32 HasAll, set has all input elements",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{1, 2},
expect: true,
},
{
name: "test Int32 HasAll, set does not have all input elements",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{8, 9},
expect: false,
},
{
name: "test Int32 HasAll, set does not have all input elements, but exist elements in set",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{1, 9},
expect: false,
},
{
name: "test Int32 HasAll, input empty",
s: map[int32]struct{}{1: {}, 2: {}, 3: {}},
input: []int32{},
expect: true,
},
}
for _, tc := range testcases {
t.Logf("running scenario: %s", tc.name)
actual := tc.s.HasAll(tc.input...)
if actual != tc.expect {
t.Errorf("expect return: %v, but got: %v", tc.expect, actual)
}
}
} | explode_data.jsonl/62325 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
1072,
18,
17,
2039,
300,
2403,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
1903,
414,
1333,
18,
17,
198,
197,
22427,
220,
3056,
396,
18,
17,
198,
197,
24952,
1807,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportClusterEmitsInitScripts(t *testing.T) {
ic := importContextForTest()
ic.importCluster(&clusters.Cluster{
InitScripts: []clusters.InitScriptStorageInfo{
{
Dbfs: &clusters.DbfsStorageInfo{
Destination: "/mnt/abc/test.sh",
},
},
},
})
assert.Equal(t, 1, len(ic.testEmits))
assert.True(t, ic.testEmits["databricks_dbfs_file[<unknown>] (id: /mnt/abc/test.sh)"])
} | explode_data.jsonl/49921 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
11511,
28678,
2269,
1199,
3803,
44942,
1155,
353,
8840,
836,
8,
341,
197,
292,
1669,
1159,
1972,
2461,
2271,
741,
197,
292,
34897,
28678,
2099,
78521,
72883,
515,
197,
98762,
44942,
25,
3056,
78521,
26849,
5910,
5793,
1731,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVolumeTypesCreateDestroy(t *testing.T) {
client, err := clients.NewBlockStorageV1Client()
if err != nil {
t.Fatalf("Unable to create a blockstorage client: %v", err)
}
volumeType, err := CreateVolumeType(t, client)
if err != nil {
t.Fatalf("Unable to create volume type: %v", err)
}
defer DeleteVolumeType(t, client, volumeType)
tools.PrintResource(t, volumeType)
} | explode_data.jsonl/32333 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
18902,
4173,
4021,
14245,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
8239,
7121,
4713,
5793,
53,
16,
2959,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
17075,
311,
1855,
264,
2504,
16172,
2943,
25,
1018... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestJob_UnprocessedRecords(t *testing.T) {
type fields struct {
session session.ServiceFormatter
info Response
}
tests := []struct {
name string
fields fields
want []UnprocessedRecord
wantErr bool
}{
{
name: "Passing",
fields: fields{
info: Response{
ID: "1234",
ColumnDelimiter: string(Pipe),
LineEnding: string(Linefeed),
},
session: &mockSessionFormatter{
url: "https://test.salesforce.com",
client: mockHTTPClient(func(req *http.Request) *http.Response {
if req.URL.String() != "https://test.salesforce.com/jobs/ingest/1234/unprocessedrecords/" {
return &http.Response{
StatusCode: 500,
Status: "Invalid URL",
Body: ioutil.NopCloser(strings.NewReader(req.URL.String())),
Header: make(http.Header),
}
}
if req.Method != http.MethodGet {
return &http.Response{
StatusCode: 500,
Status: "Invalid Method",
Body: ioutil.NopCloser(strings.NewReader(req.Method)),
Header: make(http.Header),
}
}
resp := "FirstName|LastName|DOB\nJohn|Doe|1/1/1970\nJane|Doe|1/1/1980\n"
return &http.Response{
StatusCode: http.StatusOK,
Status: "Good",
Body: ioutil.NopCloser(strings.NewReader(resp)),
Header: make(http.Header),
}
}),
},
},
want: []UnprocessedRecord{
{
Fields: map[string]string{
"FirstName": "John",
"LastName": "Doe",
"DOB": "1/1/1970",
},
},
{
Fields: map[string]string{
"FirstName": "Jane",
"LastName": "Doe",
"DOB": "1/1/1980",
},
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
j := &Job{
session: tt.fields.session,
info: tt.fields.info,
}
got, err := j.UnprocessedRecords()
if (err != nil) != tt.wantErr {
t.Errorf("Job.UnprocessedRecords() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Job.UnprocessedRecords() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/19888 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1149
} | [
2830,
3393,
12245,
40687,
34022,
25876,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
25054,
3797,
13860,
14183,
198,
197,
27043,
262,
5949,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
55276... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChatSrvGetUnreadLine(t *testing.T) {
runWithMemberTypes(t, func(mt chat1.ConversationMembersType) {
ctc := makeChatTestContext(t, "GetUnreadLine", 2)
defer ctc.cleanup()
users := ctc.users()
ui := kbtest.NewChatUI()
ctc.as(t, users[0]).h.mockChatUI = ui
ctc.as(t, users[1]).h.mockChatUI = ui
ctx1 := ctc.as(t, users[0]).startCtx
ctx2 := ctc.as(t, users[1]).startCtx
<-ctc.as(t, users[0]).h.G().ConvLoader.Stop(ctx1)
<-ctc.as(t, users[1]).h.G().ConvLoader.Stop(ctx2)
listener1 := newServerChatListener()
ctc.as(t, users[0]).h.G().NotifyRouter.AddListener(listener1)
listener2 := newServerChatListener()
ctc.as(t, users[1]).h.G().NotifyRouter.AddListener(listener2)
g1 := ctc.world.Tcs[users[0].Username].ChatG
g2 := ctc.world.Tcs[users[1].Username].ChatG
conv := mustCreateConversationForTest(t, ctc, users[0], chat1.TopicType_CHAT, mt, users[1])
msg := chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hi"})
msgID1 := mustPostLocalForTest(t, ctc, users[0], conv, msg)
consumeNewMsgRemote(t, listener1, chat1.MessageType_TEXT)
consumeNewMsgRemote(t, listener2, chat1.MessageType_TEXT)
mustEditMsg(ctx1, t, ctc, users[0], conv, msgID1)
consumeNewMsgRemote(t, listener1, chat1.MessageType_EDIT)
consumeNewMsgRemote(t, listener2, chat1.MessageType_EDIT)
assertUnreadline := func(ctx context.Context, g *globals.ChatContext, user *kbtest.FakeUser,
readMsgID, unreadLineID chat1.MessageID) {
for i := 0; i < 1; i++ {
if i == 0 {
require.NoError(t, g.ConvSource.Clear(ctx, conv.Id, user.GetUID().ToBytes()))
}
res, err := ctc.as(t, user).chatLocalHandler().GetUnreadline(ctx,
chat1.GetUnreadlineArg{
ConvID: conv.Id,
ReadMsgID: readMsgID,
})
require.NoError(t, err)
if unreadLineID == 0 {
require.Nil(t, res.UnreadlineID)
} else {
require.NotNil(t, res.UnreadlineID)
require.Equal(t, unreadLineID, *res.UnreadlineID)
}
}
}
// user2 will have an unread id of the TEXT message even after the edit
assertUnreadline(ctx1, g1, users[0], 1, msgID1)
assertUnreadline(ctx1, g1, users[0], msgID1, 0)
assertUnreadline(ctx2, g2, users[1], 1, msgID1)
assertUnreadline(ctx2, g2, users[1], msgID1, 0)
// subsequent TEXT post leaves unreadline unchanged.
msg = chat1.NewMessageBodyWithText(chat1.MessageText{Body: "hi"})
msgID2 := mustPostLocalForTest(t, ctc, users[0], conv, msg)
consumeNewMsgRemote(t, listener1, chat1.MessageType_TEXT)
consumeNewMsgRemote(t, listener2, chat1.MessageType_TEXT)
assertUnreadline(ctx2, g2, users[1], 1, msgID1)
// If user2 has read to msgID1, msgID2 is the next candidate
assertUnreadline(ctx2, g2, users[1], msgID1, msgID2)
// reaction does not affect things
mustReactToMsg(ctx1, t, ctc, users[0], conv, msgID2, ":+1:")
consumeNewMsgRemote(t, listener1, chat1.MessageType_REACTION)
consumeNewMsgRemote(t, listener2, chat1.MessageType_REACTION)
assertUnreadline(ctx2, g2, users[1], 1, msgID1)
// user2 will bump unreadLineID to msgID which the next visible msg
mustDeleteMsg(ctx1, t, ctc, users[0], conv, msgID1)
consumeNewMsgRemote(t, listener1, chat1.MessageType_DELETE)
consumeNewMsgRemote(t, listener2, chat1.MessageType_DELETE)
assertUnreadline(ctx2, g2, users[1], 1, msgID2)
// user2 will have no unread id since the only visible message was now deleted
msgID3 := mustDeleteMsg(ctx1, t, ctc, users[0], conv, msgID2)
consumeNewMsgRemote(t, listener1, chat1.MessageType_DELETE)
consumeNewMsgRemote(t, listener2, chat1.MessageType_DELETE)
assertUnreadline(ctx2, g2, users[1], 1, 0)
// if we are fully read, there is no line and we don't go to the server
g1.ConvSource.SetRemoteInterface(func() chat1.RemoteInterface {
return chat1.RemoteClient{Cli: errorClient{}}
})
assertUnreadline(ctx1, g1, users[0], msgID3, 0)
g2.ConvSource.SetRemoteInterface(func() chat1.RemoteInterface {
return chat1.RemoteClient{Cli: errorClient{}}
})
assertUnreadline(ctx2, g2, users[1], msgID3, 0)
})
} | explode_data.jsonl/63694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1696
} | [
2830,
3393,
15672,
50,
10553,
1949,
1806,
878,
2460,
1155,
353,
8840,
836,
8,
341,
56742,
2354,
9366,
4173,
1155,
11,
2915,
81618,
6236,
16,
4801,
22323,
24371,
929,
8,
341,
197,
89216,
66,
1669,
1281,
15672,
2271,
1972,
1155,
11,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.