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 TestVerifyContainerStatus(t *testing.T) {
meta := &runtimeapi.ContainerMetadata{Name: "cname", Attempt: 3}
metaWithoutName := &runtimeapi.ContainerMetadata{Attempt: 3}
imageSpec := &runtimeapi.ImageSpec{Image: "fimage"}
imageSpecWithoutImage := &runtimeapi.ImageSpec{}
statuses := []struct {
input *runtimeapi.ContainerStatus
expected error
}{
{
input: &runtimeapi.ContainerStatus{},
expected: fmt.Errorf("status.Id is not set"),
},
{
input: &runtimeapi.ContainerStatus{
Id: "1",
},
expected: fmt.Errorf("status.Metadata is not set"),
},
{
input: &runtimeapi.ContainerStatus{
Id: "2",
Metadata: metaWithoutName,
},
expected: fmt.Errorf("metadata.Name is not in metadata %q", metaWithoutName),
},
{
input: &runtimeapi.ContainerStatus{
Id: "3",
Metadata: meta,
},
expected: fmt.Errorf("status.CreatedAt is not set"),
},
{
input: &runtimeapi.ContainerStatus{
Id: "4",
Metadata: meta,
CreatedAt: 1,
Image: imageSpecWithoutImage,
},
expected: fmt.Errorf("status.Image is not set"),
},
{
input: &runtimeapi.ContainerStatus{
Id: "5",
Metadata: meta,
Image: imageSpec,
CreatedAt: 1,
},
expected: fmt.Errorf("status.ImageRef is not set"),
},
{
input: &runtimeapi.ContainerStatus{
Id: "5",
Metadata: meta,
Image: imageSpec,
CreatedAt: 1,
ImageRef: "Ref-1",
},
expected: nil,
},
}
for _, status := range statuses {
actual := verifyContainerStatus(status.input)
if actual != nil {
assert.EqualError(t, actual, status.expected.Error())
} else {
assert.Nil(t, status.expected)
}
}
} | explode_data.jsonl/19001 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 744
} | [
2830,
3393,
32627,
4502,
2522,
1155,
353,
8840,
836,
8,
341,
84004,
1669,
609,
22255,
2068,
33672,
14610,
63121,
25,
330,
78488,
497,
43517,
25,
220,
18,
532,
84004,
26040,
675,
1669,
609,
22255,
2068,
33672,
14610,
90,
47052,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestParsePath(t *testing.T) {
for _, example := range []string{
"members",
"name.familyName",
"addresses[type eq \"work\"]",
"members[value eq \"2819c223-7f76-453a-919d-413861904646\"]",
"members[value eq \"2819c223-7f76-453a-919d-413861904646\"].displayName",
} {
t.Run(example, func(t *testing.T) {
if _, err := ParsePath([]byte(example)); err != nil {
t.Error(err)
}
})
}
} | explode_data.jsonl/60380 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
14463,
1820,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
3110,
1669,
2088,
3056,
917,
515,
197,
197,
1,
22974,
756,
197,
197,
31486,
67947,
675,
756,
197,
197,
1,
53789,
21557,
8939,
7245,
1778,
75104,
756,
197,
197,
1,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_NewHandler(t *testing.T) {
// How can I test a function that returns a Struct ?
// A better Idea? Please tell me!
h := NewHandler()
handler := &h
if handler == nil {
t.Error("&NewHandler() == nil, wants !nil")
}
} | explode_data.jsonl/31609 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
39582,
3050,
1155,
353,
8840,
836,
8,
341,
197,
322,
2585,
646,
358,
1273,
264,
729,
429,
4675,
264,
16139,
17607,
197,
322,
362,
2664,
51001,
30,
5209,
3291,
752,
4894,
9598,
1669,
1532,
3050,
741,
53326,
1669,
609,
71,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandshakeServerSNIGetCertificateNotFound(t *testing.T) {
config := *testConfig
config.GetCertificate = func(clientHello *ClientHelloInfo) (*Certificate, error) {
return nil, nil
}
test := &serverTest{
name: "SNI",
command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", "-servername", "snitest.com"},
config: &config,
}
runServerTestTLS12(t, test)
} | explode_data.jsonl/80562 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
2314,
29661,
5475,
18966,
1914,
295,
33202,
10372,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
353,
1944,
2648,
271,
25873,
2234,
33202,
284,
2915,
12805,
9707,
353,
2959,
9707,
1731,
8,
4609,
33202,
11,
1465,
8,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFilterHost(t *testing.T) {
assert := assert.New(t)
rancher := NewRancherMockClient()
rancher.AddEnvironment(client.Project{Name: "Default", Resource: client.Resource{Id: "1a5"}})
host := client.Host{Hostname: "agent01.mysite.com", AccountId: "1a5", Labels: map[string]interface{}{"monitor": "true", "stage": "develop"}}
assert.True(filterHost(rancher, host, ""))
assert.True(filterHost(rancher, host, "*"))
assert.True(filterHost(rancher, host, "+agent01.mysite.com"))
assert.True(filterHost(rancher, host, "agent01.mysite.com"))
assert.True(filterHost(rancher, host, "agent01.mysite.com"))
assert.True(filterHost(rancher, host, "agent01.mysite.com,stage=develop"))
assert.False(filterHost(rancher, host, "agent02.mysite.com"))
assert.False(filterHost(rancher, host, "*,-stage=develop"))
assert.False(filterHost(rancher, host, "agent01.mysite.com,-stage=develop"))
assert.False(filterHost(rancher, host, "-agent01.mysite.com!L,stage=develop"))
assert.True(filterHost(rancher, host, "%ENV=Default"))
assert.False(filterHost(rancher, host, "%ENV=something"))
assert.False(filterHost(rancher, host, "*,-%ENV=Default"))
} | explode_data.jsonl/48864 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 427
} | [
2830,
3393,
5632,
9296,
1155,
353,
8840,
836,
8,
1476,
6948,
1669,
2060,
7121,
1155,
340,
7000,
3497,
261,
1669,
1532,
49,
3497,
261,
11571,
2959,
2822,
7000,
3497,
261,
1904,
12723,
12805,
30944,
63121,
25,
330,
3675,
497,
11765,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNiceMD_Clone(t *testing.T) {
nmd := metautils.NiceMD(metadata.Pairs(testPairs...))
fullCopied := nmd.Clone()
assert.Equal(t, len(fullCopied), len(nmd), "clone full should copy all keys")
assert.Equal(t, "uno", fullCopied.Get("singlekey"), "full copied should have content")
subCopied := nmd.Clone("multikey")
assert.Len(t, subCopied, 1, "sub copied clone should only have one key")
assert.Empty(t, subCopied.Get("singlekey"), "there shouldn't be a singlekey in the subcopied")
// Test side effects and full copying:
assert.EqualValues(t, subCopied["multikey"], nmd["multikey"], "before overwrites multikey should have the same values")
subCopied["multikey"][1] = "modifiedtwo"
assert.NotEqual(t, subCopied["multikey"], nmd["multikey"], "before overwrites multikey should have the same values")
} | explode_data.jsonl/48150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
44978,
6076,
85110,
603,
1155,
353,
8840,
836,
8,
341,
9038,
2277,
1669,
8823,
6031,
2067,
558,
6076,
54436,
1069,
4720,
8623,
54228,
1112,
1171,
94042,
56277,
1122,
1669,
308,
2277,
64463,
741,
6948,
12808,
1155,
11,
2422,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPasswordEntry_Obfuscation(t *testing.T) {
entry, window := setupPasswordImageTest()
defer teardownImageTest(window)
c := window.Canvas()
test.AssertImageMatches(t, "password_entry/obfuscation_initial.png", c.Capture())
test.Type(entry, "Hié™שרה")
assert.Equal(t, "Hié™שרה", entry.Text)
test.AssertImageMatches(t, "password_entry/obfuscation_typed.png", c.Capture())
} | explode_data.jsonl/57337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
4876,
5874,
2232,
13233,
25034,
367,
1155,
353,
8840,
836,
8,
341,
48344,
11,
3241,
1669,
6505,
4876,
1906,
2271,
741,
16867,
49304,
1906,
2271,
15906,
340,
1444,
1669,
3241,
54121,
2822,
18185,
11711,
1906,
42470,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVerifyES256(t *testing.T) {
// The token and key in this test are from:
//
// https://tools.ietf.org/html/rfc7515#appendix-A.3
s := "eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.DtEhU3ljbEg8L38VWAfUAqOyKAM6-Xx-F4GawxaepmXFCgfTjDxw5djxLa8ISlSApmWQxfKTUJqPP3-Kg6NU1Q"
encodedX := "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU"
decodedX, err := base64.RawURLEncoding.DecodeString(encodedX)
assert.NoError(t, err)
var x big.Int
x.SetBytes(decodedX)
encodedY := "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0"
decodedY, err := base64.RawURLEncoding.DecodeString(encodedY)
assert.NoError(t, err)
var y big.Int
y.SetBytes(decodedY)
publicKey := ecdsa.PublicKey{Curve: elliptic.P256(), X: &x, Y: &y}
var claims map[string]interface{}
assert.NoError(t, jwt.VerifyES256(&publicKey, []byte(s), &claims))
assert.True(t, reflect.DeepEqual(claims, map[string]interface{}{
"iss": "joe",
"exp": 1300819380.0,
"http://example.com/is_root": true,
}))
} | explode_data.jsonl/6171 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 593
} | [
2830,
3393,
32627,
1570,
17,
20,
21,
1155,
353,
8840,
836,
8,
341,
197,
322,
576,
3950,
323,
1376,
304,
419,
1273,
525,
504,
510,
197,
2289,
197,
322,
3703,
1110,
15918,
13,
74068,
2659,
13739,
93982,
22,
20,
16,
20,
2,
5090,
941,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatter(t *testing.T) {
var d core.TypedData
err := json.Unmarshal([]byte(jsonTypedData), &d)
if err != nil {
t.Fatalf("unmarshalling failed '%v'", err)
}
formatted := d.Format()
for _, item := range formatted {
fmt.Printf("'%v'\n", item.Pprint(0))
}
j, _ := json.Marshal(formatted)
fmt.Printf("'%v'\n", string(j))
} | explode_data.jsonl/30007 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
14183,
1155,
353,
8840,
836,
8,
341,
2405,
294,
6200,
98152,
1043,
198,
9859,
1669,
2951,
38097,
10556,
3782,
9304,
44466,
1043,
701,
609,
67,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
359,
36239,
16740,
4641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestConsistentForDebug(t *testing.T) {
trunk, root := prepareTruck()
defer closeTestCtx(root)
txs := make([]*gethtypes.Transaction, 9)
signer := &testcase.DumbSigner{}
tx, _ := gethtypes.NewTransaction(0, to2, big.NewInt(101), 100000, big.NewInt(1), nil).WithSignature(signer, from2.Bytes())
txs[0] = tx
tx, _ = gethtypes.NewTransaction(0, to1, big.NewInt(102), 100000, big.NewInt(1), nil).WithSignature(signer, from1.Bytes())
txs[1] = tx
tx, _ = gethtypes.NewTransaction(1, to2, big.NewInt(103), 100000, big.NewInt(1), nil).WithSignature(signer, from2.Bytes())
txs[2] = tx
tx, _ = gethtypes.NewTransaction(1, to1, big.NewInt(104), 100000, big.NewInt(1), nil).WithSignature(signer, from1.Bytes())
txs[3] = tx
tx, _ = gethtypes.NewTransaction(2, to2, big.NewInt(105), 100000, big.NewInt(1), nil).WithSignature(signer, from2.Bytes())
txs[4] = tx
tx, _ = gethtypes.NewTransaction(2, to1, big.NewInt(106), 100000, big.NewInt(1), nil).WithSignature(signer, from1.Bytes())
txs[5] = tx
tx, _ = gethtypes.NewTransaction(3, to1, big.NewInt(107), 100000, big.NewInt(1), nil).WithSignature(signer, from1.Bytes())
txs[6] = tx
tx, _ = gethtypes.NewTransaction(4, to1, big.NewInt(108), 100000, big.NewInt(1), nil).WithSignature(signer, from1.Bytes())
txs[7] = tx
tx, _ = gethtypes.NewTransaction(3, to2, big.NewInt(109), 100000, big.NewInt(1), nil).WithSignature(signer, from2.Bytes())
txs[8] = tx
r := executeTxs(txs, trunk)
//fmt.Println(r.from1.Balance().Uint64())
//fmt.Println(r.from2.Balance().Uint64())
//fmt.Println(r.to1.Balance().Uint64())
//fmt.Println(r.to2.Balance().Uint64())
for _, tx := range r.standbyTxs {
fmt.Printf(
`
starndy tx:
from:%s
to:%s
nonce:%d
`, tx.From.String(), tx.To.String(), tx.Nonce)
}
for _, tx := range r.committedTxs {
fmt.Printf(
`
commited tx:
from:%v
to:%v
nonce:%d
`, tx.From, tx.To, tx.Nonce)
}
} | explode_data.jsonl/58977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 826
} | [
2830,
3393,
15220,
18128,
2461,
7939,
1155,
353,
8840,
836,
8,
341,
25583,
3122,
11,
3704,
1669,
10549,
1282,
1942,
741,
16867,
3265,
2271,
23684,
9206,
340,
3244,
18561,
1669,
1281,
85288,
455,
426,
1804,
29284,
11,
220,
24,
340,
69054... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDriftctlCmd_Scan(t *testing.T) {
cases := []struct {
env map[string]string
args []string
err error
}{
{},
{
env: map[string]string{
"DCTL_TO": "test",
},
err: fmt.Errorf("unsupported cloud provider 'test'\nValid values are: aws+tf,github+tf,gcp+tf,azure+tf"),
},
{
env: map[string]string{
"DCTL_TO": "test",
},
args: []string{"--to", "aws+tf"},
},
{
env: map[string]string{
"DCTL_FROM": "test",
},
err: fmt.Errorf("Unable to parse from flag 'test': \nAccepted schemes are: tfstate://,tfstate+s3://,tfstate+http://,tfstate+https://,tfstate+tfcloud://,tfstate+gs://,tfstate+azurerm://"),
},
{
env: map[string]string{
"DCTL_FROM": "test",
},
args: []string{"--from", "tfstate://terraform.tfstate"},
},
{
env: map[string]string{
"DCTL_OUTPUT": "test",
},
err: fmt.Errorf("Unable to parse output flag 'test': \nAccepted formats are: console://,html://PATH/TO/FILE.html,json://PATH/TO/FILE.json,plan://PATH/TO/FILE.json"),
},
{
env: map[string]string{
"DCTL_OUTPUT": "test",
},
args: []string{"--output", "console://"},
},
{
env: map[string]string{
"DCTL_FILTER": "Type='test'",
},
err: fmt.Errorf("unable to parse filter expression: SyntaxError: Expected tRbracket, received: tUnknown"),
},
{
env: map[string]string{
"DCTL_FILTER": "Type='test'",
},
args: []string{"--filter", "Type=='test'"},
},
}
config.Init()
for index, c := range cases {
t.Run(fmt.Sprintf("%d", index), func(t *testing.T) {
if c.env != nil && len(c.env) > 0 {
for key, val := range c.env {
_ = os.Setenv(key, val)
defer os.Unsetenv(key)
}
}
cmd := NewDriftctlCmd(mocks.MockBuild{})
scanCmd, _, _ := cmd.Find([]string{"scan"})
scanCmd.RunE = func(_ *cobra.Command, args []string) error { return nil }
args := append([]string{"scan"}, c.args...)
_, err := test.Execute(&cmd.Command, args...)
if c.err == nil && err != nil || c.err != nil && err == nil {
t.Fatalf("Got error '%s', expected '%s'", err, c.err)
}
if c.err != nil && err != nil && err.Error() != c.err.Error() {
t.Fatalf("Got error '%s', expected '%s'", err.Error(), c.err.Error())
}
})
}
} | explode_data.jsonl/36199 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1031
} | [
2830,
3393,
8847,
2085,
12373,
15613,
1098,
4814,
1155,
353,
8840,
836,
8,
1476,
1444,
2264,
1669,
3056,
1235,
341,
197,
57538,
220,
2415,
14032,
30953,
198,
197,
31215,
3056,
917,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOnAddLowercaseWorkload(t *testing.T) {
globalPodInfo = &podMap{
info: make(map[string]map[string]*PodInfo),
}
globalServiceInfo = &ServiceMap{
ServiceMap: make(map[string]map[string]*K8sServiceInfo),
}
globalRsInfo = &ReplicaSetMap{
Info: make(map[string]Controller),
}
higherCase := "DaemonSet"
lowerCase := "daemonset"
isController := true
onAdd(&corev1.Pod{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
OwnerReferences: []metav1.OwnerReference{{
Kind: higherCase,
Controller: &isController,
}},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "container1",
Ports: []corev1.ContainerPort{
{
ContainerPort: 80,
},
},
},
}},
Status: corev1.PodStatus{
PodIP: "172.10.1.2",
ContainerStatuses: []corev1.ContainerStatus{
{
Name: "container1",
ContainerID: "docker://1a2b3c4d5e6f7g8h9i0j1k2",
},
},
},
})
podInfo, ok := MetaDataCache.GetPodByContainerId("1a2b3c4d5e6f")
if !ok || podInfo.WorkloadKind != lowerCase {
t.Errorf("%s wanted, but get %s", higherCase, lowerCase)
}
} | explode_data.jsonl/45098 | {
"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,
1925,
2212,
9053,
5638,
6776,
1078,
1155,
353,
8840,
836,
8,
341,
18842,
23527,
1731,
284,
609,
39073,
2227,
515,
197,
27043,
25,
1281,
9147,
14032,
60,
2186,
14032,
8465,
23527,
1731,
1326,
197,
532,
18842,
1860,
1731,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSetHeader(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintln(w, r.Header.Get("X-Test"))
}))
defer ts.Close()
client := New(Config{})
client.SetHeader("X-Test", "foobar")
cancel, resp, err := client.LifecycleR().Get(ts.URL)
defer cancel()
require.Nil(t, err)
require.NotNil(t, resp)
require.Equal(t, http.StatusOK, resp.StatusCode())
require.Equal(t, "foobar", resp.String())
} | explode_data.jsonl/7661 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
1649,
4047,
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,
197,
6878,
716,
284,
8879,
991,
33655,
3622,
11,
435,
15753,
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 TestBytes_Encode(t *testing.T) {
assertEncode(t, []encodingAssert{
{NewBytes([]byte{0, 0, 0}), MustHexDecodeString("0x0c000000")},
{NewBytes([]byte{171, 18, 52}), MustHexDecodeString("0x0cab1234")},
{NewBytes([]byte{0, 1}), MustHexDecodeString("0x080001")},
{NewBytes([]byte{18, 52, 86}), MustHexDecodeString("0x0c123456")},
})
} | explode_data.jsonl/70594 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
7078,
93529,
534,
1155,
353,
8840,
836,
8,
341,
6948,
32535,
1155,
11,
3056,
17159,
8534,
515,
197,
197,
90,
3564,
7078,
10556,
3782,
90,
15,
11,
220,
15,
11,
220,
15,
38842,
15465,
20335,
32564,
703,
445,
15,
87,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetInstanceIDByNodeName(t *testing.T) {
testCases := []struct {
description string
scaleSet string
vmList []string
nodeName string
expected string
expectError bool
}{
{
description: "scaleSet should get instance by node name",
scaleSet: "ss",
vmList: []string{"vmssee6c2000000", "vmssee6c2000001"},
nodeName: "vmssee6c2000001",
expected: "/subscriptions/script/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/ss/virtualMachines/1",
},
{
description: "scaleSet should get instance by node name with upper cases hostname",
scaleSet: "ss",
vmList: []string{"VMSSEE6C2000000", "VMSSEE6C2000001"},
nodeName: "vmssee6c2000000",
expected: "/subscriptions/script/resourceGroups/rg/providers/Microsoft.Compute/virtualMachineScaleSets/ss/virtualMachines/0",
},
{
description: "scaleSet should not get instance for non-exist nodes",
scaleSet: "ss",
vmList: []string{"vmssee6c2000000", "vmssee6c2000001"},
nodeName: "agente6c2000005",
expectError: true,
},
}
for _, test := range testCases {
ss, err := newTestScaleSet(test.scaleSet, "", 0, test.vmList)
assert.NoError(t, err, test.description)
real, err := ss.GetInstanceIDByNodeName(test.nodeName)
if test.expectError {
assert.Error(t, err, test.description)
continue
}
assert.NoError(t, err, test.description)
assert.Equal(t, test.expected, real, test.description)
}
} | explode_data.jsonl/17945 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 601
} | [
2830,
3393,
42761,
915,
1359,
1955,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
70780,
1649,
262,
914,
198,
197,
54879,
852,
414,
3056,
917,
198,
197,
20831,
675,
262,
914,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestValidateRule(t *testing.T) {
var prep = func(an, az, m bool) func() {
return func() {
viper.Set(configuration.ViperKeyAuthenticatorNoopIsEnabled, an)
viper.Set(configuration.ViperKeyAuthorizerAllowIsEnabled, az)
viper.Set(configuration.ViperKeyMutatorNoopIsEnabled, m)
}
}
for k, tc := range []struct {
setup func()
r *Rule
expectErr string
}{
{
r: &Rule{},
expectErr: `Value "match" is empty but must be set.`,
},
{
r: &Rule{Match: &Match{}},
expectErr: `Value "" of "match.url" field is not a valid url.`,
},
{
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
},
expectErr: `Value of "authenticators" must be set and can not be an empty array.`,
},
{
setup: prep(true, false, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "foo"}},
},
expectErr: `Value "foo" of "authenticators[0]" is not in list of supported authenticators: `,
},
{
setup: prep(false, false, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
},
expectErr: `Authenticator "noop" is disabled per configuration.`,
},
{
setup: prep(true, false, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
},
expectErr: `Value of "authorizer.handler" can not be empty.`,
},
{
setup: prep(true, true, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "foo"},
},
expectErr: `Value "foo" of "authorizer.handler" is not in list of supported authorizers: `,
},
{
setup: prep(true, true, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "allow"},
},
expectErr: `Value of "mutators" must be set and can not be an empty array.`,
},
{
setup: prep(true, true, true),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "allow"},
Mutators: []Handler{{Handler: "foo"}},
},
expectErr: `Value "foo" of "mutators[0]" is not in list of supported mutators: `,
},
{
setup: prep(true, true, true),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "allow"},
Mutators: []Handler{{Handler: "noop"}},
},
},
{
setup: prep(true, true, true),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"MKCOL"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "allow"},
Mutators: []Handler{{Handler: "noop"}},
},
},
{
setup: prep(true, true, false),
r: &Rule{
Match: &Match{URL: "https://www.ory.sh", Methods: []string{"POST"}},
Upstream: Upstream{URL: "https://www.ory.sh"},
Authenticators: []Handler{{Handler: "noop"}},
Authorizer: Handler{Handler: "allow"},
Mutators: []Handler{{Handler: "noop"}},
},
expectErr: `Mutator "noop" is disabled per configuration.`,
},
} {
t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
conf := internal.NewConfigurationWithDefaults()
if tc.setup != nil {
tc.setup()
}
r := internal.NewRegistry(conf)
v := NewValidatorDefault(r)
err := v.Validate(tc.r)
if tc.expectErr == "" {
require.NoError(t, err)
return
}
require.Error(t, err)
reason := errors.Cause(err).(*herodot.DefaultError).ReasonField
assert.True(t, strings.Contains(reason, tc.expectErr), "%s != %s", reason, tc.expectErr)
})
}
} | explode_data.jsonl/47678 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2086
} | [
2830,
3393,
17926,
11337,
1155,
353,
8840,
836,
8,
341,
2405,
21327,
284,
2915,
38502,
11,
12376,
11,
296,
1807,
8,
2915,
368,
341,
197,
853,
2915,
368,
341,
298,
5195,
12858,
4202,
48724,
5058,
12858,
1592,
5087,
61393,
2753,
453,
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 TestKafkaClient_Configure_BadCluster(t *testing.T) {
module := fixtureModule()
viper.Set("consumer.test.cluster", "nocluster")
assert.Panics(t, func() { module.Configure("test", "consumer.test") }, "The code did not panic")
} | explode_data.jsonl/34250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
42,
21883,
2959,
15100,
17781,
1668,
329,
28678,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
12507,
3332,
741,
5195,
12858,
4202,
445,
46764,
5958,
40501,
497,
330,
47991,
75,
4993,
5130,
6948,
1069,
276,
1211,
1155,
11,
2915... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilteredBlocktEvent(t *testing.T) {
gw := &Gateway{
options: &gatewayOptions{
Timeout: defaultTimeout,
},
}
c := mockChannelProvider("mychannel")
nw, err := newNetwork(gw, c)
if err != nil {
t.Fatalf("Failed to create network: %s", err)
}
reg, _, err := nw.RegisterFilteredBlockEvent()
if err != nil {
t.Fatalf("Failed to register filtered block event: %s", err)
}
nw.Unregister(reg)
} | explode_data.jsonl/39451 | {
"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,
67310,
4713,
83,
1556,
1155,
353,
8840,
836,
8,
1476,
3174,
86,
1669,
609,
40709,
515,
197,
35500,
25,
609,
46473,
3798,
515,
298,
197,
7636,
25,
1638,
7636,
345,
197,
197,
1583,
197,
630,
1444,
1669,
7860,
9629,
5179,
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... | 3 |
func TestReplaceInter(t *testing.T) {
v := &Value{data: []interface{}{interface{}("something"), interface{}("something"), interface{}("something"), interface{}("something"), interface{}("something"), interface{}("something")}}
rawArr := v.MustInterSlice()
replaced := v.ReplaceInter(func(index int, val interface{}) interface{} {
if index < len(rawArr)-1 {
return rawArr[index+1]
}
return rawArr[0]
})
replacedArr := replaced.MustInterSlice()
if assert.Equal(t, 6, len(replacedArr)) {
assert.Equal(t, replacedArr[0], rawArr[1])
assert.Equal(t, replacedArr[1], rawArr[2])
assert.Equal(t, replacedArr[2], rawArr[3])
assert.Equal(t, replacedArr[3], rawArr[4])
assert.Equal(t, replacedArr[4], rawArr[5])
assert.Equal(t, replacedArr[5], rawArr[0])
}
} | explode_data.jsonl/23382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
23107,
3306,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
4970,
6257,
90,
4970,
6257,
445,
33331,
3975,
3749,
6257,
445,
33331,
3975,
3749,
6257,
445,
33331,
3975,
3749,
6257,
445,
33331,
3975,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSandboxRemoveWithoutIPLeakage(t *testing.T) {
const hostLocalCheckpointDir = "/var/lib/cni"
t.Logf("Make sure host-local ipam is in use")
config, err := CRIConfig()
require.NoError(t, err)
fs, err := ioutil.ReadDir(config.NetworkPluginConfDir)
require.NoError(t, err)
require.NotEmpty(t, fs)
f := filepath.Join(config.NetworkPluginConfDir, fs[0].Name())
cniConfig, err := ioutil.ReadFile(f)
require.NoError(t, err)
if !strings.Contains(string(cniConfig), "host-local") {
t.Skip("host-local ipam is not in use")
}
t.Logf("Create a sandbox")
sbConfig := PodSandboxConfig("sandbox", "remove-without-ip-leakage")
sb, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
require.NoError(t, err)
defer func() {
// Make sure the sandbox is cleaned up in any case.
runtimeService.StopPodSandbox(sb)
runtimeService.RemovePodSandbox(sb)
}()
t.Logf("Get pod information")
status, info, err := SandboxInfo(sb)
require.NoError(t, err)
ip := status.GetNetwork().GetIp()
require.NotEmpty(t, ip)
require.NotNil(t, info.RuntimeSpec.Linux)
var netNS string
for _, n := range info.RuntimeSpec.Linux.Namespaces {
if n.Type == runtimespec.NetworkNamespace {
netNS = n.Path
}
}
require.NotEmpty(t, netNS, "network namespace should be set")
t.Logf("Should be able to find the pod ip in host-local checkpoint")
checkIP := func(ip string) bool {
found := false
filepath.Walk(hostLocalCheckpointDir, func(_ string, info os.FileInfo, _ error) error {
if info != nil && info.Name() == ip {
found = true
}
return nil
})
return found
}
require.True(t, checkIP(ip))
t.Logf("Kill sandbox container")
require.NoError(t, KillPid(int(info.Pid)))
t.Logf("Unmount network namespace")
require.NoError(t, unix.Unmount(netNS, unix.MNT_DETACH))
t.Logf("Network namespace should be closed")
_, info, err = SandboxInfo(sb)
require.NoError(t, err)
assert.True(t, info.NetNSClosed)
t.Logf("Remove network namespace")
require.NoError(t, os.RemoveAll(netNS))
t.Logf("Network namespace should still be closed")
_, info, err = SandboxInfo(sb)
require.NoError(t, err)
assert.True(t, info.NetNSClosed)
t.Logf("Sandbox state should be NOTREADY")
assert.NoError(t, Eventually(func() (bool, error) {
status, err := runtimeService.PodSandboxStatus(sb)
if err != nil {
return false, err
}
return status.GetState() == runtime.PodSandboxState_SANDBOX_NOTREADY, nil
}, time.Second, 30*time.Second), "sandbox state should become NOTREADY")
t.Logf("Should still be able to find the pod ip in host-local checkpoint")
assert.True(t, checkIP(ip))
t.Logf("Should be able to stop and remove the sandbox")
assert.NoError(t, runtimeService.StopPodSandbox(sb))
assert.NoError(t, runtimeService.RemovePodSandbox(sb))
t.Logf("Should not be able to find the pod ip in host-local checkpoint")
assert.False(t, checkIP(ip))
} | explode_data.jsonl/10379 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1062
} | [
2830,
3393,
50,
31536,
13021,
26040,
3298,
2304,
585,
424,
1155,
353,
8840,
836,
8,
341,
4777,
3468,
7319,
92688,
6184,
284,
3521,
947,
8194,
2899,
7751,
1837,
3244,
98954,
445,
8078,
2704,
3468,
40060,
5997,
309,
374,
304,
990,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConstructor(t *testing.T) {
lru := Constructor(2)
lru.Put(2, 1)
lru.Put(2, 2)
fmt.Println(lru.Get(1))
lru.Put(3, 3)
lru.Put(4, 4)
fmt.Println(lru.Get(2))
} | explode_data.jsonl/10591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
13288,
1155,
353,
8840,
836,
8,
341,
8810,
2672,
1669,
16786,
7,
17,
340,
8810,
2672,
39825,
7,
17,
11,
220,
16,
340,
8810,
2672,
39825,
7,
17,
11,
220,
17,
340,
11009,
12419,
2333,
2672,
2234,
7,
16,
1171,
8810,
2672,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateTrafficPolicy(t *testing.T) {
cases := []struct {
name string
in networking.TrafficPolicy
valid bool
}{
{name: "valid traffic policy", in: networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
valid: true},
{name: "invalid traffic policy, nil entries", in: networking.TrafficPolicy{},
valid: false},
{name: "invalid traffic policy, missing port in port level settings", in: networking.TrafficPolicy{
PortLevelSettings: []*networking.TrafficPolicy_PortTrafficPolicy{
{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
},
},
valid: false},
{name: "invalid traffic policy, bad connection pool", in: networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: 20,
},
},
valid: false},
{name: "invalid traffic policy, panic threshold too low", in: networking.TrafficPolicy{
LoadBalancer: &networking.LoadBalancerSettings{
LbPolicy: &networking.LoadBalancerSettings_Simple{
Simple: networking.LoadBalancerSettings_ROUND_ROBIN,
},
},
ConnectionPool: &networking.ConnectionPoolSettings{
Tcp: &networking.ConnectionPoolSettings_TCPSettings{MaxConnections: 7},
Http: &networking.ConnectionPoolSettings_HTTPSettings{Http2MaxRequests: 11},
},
OutlierDetection: &networking.OutlierDetection{
ConsecutiveErrors: 5,
MinHealthPercent: -1,
},
},
valid: false},
}
for _, c := range cases {
if got := validateTrafficPolicy(&c.in); (got == nil) != c.valid {
t.Errorf("ValidateTrafficPolicy failed on %v: got valid=%v but wanted valid=%v: %v",
c.name, got == nil, c.valid, got)
}
}
} | explode_data.jsonl/56923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1099
} | [
2830,
3393,
17926,
87229,
13825,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
17430,
262,
28030,
836,
956,
20615,
13825,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
47006,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSpecifyIndex(t *testing.T) {
var index *Index
index = &Index{
F1: 1,
F2: 2,
}
_, _ = dORM.Insert(index)
throwFailNow(t, AssertIs(index.Id, 1))
index = &Index{
F1: 3,
F2: 4,
}
_, _ = dORM.Insert(index)
throwFailNow(t, AssertIs(index.Id, 2))
_ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).ForceIndex(`index_f1`).One(index)
throwFailNow(t, AssertIs(index.F2, 2))
_ = dORM.QueryTable(&Index{}).Filter(`f2`, `4`).UseIndex(`index_f2`).One(index)
throwFailNow(t, AssertIs(index.F1, 3))
_ = dORM.QueryTable(&Index{}).Filter(`f1`, `1`).IgnoreIndex(`index_f1`, `index_f2`).One(index)
throwFailNow(t, AssertIs(index.F2, 2))
} | explode_data.jsonl/18128 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
70052,
1552,
1155,
353,
8840,
836,
8,
341,
2405,
1922,
353,
1552,
198,
26327,
284,
609,
1552,
515,
197,
12727,
16,
25,
220,
16,
345,
197,
12727,
17,
25,
220,
17,
345,
197,
532,
197,
6878,
716,
284,
294,
4365,
23142,
71... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewRemoveAllPushChannelsForDeviceBuilderContext(t *testing.T) {
assert := assert.New(t)
o := newRemoveAllPushChannelsForDeviceBuilderWithContext(pubnub, backgroundContext)
o.DeviceIDForPush("deviceId")
o.PushType(PNPushTypeAPNS)
str, err := o.opts.buildPath()
assert.Equal("/v1/push/sub-key/sub_key/devices/deviceId/remove", str)
assert.Nil(err)
} | explode_data.jsonl/51094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
3564,
13021,
2403,
16644,
35925,
2461,
6985,
3297,
1972,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
22229,
1669,
501,
13021,
2403,
16644,
35925,
2461,
6985,
3297,
91101,
74186,
77,
392,
11,
4004,
1972,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIndexEditorUniqueErrorDoesntPersist(t *testing.T) {
format := types.Format_Default
db, err := dbfactory.MemFactory{}.CreateDB(context.Background(), format, nil, nil)
require.NoError(t, err)
colColl := schema.NewColCollection(
schema.NewColumn("pk", 0, types.IntKind, true),
schema.NewColumn("v1", 1, types.IntKind, false))
tableSch, err := schema.SchemaFromCols(colColl)
require.NoError(t, err)
index, err := tableSch.Indexes().AddIndexByColNames("idx_unq", []string{"v1"}, schema.IndexProperties{IsUnique: true, Comment: ""})
require.NoError(t, err)
indexSch := index.Schema()
emptyMap, err := types.NewMap(context.Background(), db)
require.NoError(t, err)
indexEditor := NewIndexEditor(context.Background(), index, emptyMap, tableSch)
dRow, err := row.New(format, indexSch, row.TaggedValues{
0: types.Int(1),
1: types.Int(1),
})
require.NoError(t, err)
fullKey, partialKey, value, err := dRow.ReduceToIndexKeys(index)
require.NoError(t, err)
require.NoError(t, indexEditor.InsertRow(context.Background(), fullKey, partialKey, value))
dRow, err = row.New(format, indexSch, row.TaggedValues{
0: types.Int(2),
1: types.Int(1),
})
require.NoError(t, err)
fullKey, partialKey, value, err = dRow.ReduceToIndexKeys(index)
require.NoError(t, err)
require.Error(t, indexEditor.InsertRow(context.Background(), fullKey, partialKey, value))
dRow, err = row.New(format, indexSch, row.TaggedValues{
0: types.Int(2),
1: types.Int(2),
})
require.NoError(t, err)
fullKey, partialKey, value, err = dRow.ReduceToIndexKeys(index)
require.NoError(t, err)
require.NoError(t, indexEditor.InsertRow(context.Background(), fullKey, partialKey, value))
} | explode_data.jsonl/27209 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 621
} | [
2830,
3393,
1552,
9410,
22811,
1454,
21468,
406,
61267,
1155,
353,
8840,
836,
8,
341,
59416,
1669,
4494,
9978,
60336,
198,
20939,
11,
1848,
1669,
2927,
21618,
1321,
336,
4153,
46391,
4021,
3506,
5378,
19047,
1507,
3561,
11,
2092,
11,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestObjectUpdate(t *testing.T) {
ctx := context.Background()
c, rollback := makeConnectionWithObject(t)
defer rollback()
err := c.ObjectUpdate(ctx, CONTAINER, OBJECT, m1.ObjectHeaders())
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/12690 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
1190,
4289,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1444,
11,
60414,
1669,
1281,
4526,
2354,
1190,
1155,
340,
16867,
60414,
741,
9859,
1669,
272,
8348,
4289,
7502,
11,
16120,
34521,
11,
39786,
11,
296,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func Test_toApiError(t *testing.T) {
status, apiErr := toApiError(nil)
assert.Nil(t, apiErr)
assert.Equal(t, 200, status)
errObj := jsonapi.ErrorObject{Status: "200"}
status, apiErr = toApiError(&errObj)
assert.Equal(t, 200, status)
assert.Equal(t, errObj, *apiErr)
//bad status
errObj = jsonapi.ErrorObject{Status: "foobar"}
wantApiErr := jsonapi.ErrorObject{Status: "foobar", Detail: " bad status: foobar"}
gotStatus, gotApiErr := toApiError(&errObj)
assert.Equal(t, http.StatusInternalServerError, gotStatus)
assert.Equal(t, wantApiErr, *apiErr)
//httperr
wantApiErr = jsonapi.ErrorObject{
Status: "404",
Title: http.StatusText(404),
Detail: "not found",
}
wantStatus := 404
httpErr := echo.HTTPError{Code: 404, Message: "not found", Internal: someErr}
gotStatus, gotApiErr = toApiError(&httpErr)
assert.Equal(t, wantStatus, gotStatus)
assert.Equal(t, wantApiErr, *gotApiErr)
//pqErr
const (
msg = "ok"
code = "0100C"
codeName = "dynamic_result_sets_returned"
)
pqErr := pq.Error{Message: msg, Code: "0100C"}
wantStatus = http.StatusBadRequest
wantApiErr = jsonapi.ErrorObject{
Status: toStr(http.StatusBadRequest),
Detail: msg,
Code: codeName,
Title: "Bad Request"}
gotStatus, gotApiErr = toApiError(&pqErr)
assert.Equal(t, wantStatus, gotStatus)
assert.Equal(t, wantApiErr, *gotApiErr)
//goValidator
gvErr := govalidator.Errors{someErr}
wantApiErr = jsonapi.ErrorObject{
Title: http.StatusText(http.StatusBadRequest),
Detail: gvErr.Error(),
Code: "",
Status: toStr(http.StatusBadRequest),
}
wantStatus = http.StatusBadRequest
gotStatus, gotApiErr = toApiError(gvErr)
assert.Equal(t, wantStatus, gotStatus)
assert.Equal(t, wantApiErr, *gotApiErr)
} | explode_data.jsonl/47346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 738
} | [
2830,
3393,
2346,
6563,
1454,
1155,
353,
8840,
836,
8,
341,
23847,
11,
6330,
7747,
1669,
311,
6563,
1454,
27907,
340,
6948,
59678,
1155,
11,
6330,
7747,
340,
6948,
12808,
1155,
11,
220,
17,
15,
15,
11,
2639,
692,
9859,
5261,
1669,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSeccompContainerAnnotationTrumpsPod(t *testing.T) {
dm, fakeDocker := newTestDockerManagerWithVersion("1.10.1", "1.22")
pod := makePod("foo2", &api.PodSpec{
Containers: []api.Container{
{Name: "bar2"},
},
})
pod.Annotations = map[string]string{
api.SeccompPodAnnotationKey: "unconfined",
api.SeccompContainerAnnotationKeyPrefix + "bar2": "docker/default",
}
runSyncPod(t, dm, fakeDocker, pod, nil, false)
verifyCalls(t, fakeDocker, []string{
// Create pod infra container.
"create", "start", "inspect_container", "inspect_container",
// Create container.
"create", "start", "inspect_container",
})
fakeDocker.Lock()
if len(fakeDocker.Created) != 2 ||
!matchString(t, "/k8s_POD\\.[a-f0-9]+_foo2_new_", fakeDocker.Created[0]) ||
!matchString(t, "/k8s_bar2\\.[a-f0-9]+_foo2_new_", fakeDocker.Created[1]) {
t.Errorf("unexpected containers created %v", fakeDocker.Created)
}
fakeDocker.Unlock()
newContainer, err := fakeDocker.InspectContainer(fakeDocker.Created[1])
if err != nil {
t.Fatalf("unexpected error %v", err)
}
assert.NotContains(t, newContainer.HostConfig.SecurityOpt, "seccomp:unconfined", "Container annotation should trump the pod annotation for seccomp.")
} | explode_data.jsonl/31190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
1514,
638,
14435,
4502,
19711,
1282,
11793,
23527,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
12418,
35,
13659,
1669,
501,
2271,
35,
13659,
2043,
2354,
5637,
445,
16,
13,
16,
15,
13,
16,
497,
330,
16,
13,
17,
17,
1138... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseTagMarkdownDescription(t *testing.T) {
searchDir := "testdata/tags"
p := New(SetMarkdownFileDirectory(searchDir))
p.PropNamingStrategy = PascalCase
err := p.ParseAPI(searchDir, mainAPIFile, defaultParseDepth)
if err != nil {
t.Error("Failed to parse api description: " + err.Error())
}
if len(p.swagger.Tags) != 3 {
t.Error("Number of tags did not match")
}
apes := p.swagger.Tags[2]
if apes.TagProps.Description == "" {
t.Error("Failed to parse tag description markdown file")
}
} | explode_data.jsonl/63582 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
14463,
5668,
68005,
5009,
1155,
353,
8840,
836,
8,
341,
45573,
6184,
1669,
330,
92425,
84460,
698,
3223,
1669,
1532,
52474,
68005,
1703,
9310,
20447,
6184,
1171,
3223,
42483,
85410,
19816,
284,
57359,
4207,
198,
9859,
1669,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFetchSpotExchangeLimits(t *testing.T) {
t.Parallel()
limits, err := b.FetchSpotExchangeLimits(context.Background())
if !errors.Is(err, nil) {
t.Errorf("received '%v', epected '%v'", err, nil)
}
if len(limits) == 0 {
t.Error("expected a response")
}
} | explode_data.jsonl/76707 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
20714,
47049,
31564,
94588,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
41078,
11,
1848,
1669,
293,
78506,
47049,
31564,
94588,
5378,
19047,
2398,
743,
753,
7650,
4506,
3964,
11,
2092,
8,
341,
197,
3244,
13080... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMutateCreatedAt(t *testing.T) {
source := sourceImage(t)
want := time.Now().Add(-2 * time.Minute)
result, err := mutate.CreatedAt(source, v1.Time{Time: want})
if err != nil {
t.Fatalf("CreatedAt: %v", err)
}
if configDigestsAreEqual(t, source, result) {
t.Errorf("mutating the created time MUST mutate the config digest")
}
got := getConfigFile(t, result).Created.Time
if got != want {
t.Errorf("mutating the created time MUST mutate the time from %v to %v", got, want)
}
} | explode_data.jsonl/3095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
51440,
349,
70387,
1155,
353,
8840,
836,
8,
341,
47418,
1669,
2530,
1906,
1155,
340,
50780,
1669,
882,
13244,
1005,
2212,
4080,
17,
353,
882,
75770,
340,
9559,
11,
1848,
1669,
67182,
45413,
1655,
12437,
11,
348,
16,
16299,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListAll(t *testing.T) {
list := New()
list.Add("a", "b", "c")
all := list.All(func(index int, value interface{}) bool {
return value.(string) >= "a" && value.(string) <= "c"
})
if all != true {
t.Errorf("Got %v expected %v", all, true)
}
all = list.All(func(index int, value interface{}) bool {
return value.(string) >= "a" && value.(string) <= "b"
})
if all != false {
t.Errorf("Got %v expected %v", all, false)
}
} | explode_data.jsonl/18297 | {
"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,
852,
2403,
1155,
353,
8840,
836,
8,
341,
14440,
1669,
1532,
741,
14440,
1904,
445,
64,
497,
330,
65,
497,
330,
66,
1138,
50960,
1669,
1140,
16764,
18552,
7195,
526,
11,
897,
3749,
28875,
1807,
341,
197,
853,
897,
12832,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigParseArgs(t *testing.T) {
assert := assert.New(t)
c, err := NewConfig([]string{
"--cookie-name=cookiename",
"--csrf-cookie-name", "\"csrfcookiename\"",
"--default-provider", "\"oidc\"",
"--rule.1.action=allow",
"--rule.1.rule=PathPrefix(`/one`)",
"--rule.two.action=auth",
"--rule.two.rule=\"Host(`two.com`) && Path(`/two`)\"",
})
require.Nil(t, err)
// Check normal flags
assert.Equal("cookiename", c.CookieName)
assert.Equal("csrfcookiename", c.CSRFCookieName)
assert.Equal("oidc", c.DefaultProvider)
// Check rules
assert.Equal(map[string]*Rule{
"1": {
Action: "allow",
Rule: "PathPrefix(`/one`)",
Provider: "oidc",
},
"two": {
Action: "auth",
Rule: "Host(`two.com`) && Path(`/two`)",
Provider: "oidc",
},
}, c.Rules)
} | explode_data.jsonl/33752 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
2648,
14463,
4117,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
1444,
11,
1848,
1669,
1532,
2648,
10556,
917,
515,
197,
197,
74757,
16236,
11494,
28,
1015,
38191,
1840,
756,
197,
197,
74757,
24102,
87239,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMax(t *testing.T) {
t.Parallel()
testCases := []struct {
slice []float64
val float64
}{
{
slice: []float64{1, 2, 3, 4},
val: 4,
},
{
slice: []float64{-1, -2, -3, -4},
val: -1,
},
{
slice: []float64{math.Inf(-1), 2, 3, math.Inf(1)},
val: math.Inf(1),
},
}
r := reducer.Max()
for _, c := range testCases {
val, err := r.Reduce(c.slice)
require.NoError(t, err)
require.Equal(t, c.val, val)
}
} | explode_data.jsonl/4718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
5974,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
37302,
1669,
3056,
1235,
341,
197,
1903,
4754,
3056,
3649,
21,
19,
198,
197,
19302,
256,
2224,
21,
19,
198,
197,
59403,
197,
197,
515,
298,
1903,
4754,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMultiTenantServicePrincipalToken(t *testing.T) {
config := &AzureAuthConfig{
TenantID: "TenantID",
AADClientID: "AADClientID",
AADClientSecret: "AADClientSecret",
NetworkResourceTenantID: "NetworkResourceTenantID",
NetworkResourceSubscriptionID: "NetworkResourceSubscriptionID",
}
env := &azure.PublicCloud
multiTenantToken, err := GetMultiTenantServicePrincipalToken(config, env)
assert.NoError(t, err)
multiTenantOAuthConfig, err := adal.NewMultiTenantOAuthConfig(env.ActiveDirectoryEndpoint, config.TenantID, []string{config.NetworkResourceTenantID}, adal.OAuthOptions{})
assert.NoError(t, err)
spt, err := adal.NewMultiTenantServicePrincipalToken(multiTenantOAuthConfig, config.AADClientID, config.AADClientSecret, env.ServiceManagementEndpoint)
assert.NoError(t, err)
assert.Equal(t, multiTenantToken, spt)
} | explode_data.jsonl/30649 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 347
} | [
2830,
3393,
1949,
20358,
71252,
1860,
31771,
3323,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
609,
78107,
5087,
2648,
515,
197,
10261,
25121,
915,
25,
2549,
330,
71252,
915,
756,
197,
22985,
1808,
2959,
915,
25,
4293,
330,
81380,
2959,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJSONSupport(t *testing.T) {
session := createSession(t)
defer session.Close()
if session.cfg.ProtoVersion < 4 {
t.Skip("skipping JSON support on proto < 4")
}
if err := createTable(session, `CREATE TABLE gocql_test.test_json (
id text PRIMARY KEY,
age int,
state text
)`); err != nil {
t.Fatal(err)
}
err := session.Query("INSERT INTO test_json JSON ?", `{"id": "user123", "age": 42, "state": "TX"}`).Exec()
if err != nil {
t.Fatal(err)
}
var (
id string
age int
state string
)
err = session.Query("SELECT id, age, state FROM test_json WHERE id = ?", "user123").Scan(&id, &age, &state)
if err != nil {
t.Fatal(err)
}
if id != "user123" {
t.Errorf("got id %q expected %q", id, "user123")
}
if age != 42 {
t.Errorf("got age %d expected %d", age, 42)
}
if state != "TX" {
t.Errorf("got state %q expected %q", state, "TX")
}
} | explode_data.jsonl/11186 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 382
} | [
2830,
3393,
5370,
7916,
1155,
353,
8840,
836,
8,
341,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
743,
3797,
30481,
7763,
983,
5637,
366,
220,
19,
341,
197,
3244,
57776,
445,
4886,
5654,
4718,
1824,
389,
18433,
366,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestArgParser(t *testing.T) {
for _, tc := range []struct {
Args []string
Expected interface{}
}{{
Args: []string{"init"},
Expected: initCmd{},
}, {
Args: []string{"init", "-f"},
Expected: initCmd{
Force: true,
},
}, {
Args: []string{"init", "--force"},
Expected: initCmd{
Force: true,
},
}, {
Args: []string{"new", "foo", "bar"},
Expected: createCmd{
Project: "foo",
Template: "bar",
},
}, {
Args: []string{"update"},
Expected: initCmd{},
}} {
t.Run(strings.Join(tc.Args, " "), func(t *testing.T) {
require := require.New(t)
tc := tc
ctx := parse(tc.Args)
actual := ctx.Selected().Target.Interface()
require.EqualValues(tc.Expected, actual)
})
}
} | explode_data.jsonl/27772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
2735,
6570,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
197,
4117,
257,
3056,
917,
198,
197,
197,
18896,
3749,
16094,
197,
15170,
515,
197,
197,
4117,
25,
257,
3056,
917,
4913,
2327,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuntimeRequirePreload(t *testing.T) {
modules := map[string]string{
STATS_MODULE_NAME: STATS_MODULE_DATA,
"states-invoke": `
local stats = require("stats")
t = {[1]=5, [2]=7, [3]=8, [4]='Something else.'}
print(stats.mean(t))`,
}
_, err := runtimeWithModules(t, modules)
if err != nil {
t.Fatal(err.Error())
}
} | explode_data.jsonl/59778 | {
"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,
15123,
17959,
4703,
1078,
1155,
353,
8840,
836,
8,
341,
42228,
2425,
1669,
2415,
14032,
30953,
515,
197,
197,
22595,
50,
13953,
4708,
25,
75982,
13953,
7896,
345,
197,
197,
1,
32069,
3419,
7621,
788,
22074,
2438,
10472,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAdmin_ReadOnlyWithAge(t *testing.T) {
srv, ts := prep(t)
assert.NotNil(t, srv)
defer cleanup(ts)
c1 := store.Comment{Text: "test test #1", Locator: store.Locator{SiteID: "radio-t",
URL: "https://radio-t.com/blah"}, User: store.User{Name: "user1 name", ID: "user1"},
Timestamp: time.Date(2001, 1, 1, 1, 1, 1, 0, time.Local)}
_, err := srv.DataService.Create(c1)
assert.Nil(t, err)
info, err := srv.DataService.Info(store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}, 10)
assert.Nil(t, err)
assert.True(t, info.ReadOnly, "ro by age")
client := http.Client{}
// set post to read-only
req, err := http.NewRequest(http.MethodPut,
fmt.Sprintf("%s/api/v1/admin/readonly?site=radio-t&url=https://radio-t.com/blah&ro=1", ts.URL), nil)
assert.Nil(t, err)
req.SetBasicAuth("dev", "password")
resp, err := client.Do(req)
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
info, err = srv.DataService.Info(store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}, 0)
assert.Nil(t, err)
assert.True(t, info.ReadOnly)
// reset post's read-only
req, err = http.NewRequest(http.MethodPut,
fmt.Sprintf("%s/api/v1/admin/readonly?site=radio-t&url=https://radio-t.com/blah&ro=0", ts.URL), nil)
assert.Nil(t, err)
req.SetBasicAuth("dev", "password")
resp, err = client.Do(req)
assert.Equal(t, 403, resp.StatusCode)
require.Nil(t, err)
info, err = srv.DataService.Info(store.Locator{SiteID: "radio-t", URL: "https://radio-t.com/blah"}, 0)
assert.Nil(t, err)
assert.True(t, info.ReadOnly)
} | explode_data.jsonl/70322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 669
} | [
2830,
3393,
7210,
62,
20914,
2354,
16749,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
11,
10591,
1669,
21327,
1155,
340,
6948,
93882,
1155,
11,
43578,
340,
16867,
21290,
35864,
692,
1444,
16,
1669,
3553,
56730,
90,
1178,
25,
330,
1944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCertificate(t *testing.T) {
man := &Manager{Prompt: AcceptTOS}
defer man.stopRenew()
hello := clientHelloInfo("example.org", true)
testGetCertificate(t, man, "example.org", hello)
} | explode_data.jsonl/65044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
1949,
33202,
1155,
353,
8840,
836,
8,
341,
197,
1515,
1669,
609,
2043,
90,
54615,
25,
20829,
51,
3126,
532,
16867,
883,
13227,
34625,
365,
741,
9598,
4791,
1669,
2943,
9707,
1731,
445,
8687,
2659,
497,
830,
340,
18185,
194... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetEvents(t *testing.T) {
t.Run("should get events in the response", func(t *testing.T) {
// Create a request to send to the above route
req, _ := http.NewRequest("GET", "/events", nil)
authenticate(req)
testHTTPResponse(t, r, req, func(w *httptest.ResponseRecorder) bool {
// Test that the http status code is 200
statusOK := w.Code == http.StatusOK
var pageOK bool
if statusOK {
var payload representations.CommitResults
err := json.NewDecoder(w.Body).Decode(&payload)
pageOK = err == nil && payload.Items != nil
}
return statusOK && pageOK
})
})
} | explode_data.jsonl/4636 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
1949,
7900,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
5445,
633,
4357,
304,
279,
2033,
497,
2915,
1155,
353,
8840,
836,
8,
1476,
197,
197,
322,
4230,
264,
1681,
311,
3624,
311,
279,
3403,
6021,
198,
197,
24395,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPrimitiveGetDateTimeRFC1123(t *testing.T) {
client := newPrimitiveClient()
result, err := client.GetDateTimeRFC1123(context.Background(), nil)
if err != nil {
t.Fatalf("GetDateTimeRFC1123: %v", err)
}
f, _ := time.Parse(time.RFC1123, "Mon, 01 Jan 0001 00:00:00 GMT")
n, _ := time.Parse(time.RFC1123, "Mon, 18 May 2015 11:38:00 GMT")
if r := cmp.Diff(result.Datetimerfc1123Wrapper, Datetimerfc1123Wrapper{
Field: &f,
Now: &n,
}); r != "" {
t.Fatal(r)
}
} | explode_data.jsonl/61687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
33313,
1949,
7689,
64371,
16,
16,
17,
18,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
33313,
2959,
741,
9559,
11,
1848,
1669,
2943,
2234,
7689,
64371,
16,
16,
17,
18,
5378,
19047,
1507,
2092,
340,
743,
1848,
961,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPartitionRanges(t *testing.T) {
const maxGapSize = 1024 * 512
for _, c := range []struct {
input [][2]int
expected [][2]int
}{
{
input: [][2]int{{1, 10}},
expected: [][2]int{{0, 1}},
},
{
input: [][2]int{{1, 2}, {3, 5}, {7, 10}},
expected: [][2]int{{0, 3}},
},
{
input: [][2]int{
{1, 2},
{3, 5},
{20, 30},
{maxGapSize + 31, maxGapSize + 32},
},
expected: [][2]int{{0, 3}, {3, 4}},
},
// Overlapping ranges.
{
input: [][2]int{
{1, 30},
{3, 28},
{1, 4},
{maxGapSize + 31, maxGapSize + 32},
{maxGapSize + 31, maxGapSize + 40},
},
expected: [][2]int{{0, 3}, {3, 5}},
},
} {
res := partitionRanges(len(c.input), func(i int) (uint64, uint64) {
return uint64(c.input[i][0]), uint64(c.input[i][1])
}, maxGapSize)
testutil.Equals(t, c.expected, res)
}
} | explode_data.jsonl/39691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 473
} | [
2830,
3393,
49978,
74902,
1155,
353,
8840,
836,
8,
341,
4777,
1932,
12868,
1695,
284,
220,
16,
15,
17,
19,
353,
220,
20,
16,
17,
271,
2023,
8358,
272,
1669,
2088,
3056,
1235,
341,
197,
22427,
262,
508,
1457,
17,
63025,
198,
197,
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 TestIsInCheck(t *testing.T) {
tests := []struct {
sfen string
check bool
}{
{"1r6l/3g2kg1/3sSpn2/4P1p1p/l1Pp1P3/2Sn1B2P/1P4B2/K1gG2+r2/LN6L b N8Psp 1", true},
{"1r6l/3g2kg1/3sSpn2/4P1p1p/l1Pp1P3/2Sn1B2P/PP4B2/K1gG2+r2/LN6L w N7Psp 1", false},
{"l2g1p1nl/1s4k2/p2p2ppp/9/1r3G1NP/2B2P1PL/P1pP2P2/3s1SSK1/L4G3 w R4Pbg2np 1", true},
{"l2g1p1nl/1s4k2/p2p1bppp/9/1r3G1NP/2B2P1PL/P1pP2P2/3s1SSK1/L4G3 b R4Pg2np 1", false},
{"4k4/9/9/9/9/9/4B4/9/1r2L4 w - 1", false},
{"4k4/9/9/1B7/9/9/9/9/1r2L4 w - 1", true},
{"k8/9/9/LK7/9/9/9/9/9 w - 1", true},
{"k8/n8/9/LK7/9/9/9/9/9 b - 1", true},
}
for _, test := range tests {
p, err := NewPositionFromSFEN(test.sfen)
if err != nil {
t.Fatal(err)
}
if p.IsInCheck() != test.check {
t.Errorf("%v.IsInCheck(): want %v, got %v", test.sfen, test.check, p.IsInCheck())
}
}
} | explode_data.jsonl/40641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 566
} | [
2830,
3393,
3872,
641,
3973,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
1903,
30353,
220,
914,
198,
197,
25157,
1807,
198,
197,
59403,
197,
197,
4913,
16,
81,
21,
75,
14,
18,
70,
17,
7351,
16,
14,
18,
82,
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... | 4 |
func TestLDAPToEmail(t *testing.T) {
th := Setup().InitBasic()
Client := th.BasicClient
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
rteam, _ := Client.CreateTeam(&team)
user := model.User{Email: strings.ToLower(model.NewId()) + "success+test@simulator.amazonses.com", Nickname: "Corey Hulen", Password: "passwd1"}
ruser := Client.Must(Client.CreateUser(&user, "")).Data.(*model.User)
LinkUserToTeam(ruser, rteam.Data.(*model.Team))
store.Must(app.Srv.Store.User().VerifyEmail(ruser.Id))
Client.Login(user.Email, user.Password)
m := map[string]string{}
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - empty data")
}
m["email_password"] = "passwd1"
_, err := Client.LDAPToEmail(m)
if err == nil {
t.Fatal("should have failed - missing team_name, ldap_password, email")
}
m["team_name"] = team.Name
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - missing email, ldap_password")
}
m["ldap_password"] = "passwd1"
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - missing email")
}
m["email"] = ruser.Email
m["team_name"] = "junk"
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - bad team name")
}
m["team_name"] = team.Name
m["email"] = "junk"
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - bad email")
}
m["email"] = user.Email
if _, err := Client.LDAPToEmail(m); err == nil {
t.Fatal("should have failed - user is not an AD/LDAP user")
}
} | explode_data.jsonl/13823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 636
} | [
2830,
3393,
93497,
1249,
4781,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
71724,
1669,
270,
48868,
2959,
271,
197,
9196,
1669,
1614,
65842,
90,
26456,
25,
330,
675,
497,
3988,
25,
330,
89,
9141,
27651,
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... | 8 |
func TestLedgerMgmt(t *testing.T) {
// Check for error when creating/opening ledger without initialization.
gb, _ := test.MakeGenesisBlock(constructTestLedgerID(0))
l, err := CreateLedger(gb)
testutil.AssertNil(t, l)
testutil.AssertEquals(t, err, ErrLedgerMgmtNotInitialized)
ledgerID := constructTestLedgerID(2)
l, err = OpenLedger(ledgerID)
testutil.AssertNil(t, l)
testutil.AssertEquals(t, err, ErrLedgerMgmtNotInitialized)
ids, err := GetLedgerIDs()
testutil.AssertNil(t, ids)
testutil.AssertEquals(t, err, ErrLedgerMgmtNotInitialized)
Close()
InitializeTestEnv()
defer CleanupTestEnv()
numLedgers := 10
ledgers := make([]ledger.PeerLedger, numLedgers)
for i := 0; i < numLedgers; i++ {
gb, _ := test.MakeGenesisBlock(constructTestLedgerID(i))
l, _ := CreateLedger(gb)
ledgers[i] = l
}
ids, _ = GetLedgerIDs()
testutil.AssertEquals(t, len(ids), numLedgers)
for i := 0; i < numLedgers; i++ {
testutil.AssertEquals(t, ids[i], constructTestLedgerID(i))
}
ledgerID = constructTestLedgerID(2)
t.Logf("Ledger selected for test = %s", ledgerID)
_, err = OpenLedger(ledgerID)
testutil.AssertEquals(t, err, ErrLedgerAlreadyOpened)
l = ledgers[2]
l.Close()
l, err = OpenLedger(ledgerID)
testutil.AssertNoError(t, err, "")
l, err = OpenLedger(ledgerID)
testutil.AssertEquals(t, err, ErrLedgerAlreadyOpened)
// close all opened ledgers and ledger mgmt
Close()
// Restart ledger mgmt with existing ledgers
Initialize()
l, err = OpenLedger(ledgerID)
testutil.AssertNoError(t, err, "")
Close()
} | explode_data.jsonl/65679 | {
"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,
60850,
1389,
44,
46063,
1155,
353,
8840,
836,
8,
341,
197,
322,
4248,
369,
1465,
979,
6825,
37644,
287,
46933,
2041,
17465,
624,
3174,
65,
11,
716,
1669,
1273,
50133,
84652,
4713,
7,
7596,
2271,
60850,
1389,
915,
7,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDexPreoptApexSystemServerJars(t *testing.T) {
config := android.TestConfig("out", nil, "", nil)
ctx := android.BuilderContextForTesting(config)
globalSoong := globalSoongConfigForTests()
global := GlobalConfigForTests(ctx)
module := testApexModuleConfig(ctx, "service-A", "com.android.apex1")
global.ApexSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"com.android.apex1:service-A"})
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module)
if err != nil {
t.Fatal(err)
}
wantInstalls := android.RuleBuilderInstalls{
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.odex"},
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.vdex"},
}
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
} | explode_data.jsonl/56809 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
35,
327,
4703,
2912,
10611,
327,
2320,
5475,
41,
1561,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2103,
8787,
2648,
445,
411,
497,
2092,
11,
7342,
2092,
340,
20985,
1669,
2103,
15641,
1972,
2461,
16451,
8754,
340,
18842,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPeer_Send_Timeout_Mutex_TryLockCtx(t *testing.T) {
t.Parallel()
conn, remote := newPipeConnPair()
p := newPeer(nil, conn, nil)
go remote.Recv()
p.sending.Lock()
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
assert.Error(t, p.Send(ctx, wire.NewPingMsg()),
"Send() must timeout on locked mutex")
assert.True(t, p.IsClosed(), "peer must be closed after failed Send()")
} | explode_data.jsonl/51237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
30888,
46267,
39080,
411,
1245,
9371,
1139,
884,
11989,
23684,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
32917,
11,
8699,
1669,
501,
34077,
9701,
12443,
741,
3223,
1669,
501,
30888,
27907,
11,
4534,
11,
2092,
692... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSanitizeBranchName(t *testing.T) {
type args struct {
name string
}
tests := []struct {
name string
args args
want string
}{
{
"master",
args{
"master",
},
"refs/heads/master",
},
{
"refs/heads/master",
args{
"refs/heads/master",
},
"refs/heads/master",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SanitizeBranchName(tt.args.name); got != tt.want {
t.Errorf("SanitizeBranchName() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/82301 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
23729,
26310,
18197,
675,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
11609,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
914,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestScrapeWorkScrapeInternalFailure(t *testing.T) {
dataExpected := `
up 0 123
scrape_samples_scraped 0 123
scrape_duration_seconds 0 123
scrape_samples_post_metric_relabeling 0 123
scrape_series_added 0 123
`
timeseriesExpected := parseData(dataExpected)
var sw scrapeWork
sw.Config = &ScrapeWork{}
readDataCalls := 0
sw.ReadData = func(dst []byte) ([]byte, error) {
readDataCalls++
return dst, fmt.Errorf("error when reading data")
}
pushDataCalls := 0
var pushDataErr error
sw.PushData = func(wr *prompbmarshal.WriteRequest) {
if err := expectEqualTimeseries(wr.Timeseries, timeseriesExpected); err != nil {
pushDataErr = fmt.Errorf("unexpected data pushed: %w\ngot\n%#v\nwant\n%#v", err, wr.Timeseries, timeseriesExpected)
}
pushDataCalls++
}
timestamp := int64(123000)
if err := sw.scrapeInternal(timestamp, timestamp); err == nil {
t.Fatalf("expecting non-nil error")
}
if pushDataErr != nil {
t.Fatalf("unexpected error: %s", pushDataErr)
}
if readDataCalls != 1 {
t.Fatalf("unexpected number of readData calls; got %d; want %d", readDataCalls, 1)
}
if pushDataCalls != 1 {
t.Fatalf("unexpected number of pushData calls; got %d; want %d", pushDataCalls, 1)
}
} | explode_data.jsonl/68862 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 474
} | [
2830,
3393,
3326,
19842,
6776,
3326,
19842,
11569,
17507,
1155,
353,
8840,
836,
8,
341,
8924,
18896,
1669,
22074,
197,
59810,
220,
15,
220,
16,
17,
18,
198,
197,
29928,
19842,
18297,
13171,
4611,
291,
220,
15,
220,
16,
17,
18,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateLabelsFlags(t *testing.T) {
for _, tt := range []struct {
name string
deploymentLabelCMDFlags DeploymentLabelFlags
expectedResult error
}{{
name: "Knative Eventing with no deployment aspect",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You need to specify what to configure for the deployment or service in Knative: NodeSelector, Annotation, Selector or Label."),
}, {
name: "Knative Eventing with multiple aspects",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Annotation: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You can only specify one of the following in the command line: NodeSelector, Annotation, Selector or Label."),
}, {
name: "Knative Eventing",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: nil,
}, {
name: "Knative Eventing with service name",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
ServiceName: "eventing-controller",
},
expectedResult: nil,
}, {
name: "Knative Eventing with service name and nodeSelector",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Selector: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
ServiceName: "eventing-controller",
},
expectedResult: nil,
}, {
name: "Knative Eventing with service name and nodeSelector",
deploymentLabelCMDFlags: DeploymentLabelFlags{
NodeSelector: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
ServiceName: "eventing-controller",
},
expectedResult: fmt.Errorf("You cannot configure the nodeSelector for the service."),
}, {
name: "Knative Eventing with deployment name and nodeSelector",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Selector: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You cannot configure the selector for the deployment."),
}, {
name: "Knative Eventing with no deployment name or service name",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-key",
Value: "test-value",
Component: "eventing",
Namespace: "test-eventing",
},
expectedResult: fmt.Errorf("You need to specify the name of the deployment or the service."),
}, {
name: "Knative Eventing with invalid component name",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-key",
Value: "test-value",
Component: "eventing-test",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You need to specify the component for Knative: serving or eventing."),
}, {
name: "Knative Eventing with no namespace",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-key",
Value: "test-value",
Component: "eventing-test",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You need to specify the namespace."),
}, {
name: "Knative Eventing with no key",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Value: "test-value",
Component: "eventing-test",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You need to specify the key for the deployment."),
}, {
name: "Knative Eventing with no value",
deploymentLabelCMDFlags: DeploymentLabelFlags{
Label: true,
Key: "test-value",
Component: "eventing-test",
Namespace: "test-eventing",
DeployName: "eventing-controller",
},
expectedResult: fmt.Errorf("You need to specify the value for the deployment."),
}} {
t.Run(tt.name, func(t *testing.T) {
result := validateLabelsFlags(tt.deploymentLabelCMDFlags)
if tt.expectedResult == nil {
testingUtil.AssertEqual(t, result, nil)
} else {
testingUtil.AssertEqual(t, result.Error(), tt.expectedResult.Error())
}
})
}
} | explode_data.jsonl/69536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1908
} | [
2830,
3393,
17926,
23674,
9195,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
503,
914,
198,
197,
197,
82213,
2476,
38680,
9195,
66292,
2476,
9195,
198,
197,
42400,
2077,
688,
1465,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCustomFieldName(t *testing.T) {
validate := New()
validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
name := strings.SplitN(fld.Tag.Get("schema"), ",", 2)[0]
if name == "-" {
return ""
}
return name
})
type A struct {
B string `schema:"b" validate:"required"`
C string `schema:"c" validate:"required"`
D []bool `schema:"d" validate:"required"`
E string `schema:"-" validate:"required"`
}
a := &A{}
err := validate.Struct(a)
NotEqual(t, err, nil)
errs := err.(ValidationErrors)
Equal(t, len(errs), 4)
Equal(t, getError(errs, "A.b", "A.B").Field(), "b")
Equal(t, getError(errs, "A.c", "A.C").Field(), "c")
Equal(t, getError(errs, "A.d", "A.D").Field(), "d")
Equal(t, getError(errs, "A.E", "A.E").Field(), "E")
v2 := New()
err = v2.Struct(a)
NotEqual(t, err, nil)
errs = err.(ValidationErrors)
Equal(t, len(errs), 4)
Equal(t, getError(errs, "A.B", "A.B").Field(), "B")
Equal(t, getError(errs, "A.C", "A.C").Field(), "C")
Equal(t, getError(errs, "A.D", "A.D").Field(), "D")
Equal(t, getError(errs, "A.E", "A.E").Field(), "E")
} | explode_data.jsonl/77336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 507
} | [
2830,
3393,
10268,
51241,
1155,
353,
8840,
836,
8,
1476,
197,
7067,
1669,
1532,
741,
197,
7067,
19983,
22616,
9626,
18552,
955,
507,
8708,
51445,
1877,
8,
914,
341,
197,
11609,
1669,
9069,
19823,
45,
955,
507,
23676,
2234,
445,
17349,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFileExistenceCheckComplianceResults(t *testing.T) {
testCases := []struct {
desc string
fileCheck *ipb.FileCheck
expectedResult *apb.ComplianceResult
}{
{
desc: "File exists and should",
fileCheck: &ipb.FileCheck{
FilesToCheck: []*ipb.FileSet{testconfigcreator.SingleFileWithPath(testFilePath)},
CheckType: &ipb.FileCheck_Existence{Existence: &ipb.ExistenceCheck{ShouldExist: true}},
},
expectedResult: &apb.ComplianceResult{
Id: "id",
ComplianceOccurrence: &cpb.ComplianceOccurrence{},
},
},
{
desc: "File doesn't exist and shouldn't",
fileCheck: &ipb.FileCheck{
FilesToCheck: []*ipb.FileSet{testconfigcreator.SingleFileWithPath(nonExistentFilePath)},
CheckType: &ipb.FileCheck_Existence{Existence: &ipb.ExistenceCheck{ShouldExist: false}},
},
expectedResult: &apb.ComplianceResult{
Id: "id",
ComplianceOccurrence: &cpb.ComplianceOccurrence{},
},
},
{
desc: "File doesn't exist but should",
fileCheck: &ipb.FileCheck{
FilesToCheck: []*ipb.FileSet{testconfigcreator.SingleFileWithPath(nonExistentFilePath)},
CheckType: &ipb.FileCheck_Existence{Existence: &ipb.ExistenceCheck{ShouldExist: true}},
},
expectedResult: &apb.ComplianceResult{
Id: "id",
ComplianceOccurrence: &cpb.ComplianceOccurrence{
NonCompliantFiles: []*cpb.NonCompliantFile{
&cpb.NonCompliantFile{
Path: fileset.FileSetToString(testconfigcreator.SingleFileWithPath(nonExistentFilePath)),
Reason: "File doesn't exist but it should",
},
},
},
},
},
{
desc: "File in directory doesn't exist but it should",
fileCheck: &ipb.FileCheck{
FilesToCheck: []*ipb.FileSet{&ipb.FileSet{
FilePath: &ipb.FileSet_FilesInDir_{FilesInDir: &ipb.FileSet_FilesInDir{
DirPath: testDirPath,
Recursive: true,
FilenameRegex: "non-existent",
}},
}},
CheckType: &ipb.FileCheck_Existence{Existence: &ipb.ExistenceCheck{ShouldExist: true}},
},
expectedResult: &apb.ComplianceResult{
Id: "id",
ComplianceOccurrence: &cpb.ComplianceOccurrence{
NonCompliantFiles: []*cpb.NonCompliantFile{
&cpb.NonCompliantFile{
Path: fileset.FileSetToString(&ipb.FileSet{
FilePath: &ipb.FileSet_FilesInDir_{FilesInDir: &ipb.FileSet_FilesInDir{
DirPath: testDirPath,
Recursive: true,
FilenameRegex: "non-existent",
}},
}),
Reason: "File doesn't exist but it should",
},
},
},
},
},
{
desc: "File exists but it shouldn't",
fileCheck: &ipb.FileCheck{
FilesToCheck: []*ipb.FileSet{testconfigcreator.SingleFileWithPath(testFilePath)},
CheckType: &ipb.FileCheck_Existence{Existence: &ipb.ExistenceCheck{ShouldExist: false}},
},
expectedResult: &apb.ComplianceResult{
Id: "id",
ComplianceOccurrence: &cpb.ComplianceOccurrence{
NonCompliantFiles: []*cpb.NonCompliantFile{
&cpb.NonCompliantFile{
Path: testFilePath,
Reason: "File exists but it shouldn't",
},
},
},
},
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
check := createFileCheckBatch(t, "id", []*ipb.FileCheck{tc.fileCheck}, newFakeAPI())
resultMap, err := check.Exec()
if err != nil {
t.Fatalf("check.Exec() returned an error: %v", err)
}
result, gotSingleton := singleComplianceResult(resultMap)
if !gotSingleton {
t.Fatalf("check.Exec() expected to return 1 result, got %d", len(resultMap))
}
if diff := cmp.Diff(tc.expectedResult, result, protocmp.Transform()); diff != "" {
t.Errorf("check.Exec() returned unexpected diff (-want +got):\n%s", diff)
}
})
}
} | explode_data.jsonl/24470 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1686
} | [
2830,
3393,
1703,
25613,
763,
3973,
1092,
31612,
9801,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
1843,
914,
198,
197,
17661,
3973,
414,
353,
573,
65,
8576,
3973,
198,
197,
42400,
2077,
353,
391,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDetermineDateMacro(t *testing.T) {
def := Definition{
DateMacroFormat: "2006-01-02",
Tests: []Test{
{
Condition: Condition{
Query: "start1${date.today}end1",
},
Expect: Expect{
Speech: "start2${date.today}end2",
Speeches: []string{
"start3${date.today}end3",
},
Parameters: map[interface{}]interface{}{
"key1": "start4${date.today}end4",
"key2": "start5${date.today}end5",
"key3": map[interface{}]interface{}{
"key4": "start6${date.today}end6",
},
},
},
},
},
}
determineDateMacro(&def)
test := def.Tests[0]
date := time.Now().Format("2006-01-02")
if test.Condition.Query != "start1" + date + "end1" {
t.Fatalf("test.Condition.Query is not expected value: %s", test.Condition.Query)
}
if test.Expect.Speech != "start2" + date + "end2" {
t.Fatalf("test.Expect.Speech is not expected value: %s", test.Expect.Speech)
}
if test.Expect.Speeches[0] != "start3" + date + "end3" {
t.Fatalf("test.Expect.Speeches[0] is not expected value: %s", test.Expect.Speeches[0])
}
if test.Expect.Parameters["key1"] != "start4" + date + "end4" {
t.Fatalf("test.Expect.Parameters[\"key1\"] is not expected value: %s", test.Expect.Parameters["key1"])
}
if test.Expect.Parameters["key2"] != "start5" + date + "end5" {
t.Fatalf("test.Expect.Parameters[\"key2\"] is not expected value: %s", test.Expect.Parameters["key2"])
}
if test.Expect.Parameters["key3"].(map[interface{}]interface{})["key4"] != "start6" + date + "end6" {
t.Fatalf("test.Expect.Parameters[\"key3\"][\"key4\"] is not expected value: %s", test.Expect.Parameters["key3"].(map[interface{}]interface{})["key4"])
}
} | explode_data.jsonl/65419 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 741
} | [
2830,
3393,
35,
24308,
1916,
60175,
1155,
353,
8840,
836,
8,
341,
7452,
1669,
19709,
515,
197,
48730,
60175,
4061,
25,
330,
17,
15,
15,
21,
12,
15,
16,
12,
15,
17,
756,
197,
197,
18200,
25,
3056,
2271,
515,
298,
197,
515,
571,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestClearAndResetStrandedTask(t *testing.T) {
require.NoError(t, db.ClearCollections(host.Collection, task.Collection, task.OldCollection, build.Collection), t, "error clearing collection")
assert := assert.New(t)
runningTask := &task.Task{
Id: "t",
Status: evergreen.TaskStarted,
Activated: true,
ActivatedTime: time.Now(),
BuildId: "b",
}
assert.NoError(runningTask.Insert())
h := &host.Host{
Id: "h1",
RunningTask: "t",
}
assert.NoError(h.Insert())
b := build.Build{
Id: "b",
Tasks: []build.TaskCache{
build.TaskCache{
Id: "t",
},
},
}
assert.NoError(b.Insert())
assert.NoError(ClearAndResetStrandedTask(h))
runningTask, err := task.FindOne(task.ById("t"))
assert.NoError(err)
assert.Equal(evergreen.TaskUndispatched, runningTask.Status)
} | explode_data.jsonl/60444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
14008,
3036,
14828,
2580,
6465,
6262,
1155,
353,
8840,
836,
8,
341,
17957,
35699,
1155,
11,
2927,
13524,
52730,
19973,
28629,
11,
3383,
28629,
11,
3383,
8382,
507,
6482,
11,
1936,
28629,
701,
259,
11,
330,
841,
32750,
4426,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestList_Removes(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
l := New()
a1 := []interface{}{1, 2, 3, 4}
l.PushFronts(a1)
e1 := l.Back()
l.Removes([]*Element{e1})
t.Assert(l.Len(), 3)
e2 := l.Back()
l.Removes([]*Element{e2})
t.Assert(l.Len(), 2)
checkList(t, l, []interface{}{4, 3})
})
} | explode_data.jsonl/30909 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
852,
54551,
10088,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
8810,
1669,
1532,
741,
197,
11323,
16,
1669,
3056,
4970,
6257,
90,
16,
11,
220,
17,
11,
220,
18,
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 TestServeFileWithContentEncoding(t *testing.T) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
w.Header().Set("Content-Encoding", "foo")
ServeFile(w, r, "testdata/file")
}))
defer ts.Close()
resp, err := Get(ts.URL)
if err != nil {
t.Fatal(err)
}
resp.Body.Close()
if g, e := resp.ContentLength, int64(-1); g != e {
t.Errorf("Content-Length mismatch: got %d, want %d", g, e)
}
} | explode_data.jsonl/48234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
60421,
1703,
2354,
2762,
14690,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
57441,
1669,
54320,
70334,
7121,
5475,
7,
3050,
9626,
18552,
3622,
5949,
6492,
11,
435,
353,
1900,
8,
341,
197,
6692,
15753,
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... | 1 |
func TestInviteUsersToTeamWithUserLimit(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
email1 := th.GenerateTestEmail()
email2 := th.GenerateTestEmail()
email3 := th.GenerateTestEmail()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.EnableEmailInvitations = true
*cfg.ExperimentalSettings.CloudUserLimit = 2
})
t.Run("System admin, invite when at limit should fail", func(t *testing.T) {
invitesWithErrors, resp := th.SystemAdminClient.InviteUsersToTeamGracefully(th.BasicTeam.Id, []string{email1, email2})
CheckNoError(t, resp)
require.Len(t, invitesWithErrors, 2)
require.NotNil(t, invitesWithErrors[0].Error)
assert.Equal(t, invitesWithErrors[0].Error.Message, "You've reached the free tier user limit")
require.NotNil(t, invitesWithErrors[1].Error)
assert.Equal(t, invitesWithErrors[1].Error.Message, "You've reached the free tier user limit")
})
t.Run("Regular user, invite when at limit should succeed", func(t *testing.T) {
invitesWithErrors, resp := th.Client.InviteUsersToTeamGracefully(th.BasicTeam.Id, []string{email3})
CheckNoError(t, resp)
require.Len(t, invitesWithErrors, 1)
assert.Nil(t, invitesWithErrors[0].Error)
})
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ExperimentalSettings.CloudUserLimit = 5
})
t.Run("With one remaining user inviting more than one user as admin invites only one user", func(t *testing.T) {
invitesWithErrors, resp := th.SystemAdminClient.InviteUsersToTeamGracefully(th.BasicTeam.Id, []string{email1, email2})
CheckNoError(t, resp)
require.Len(t, invitesWithErrors, 2)
require.Nil(t, invitesWithErrors[0].Error)
require.NotNil(t, invitesWithErrors[1].Error)
assert.Equal(t, invitesWithErrors[1].Error.Message, "You've reached the free tier user limit")
})
t.Run("With one remaining user inviting more than one user as a regular user sends all invites", func(t *testing.T) {
invitesWithErrors, resp := th.Client.InviteUsersToTeamGracefully(th.BasicTeam.Id, []string{email1, email2})
CheckNoError(t, resp)
require.Len(t, invitesWithErrors, 2)
assert.Nil(t, invitesWithErrors[0].Error)
assert.Nil(t, invitesWithErrors[1].Error)
})
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ExperimentalSettings.CloudUserLimit = 100
})
t.Run("Invited user count is well below limit", func(t *testing.T) {
invitesWithErrors, resp := th.SystemAdminClient.InviteUsersToTeamGracefully(th.BasicTeam.Id, []string{email1, email2})
CheckNoError(t, resp)
require.Len(t, invitesWithErrors, 2)
require.Nil(t, invitesWithErrors[0].Error)
})
} | explode_data.jsonl/70737 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 938
} | [
2830,
3393,
93540,
7137,
1249,
14597,
2354,
1474,
16527,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
57549,
16,
1669,
270,
57582,
2271,
4781,
741,
57549,
17,
1669,
270,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnableTracing(t *testing.T) {
a := NewArgs()
if a.EnableTracing() {
t.Fatal("default arg values should not have enabled tracing")
}
a = NewArgs()
a.LogTraceSpans = true
if !a.EnableTracing() {
t.Fatal("logTraceSpans should have trigged tracing")
}
a = NewArgs()
a.ZipkinURL = "http://foo.bar.com"
if !a.EnableTracing() {
t.Fatal("zipkinURL should have trigged tracing")
}
a = NewArgs()
a.JaegerURL = "http://foo.bar.com"
if !a.EnableTracing() {
t.Fatal("jaegerURL should have trigged tracing")
}
} | explode_data.jsonl/24310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 215
} | [
2830,
3393,
11084,
1282,
4527,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
4117,
2822,
743,
264,
32287,
1282,
4527,
368,
341,
197,
3244,
26133,
445,
2258,
1392,
2750,
1265,
537,
614,
8970,
45415,
1138,
197,
630,
11323,
284,
1532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestReconciler_CreateDeployment_RollingUpgrade_Destructive(t *testing.T) {
job := mock.Job()
job.TaskGroups[0].Update = noCanaryUpdate
// Create 10 allocations from the old job
var allocs []*structs.Allocation
for i := 0; i < 10; i++ {
alloc := mock.Alloc()
alloc.Job = job
alloc.JobID = job.ID
alloc.NodeID = uuid.Generate()
alloc.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i))
alloc.TaskGroup = job.TaskGroups[0].Name
allocs = append(allocs, alloc)
}
reconciler := NewAllocReconciler(testLogger(), allocUpdateFnDestructive, false, job.ID, job, nil, allocs, nil)
r := reconciler.Compute()
d := structs.NewDeployment(job)
d.TaskGroups[job.TaskGroups[0].Name] = &structs.DeploymentState{
DesiredTotal: 10,
}
// Assert the correct results
assertResults(t, r, &resultExpectation{
createDeployment: d,
deploymentUpdates: nil,
destructive: 4,
desiredTGUpdates: map[string]*structs.DesiredUpdates{
job.TaskGroups[0].Name: {
DestructiveUpdate: 4,
Ignore: 6,
},
},
})
assertNamesHaveIndexes(t, intRange(0, 3), destructiveResultsToNames(r.destructiveUpdate))
} | explode_data.jsonl/67251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
693,
40446,
5769,
34325,
75286,
2568,
965,
287,
43861,
1557,
29294,
533,
1155,
353,
8840,
836,
8,
341,
68577,
1669,
7860,
45293,
741,
68577,
28258,
22173,
58,
15,
936,
4289,
284,
902,
6713,
658,
4289,
271,
197,
322,
4230,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTerragruntOutputAllCommandSpecificVariableIgnoreDependencyErrors(t *testing.T) {
t.Parallel()
s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId()))
defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_OUTPUT_ALL)
rootTerragruntConfigPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL, config.DefaultTerragruntConfigPath)
copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, "not-used", "not-used")
environmentPath := fmt.Sprintf("%s/%s/env1", tmpEnvPath, TEST_FIXTURE_OUTPUT_ALL)
runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s", environmentPath))
var (
stdout bytes.Buffer
stderr bytes.Buffer
)
// Call runTerragruntCommand directly because this command contains failures (which causes runTerragruntRedirectOutput to abort) but we don't care.
runTerragruntCommand(t, fmt.Sprintf("terragrunt output-all app2_text --terragrunt-ignore-dependency-errors --terragrunt-non-interactive --terragrunt-working-dir %s", environmentPath), &stdout, &stderr)
output := stdout.String()
logBufferContentsLineByLine(t, stdout, "output-all stdout")
logBufferContentsLineByLine(t, stderr, "output-all stderr")
// Without --terragrunt-ignore-dependency-errors, app2 never runs because its dependencies have "errors" since they don't have the output "app2_text".
assert.True(t, strings.Contains(output, "app2 output"))
} | explode_data.jsonl/10086 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 556
} | [
2830,
3393,
51402,
68305,
3850,
5097,
2403,
4062,
47514,
7827,
12497,
36387,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
18,
36018,
675,
1669,
8879,
17305,
445,
465,
4101,
81,
3850,
16839,
1455,
11152,
11069,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGraph_BuildOrderError(t *testing.T) {
testSuite := []struct {
title string
variables []string
dependencies map[string][]string
}{
{
title: "simple circular dep",
variables: []string{"a", "b"},
dependencies: map[string][]string{
"a": {"b"},
"b": {"a"},
},
},
{
title: "circular dep on the same node",
variables: []string{"a"},
dependencies: map[string][]string{
"a": {"a"},
},
},
{
title: "circular dep with transition",
variables: []string{"f", "d", "c", "b", "g", "a", "h", "e"},
dependencies: map[string][]string{
"e": {"a", "b"},
"a": {"c", "f", "b"},
"h": {"b"},
"g": {"d", "c"},
"c": {"f"},
"b": {"f"},
"d": {"d"},
},
},
}
for _, test := range testSuite {
t.Run(test.title, func(t *testing.T) {
g := newGraph(test.variables, test.dependencies, nil, nil)
_, err := g.buildOrder()
assert.Equal(t, fmt.Errorf("circular dependency detected"), err)
})
}
} | explode_data.jsonl/34533 | {
"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,
11212,
96686,
4431,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
28000,
1669,
3056,
1235,
341,
197,
24751,
286,
914,
198,
197,
2405,
2156,
82,
262,
3056,
917,
198,
197,
197,
54274,
2415,
14032,
45725,
917,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUpdateEngineForComplete(t *testing.T) {
tests := map[string]struct {
engine chaosTypes.EngineInfo
isErr bool
}{
"Test Positive-1": {
engine: chaosTypes.EngineInfo{
Instance: &v1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "engine-complete-p1",
Namespace: "default",
},
Spec: v1alpha1.ChaosEngineSpec{
Appinfo: v1alpha1.ApplicationParams{
Applabel: "app=nginx",
AppKind: "deployment",
},
EngineState: v1alpha1.EngineStateActive,
AnnotationCheck: "false",
Components: v1alpha1.ComponentParams{
Runner: v1alpha1.RunnerInfo{
Image: "fake-runner-image",
},
},
Experiments: []v1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
Status: v1alpha1.ChaosEngineStatus{
EngineStatus: v1alpha1.EngineStatusCompleted,
},
},
},
isErr: false,
},
"Test Positive-2": {
engine: chaosTypes.EngineInfo{
Instance: &v1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "engine-complete-p2",
Namespace: "default",
},
Spec: v1alpha1.ChaosEngineSpec{
Appinfo: v1alpha1.ApplicationParams{
Applabel: "app=nginx",
AppKind: "deployment",
},
EngineState: v1alpha1.EngineStateActive,
AnnotationCheck: "false",
Experiments: []v1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
Status: v1alpha1.ChaosEngineStatus{
EngineStatus: v1alpha1.EngineStatusInitialized,
},
},
},
isErr: false,
},
"Test Positive-3": {
engine: chaosTypes.EngineInfo{
Instance: &v1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "engine-complete-p3",
Namespace: "default",
},
Spec: v1alpha1.ChaosEngineSpec{
Appinfo: v1alpha1.ApplicationParams{
Applabel: "app=nginx",
AppKind: "deployment",
},
EngineState: v1alpha1.EngineStateActive,
AnnotationCheck: "false",
Experiments: []v1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
Status: v1alpha1.ChaosEngineStatus{
EngineStatus: v1alpha1.EngineStatusStopped,
},
},
},
isErr: false,
},
}
for name, mock := range tests {
t.Run(name, func(t *testing.T) {
r := CreateFakeClient(t)
err := r.client.Create(context.TODO(), mock.engine.Instance)
if err != nil {
fmt.Printf("Unable to create engine: %v", err)
}
err = r.updateEngineForComplete(&mock.engine, true)
if mock.isErr && err == nil {
t.Fatalf("Test %q failed: expected error not to be nil", name)
}
if !mock.isErr && err != nil {
t.Fatalf("Test %q failed: expected error to be nil", name)
}
})
}
} | explode_data.jsonl/32127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1391
} | [
2830,
3393,
4289,
4571,
2461,
12548,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
80118,
26915,
4173,
54424,
1731,
198,
197,
19907,
7747,
220,
1807,
198,
197,
59403,
197,
197,
1,
2271,
43903,
12,
16,
788... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventChannel_Push(t *testing.T) {
data := make([]byte, 0)
send := newSender(&data)
eventChannel := NewEventChannel(send, 15000, 5, 5*time.Millisecond)
defer eventChannel.Close()
eventChannel.Push([]byte("one"))
eventChannel.Push([]byte("two"))
eventChannel.Push([]byte("three"))
eventChannel.Push([]byte("four"))
eventChannel.Push([]byte("five"))
eventChannel.Push([]byte("six"))
eventChannel.Push([]byte("seven"))
time.Sleep(10 * time.Millisecond)
assert.Equal(t, string(data), "onetwothreefourfivesixseven")
} | explode_data.jsonl/43921 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
1556,
9629,
1088,
1116,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
1281,
10556,
3782,
11,
220,
15,
340,
32817,
1669,
501,
20381,
2099,
691,
692,
28302,
9629,
1669,
1532,
1556,
9629,
47617,
11,
220,
16,
20,
15,
15,
15,
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 TestReverse(t *testing.T) {
cases := []struct {
input, want string
}{
{"Hello, world", "dlrow ,olleH"},
{"Hello, 世界", "界世 ,olleH"},
{"", ""},
}
for _, testCase := range cases {
got := Reverse(testCase.input)
if got != testCase.want {
t.Errorf("Reverse(%q) == %q, want %q", testCase.input, got, testCase.want)
}
}
} | explode_data.jsonl/74331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
45695,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
22427,
11,
1366,
914,
198,
197,
59403,
197,
197,
4913,
9707,
11,
1879,
497,
330,
8736,
651,
1154,
54048,
39,
7115,
197,
197,
4913,
9707,
11,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_DocumentProperties_GetDocumentPropertyOnline(t *testing.T) {
config := ReadConfiguration(t)
client, ctx := PrepareTest(t, config)
localFile := "Common/test_multi_pages.docx"
options := map[string]interface{}{
}
request := &models.GetDocumentPropertyOnlineRequest{
Document: OpenFile(t, localFile),
PropertyName: ToStringPointer("Author"),
Optionals: options,
}
_, _, err := client.WordsApi.GetDocumentPropertyOnline(ctx, request)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/26158 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 209
} | [
2830,
3393,
1557,
1452,
7903,
13614,
7524,
3052,
19598,
1155,
353,
8840,
836,
8,
341,
262,
2193,
1669,
4457,
7688,
1155,
340,
262,
2943,
11,
5635,
1669,
31166,
2271,
1155,
11,
2193,
340,
262,
2205,
1703,
1669,
330,
10839,
12697,
25133,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatus(t *testing.T) {
t.Log("Starting server")
h := httplistener.NewHTTP()
h.Addr = "localhost:19998"
m := NewMockBE()
h.BackendMgr = m
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
err := h.Run()
if err != nil {
t.Fatalf("Found an error with server: %v", err)
}
wg.Done()
}()
time.Sleep(time.Second)
r, err := http.Get("http://localhost:19998/status")
if err != nil {
t.Fatalf("Could not connect to status endpoint: %v", err)
}
if r.StatusCode != http.StatusOK {
t.Fatalf("Status on Mock server is not successful: %v", err)
}
body, _ := ioutil.ReadAll(r.Body)
t.Logf("Status: %v", string(body))
} | explode_data.jsonl/22200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
2522,
1155,
353,
8840,
836,
8,
1476,
3244,
5247,
445,
24617,
3538,
1138,
9598,
1669,
54320,
39934,
798,
7121,
9230,
741,
9598,
93626,
284,
330,
8301,
25,
16,
24,
24,
24,
23,
698,
2109,
1669,
1532,
11571,
11594,
741,
9598,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIDJSONMarshaling(t *testing.T) {
id := ID{0x4d, 0x88, 0xe1, 0x5b, 0x60, 0xf4, 0x86, 0xe4, 0x28, 0x41, 0x2d, 0xc9}
v := jsonType{ID: &id, Str: "test"}
data, err := json.Marshal(&v)
assert.NoError(t, err)
assert.Equal(t, `{"ID":"9m4e2mr0ui3e8a215n4g","Str":"test"}`, string(data))
} | explode_data.jsonl/58923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
915,
5370,
79712,
6132,
1155,
353,
8840,
836,
8,
341,
15710,
1669,
3034,
90,
15,
87,
19,
67,
11,
220,
15,
87,
23,
23,
11,
220,
15,
8371,
16,
11,
220,
15,
87,
20,
65,
11,
220,
15,
87,
21,
15,
11,
220,
15,
5848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_MemoryStore_Get(t *testing.T) {
m := NewMemoryStore()
m.Open()
pm := newPublishMsg(QOS_ONE, "/a/b/c", []byte{0xBE, 0xEF, 0xED})
pm.setMsgId(120)
key := obound_mid2key(pm.MsgId())
m.Put(key, pm)
if len(m.messages) != 1 {
t.Fatalf("message not in store")
}
exp := []byte{
/* msg type */
0x32, // qos 1
/* remlen */
0x0d,
/* topic, msg id in varheader */
0x00, // length of topic
0x06,
0x2F, // /
0x61, // a
0x2F, // /
0x62, // b
0x2F, // /
0x63, // c
/* msg id (is always 2 bytes) */
0x00,
0x78,
/*payload */
0xBE,
0xEF,
0xED,
}
msg := m.Get(key)
if msg == nil {
t.Fatalf("message not retreived from store")
}
if !bytes.Equal(exp, msg.Bytes()) {
t.Fatalf("message from store not same as what went in")
}
} | explode_data.jsonl/37296 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
1245,
4731,
6093,
13614,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
10642,
6093,
741,
2109,
12953,
741,
86511,
1669,
501,
50145,
6611,
6253,
3126,
34727,
11,
3521,
64,
3470,
2899,
497,
3056,
3782,
90,
15,
85449,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCT_PTabMarshalUnmarshal(t *testing.T) {
v := wml.NewCT_PTab()
buf, _ := xml.Marshal(v)
v2 := wml.NewCT_PTab()
xml.Unmarshal(buf, v2)
} | explode_data.jsonl/75485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
1162,
1088,
8582,
55438,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
289,
1014,
7121,
1162,
1088,
8582,
741,
26398,
11,
716,
1669,
8396,
37271,
3747,
340,
5195,
17,
1669,
289,
1014,
7121,
1162,
1088,
8582,
741,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLegacyReplicaCalcScaleUpCM(t *testing.T) {
tc := legacyReplicaCalcTestCase{
currentReplicas: 3,
expectedReplicas: 4,
metric: &metricInfo{
name: "qps",
levels: []int64{20000, 10000, 30000},
targetUtilization: 15000,
expectedUtilization: 20000,
},
}
tc.runTest(t)
} | explode_data.jsonl/26680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
77415,
18327,
15317,
47168,
6947,
2324,
9985,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
19588,
18327,
15317,
47168,
16458,
515,
197,
20121,
18327,
52210,
25,
220,
220,
18,
345,
197,
42400,
18327,
52210,
25,
220,
19,
345,
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 TestWorkspace_WriteAddon(t *testing.T) {
testCases := map[string]struct {
marshaler mockBinaryMarshaler
svc string
storageName string
wantedPath string
wantedErr error
}{
"writes addons file with content": {
marshaler: mockBinaryMarshaler{
content: []byte("hello"),
},
svc: "webhook",
storageName: "s3",
wantedPath: "/copilot/webhook/addons/s3.yml",
},
"wraps error if cannot marshal to binary": {
marshaler: mockBinaryMarshaler{
err: errors.New("some error"),
},
svc: "webhook",
storageName: "s3",
wantedErr: errors.New("marshal binary addon content: some error"),
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
// GIVEN
fs := afero.NewMemMapFs()
utils := &afero.Afero{
Fs: fs,
}
utils.MkdirAll(filepath.Join("/", "copilot", tc.svc), 0755)
ws := &Workspace{
workingDir: "/",
copilotDir: "/copilot",
fsUtils: utils,
}
// WHEN
actualPath, actualErr := ws.WriteAddon(tc.marshaler, tc.svc, tc.storageName)
// THEN
if tc.wantedErr != nil {
require.EqualError(t, actualErr, tc.wantedErr.Error(), "expected the same error")
} else {
require.Equal(t, tc.wantedPath, actualPath, "expected the same path")
out, err := utils.ReadFile(tc.wantedPath)
require.NoError(t, err)
require.Equal(t, tc.marshaler.content, out, "expected the contents of the file to match")
}
})
}
} | explode_data.jsonl/30120 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 660
} | [
2830,
3393,
45981,
31825,
84312,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
2109,
28423,
261,
256,
7860,
21338,
55438,
261,
198,
197,
1903,
7362,
260,
914,
198,
197,
197,
16172,
675,
914,
271,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScaleGetWithoutSpecReplicas(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.CustomResource.Store.DestroyFunc()
name := "foo"
var cr unstructured.Unstructured
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
key := "/noxus/" + metav1.NamespaceDefault + "/" + name
withoutSpecReplicas := validCustomResource.DeepCopy()
unstructured.RemoveNestedField(withoutSpecReplicas.Object, "spec", "replicas")
if err := storage.CustomResource.Storage.Create(ctx, key, withoutSpecReplicas, &cr, 0); err != nil {
t.Fatalf("error setting new custom resource (key: %s) %v: %v", key, withoutSpecReplicas, err)
}
_, err := storage.Scale.Get(ctx, name, &metav1.GetOptions{})
if err == nil {
t.Fatalf("error expected for %s", name)
}
if expected := `the spec replicas field ".spec.replicas" does not exist`; !strings.Contains(err.Error(), expected) {
t.Fatalf("expected error string %q, got: %v", expected, err)
}
} | explode_data.jsonl/71532 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
6947,
1949,
26040,
8327,
18327,
52210,
1155,
353,
8840,
836,
8,
341,
197,
16172,
11,
3538,
1669,
501,
5793,
1155,
340,
16867,
3538,
836,
261,
34016,
1155,
340,
16867,
5819,
27649,
4783,
38047,
57011,
9626,
2822,
11609,
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 TestValidateLink(t *testing.T) {
var mb Metablock
if err := mb.Load("package.2f89b927.link"); err != nil {
t.Errorf("Metablock load returned '%s'", err)
}
if err := validateLink(mb.Signed.(Link)); err != nil {
t.Errorf("Link metadata validation failed, returned '%s'", err)
}
testMb := Metablock{
Signed: Link{
Type: "invalid",
Name: "test_type",
Command: []string{
"tar",
"zcvf",
"foo.tar.gz",
"foo.py",
},
Materials: map[string]interface{}{
"foo.py": map[string]interface{}{
"sha256": "74dc3727c6e89308b39e4dfedf787e37841198b1fa165a27c013544a60502549",
},
},
Products: map[string]interface{}{
"foo.tar.gz": map[string]interface{}{
"sha256": "52947cb78b91ad01fe81cd6aef42d1f6817e92b9e6936c1e5aabb7c98514f355",
},
},
ByProducts: map[string]interface{}{
"return-value": float64(0),
"stderr": "a foo.py\n",
"stdout": "",
},
Environment: map[string]interface{}{},
},
}
err := validateLink(testMb.Signed.(Link))
if err.Error() != "invalid type for link 'test_type': should be 'link'" {
t.Error("validateLink error - incorrect type not detected")
}
testMb = Metablock{
Signed: Link{
Type: "link",
Name: "test_material_hash",
Command: []string{
"tar",
"zcvf",
"foo.tar.gz",
"foo.py",
},
Materials: map[string]interface{}{
"foo.py": map[string]interface{}{
"sha256": "!@#$%",
},
},
Products: map[string]interface{}{
"foo.tar.gz": map[string]interface{}{
"sha256": "52947cb78b91ad01fe81cd6aef42d1f6817e92b9e69" +
"36c1e5aabb7c98514f355",
},
},
ByProducts: map[string]interface{}{
"return-value": float64(0),
"stderr": "a foo.py\n",
"stdout": "",
},
Environment: map[string]interface{}{},
},
}
err = validateLink(testMb.Signed.(Link))
if err.Error() != "in materials of link 'test_material_hash': in artifact"+
" 'foo.py', sha256 hash value: invalid hex string: !@#$%" {
t.Error("validateLink error - invalid hashes not detected")
}
testMb = Metablock{
Signed: Link{
Type: "link",
Name: "test_product_hash",
Command: []string{
"tar",
"zcvf",
"foo.tar.gz",
"foo.py",
},
Materials: map[string]interface{}{
"foo.py": map[string]interface{}{
"sha256": "74dc3727c6e89308b39e4dfedf787e37841198b1fa165a27c013544a60502549",
},
},
Products: map[string]interface{}{
"foo.tar.gz": map[string]interface{}{
"sha256": "!@#$%",
},
},
ByProducts: map[string]interface{}{
"return-value": float64(0),
"stderr": "a foo.py\n",
"stdout": "",
},
Environment: map[string]interface{}{},
},
}
err = validateLink(testMb.Signed.(Link))
if err.Error() != "in products of link 'test_product_hash': in artifact "+
"'foo.tar.gz', sha256 hash value: invalid hex string: !@#$%" {
t.Error("validateLink error - invalid hashes not detected")
}
} | explode_data.jsonl/51761 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1404
} | [
2830,
3393,
17926,
3939,
1155,
353,
8840,
836,
8,
341,
2405,
10016,
6212,
370,
1023,
198,
743,
1848,
1669,
10016,
13969,
445,
1722,
13,
17,
69,
23,
24,
65,
24,
17,
22,
18076,
5038,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
34673,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRedfishRemoteDirectNormal(t *testing.T) {
m := &redfishMocks.RedfishAPI{}
defer m.AssertExpectations(t)
systemID := computerSystemID
httpResp := &http.Response{StatusCode: 200}
m.On("GetSystem", context.Background(), systemID).Times(1).
Return(getTestSystem(), httpResp, nil)
m.On("InsertVirtualMedia", context.Background(), "manager-1", "Cd", mock.Anything).
Return(redfishClient.RedfishError{}, httpResp, nil)
m.On("GetSystem", context.Background(), systemID).Times(1).
Return(getTestSystem(), httpResp, nil)
systemReq := redfishClient.ComputerSystem{
Boot: redfishClient.Boot{
BootSourceOverrideTarget: redfishClient.BOOTSOURCE_CD,
},
}
m.On("SetSystem", context.Background(), systemID, systemReq).
Times(1).
Return(redfishClient.ComputerSystem{}, httpResp, nil)
resetReq := redfishClient.ResetRequestBody{}
resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF
m.On("ResetSystem", context.Background(), systemID, resetReq).
Times(1).
Return(redfishClient.RedfishError{}, httpResp, nil)
m.On("GetSystem", context.Background(), systemID).Times(1).
Return(redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, httpResp, nil)
resetReq.ResetType = redfishClient.RESETTYPE_ON
m.On("ResetSystem", context.Background(), systemID, resetReq).
Times(1).
Return(redfishClient.RedfishError{}, httpResp, nil)
m.On("GetSystem", context.Background(), systemID).Times(1).
Return(redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_ON}, httpResp, nil)
rDCfg := getDefaultRedfishRemoteDirectObj(t, m)
err := rDCfg.DoRemoteDirect()
assert.NoError(t, err)
} | explode_data.jsonl/12276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 570
} | [
2830,
3393,
6033,
18170,
24703,
16027,
12206,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
609,
1151,
18170,
72577,
20943,
18170,
7082,
16094,
16867,
296,
11711,
17536,
804,
1155,
692,
40293,
915,
1669,
6366,
2320,
915,
198,
28080,
36555,
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 TestSet_Var(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var s gset.Set
s.Add(1, 1, 2)
s.Add([]interface{}{3, 4}...)
t.Assert(s.Size(), 4)
t.AssertIN(1, s.Slice())
t.AssertIN(2, s.Slice())
t.AssertIN(3, s.Slice())
t.AssertIN(4, s.Slice())
t.AssertNI(0, s.Slice())
t.Assert(s.Contains(4), true)
t.Assert(s.Contains(5), false)
s.Remove(1)
t.Assert(s.Size(), 3)
s.Clear()
t.Assert(s.Size(), 0)
})
} | explode_data.jsonl/34377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
1649,
61251,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
2405,
274,
342,
746,
4202,
198,
197,
1903,
1904,
7,
16,
11,
220,
16,
11,
220,
17,
340,
197,
1903,
1904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTxGasLimits(t *testing.T) {
gasGranted := uint64(10)
anteOpt := func(bapp *BaseApp) {
bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted))
// AnteHandlers must have their own defer/recover in order for the BaseApp
// to know how much gas was used! This is because the GasMeter is created in
// the AnteHandler, but if it panics the context won't be set properly in
// runTx's recover call.
defer func() {
if r := recover(); r != nil {
switch rType := r.(type) {
case sdk.ErrorOutOfGas:
err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor)
default:
panic(r)
}
}
}()
count := tx.(*txTest).Counter
newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante")
return newCtx, nil
})
}
routerOpt := func(bapp *BaseApp) {
bapp.Router().AddRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
return &sdk.Result{}, nil
})
}
app := setupBaseApp(t, anteOpt, routerOpt)
header := abci.Header{Height: 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
testCases := []struct {
tx *txTest
gasUsed uint64
fail bool
}{
{newTxCounter(0, 0), 0, false},
{newTxCounter(1, 1), 2, false},
{newTxCounter(9, 1), 10, false},
{newTxCounter(1, 9), 10, false},
{newTxCounter(10, 0), 10, false},
{newTxCounter(0, 10), 10, false},
{newTxCounter(0, 8, 2), 10, false},
{newTxCounter(0, 5, 1, 1, 1, 1, 1), 10, false},
{newTxCounter(0, 5, 1, 1, 1, 1), 9, false},
{newTxCounter(9, 2), 11, true},
{newTxCounter(2, 9), 11, true},
{newTxCounter(9, 1, 1), 11, true},
{newTxCounter(1, 8, 1, 1), 11, true},
{newTxCounter(11, 0), 11, true},
{newTxCounter(0, 11), 11, true},
{newTxCounter(0, 5, 11), 16, true},
}
for i, tc := range testCases {
tx := tc.tx
gInfo, result, err := app.Deliver(tx)
// check gas used and wanted
require.Equal(t, tc.gasUsed, gInfo.GasUsed, fmt.Sprintf("tc #%d; gas: %v, result: %v, err: %s", i, gInfo, result, err))
// check for out of gas
if !tc.fail {
require.NotNil(t, result, fmt.Sprintf("%d: %v, %v", i, tc, err))
} else {
require.Error(t, err)
require.Nil(t, result)
space, code, _ := sdkerrors.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
}
}
} | explode_data.jsonl/67059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1137
} | [
2830,
3393,
31584,
58728,
94588,
1155,
353,
8840,
836,
8,
341,
3174,
300,
55481,
1669,
2622,
21,
19,
7,
16,
15,
340,
197,
4942,
21367,
1669,
2915,
1883,
676,
353,
3978,
2164,
8,
341,
197,
2233,
676,
4202,
17117,
68,
3050,
18552,
750... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parseTestSummaries(t *testing.T) {
const testID = "ios_simple_objcTests/testExample"
const testStatus = "Success"
type args struct {
testSummariesContent plistutil.PlistData
}
tests := []struct {
name string
args args
want []TestResult
wantErr bool
}{
{
name: "Simple, single test result",
args: args{
plistutil.PlistData{
"TestableSummaries": []interface{}{
map[string]interface{}{
"Tests": []interface{}{
map[string]interface{}{
"Subtests": []interface{}{
map[string]interface{}{
"TestIdentifier": testID,
"TestStatus": testStatus,
},
},
},
},
},
},
},
},
want: []TestResult{
{
ID: testID,
Status: testStatus,
FailureInfo: nil,
Activities: nil,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parseTestSummaries(tt.args.testSummariesContent)
// t.Logf(pretty.Object(got))
if (err != nil) != tt.wantErr {
t.Errorf("parseTestSummaries() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("parseTestSummaries() = %v, want %v", pretty.Object(got), pretty.Object(tt.want))
}
})
}
} | explode_data.jsonl/12517 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 670
} | [
2830,
3393,
21039,
2271,
9190,
89333,
1155,
353,
8840,
836,
8,
341,
4777,
1273,
915,
284,
330,
3530,
30015,
7328,
66,
18200,
12697,
13314,
698,
4777,
1273,
2522,
284,
330,
7188,
698,
13158,
2827,
2036,
341,
197,
18185,
9190,
89333,
2762... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListSets(t *testing.T) {
output := `foo
bar
baz`
expected := []string{"foo", "bar", "baz"}
fcmd := fakeexec.FakeCmd{
CombinedOutputScript: []fakeexec.FakeAction{
// Success
func() ([]byte, []byte, error) { return []byte(output), nil, nil },
},
}
fexec := fakeexec.FakeExec{
CommandScript: []fakeexec.FakeCommandAction{
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
},
}
runner := New(&fexec)
// Success
list, err := runner.ListSets()
if err != nil {
t.Errorf("expected success, got: %v", err)
}
if fcmd.CombinedOutputCalls != 1 {
t.Errorf("expected 1 CombinedOutput() calls, got: %d", fcmd.CombinedOutputCalls)
}
if !sets.NewString(fcmd.CombinedOutputLog[0]...).HasAll("ipset", "list", "-n") {
t.Errorf("wrong CombinedOutput() log, got: %s", fcmd.CombinedOutputLog[0])
}
if len(list) != len(expected) {
t.Errorf("expected %d sets, got: %d", len(expected), len(list))
}
if !reflect.DeepEqual(list, expected) {
t.Errorf("expected sets: %v, got: %v", expected, list)
}
} | explode_data.jsonl/74015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 421
} | [
2830,
3393,
852,
30175,
1155,
353,
8840,
836,
8,
341,
21170,
1669,
1565,
7975,
198,
2257,
198,
42573,
19324,
42400,
1669,
3056,
917,
4913,
7975,
497,
330,
2257,
497,
330,
42573,
63159,
1166,
8710,
1669,
12418,
11748,
991,
726,
15613,
51... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Key64(t *testing.T) {
t.Log("Expecting Key64 to properly return the key in base64.")
var s *Secrets
// ------------- call the function
val := s.Key64()
// -------------- testing
if val != "" {
t.Errorf("Expected Key64() to return an empty string. Got '%s'", val)
}
// -------------- Update context
s = NewSecrets()
if s == nil {
t.Error("Test context failure. secret is nil")
return
}
// ------------- call the function
val = s.Key64()
// -------------- testing
if val != "" {
t.Errorf("Expected Key64() to return an empty string. Got '%s'", val)
}
// -------------- Update context
err := s.GenerateKey()
if err != nil {
t.Errorf("Test context failure. key generate error: %s", err)
return
}
// ------------- call the function
val = s.Key64()
// -------------- testing
if val == "" {
t.Error("Expected Key64() to return an non empty string. Is empty")
} else if val != s.key64 {
t.Error("Expected Key64() to return the internal base64 key. Got a different one")
}
} | explode_data.jsonl/59960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 350
} | [
2830,
3393,
35253,
21,
19,
1155,
353,
8840,
836,
8,
341,
3244,
5247,
445,
17536,
287,
5309,
21,
19,
311,
10277,
470,
279,
1376,
304,
2331,
21,
19,
31225,
2405,
274,
353,
19773,
82,
271,
197,
322,
96803,
1618,
279,
729,
198,
19302,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMockServer_EXPECT(t *testing.T) {
check := assert.New(t)
tests := []struct {
Description string
Run func(mockServer *httpmockserver.MockServer, url string)
}{
{
Description: "simple get on /hello",
Run: func(mockServer *httpmockserver.MockServer, url string) {
mockServer.EXPECT().Get("/hello").Response(200)
res, err := Get(url+"/hello", nil)
check.NoError(err)
check.Equal(200, res.StatusCode)
},
},
{
Description: "simple get on /hello with header",
Run: func(mockServer *httpmockserver.MockServer, url string) {
mockServer.EXPECT().Get("/hello").Header("Test", "123").Response(200)
res, err := Get(url+"/hello", map[string]string{"Test": "123"})
check.NoError(err)
check.Equal(200, res.StatusCode)
},
},
{
Description: "default calls",
Run: func(mockServer *httpmockserver.MockServer, url string) {
mockServer.DEFAULT().AnyRequest().Response(201)
mockServer.EXPECT().Get("/hello").Header("Test", "123").Response(200)
res, err := Get(url+"/hello", map[string]string{"Test": "123"})
check.NoError(err)
check.Equal(200, res.StatusCode)
res, err = Get(url+"/hello", map[string]string{"Test": "123"})
check.NoError(err)
check.Equal(201, res.StatusCode)
res, err = Post(url+"/test", map[string]string{"Test": "123"}, []byte("Hello World"))
check.NoError(err)
check.Equal(201, res.StatusCode)
},
},
{
Description: "min max calls",
Run: func(mockServer *httpmockserver.MockServer, url string) {
mockServer.EXPECT().Get("/min").MinTimes(1).Response(200)
mockServer.EXPECT().Get("/max").MinTimes(2).Response(200)
mockServer.EXPECT().Get("/times").Times(3).Response(200)
Get(url+"/min", nil)
Get(url+"/max", nil)
Get(url+"/max", nil)
Get(url+"/max", nil)
Get(url+"/times", nil)
Get(url+"/times", nil)
Get(url+"/times", nil)
},
},
}
for _, test := range tests {
func() {
server := httpmockserver.New(t)
defer server.Shutdown()
test.Run(server, server.URL())
server.Finish()
}()
}
} | explode_data.jsonl/11965 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 913
} | [
2830,
3393,
11571,
5475,
68208,
1155,
353,
8840,
836,
8,
341,
25157,
1669,
2060,
7121,
1155,
692,
78216,
1669,
3056,
1235,
341,
197,
47414,
914,
198,
197,
85952,
260,
2915,
30389,
5475,
353,
1254,
16712,
4030,
24664,
5475,
11,
2515,
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... | 1 |
func TestServerLink(t *testing.T) {
skipIfWindows(t) // No hard links on windows.
listenerGo, hostGo, portGo := testServer(t, GolangSFTP, READONLY)
defer listenerGo.Close()
tmpFileLocalData := randData(999)
linkdest := "/tmp/" + randName()
defer os.RemoveAll(linkdest)
if err := ioutil.WriteFile(linkdest, tmpFileLocalData, 0644); err != nil {
t.Fatal(err)
}
link := "/tmp/" + randName()
defer os.RemoveAll(link)
// now create a hard link within the new directory
if output, err := runSftpClient(t, fmt.Sprintf("ln %s %s", linkdest, link), "/", hostGo, portGo); err != nil {
t.Fatalf("failed: %v %v", err, string(output))
}
// file should now exist and be the same size as linkdest
if stat, err := os.Lstat(link); err != nil {
t.Fatal(err)
} else if int(stat.Size()) != len(tmpFileLocalData) {
t.Fatalf("wrong size: %v", len(tmpFileLocalData))
}
} | explode_data.jsonl/6579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
5475,
3939,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
2679,
13164,
1155,
8,
442,
2308,
2588,
7746,
389,
11030,
624,
14440,
798,
10850,
11,
3468,
10850,
11,
2635,
10850,
1669,
1273,
5475,
1155,
11,
479,
37287,
50,
56468,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAgent_RegisterService_UnmanagedConnectProxyInvalid(t *testing.T) {
t.Parallel()
assert := assert.New(t)
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
args := &structs.ServiceDefinition{
Kind: structs.ServiceKindConnectProxy,
Name: "connect-proxy",
ProxyDestination: "db",
Check: structs.CheckType{
TTL: 15 * time.Second,
},
}
req, _ := http.NewRequest("PUT", "/v1/agent/service/register?token=abc123", jsonReader(args))
resp := httptest.NewRecorder()
obj, err := a.srv.AgentRegisterService(resp, req)
assert.Nil(err)
assert.Nil(obj)
assert.Equal(http.StatusBadRequest, resp.Code)
assert.Contains(resp.Body.String(), "Port")
// Ensure the service doesn't exist
_, ok := a.State.Services()["connect-proxy"]
assert.False(ok)
} | explode_data.jsonl/33632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
16810,
73124,
1860,
40687,
25270,
14611,
16219,
7928,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
14676,
16867,
264,
10849,
18452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSpanOperationName(t *testing.T) {
assert := assert.New(t)
span := newBasicSpan("web.request")
span.SetOperationName("http.request")
assert.Equal("http.request", span.Name)
} | explode_data.jsonl/42836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
12485,
8432,
675,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
197,
1480,
1669,
501,
15944,
12485,
445,
2911,
8223,
1138,
197,
1480,
4202,
8432,
675,
445,
1254,
8223,
1138,
6948,
12808,
445,
1254,
8223,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSummaryValueAtPercentileSlice_CopyTo(t *testing.T) {
dest := NewSummaryValueAtPercentileSlice()
// Test CopyTo to empty
NewSummaryValueAtPercentileSlice().CopyTo(dest)
assert.EqualValues(t, NewSummaryValueAtPercentileSlice(), dest)
// Test CopyTo larger slice
generateTestSummaryValueAtPercentileSlice().CopyTo(dest)
assert.EqualValues(t, generateTestSummaryValueAtPercentileSlice(), dest)
// Test CopyTo same size slice
generateTestSummaryValueAtPercentileSlice().CopyTo(dest)
assert.EqualValues(t, generateTestSummaryValueAtPercentileSlice(), dest)
} | explode_data.jsonl/19583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
19237,
1130,
1655,
32010,
457,
33236,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
49616,
1669,
1532,
19237,
1130,
1655,
32010,
457,
33236,
741,
197,
322,
3393,
14540,
1249,
311,
4287,
198,
197,
3564,
19237,
1130,
1655,
32010,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFlushable(t *testing.T) {
assertar := assert.New(t)
tries := 60 // number of test iterations
opsPerIter := 0x140 // max number of put/delete ops per iteration
dictSize := opsPerIter // number of different words
disk := dbProducer("TestFlushable")
// open raw databases
leveldb1, _ := disk.OpenDB("1")
defer leveldb1.Drop()
defer leveldb1.Close()
leveldb2, _ := disk.OpenDB("2")
defer leveldb2.Drop()
defer leveldb2.Close()
// create wrappers
dbs := map[string]kvdb.Store{
"leveldb": leveldb1,
"memory": memorydb.New(),
}
flushableDbs := map[string]*Flushable{
"cache-over-leveldb": Wrap(leveldb2),
"cache-over-memory": Wrap(memorydb.New()),
}
baseLdb := table.New(dbs["leveldb"], []byte{})
baseMem := table.New(dbs["memory"], []byte{})
dbsTables := [][]kvdb.Store{
{
dbs["leveldb"],
baseLdb.NewTable([]byte{0, 1}),
baseLdb.NewTable([]byte{0}).NewTable(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffff")),
},
{
dbs["memory"],
baseMem.NewTable([]byte{0, 1}),
baseMem.NewTable([]byte{0}).NewTable(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffff")),
},
}
baseLdb = table.New(flushableDbs["cache-over-leveldb"], []byte{})
baseMem = table.New(flushableDbs["cache-over-memory"], []byte{})
flushableDbsTables := [][]kvdb.Store{
{
flushableDbs["cache-over-leveldb"],
baseLdb.NewTable([]byte{0, 1}),
baseLdb.NewTable([]byte{0}).NewTable(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffff")),
},
{
flushableDbs["cache-over-memory"],
baseMem.NewTable([]byte{0, 1}),
baseMem.NewTable([]byte{0}).NewTable(common.Hex2Bytes("ffffffffffffffffffffffffffffffffffff")),
},
}
assertar.Equal(len(dbsTables), len(flushableDbsTables))
assertar.Equal(len(dbsTables[0]), len(flushableDbsTables[0]))
groupsNum := len(dbsTables)
tablesNum := len(dbsTables[0])
// use the same seed for determinism
rand := rand.New(rand.NewSource(0))
// words dictionary
prefixes := [][]byte{
{},
{0},
{0x1},
{0x22},
{0x33},
{0x11},
{0x11, 0x22},
{0x11, 0x23},
{0x11, 0x22, 0x33},
{0x11, 0x22, 0x34},
}
dict := [][]byte{}
for i := 0; i < dictSize; i++ {
b := append(prefixes[i%len(prefixes)], big.NewInt(rand.Int63()).Bytes()...)
dict = append(dict, b)
}
for try := 0; try < tries; try++ {
// random put/delete operations
putDeleteRandom := func() {
for j := 0; j < tablesNum; j++ {
var batches []kvdb.Batch
for i := 0; i < groupsNum; i++ {
batches = append(batches, dbsTables[i][j].NewBatch())
batches = append(batches, flushableDbsTables[i][j].NewBatch())
}
ops := 1 + rand.Intn(opsPerIter)
for p := 0; p < ops; p++ {
var pair kv
if rand.Intn(2) == 0 { // put
pair = kv{
k: dict[rand.Intn(len(dict))],
v: dict[rand.Intn(len(dict))],
}
} else { // delete
pair = kv{
k: dict[rand.Intn(len(dict))],
v: nil,
}
}
for _, batch := range batches {
if pair.v != nil {
assertar.NoError(batch.Put(pair.k, pair.v))
} else {
assertar.NoError(batch.Delete(pair.k))
}
}
}
for _, batch := range batches {
size := batch.ValueSize()
assertar.NotEqual(0, size)
assertar.NoError(batch.Write())
assertar.Equal(size, batch.ValueSize())
batch.Reset()
assertar.Equal(0, batch.ValueSize())
}
}
}
// put/delete values
putDeleteRandom()
// flush
for _, db := range flushableDbs {
if try == 0 && !assertar.NotEqual(0, db.NotFlushedPairs()) {
return
}
assertar.NoError(db.Flush())
assertar.Equal(0, db.NotFlushedPairs())
}
// put/delete values (not flushed)
putDeleteRandom()
// try to ForEach random prefix
prefix := prefixes[try%len(prefixes)]
if try == 1 {
prefix = []byte{0, 0, 0, 0, 0, 0} // not existing prefix
}
for j := 0; j < tablesNum; j++ {
expectPairs := []kv{}
testForEach := func(db kvdb.Store, first bool) {
var it kvdb.Iterator
if try%4 == 0 {
it = db.NewIterator(nil, nil)
} else if try%4 == 1 {
it = db.NewIterator(prefix, nil)
} else if try%4 == 2 {
it = db.NewIterator(nil, prefix)
} else {
it = db.NewIterator(prefix[:len(prefix)/2], prefix[len(prefix)/2:])
}
defer it.Release()
var got int
for got = 0; it.Next(); got++ {
if first {
expectPairs = append(expectPairs, kv{
k: common.CopyBytes(it.Key()),
v: common.CopyBytes(it.Value()),
})
} else {
assertar.NotEqual(len(expectPairs), got, try) // check that we've for the same num of values
if t.Failed() {
return
}
assertar.Equal(expectPairs[got].k, it.Key(), try)
assertar.Equal(expectPairs[got].v, it.Value(), try)
}
}
if !assertar.NoError(it.Error()) {
return
}
assertar.Equal(len(expectPairs), got) // check that we've got the same num of pairs
}
// check that all groups return the same result
for i := 0; i < groupsNum; i++ {
testForEach(dbsTables[i][j], i == 0)
if t.Failed() {
return
}
testForEach(flushableDbsTables[i][j], false)
if t.Failed() {
return
}
}
}
// try to get random values
ops := rand.Intn(opsPerIter)
for p := 0; p < ops; p++ {
key := dict[rand.Intn(len(dict))]
for j := 0; j < tablesNum; j++ {
// get values for first group, so we could check that all groups return the same result
ok, _ := dbsTables[0][j].Has(key)
vl, _ := dbsTables[0][j].Get(key)
// check that all groups return the same result
for i := 0; i < groupsNum; i++ {
ok1, err := dbsTables[i][j].Has(key)
assertar.NoError(err)
vl1, err := dbsTables[i][j].Get(key)
assertar.NoError(err)
ok2, err := flushableDbsTables[i][j].Has(key)
assertar.NoError(err)
vl2, err := flushableDbsTables[i][j].Get(key)
assertar.NoError(err)
assertar.Equal(ok1, ok2)
assertar.Equal(vl1, vl2)
assertar.Equal(ok1, ok)
assertar.Equal(vl1, vl)
}
}
}
if t.Failed() {
return
}
}
} | explode_data.jsonl/18346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2887
} | [
2830,
3393,
46874,
480,
1155,
353,
8840,
836,
8,
341,
6948,
277,
1669,
2060,
7121,
1155,
692,
197,
4543,
1669,
220,
21,
15,
310,
442,
1372,
315,
1273,
25687,
198,
197,
3721,
3889,
8537,
1669,
220,
15,
87,
16,
19,
15,
262,
442,
193... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestCanIGetLogsAllowSwitchOff(t *testing.T) {
ctx := accountFixture.Given(t)
ctx.
Name("test").
When().
Create().
Login().
SetParamInSettingConfigMap("server.rbac.log.enforce.enable", "false").
CanIGetLogs().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "yes"))
})
} | explode_data.jsonl/20987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
6713,
1914,
295,
51053,
18605,
16837,
4596,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2692,
18930,
1224,
2071,
1155,
340,
20985,
624,
197,
21297,
445,
1944,
38609,
197,
197,
4498,
25829,
197,
75569,
25829,
197,
197,
6231,
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 TestWeekly(t *testing.T) {
days := [...]interface{}{
"sunday", time.Sunday,
"monday", time.Monday,
"tuesday", time.Tuesday,
"wednesday", time.Wednesday,
"thursday", time.Thursday,
"friday", time.Friday,
"saturday", time.Saturday}
for i := 0; i < len(days); i += 2 {
re := parseRe("[] bla (every " + days[i].(string) + ")")
assert.NotNil(t, re)
assert.Equal(t, moment.RecurWeekly, re.Recurrence)
assert.Equal(t, days[i+1].(time.Weekday), re.RefDate.Time.Weekday())
}
} | explode_data.jsonl/67513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
80516,
1155,
353,
8840,
836,
8,
341,
2698,
942,
1669,
48179,
4970,
67066,
197,
197,
40787,
6676,
497,
882,
808,
6676,
345,
197,
197,
1,
1645,
1292,
497,
882,
52211,
1292,
345,
197,
197,
1,
83,
7047,
497,
882,
836,
7047,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecoders(t *testing.T) {
assert := assert.New(t)
testCases := []struct {
payload io.Reader
decoder ClientDecoder
}{
{payload: getJSONPayload(), decoder: newJSONDecoder()},
{payload: getMsgpackPayload(), decoder: newMsgpackDecoder()},
}
for _, tc := range testCases {
var traces Traces
l, err := tc.decoder.Decode(tc.payload, &traces)
assert.Nil(err)
assert.NotEqual(0, l)
assert.Len(traces, 1)
trace := traces[0]
assert.Len(trace, 1)
span := trace[0]
assert.Equal(uint64(math.MaxUint64), span.TraceID)
assert.Equal(uint64(math.MaxUint64), span.SpanID)
assert.Equal(int64(math.MaxInt64), span.Duration)
assert.Equal("fennel_IS amazing!", span.Service)
assert.Equal("something &&<@# that should be a metric!", span.Name)
assert.Equal("NOT touched because it is going to be hashed", span.Resource)
assert.Equal("192.168.0.1", span.Meta["http.host"])
assert.Equal(math.MaxFloat64, span.Metrics["http.monitor"])
}
} | explode_data.jsonl/35760 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
4900,
52498,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
18185,
37302,
1669,
3056,
1235,
341,
197,
76272,
6399,
47431,
198,
197,
197,
48110,
8423,
20732,
198,
197,
59403,
197,
197,
90,
19427,
25,
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... | 2 |
func TestArtTreeInsert2AndSearch(t *testing.T) {
tree := NewArtTree()
tree.Insert([]byte("hello"), "world")
tree.Insert([]byte("yo"), "earth")
res := tree.Search([]byte("yo"))
if res == nil {
t.Error("Could not find Leaf Node with expected key: 'yo'")
} else {
if res != "earth" {
t.Error("Unexpected search result.")
}
}
res2 := tree.Search([]byte("hello"))
if res2 == nil {
t.Error("Could not find Leaf Node with expected key: 'hello'")
} else {
if res2 != "world" {
t.Error("Unexpected search result.")
}
}
} | explode_data.jsonl/43948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
9286,
6533,
13780,
17,
3036,
5890,
1155,
353,
8840,
836,
8,
341,
51968,
1669,
1532,
9286,
6533,
2822,
51968,
23142,
10556,
3782,
445,
14990,
3975,
330,
14615,
1138,
51968,
23142,
10556,
3782,
445,
16032,
3975,
330,
27541,
5130... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWrapFactoryCustomEntry(t *testing.T) {
o := DecryptionClientOptions{
CryptoRegistry: initCryptoRegistryFrom(map[string]WrapEntry{
"custom": (kmsKeyHandler{
kms: kms.New(unit.Session),
}).decryptHandler,
}, map[string]CEKEntry{
AESGCMNoPadding: newAESGCMContentCipher,
}, map[string]Padder{}),
}
env := Envelope{
WrapAlg: "custom",
MatDesc: `{"kms_cmk_id":""}`,
}
wrap, err := wrapFromEnvelope(o, env)
if err != nil {
t.Errorf("expected no error, but received %v", err)
}
if wrap == nil {
t.Errorf("expected nil wrap value, received %v", wrap)
}
} | explode_data.jsonl/63023 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
26787,
4153,
10268,
5874,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
3714,
15597,
2959,
3798,
515,
197,
6258,
9444,
15603,
25,
2930,
58288,
15603,
3830,
9147,
14032,
60,
26787,
5874,
515,
298,
197,
1,
9163,
788,
320,
74,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBrokerImmutableFields(t *testing.T) {
original := &eventingv1.Broker{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"eventing.knative.dev/broker.class": "original"},
},
Spec: eventingv1.BrokerSpec{
Config: &duckv1.KReference{
Namespace: "namespace",
Name: "name",
Kind: "Secret",
APIVersion: "v1",
},
},
}
current := &RabbitBroker{eventingv1.Broker{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"eventing.knative.dev/broker.class": "RabbitMQBroker"},
},
Spec: eventingv1.BrokerSpec{
Config: &duckv1.KReference{
Namespace: "namespace",
Name: "name",
Kind: "Secret",
APIVersion: "v1",
},
},
}}
currentRealBroker := &eventingv1.Broker{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"eventing.knative.dev/broker.class": "RabbitMQBroker"},
},
Spec: eventingv1.BrokerSpec{
Config: &duckv1.KReference{
Namespace: "namespace",
Name: "name",
Kind: "Secret",
APIVersion: "v1",
},
},
}
originalValid := &eventingv1.Broker{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{"eventing.knative.dev/broker.class": "RabbitMQBroker"},
},
Spec: eventingv1.BrokerSpec{
Config: &duckv1.KReference{
Namespace: "namespace",
Name: "name",
Kind: "RabbitmqCluster",
APIVersion: "rabbitmq.com/v1beta1",
},
},
}
tests := map[string]struct {
og *eventingv1.Broker
wantErr *apis.FieldError
}{
"nil original": {
wantErr: nil,
},
"no BrokerClassAnnotation mutation": {
og: currentRealBroker,
wantErr: nil,
},
"BrokerClassAnnotation mutated": {
og: original,
wantErr: &apis.FieldError{
Message: "Immutable fields changed (-old +new)",
Paths: []string{"annotations"},
Details: `{string}:
-: "original"
+: "RabbitMQBroker"
`,
},
},
"Config mutated": {
og: originalValid,
wantErr: &apis.FieldError{
Message: "Immutable fields changed (-old +new)",
Paths: []string{"spec"},
Details: `{v1.BrokerSpec}.Config.Kind:
-: "RabbitmqCluster"
+: "Secret"
{v1.BrokerSpec}.Config.APIVersion:
-: "rabbitmq.com/v1beta1"
+: "v1"
`,
},
},
}
for n, test := range tests {
t.Run(n, func(t *testing.T) {
ctx := context.Background()
ctx = apis.WithinUpdate(ctx, test.og)
got := current.Validate(ctx)
if diff := cmp.Diff(test.wantErr.Error(), got.Error()); diff != "" {
t.Error("Broker.CheckImmutableFields (-want, +got) =", diff)
}
})
}
} | explode_data.jsonl/34998 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1193
} | [
2830,
3393,
65545,
58890,
8941,
1155,
353,
8840,
836,
8,
341,
197,
9889,
1669,
609,
3087,
287,
85,
16,
1785,
45985,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
197,
21418,
25,
2415,
14032,
30953,
4913,
3087,
287,
5202,
297... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGetExtensionSuccessfully(t)
actual, err := extensions.Get(client.ServiceClient(), "agent").Extract()
th.AssertNoErr(t, err)
th.CheckDeepEquals(t, SingleExtension, actual)
} | explode_data.jsonl/7066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
741,
197,
6999,
1949,
12049,
35959,
1155,
692,
88814,
11,
1848,
1669,
19721,
2234,
12805,
13860,
2959,
1507,
330,
8092,
1827,
28959,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterpretTypeSymlink(t *testing.T) {
_, dstFileInfo := testInterpret(t,
os.TempDir(),
"test_file",
tar.TypeSymlink,
createFile,
os.Remove,
)
assert.True(t, dstFileInfo.Mode()&os.ModeSymlink != 0)
} | explode_data.jsonl/5619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
3306,
8043,
929,
34667,
44243,
1155,
353,
8840,
836,
8,
341,
197,
6878,
10648,
45430,
1669,
1273,
3306,
8043,
1155,
345,
197,
25078,
65009,
6184,
79322,
197,
197,
1,
1944,
2458,
756,
197,
3244,
277,
10184,
34667,
44243,
3554... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoundSkipOnNilPolkaFromHigherRound(t *testing.T) {
config := configSetup(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cs1, vss := makeState(ctx, t, makeStateArgs{config: config})
vs2, vs3, vs4 := vss[1], vss[2], vss[3]
height, round := cs1.Height, cs1.Round
timeoutWaitCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryTimeoutWait)
newRoundCh := subscribe(ctx, t, cs1.eventBus, types.EventQueryNewRound)
pv1, err := cs1.privValidator.GetPubKey(ctx)
require.NoError(t, err)
addr := pv1.Address()
voteCh := subscribeToVoter(ctx, t, cs1, addr)
// start round
startTestRound(ctx, cs1, height, round)
ensureNewRound(t, newRoundCh, height, round)
ensurePrevote(t, voteCh, height, round)
incrementRound(vss[1:]...)
signAddVotes(ctx, t, cs1, tmproto.PrecommitType, config.ChainID(), types.BlockID{}, vs2, vs3, vs4)
round++ // moving to the next round
ensureNewRound(t, newRoundCh, height, round)
ensurePrecommit(t, voteCh, height, round)
validatePrecommit(ctx, t, cs1, round, -1, vss[0], nil, nil)
ensureNewTimeout(t, timeoutWaitCh, height, round, cs1.voteTimeout(round).Nanoseconds())
round++ // moving to the next round
ensureNewRound(t, newRoundCh, height, round)
} | explode_data.jsonl/54286 | {
"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,
27497,
35134,
1925,
19064,
14658,
4554,
3830,
87445,
27497,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2193,
21821,
1155,
340,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
71899,
16,
11,
348,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNumberFormatRounding(t *testing.T) {
const SCRIPT = `
assert.sameValue((123.456).toExponential(undefined), "1.23456e+2", "undefined");
assert.sameValue((0.000001).toPrecision(2), "0.0000010")
assert.sameValue((-7).toPrecision(1), "-7");
assert.sameValue((-42).toPrecision(1), "-4e+1");
assert.sameValue((0.000001).toPrecision(1), "0.000001");
assert.sameValue((123.456).toPrecision(1), "1e+2", "1");
assert.sameValue((123.456).toPrecision(2), "1.2e+2", "2");
var n = new Number("0.000000000000000000001"); // 1e-21
assert.sameValue((n).toPrecision(1), "1e-21");
assert.sameValue((25).toExponential(0), "3e+1");
assert.sameValue((-25).toExponential(0), "-3e+1");
assert.sameValue((12345).toExponential(3), "1.235e+4");
assert.sameValue((25.5).toFixed(0), "26");
assert.sameValue((-25.5).toFixed(0), "-26");
assert.sameValue((99.9).toFixed(0), "100");
assert.sameValue((99.99).toFixed(1), "100.0");
`
testScript1(TESTLIB+SCRIPT, _undefined, t)
} | explode_data.jsonl/10457 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 405
} | [
2830,
3393,
2833,
4061,
49,
13586,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
6948,
97503,
1130,
1188,
16,
17,
18,
13,
19,
20,
21,
568,
983,
840,
59825,
43759,
701,
330,
16,
13,
17,
18,
19,
20,
21,
68,
10,
17,
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... | 1 |
func TestExtractionRules(t *testing.T) {
c, _ := newTestClientWithRulesAndFilters(t, ExtractionRules{}, Filters{})
pod := &api_v1.Pod{
ObjectMeta: meta_v1.ObjectMeta{
Name: "auth-service-abc12-xyz3",
UID: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
Namespace: "ns1",
CreationTimestamp: meta_v1.Now(),
Labels: map[string]string{
"label1": "lv1",
"label2": "k1=v1 k5=v5 extra!",
},
Annotations: map[string]string{
"annotation1": "av1",
},
},
Spec: api_v1.PodSpec{
NodeName: "node1",
},
Status: api_v1.PodStatus{
PodIP: "1.1.1.1",
},
}
testCases := []struct {
name string
rules ExtractionRules
attributes map[string]string
}{{
name: "no-rules",
rules: ExtractionRules{},
attributes: nil,
}, {
name: "deployment",
rules: ExtractionRules{
Deployment: true,
},
attributes: map[string]string{
"k8s.deployment.name": "auth-service",
},
}, {
name: "metadata",
rules: ExtractionRules{
Deployment: true,
Namespace: true,
PodName: true,
PodUID: true,
Node: true,
Cluster: true,
StartTime: true,
},
attributes: map[string]string{
"k8s.deployment.name": "auth-service",
"k8s.namespace.name": "ns1",
"k8s.node.name": "node1",
"k8s.pod.name": "auth-service-abc12-xyz3",
"k8s.pod.uid": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"k8s.pod.start_time": pod.GetCreationTimestamp().String(),
},
}, {
name: "labels",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "a1",
Key: "annotation1",
From: MetadataFromPod,
},
},
Labels: []FieldExtractionRule{{
Name: "l1",
Key: "label1",
From: MetadataFromPod,
}, {
Name: "l2",
Key: "label2",
Regex: regexp.MustCompile(`k5=(?P<value>[^\s]+)`),
From: MetadataFromPod,
},
},
},
attributes: map[string]string{
"l1": "lv1",
"l2": "v5",
"a1": "av1",
},
}, {
// By default if the From field is not set for labels and annotations we want to extract them from pod
name: "labels-annotations-default-pod",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "a1",
Key: "annotation1",
},
},
Labels: []FieldExtractionRule{{
Name: "l1",
Key: "label1",
}, {
Name: "l2",
Key: "label2",
Regex: regexp.MustCompile(`k5=(?P<value>[^\s]+)`),
},
},
},
attributes: map[string]string{
"l1": "lv1",
"l2": "v5",
"a1": "av1",
},
},
{
name: "all-labels",
rules: ExtractionRules{
Labels: []FieldExtractionRule{{
KeyRegex: regexp.MustCompile("la*"),
From: MetadataFromPod,
},
},
},
attributes: map[string]string{
"k8s.pod.labels.label1": "lv1",
"k8s.pod.labels.label2": "k1=v1 k5=v5 extra!",
},
},
{
name: "all-annotations",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
KeyRegex: regexp.MustCompile("an*"),
From: MetadataFromPod,
},
},
},
attributes: map[string]string{
"k8s.pod.annotations.annotation1": "av1",
},
},
{
name: "captured-groups",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "$1",
KeyRegex: regexp.MustCompile(`annotation(\d+)`),
HasKeyRegexReference: true,
From: MetadataFromPod,
},
},
},
attributes: map[string]string{
"1": "av1",
},
},
{
name: "captured-groups-$0",
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "$0",
KeyRegex: regexp.MustCompile(`annotation(\d+)`),
HasKeyRegexReference: true,
From: MetadataFromPod,
},
},
},
attributes: map[string]string{
"annotation1": "av1",
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c.Rules = tc.rules
c.handlePodAdd(pod)
p, ok := c.GetPod(PodIdentifier(pod.Status.PodIP))
require.True(t, ok)
assert.Equal(t, len(tc.attributes), len(p.Attributes))
for k, v := range tc.attributes {
got, ok := p.Attributes[k]
assert.True(t, ok)
assert.Equal(t, v, got)
}
})
}
} | explode_data.jsonl/56853 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2193
} | [
2830,
3393,
840,
26425,
26008,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
501,
2271,
2959,
2354,
26008,
3036,
28351,
1155,
11,
94506,
26008,
22655,
45012,
6257,
692,
3223,
347,
1669,
609,
2068,
2273,
16,
88823,
515,
197,
23816,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStringReplace_Replace_OldVariable(t *testing.T) {
variables := NewVariables()
variables["VAR"] = "foo"
stringReplace := StringReplace{Old: "$VAR", New: "bar"}
assert.Equal(t, "should be bar", stringReplace.Replace("should be foo", variables))
} | explode_data.jsonl/66407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
703,
23107,
62,
23107,
2232,
507,
7827,
1155,
353,
8840,
836,
8,
341,
262,
7332,
1669,
1532,
22678,
741,
262,
7332,
1183,
33040,
1341,
284,
330,
7975,
698,
262,
914,
23107,
1669,
923,
23107,
90,
18284,
25,
5201,
33040,
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... | 1 |
func TestEmptyFolderImport(t *testing.T) {
_, err := Import(".", "testdata/empty", 0)
if _, ok := err.(*NoGoError); !ok {
t.Fatal(`Import("testdata/empty") did not return NoGoError.`)
}
} | explode_data.jsonl/514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
3522,
13682,
11511,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
13213,
64217,
330,
92425,
14,
3194,
497,
220,
15,
340,
743,
8358,
5394,
1669,
1848,
41399,
2753,
10850,
1454,
1215,
753,
562,
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
] | 2 |
func TestReconcileWithDifferentServiceAccounts(t *testing.T) {
names.TestingSeed()
ps := []*v1alpha1.Pipeline{tb.Pipeline("test-pipeline", "foo", tb.PipelineSpec(
tb.PipelineTask("hello-world-0", "hello-world-task"),
tb.PipelineTask("hello-world-1", "hello-world-task"),
))}
prs := []*v1alpha1.PipelineRun{tb.PipelineRun("test-pipeline-run-different-service-accs", "foo",
tb.PipelineRunSpec("test-pipeline",
tb.PipelineRunServiceAccount("test-sa-0"),
tb.PipelineRunServiceAccountTask("hello-world-1", "test-sa-1"),
),
)}
ts := []*v1alpha1.Task{
tb.Task("hello-world-task", "foo"),
}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
}
testAssets, cancel := getPipelineRunController(t, d)
defer cancel()
c := testAssets.Controller
clients := testAssets.Clients
err := c.Reconciler.Reconcile(context.Background(), "foo/test-pipeline-run-different-service-accs")
if err != nil {
t.Errorf("Did not expect to see error when reconciling completed PipelineRun but saw %s", err)
}
// Check that the PipelineRun was reconciled correctly
_, err = clients.Pipeline.Tekton().PipelineRuns("foo").Get("test-pipeline-run-different-service-accs", metav1.GetOptions{})
if err != nil {
t.Fatalf("Somehow had error getting completed reconciled run out of fake client: %s", err)
}
taskRunNames := []string{"test-pipeline-run-different-service-accs-hello-world-0-9l9zj", "test-pipeline-run-different-service-accs-hello-world-1-mz4c7"}
expectedTaskRuns := []*v1alpha1.TaskRun{
tb.TaskRun(taskRunNames[0], "foo",
tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs",
tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"),
tb.Controller, tb.BlockOwnerDeletion,
),
tb.TaskRunSpec(
tb.TaskRunTaskRef("hello-world-task"),
tb.TaskRunServiceAccount("test-sa-0"),
),
tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"),
tb.TaskRunLabel("tekton.dev/pipelineRun", "test-pipeline-run-different-service-accs"),
tb.TaskRunLabel("tekton.dev/pipelineTask", "hello-world-0"),
),
tb.TaskRun(taskRunNames[1], "foo",
tb.TaskRunOwnerReference("PipelineRun", "test-pipeline-run-different-service-accs",
tb.OwnerReferenceAPIVersion("tekton.dev/v1alpha1"),
tb.Controller, tb.BlockOwnerDeletion,
),
tb.TaskRunSpec(
tb.TaskRunTaskRef("hello-world-task"),
tb.TaskRunServiceAccount("test-sa-1"),
),
tb.TaskRunLabel("tekton.dev/pipeline", "test-pipeline"),
tb.TaskRunLabel("tekton.dev/pipelineRun", "test-pipeline-run-different-service-accs"),
tb.TaskRunLabel("tekton.dev/pipelineTask", "hello-world-1"),
),
}
for i := range ps[0].Spec.Tasks {
// Check that the expected TaskRun was created
actual, err := clients.Pipeline.Tekton().TaskRuns("foo").Get(taskRunNames[i], metav1.GetOptions{})
if err != nil {
t.Fatalf("Expected a TaskRun to be created, but it wasn't: %s", err)
}
if d := cmp.Diff(actual, expectedTaskRuns[i]); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRuns[i], d)
}
}
} | explode_data.jsonl/81294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1288
} | [
2830,
3393,
693,
40446,
457,
2354,
69123,
1860,
41369,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
35009,
1669,
29838,
85,
16,
7141,
16,
1069,
8790,
90,
18387,
1069,
8790,
445,
1944,
2268,
8790,
497,
330,
7975,
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,
1... | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.