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 TestUploadOrderMultiBufferedReaderExceedTotalParts(t *testing.T) {
s, ops, _ := loggingSvc([]string{"UploadPart"})
mgr := s3manager.NewUploaderWithClient(s, func(u *s3manager.Uploader) {
u.Concurrency = 1
u.MaxUploadParts = 2
})
resp, err := mgr.Upload(&s3manager.UploadInput{
Bucket: aws.String("Bucket"),
Key: aws.String("Key"),
Body: &sizedReader{size: 1024 * 1024 * 12},
})
if err == nil {
t.Error("Expected an error, but received nil")
}
if resp != nil {
t.Errorf("Expected nil, but receievd %v", resp)
}
if e, a := []string{"CreateMultipartUpload", "AbortMultipartUpload"}, *ops; !reflect.DeepEqual(e, a) {
t.Errorf("Expected %v, but receievd %v", e, a)
}
aerr := err.(awserr.Error)
if e, a := "MultipartUpload", aerr.Code(); e != a {
t.Errorf("Expected %q, but received %q", e, a)
}
if e, a := "TotalPartsExceeded", aerr.OrigErr().(awserr.Error).Code(); e != a {
t.Errorf("Expected %q, but received %q", e, a)
}
if !strings.Contains(aerr.Error(), "configured MaxUploadParts (2)") {
t.Errorf("Expected error to contain 'configured MaxUploadParts (2)', but receievd %q", aerr.Error())
}
} | explode_data.jsonl/55647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
13844,
4431,
20358,
4095,
17120,
840,
4635,
7595,
28921,
1155,
353,
8840,
836,
8,
341,
1903,
11,
27132,
11,
716,
1669,
8392,
92766,
10556,
917,
4913,
13844,
5800,
23625,
2109,
901,
1669,
274,
18,
13297,
7121,
67574,
2354,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOCIConveyorOCILayout(t *testing.T) {
test.DropPrivilege(t)
defer test.ResetPrivilege(t)
archive, err := getTestTar(ociArchiveURI)
if err != nil {
t.Fatalf("Could not download oci archive test file: %v", err)
}
defer os.Remove(archive)
// We need to extract the oci archive to a directory
// Don't want to implement untar routines here, so use system tar
dir, err := ioutil.TempDir("", "oci-test")
if err != nil {
t.Fatalf("Could not create temporary directory: %v", err)
}
defer os.RemoveAll(dir)
cmd := exec.Command("tar", "-C", dir, "-xf", archive)
err = cmd.Run()
if err != nil {
t.Fatalf("Error extracting oci archive to layout: %v", err)
}
b, err := types.NewBundle("", "sbuild-oci")
if err != nil {
return
}
layoutURI := "oci:" + dir
b.Recipe, err = types.NewDefinitionFromURI(layoutURI)
if err != nil {
t.Fatalf("unable to parse URI %s: %v\n", layoutURI, err)
}
// set a clean image cache
imgCache, cleanup := setupCache(t)
defer cleanup()
b.Opts.ImgCache = imgCache
cp := &sources.OCIConveyorPacker{}
err = cp.Get(b)
// clean up tmpfs since assembler isnt called
defer cp.CleanUp()
if err != nil {
t.Fatalf("failed to Get from %s: %v\n", layoutURI, err)
}
} | explode_data.jsonl/48101 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 470
} | [
2830,
3393,
63983,
1109,
68869,
7612,
1715,
1407,
1155,
353,
8840,
836,
8,
341,
18185,
21688,
32124,
42769,
1155,
340,
16867,
1273,
36660,
32124,
42769,
1155,
692,
197,
16019,
11,
1848,
1669,
633,
2271,
62733,
7,
2119,
42502,
10301,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestGetOrderInfo(t *testing.T) {
_, err := b.GetOrderInfo("1337")
if err == nil {
t.Error("Test failed - GetOrderInfo() error", err)
}
} | explode_data.jsonl/49000 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
1949,
4431,
1731,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
293,
2234,
4431,
1731,
445,
16,
18,
18,
22,
1138,
743,
1848,
621,
2092,
341,
197,
3244,
6141,
445,
2271,
4641,
481,
2126,
4431,
1731,
368,
1465,
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
] | 2 |
func TestBadPC(t *testing.T) {
t.Parallel()
type pcTest struct {
script, off int
}
pcTests := []pcTest{
{
script: 2,
off: 0,
},
{
script: 0,
off: 2,
},
}
// tx with almost empty scripts.
tx := &wire.MsgTx{
Version: 1,
TxIn: []*wire.TxIn{
{
PreviousOutPoint: wire.OutPoint{
Hash: wire.ShaHash([32]byte{
0xc9, 0x97, 0xa5, 0xe5,
0x6e, 0x10, 0x41, 0x02,
0xfa, 0x20, 0x9c, 0x6a,
0x85, 0x2d, 0xd9, 0x06,
0x60, 0xa2, 0x0b, 0x2d,
0x9c, 0x35, 0x24, 0x23,
0xed, 0xce, 0x25, 0x85,
0x7f, 0xcd, 0x37, 0x04,
}),
Index: 0,
},
SignatureScript: []uint8{txscript.OP_NOP},
Sequence: 4294967295,
},
},
TxOut: []*wire.TxOut{
{
Value: 1000000000,
PkScript: nil,
},
},
LockTime: 0,
}
pkScript := []byte{txscript.OP_NOP}
for _, test := range pcTests {
vm, err := txscript.NewEngine(pkScript, tx, 0, 0, nil)
if err != nil {
t.Errorf("Failed to create script: %v", err)
}
// set to after all scripts
vm.TstSetPC(test.script, test.off)
_, err = vm.Step()
if err == nil {
t.Errorf("Step with invalid pc (%v) succeeds!", test)
continue
}
_, err = vm.DisasmPC()
if err == nil {
t.Errorf("DisasmPC with invalid pc (%v) succeeds!",
test)
}
}
} | explode_data.jsonl/24198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
17082,
4872,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
13158,
13312,
2271,
2036,
341,
197,
86956,
11,
1007,
526,
198,
197,
532,
82013,
18200,
1669,
3056,
3992,
2271,
515,
197,
197,
515,
298,
86956,
25,
220,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRangeCacheEntryUpdateLease(t *testing.T) {
defer leaktest.AfterTest(t)()
rep1 := roachpb.ReplicaDescriptor{
NodeID: 1,
StoreID: 1,
ReplicaID: 1,
}
rep2 := roachpb.ReplicaDescriptor{
NodeID: 2,
StoreID: 2,
ReplicaID: 2,
}
repNonMember := roachpb.ReplicaDescriptor{
NodeID: 3,
StoreID: 3,
ReplicaID: 3,
}
desc := roachpb.RangeDescriptor{
StartKey: roachpb.RKeyMin,
EndKey: roachpb.RKeyMax,
InternalReplicas: []roachpb.ReplicaDescriptor{
rep1, rep2,
},
Generation: 0,
}
e := &rangeCacheEntry{
desc: desc,
lease: roachpb.Lease{},
}
// Check that some lease overwrites an empty lease.
l := &roachpb.Lease{
Replica: rep1,
Sequence: 1,
}
ok, e := e.updateLease(l)
require.True(t, ok)
require.True(t, l.Equal(e.Lease()))
// Check that a lease with no sequence number overwrites any other lease.
l = &roachpb.Lease{
Replica: rep1,
Sequence: 0,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.NotNil(t, e.Leaseholder())
require.True(t, l.Replica.Equal(*e.Leaseholder()))
// Check that Seq=0 leases are not returned by Lease().
require.Nil(t, e.Lease())
// Check that another lease with no seq num overwrites a lease with no seq num.
l = &roachpb.Lease{
Replica: rep2,
Sequence: 0,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.NotNil(t, e.Leaseholder())
require.True(t, l.Replica.Equal(*e.Leaseholder()))
// Check that another lease with no seq num overwrites a lease with no seq num.
l = &roachpb.Lease{
Replica: rep1,
Sequence: 0,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.NotNil(t, e.Leaseholder())
require.True(t, l.Replica.Equal(*e.Leaseholder()))
// Set a lease
l = &roachpb.Lease{
Replica: rep1,
Sequence: 2,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.NotNil(t, e.Leaseholder())
require.True(t, l.Equal(*e.Lease()))
// Check that updating to an older lease doesn't work.
l = &roachpb.Lease{
Replica: rep2,
Sequence: 1,
}
ok, e = e.updateLease(l)
require.False(t, ok)
require.False(t, l.Equal(*e.Lease()))
// Check that updating to a lease at the same sequence as the existing one works.
l = &roachpb.Lease{
Replica: rep2,
Sequence: 2,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.True(t, l.Equal(e.Lease()))
// Check that updating to the same lease returns false.
l = &roachpb.Lease{
Replica: rep2,
Sequence: 2,
}
require.True(t, l.Equal(e.Lease()))
ok, e = e.updateLease(l)
require.False(t, ok)
require.True(t, l.Equal(e.Lease()))
// Check that updating the lease to a non-member replica returns a nil
// entry.
l = &roachpb.Lease{
Replica: repNonMember,
Sequence: 0,
}
ok, e = e.updateLease(l)
require.True(t, ok)
require.Nil(t, e)
} | explode_data.jsonl/28197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1232
} | [
2830,
3393,
6046,
8233,
5874,
4289,
2304,
519,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
73731,
16,
1669,
926,
610,
16650,
2817,
79,
15317,
11709,
515,
197,
30217,
915,
25,
262,
220,
16,
345,
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 TestPermanentError(t *testing.T) {
err := new(fakeError)
permErr := NewPermanentError(err)
if !IsPermanentError(permErr) {
t.Errorf("Expected type %T to be a permanentError", permErr)
}
if IsPermanentError(err) {
t.Errorf("Expected type %T to not be a permanentError", err)
}
wrapPermErr := fmt.Errorf("wrapped: %w", permErr)
if !IsPermanentError(wrapPermErr) {
t.Error("Expected wrapped permanentError to be equivalent to a permanentError")
}
unwrapErr := new(fakeError)
if !errors.As(permErr, &unwrapErr) {
t.Errorf("Could not unwrap %T from permanentError", unwrapErr)
}
} | explode_data.jsonl/45289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
78793,
1454,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
501,
74138,
1454,
340,
197,
19913,
7747,
1669,
1532,
78793,
1454,
3964,
340,
743,
753,
3872,
78793,
1454,
7,
19913,
7747,
8,
341,
197,
3244,
13080,
445,
18896,
943,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSessions(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
user := th.BasicUser
th.Client.Login(user.Email, user.Password)
sessions, _, err := th.Client.GetSessions(user.Id, "")
require.NoError(t, err)
for _, session := range sessions {
require.Equal(t, user.Id, session.UserId, "user id should match session user id")
}
resp, err := th.Client.RevokeSession("junk", model.NewId())
require.Error(t, err)
CheckBadRequestStatus(t, resp)
_, resp, err = th.Client.GetSessions(th.BasicUser2.Id, "")
require.Error(t, err)
CheckForbiddenStatus(t, resp)
_, resp, err = th.Client.GetSessions(model.NewId(), "")
require.Error(t, err)
CheckForbiddenStatus(t, resp)
th.Client.Logout()
_, resp, err = th.Client.GetSessions(th.BasicUser2.Id, "")
require.Error(t, err)
CheckUnauthorizedStatus(t, resp)
_, _, err = th.SystemAdminClient.GetSessions(user.Id, "")
require.NoError(t, err)
_, _, err = th.SystemAdminClient.GetSessions(th.BasicUser2.Id, "")
require.NoError(t, err)
_, _, err = th.SystemAdminClient.GetSessions(model.NewId(), "")
require.NoError(t, err)
} | explode_data.jsonl/47530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 437
} | [
2830,
3393,
1949,
59062,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
19060,
1669,
270,
48868,
1474,
271,
70479,
11716,
32499,
4277,
24066,
11,
1196,
25690,
692,
1903,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRulePrefixLike(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := []string{
"select col from tbl where id like '%abc'",
"select col from tbl where id like '_abc'",
}
for _, sql := range sqls {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RulePrefixLike()
if rule.Item != "ARG.001" {
t.Error("Rule not match:", rule.Item, "Expect : ARG.001")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
11337,
14335,
12949,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
3056,
917,
515,
197,
197,
1,
1742,
1375,
504,
21173,
1380,
877,
1075,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMissingValidEntityToConfigure(t *testing.T) {
toggleNonInteractive()
defer toggleNonInteractive()
data := aws.GenerateAwsTfConfigurationArgs{}
err := promptAwsGenerate(&data, &aws.ExistingIamRoleDetails{}, &AwsGenerateCommandExtraState{Output: "/tmp"})
assert.Error(t, err)
assert.Equal(t, "must enable cloudtrail or config", err.Error())
} | explode_data.jsonl/19408 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
25080,
4088,
3030,
1249,
28560,
1155,
353,
8840,
836,
8,
341,
3244,
5216,
8121,
71686,
741,
16867,
14999,
8121,
71686,
2822,
8924,
1669,
31521,
57582,
47359,
51,
69,
7688,
4117,
16094,
9859,
1669,
9934,
47359,
31115,
2099,
691... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReffedConn(t *testing.T) {
tracking := &closeReffedConn{}
wrapper := dialer.NewRefCountedConnWrapper(tracking, nil)
conn1 := wrapper.Ref()
conn2 := wrapper.Ref()
test.That(t, conn1.Close(), test.ShouldBeNil)
test.That(t, tracking.closeCalled, test.ShouldEqual, 0)
test.That(t, conn2.Close(), test.ShouldBeNil)
test.That(t, tracking.closeCalled, test.ShouldEqual, 1)
test.That(t, conn1.Close(), test.ShouldBeNil)
test.That(t, tracking.closeCalled, test.ShouldEqual, 1)
test.That(t, conn2.Close(), test.ShouldBeNil)
test.That(t, tracking.closeCalled, test.ShouldEqual, 1)
} | explode_data.jsonl/35829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 233
} | [
2830,
3393,
693,
542,
291,
9701,
1155,
353,
8840,
836,
8,
341,
25583,
8985,
1669,
609,
5552,
693,
542,
291,
9701,
16094,
6692,
5518,
1669,
27860,
261,
7121,
98537,
291,
9701,
11542,
7624,
8985,
11,
2092,
340,
32917,
16,
1669,
13261,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVariablesWithExternalLinking(t *testing.T) {
protest.MustHaveCgo(t)
// Tests that macOSDebugFrameBugWorkaround works.
// See:
// https://github.com/golang/go/issues/25841
// https://github.com/go-delve/delve/issues/2346
withTestProcessArgs("testvariables2", t, ".", []string{}, protest.BuildModeExternalLinker, func(p *proc.Target, fixture protest.Fixture) {
assertNoError(p.Continue(), t, "Continue()")
str1Var := evalVariable(p, t, "str1")
if str1Var.Unreadable != nil {
t.Fatalf("variable str1 is unreadable: %v", str1Var.Unreadable)
}
t.Logf("%#v", str1Var)
if constant.StringVal(str1Var.Value) != "01234567890" {
t.Fatalf("wrong value for str1: %v", str1Var.Value)
}
})
} | explode_data.jsonl/56355 | {
"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,
7827,
16056,
25913,
3939,
287,
1155,
353,
8840,
836,
8,
341,
197,
776,
1944,
50463,
12116,
34,
3346,
1155,
340,
197,
322,
20150,
429,
67178,
7939,
4369,
46773,
6776,
19454,
4278,
624,
197,
322,
3496,
510,
197,
322,
220,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ListTestDefinitionNames(t *testing.T) {
testData := []struct {
testName string
shouldFail bool
inputDefinitions oct.TestDefinitionList
expectedResult []string
}{
{
testName: "correct list",
shouldFail: false,
inputDefinitions: oct.TestDefinitionList{
Items: []oct.TestDefinition{
{
ObjectMeta: metav1.ObjectMeta{
Name: "test1",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "test2",
},
},
},
},
expectedResult: []string{"test1", "test2"},
},
{
testName: "incorrect list",
shouldFail: true,
inputDefinitions: oct.TestDefinitionList{
Items: []oct.TestDefinition{
{
ObjectMeta: metav1.ObjectMeta{
Name: "test1",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "test2",
},
},
},
},
expectedResult: []string{"test1", "test3"},
},
}
for _, tt := range testData {
mCli := octopus.NewMockedOctopusRestClient(&tt.inputDefinitions, nil, nil)
dNames, err := listTestDefinitionNames(mCli)
if !tt.shouldFail {
require.Nil(t, err, tt.testName)
require.Equal(t, dNames, tt.expectedResult)
} else {
require.NotEqual(t, dNames, tt.expectedResult)
}
}
} | explode_data.jsonl/20536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 600
} | [
2830,
3393,
27104,
2271,
10398,
7980,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
3056,
1235,
341,
197,
18185,
675,
260,
914,
198,
197,
197,
5445,
19524,
981,
1807,
198,
197,
22427,
50542,
18491,
8787,
10398,
852,
198,
197,
42400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNonsenseKey(t *testing.T) {
var args struct {
X []string `arg:"positional, nonsense"`
}
err := parse("x", &args)
assert.Error(t, err)
} | explode_data.jsonl/13012 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 60
} | [
2830,
3393,
45,
97733,
1592,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
22123,
3056,
917,
1565,
858,
2974,
966,
3005,
11,
40802,
8805,
197,
532,
9859,
1669,
4715,
445,
87,
497,
609,
2116,
340,
6948,
6141,
1155,
11,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStreamWriter4(t *testing.T) {
runBadgerTest(t, nil, func(t *testing.T, db *DB) {
// first insert some entries in db
for i := 0; i < 10; i++ {
err := db.Update(func(txn *Txn) error {
key := []byte(fmt.Sprintf("key-%d", i))
value := []byte(fmt.Sprintf("val-%d", i))
return txn.Set(key, value)
})
require.NoError(t, err, "error while updating db")
}
list := &pb.KVList{}
list.Kv = append(list.Kv, &pb.KV{
Key: []byte("key-1"),
Value: []byte("value-1"),
Version: 1,
})
sw := db.NewStreamWriter()
require.NoError(t, sw.Prepare(), "sw.Prepare() failed")
require.NoError(t, sw.Write(list), "sw.Write() failed")
require.NoError(t, sw.Flush(), "sw.Flush() failed")
})
} | explode_data.jsonl/17982 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 334
} | [
2830,
3393,
93031,
19,
1155,
353,
8840,
836,
8,
341,
56742,
17082,
1389,
2271,
1155,
11,
2092,
11,
2915,
1155,
353,
8840,
836,
11,
2927,
353,
3506,
8,
341,
197,
197,
322,
1156,
5656,
1045,
10695,
304,
2927,
198,
197,
2023,
600,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResolvePathParam(t *testing.T) {
cxt := context.NewTestContext(t)
m := &Manifest{
Parameters: []ParameterDefinition{
{
Name: "person",
Destination: Location{
Path: "person.txt",
},
},
},
}
rm := NewRuntimeManifest(cxt.Context, ActionInstall, m)
s := &Step{
Data: map[string]interface{}{
"description": "a test step",
"Parameters": map[string]interface{}{
"Thing": "{{bundle.parameters.person}}",
},
},
}
before, _ := yaml.Marshal(s)
t.Logf("Before:\n %s", before)
err := rm.ResolveStep(s)
require.NoError(t, err)
after, _ := yaml.Marshal(s)
t.Logf("After:\n %s", after)
assert.NotNil(t, s.Data)
t.Logf("Length of data:%d", len(s.Data))
assert.NotEmpty(t, s.Data["Parameters"])
for k, v := range s.Data {
t.Logf("Key %s, value: %s, type: %T", k, v, v)
}
pms, ok := s.Data["Parameters"].(map[interface{}]interface{})
assert.True(t, ok)
val, ok := pms["Thing"].(string)
assert.True(t, ok)
assert.Equal(t, "person.txt", val)
} | explode_data.jsonl/37708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
56808,
93492,
1155,
353,
8840,
836,
8,
341,
1444,
2252,
1669,
2266,
7121,
2271,
1972,
1155,
340,
2109,
1669,
609,
38495,
515,
197,
197,
9706,
25,
3056,
4971,
10398,
515,
298,
197,
515,
571,
21297,
25,
330,
8987,
756,
571,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestKendall(t *testing.T) {
for i, test := range []struct {
x []float64
y []float64
weights []float64
ans float64
}{
{
x: []float64{0, 1, 2, 3},
y: []float64{0, 1, 2, 3},
weights: nil,
ans: 1,
},
{
x: []float64{0, 1},
y: []float64{1, 0},
weights: nil,
ans: -1,
},
{
x: []float64{8, -3, 7, 8, -4},
y: []float64{10, 15, 4, 5, -1},
weights: nil,
ans: 0.2,
},
{
x: []float64{8, -3, 7, 8, -4},
y: []float64{10, 5, 6, 3, -1},
weights: nil,
ans: 0.4,
},
{
x: []float64{1, 2, 3, 4, 5},
y: []float64{2, 3, 4, 5, 6},
weights: []float64{1, 1, 1, 1, 1},
ans: 1,
},
{
x: []float64{1, 2, 3, 2, 1},
y: []float64{2, 3, 2, 1, 0},
weights: []float64{1, 1, 0, 0, 0},
ans: 1,
},
} {
c := Kendall(test.x, test.y, test.weights)
if math.Abs(test.ans-c) > 1e-14 {
t.Errorf("Correlation mismatch case %d. Expected %v, Found %v", i, test.ans, c)
}
}
if !panics(func() { Kendall(make([]float64, 2), make([]float64, 3), make([]float64, 3)) }) {
t.Errorf("Kendall did not panic with length mismatch")
}
if !panics(func() { Kendall(make([]float64, 2), make([]float64, 3), nil) }) {
t.Errorf("Kendall did not panic with length mismatch")
}
if !panics(func() { Kendall(make([]float64, 3), make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Kendall did not panic with weights length mismatch")
}
} | explode_data.jsonl/1761 | {
"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,
42,
408,
541,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
981,
3056,
3649,
21,
19,
198,
197,
14522,
981,
3056,
3649,
21,
19,
198,
197,
197,
13327,
3056,
3649,
21,
19,
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 TestMatSplit(t *testing.T) {
src := IMRead("images/face.jpg", 1)
chans := Split(src)
if len(chans) != src.Channels() {
t.Error("Split Channel count differs")
}
dst := NewMat()
Merge(chans, &dst)
diff := NewMat()
AbsDiff(src, dst, &diff)
sum := diff.Sum()
if sum.Val1 != 0 || sum.Val2 != 0 || sum.Val3 != 0 {
t.Error("Split/Merged images differ")
}
} | explode_data.jsonl/81718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
11575,
20193,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
6517,
4418,
445,
3642,
14,
1564,
4819,
497,
220,
16,
340,
23049,
596,
1669,
27810,
14705,
340,
743,
2422,
7520,
596,
8,
961,
2286,
6353,
6680,
368,
341,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestBackoffLifecycle(t *testing.T) {
count := 0
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
count++
t.Logf("Attempt %d", count)
if count == 5 || count == 9 {
w.WriteHeader(http.StatusOK)
return
} else {
w.WriteHeader(http.StatusGatewayTimeout)
return
}
}))
defer testServer.Close()
c := testRESTClient(t, testServer)
// Test backoff recovery and increase. This correlates to the constants
// which are used in the server implementation returning StatusOK above.
seconds := []int{0, 1, 2, 4, 8, 0, 1, 2, 4, 0}
request := c.Verb("POST").Prefix("backofftest").Suffix("abc")
clock := clock.FakeClock{}
request.backoffMgr = &URLBackoff{
// Use a fake backoff here to avoid flakes and speed the test up.
Backoff: flowcontrol.NewFakeBackOff(
time.Duration(1)*time.Second,
time.Duration(200)*time.Second,
&clock,
)}
for _, sec := range seconds {
thisBackoff := request.backoffMgr.CalculateBackoff(request.URL())
t.Logf("Current backoff %v", thisBackoff)
if thisBackoff != time.Duration(sec)*time.Second {
t.Errorf("Backoff is %v instead of %v", thisBackoff, sec)
}
now := clock.Now()
request.DoRaw()
elapsed := clock.Since(now)
if clock.Since(now) != thisBackoff {
t.Errorf("CalculatedBackoff not honored by clock: Expected time of %v, but got %v ", thisBackoff, elapsed)
}
}
} | explode_data.jsonl/13271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
3707,
1847,
62731,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
220,
15,
198,
18185,
5475,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
4232,
353,
1254,
9659,
8,
341,
197,
18032,
22940,
197,
3244... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCreateStorageKeyDoubleMapV10(t *testing.T) {
m := ExamplaryMetadataV10
key, err := CreateStorageKey(m, "Session", "NextKeys",
[]byte{0x34, 0x3a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x6b, 0x65, 0x79, 0x73},
[]byte{0xbe, 0x5d, 0xdb, 0x15, 0x79, 0xb7, 0x2e, 0x84, 0x52, 0x4f, 0xc2, 0x9e, 0x78, 0x60, 0x9e, 0x3c,
0xaf, 0x42, 0xe8, 0x5a, 0xa1, 0x18, 0xeb, 0xfe, 0x0b, 0x0a, 0xd4, 0x04, 0xb5, 0xbd, 0xd2, 0x5f},
)
assert.NoError(t, err)
hex, err := Hex(key)
assert.NoError(t, err)
assert.Equal(t, "0x"+
"cec5070d609dd3497f72bde07fc96ba0"+ // twox 128
"4c014e6bf8b8c2c011e7290b85696bb3"+ // twox 128
"9fe6329cc0b39e09"+ // twox 64
"343a73657373696f6e3a6b657973"+ // twox 64 (concat, with length)
"4724e5390fcf0d08afc9608ff4c45df257266ae599ac7a32baba26155dcf4402", // blake2
hex) //nolint:lll
} | explode_data.jsonl/3058 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
4021,
5793,
1592,
7378,
2227,
53,
16,
15,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
32310,
500,
658,
14610,
53,
16,
15,
198,
23634,
11,
1848,
1669,
4230,
5793,
1592,
1255,
11,
330,
5283,
497,
330,
5847,
8850,
756,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewDNSProviderConfig(t *testing.T) {
testCases := []struct {
desc string
loginToken string
expected string
}{
{
desc: "success",
loginToken: "123",
},
{
desc: "missing credentials",
expected: "dnspod: credentials missing",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
config := NewDefaultConfig()
config.LoginToken = test.loginToken
p, err := NewDNSProviderConfig(config)
if len(test.expected) == 0 {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
require.NotNil(t, p.client)
} else {
require.EqualError(t, err, test.expected)
}
})
}
} | explode_data.jsonl/70414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
3564,
61088,
5179,
2648,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
981,
914,
198,
197,
75755,
3323,
914,
198,
197,
42400,
256,
914,
198,
197,
59403,
197,
197,
515,
298,
41653,
25,
981,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnableJob_CrdFailure(t *testing.T) {
store, manager, job := initWithJob(t)
defer store.Close()
manager.scheduledWorkflowClient = &FakeBadScheduledWorkflowClient{}
err := manager.EnableJob(job.UUID, false)
assert.Equal(t, codes.Internal, err.(*util.UserError).ExternalStatusCode())
assert.Contains(t, err.Error(), "Check job exist failed: some error")
} | explode_data.jsonl/28383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
11084,
12245,
920,
6498,
17507,
1155,
353,
8840,
836,
8,
341,
57279,
11,
6645,
11,
2618,
1669,
13864,
12245,
1155,
340,
16867,
3553,
10421,
741,
92272,
514,
26644,
62768,
2959,
284,
609,
52317,
17082,
88137,
62768,
2959,
16094... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInstallPluginCommand(t *testing.T) {
pluginsDir := setupFakePluginsDir(t)
c, err := commandstest.NewCliContext(map[string]string{"pluginsDir": pluginsDir})
require.NoError(t, err)
client := &commandstest.FakeGrafanaComClient{
GetPluginFunc: func(pluginId, repoUrl string) (models.Plugin, error) {
require.Equal(t, "test-plugin-panel", pluginId)
plugin := models.Plugin{
ID: "test-plugin-panel",
Category: "",
Versions: []models.Version{
{
Commit: "commit",
URL: "url",
Version: "1.0.0",
Arch: map[string]models.ArchMeta{
fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH): {
SHA256: "test",
},
},
},
},
}
return plugin, nil
},
DownloadFileFunc: func(pluginName string, tmpFile *os.File, url string, checksum string) (err error) {
require.Equal(t, "test-plugin-panel", pluginName)
require.Equal(t, "/test-plugin-panel/versions/1.0.0/download", url)
require.Equal(t, "test", checksum)
f, err := os.Open("testdata/grafana-simple-json-datasource-ec18fa4da8096a952608a7e4c7782b4260b41bcf.zip")
require.NoError(t, err)
_, err = io.Copy(tmpFile, f)
require.NoError(t, err)
return nil
},
}
err = InstallPlugin("test-plugin-panel", "", c, client)
assert.NoError(t, err)
} | explode_data.jsonl/74303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 585
} | [
2830,
3393,
24690,
11546,
4062,
1155,
353,
8840,
836,
8,
341,
197,
18716,
6184,
1669,
6505,
52317,
45378,
6184,
1155,
340,
1444,
11,
1848,
1669,
3210,
267,
477,
7121,
87014,
1972,
9147,
14032,
30953,
4913,
18716,
6184,
788,
17215,
6184,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_CardinalityUnsafeSet(t *testing.T) {
a := NewThreadUnsafeSet()
if a.Cardinality() != 0 {
t.Error("set should be an empty set")
}
a.Add(1)
if a.Cardinality() != 1 {
t.Error("set should have a size of 1")
}
a.Remove(1)
if a.Cardinality() != 0 {
t.Error("set should be an empty set")
}
a.Add(9)
if a.Cardinality() != 1 {
t.Error("set should have a size of 1")
}
a.Clear()
if a.Cardinality() != 0 {
t.Error("set should have a size of 1")
}
} | explode_data.jsonl/181 | {
"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,
920,
567,
80777,
78770,
1649,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
6855,
78770,
1649,
2822,
743,
264,
48613,
80777,
368,
961,
220,
15,
341,
197,
3244,
6141,
445,
746,
1265,
387,
458,
4287,
738,
1138,
197,
630,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDatabaseFetchBlocksNamespaceNotOwned(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctx := context.NewContext()
defer ctx.Close()
d, mapCh, _ := newTestDatabase(t, ctrl, Bootstrapped)
defer func() {
close(mapCh)
}()
now := time.Now()
starts := []time.Time{now, now.Add(time.Second), now.Add(-time.Second)}
res, err := d.FetchBlocks(ctx, ident.StringID("non-existent-ns"), 0, ident.StringID("foo"), starts)
require.Nil(t, res)
require.True(t, xerrors.IsInvalidParams(err))
} | explode_data.jsonl/46528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
5988,
20714,
29804,
22699,
2623,
57641,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
20985,
1669,
2266,
7121,
1972,
741,
16867,
5635,
10421,
2822,
2698,
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 TestAPISIXJsonSchemaValidator_checkUpstream(t *testing.T) {
validator, err := NewAPISIXJsonSchemaValidator("main.route")
assert.Nil(t, err)
// type:chash, hash_on: consumer, missing key, ok
route := &entity.Route{}
reqBody := `{
"id": "1",
"name": "route1",
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "chash",
"hash_on":"consumer"
},
"desc": "new route",
"uri": "/index.html"
}`
err = json.Unmarshal([]byte(reqBody), route)
assert.Nil(t, err)
err = validator.Validate(route)
assert.Nil(t, err)
// type:chash, hash_on: default(vars), missing key
route2 := &entity.Route{}
reqBody = `{
"id": "1",
"name": "route1",
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "chash"
},
"desc": "new route",
"uri": "/index.html"
}`
err = json.Unmarshal([]byte(reqBody), route2)
assert.Nil(t, err)
err = validator.Validate(route2)
assert.NotNil(t, err)
assert.EqualError(t, err, "missing key")
//type:chash, hash_on: header, missing key
route3 := &entity.Route{}
reqBody = `{
"id": "1",
"name": "route1",
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "chash",
"hash_on":"header"
},
"desc": "new route",
"uri": "/index.html"
}`
err = json.Unmarshal([]byte(reqBody), route3)
assert.Nil(t, err)
err = validator.Validate(route3)
assert.NotNil(t, err)
assert.EqualError(t, err, "missing key")
//type:chash, hash_on: cookie, missing key
route4 := &entity.Route{}
reqBody = `{
"id": "1",
"name": "route1",
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "chash",
"hash_on":"cookie"
},
"desc": "new route",
"uri": "/index.html"
}`
err = json.Unmarshal([]byte(reqBody), route4)
assert.Nil(t, err)
err = validator.Validate(route4)
assert.NotNil(t, err)
assert.EqualError(t, err, "missing key")
//type:chash, hash_on: vars, wrong key
route5 := &entity.Route{}
reqBody = `{
"id": "1",
"name": "route1",
"methods": ["GET"],
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "chash",
"hash_on":"vars",
"key": "not_support"
},
"desc": "new route",
"uri": "/index.html"
}`
err = json.Unmarshal([]byte(reqBody), route5)
assert.Nil(t, err)
err = validator.Validate(route5)
assert.NotNil(t, err)
assert.EqualError(t, err, "schema validate failed: (root): Does not match pattern '^((uri|server_name|server_addr|request_uri|remote_port|remote_addr|query_string|host|hostname)|arg_[0-9a-zA-z_-]+)$'")
} | explode_data.jsonl/50250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1252
} | [
2830,
3393,
2537,
1637,
5396,
5014,
8632,
14256,
7200,
2324,
4027,
1155,
353,
8840,
836,
8,
341,
197,
16112,
11,
1848,
1669,
1532,
2537,
1637,
5396,
5014,
8632,
14256,
445,
3817,
11842,
1138,
6948,
59678,
1155,
11,
1848,
692,
197,
322,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubbyJSON(t *testing.T) {
seed := time.Now().UnixNano()
popr := math_rand.New(math_rand.NewSource(seed))
p := NewPopulatedSubby(popr, true)
marshaler := github_com_gogo_protobuf_jsonpb.Marshaler{}
jsondata, err := marshaler.MarshalToString(p)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
msg := &Subby{}
err = github_com_gogo_protobuf_jsonpb.UnmarshalString(jsondata, msg)
if err != nil {
t.Fatalf("seed = %d, err = %v", seed, err)
}
if err := p.VerboseEqual(msg); err != nil {
t.Fatalf("seed = %d, %#v !VerboseProto %#v, since %v", seed, msg, p, err)
}
if !p.Equal(msg) {
t.Fatalf("seed = %d, %#v !Json Equal %#v", seed, msg, p)
}
} | explode_data.jsonl/697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
3136,
1694,
5370,
1155,
353,
8840,
836,
8,
341,
197,
22602,
1669,
882,
13244,
1005,
55832,
83819,
741,
3223,
46288,
1669,
6888,
33864,
7121,
37270,
33864,
7121,
3608,
44163,
1171,
3223,
1669,
1532,
11598,
7757,
3136,
1694,
401... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBar(t *testing.T) {
bar := New(0)
if err := bar.Add(1); err == nil {
t.Error("should have an error for 0 bar")
}
bar = New(10)
if err := bar.Add(11); err == nil {
t.Error("should have an error for adding > bar")
}
} | explode_data.jsonl/52760 | {
"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,
3428,
1155,
353,
8840,
836,
8,
341,
90709,
1669,
1532,
7,
15,
340,
743,
1848,
1669,
3619,
1904,
7,
16,
1215,
1848,
621,
2092,
341,
197,
3244,
6141,
445,
5445,
614,
458,
1465,
369,
220,
15,
3619,
1138,
197,
532,
90709,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPbft(t *testing.T) {
q, chain, p2pnet, s, mem, exec, cs, wallet := initEnvPbft()
defer chain.Close()
defer mem.Close()
defer p2pnet.Close()
defer exec.Close()
defer s.Close()
defer cs.Close()
defer q.Close()
defer wallet.Close()
time.Sleep(5 * time.Second)
sendReplyList(q)
clearTestData()
} | explode_data.jsonl/66282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
47,
65,
723,
1155,
353,
8840,
836,
8,
341,
18534,
11,
8781,
11,
281,
17,
79,
4711,
11,
274,
11,
1833,
11,
3883,
11,
10532,
11,
15085,
1669,
2930,
14359,
47,
65,
723,
741,
16867,
8781,
10421,
741,
16867,
1833,
10421,
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 |
func TestIssue29WithNumericTable(t *testing.T) {
NegativeTest{
Name: "issue29 with numeric column",
Query: "CREATE TABLE 1(foo)",
}.Run(t)
} | explode_data.jsonl/31977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
42006,
17,
24,
2354,
36296,
2556,
1155,
353,
8840,
836,
8,
341,
18317,
15060,
2271,
515,
197,
21297,
25,
220,
330,
11159,
17,
24,
448,
24064,
3250,
756,
197,
60362,
25,
330,
22599,
14363,
220,
16,
71880,
15752,
197,
7810,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOverlayMount(t *testing.T) {
if err := common.SupportsOverlay(); err != nil {
t.Skipf("Overlay fs not supported: %v", err)
}
tests := []overlay.MountCfg{
{"test1", "test2", "test3", "merged", ""},
{"test:1", "test:2", "test:3", "merged:1", ""},
{"test,1", "test,2", "test,3", "merged,1", ""},
}
for i, tt := range tests {
err := overlayMount(tt)
if err != nil {
text := "#%d: expected to mount at %s, got error (err=%v)"
t.Errorf(text, i, tt.Dest, err)
}
}
} | explode_data.jsonl/989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
32755,
16284,
1155,
353,
8840,
836,
8,
341,
743,
1848,
1669,
4185,
79990,
82,
32755,
2129,
1848,
961,
2092,
341,
197,
3244,
57776,
69,
445,
32755,
8619,
537,
7248,
25,
1018,
85,
497,
1848,
340,
197,
630,
78216,
1669,
3056,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_Mock_Return_Nothing(t *testing.T) {
// make a test impl object
var mockedService = new(TestExampleImplementation)
c := mockedService.
On("TheExampleMethod", "A", "B", true).
Return()
require.Equal(t, []*Call{c}, mockedService.ExpectedCalls)
call := mockedService.ExpectedCalls[0]
assert.Equal(t, "TheExampleMethod", call.Method)
assert.Equal(t, "A", call.Arguments[0])
assert.Equal(t, "B", call.Arguments[1])
assert.Equal(t, true, call.Arguments[2])
assert.Equal(t, 0, len(call.ReturnArguments))
} | explode_data.jsonl/8587 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
1245,
1176,
53316,
36989,
1596,
1155,
353,
8840,
836,
8,
8022,
197,
322,
1281,
264,
1273,
11605,
1633,
319,
2405,
46149,
1860,
284,
501,
31159,
13314,
36850,
7229,
1444,
1669,
46149,
1860,
3224,
197,
86391,
445,
785,
13314,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClient_Query2(t *testing.T) {
client := requireClient(t, true)
q := "Select+id,createdbyid,parentid,parent.casenumber,parent.subject,createdby.name,createdby.alias+from+casecomment"
result, err := client.Query(q)
if err != nil {
t.FailNow()
}
if len(result.Records) > 0 {
comment1 := &result.Records[0]
case1 := comment1.SObjectField("Case", "Parent").Get()
if comment1.StringField("ParentId") != case1.ID() {
t.Fail()
}
}
} | explode_data.jsonl/27755 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
2959,
48042,
17,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
1373,
2959,
1155,
11,
830,
692,
18534,
1669,
330,
3379,
10,
307,
11,
7120,
1694,
307,
90616,
307,
90616,
520,
300,
268,
890,
90616,
33243,
11,
7120,
1694,
2644,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetPVCNamesFromPod(t *testing.T) {
rand.Seed(time.Now().UnixNano())
pod := v1.Pod{}
var pvcNamesWant []string
for i := 1; i <= 30; i++ {
switch rand.Intn(4) {
case 0:
pod.Spec.Volumes = append(pod.Spec.Volumes, v1.Volume{
Name: "volume" + strconv.Itoa(i),
VolumeSource: v1.VolumeSource{
HostPath: &v1.HostPathVolumeSource{
Path: "/tmp/data" + strconv.Itoa(i),
},
},
})
case 1:
pod.Spec.Volumes = append(pod.Spec.Volumes, v1.Volume{
Name: "volume" + strconv.Itoa(i),
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "pvc" + strconv.Itoa(i),
ReadOnly: true,
},
},
})
pvcNamesWant = append(pvcNamesWant, "pvc"+strconv.Itoa(i))
case 2:
pod.Spec.Volumes = append(pod.Spec.Volumes, v1.Volume{
Name: "volume" + strconv.Itoa(i),
VolumeSource: v1.VolumeSource{
EmptyDir: &v1.EmptyDirVolumeSource{},
},
})
case 3:
pod.Spec.Volumes = append(pod.Spec.Volumes, v1.Volume{
Name: "volume" + strconv.Itoa(i),
VolumeSource: v1.VolumeSource{
NFS: &v1.NFSVolumeSource{
Server: "172.0.0." + strconv.Itoa(i),
Path: "/data" + strconv.Itoa(i),
ReadOnly: true,
},
},
})
}
}
pvcNames := GetPVCNamesFromPod(&pod)
if !reflect.DeepEqual(pvcNames, pvcNamesWant) {
t.Errorf("the result of GetPVCNamesFromPod is not right")
}
} | explode_data.jsonl/28339 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 695
} | [
2830,
3393,
1949,
47,
11287,
7980,
3830,
23527,
1155,
353,
8840,
836,
8,
341,
7000,
437,
5732,
291,
9730,
13244,
1005,
55832,
83819,
2398,
3223,
347,
1669,
348,
16,
88823,
16094,
2405,
281,
7362,
7980,
28823,
3056,
917,
198,
2023,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLimitSpecSerialization(t *testing.T) {
limit := &DefaultLimit{
LimitType: Default,
Limit: 10000,
Columns: []sorting.OrderByColumn{
{
Dimension: "dim1",
Direction: sorting.Ascending,
DimensionOrder: sorting.Lexicographic,
},
},
}
jsonBytes, _ := json.Marshal(limit)
expected := `{
"type" : "default",
"limit" : 10000,
"columns" : [{
"dimension" : "dim1",
"direction" : "ascending",
"dimensionOrder" : "lexicographic"
}]
}`
require.JSONEq(t, expected, string(jsonBytes))
} | explode_data.jsonl/73031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
16527,
8327,
35865,
1155,
353,
8840,
836,
8,
341,
8810,
2353,
1669,
609,
3675,
16527,
515,
197,
15070,
2353,
929,
25,
7899,
345,
197,
15070,
2353,
25,
257,
220,
16,
15,
15,
15,
15,
345,
197,
197,
13965,
25,
3056,
67039,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSpecificOrderbook(t *testing.T) {
e := CreateTestBot(t)
var bids []orderbook.Item
bids = append(bids, orderbook.Item{Price: 1000, Amount: 1})
base := orderbook.Base{
Pair: currency.NewPair(currency.BTC, currency.USD),
Bids: bids,
Exchange: "Bitstamp",
Asset: asset.Spot,
}
err := base.Process()
if err != nil {
t.Fatal("Unexpected result", err)
}
btsusd, err := currency.NewPairFromStrings("BTC", "USD")
if err != nil {
t.Fatal(err)
}
ob, err := e.GetSpecificOrderbook(btsusd, testExchange, asset.Spot)
if err != nil {
t.Fatal(err)
}
if ob.Bids[0].Price != 1000 {
t.Fatal("Unexpected result")
}
ethltc, err := currency.NewPairFromStrings("ETH", "LTC")
if err != nil {
t.Fatal(err)
}
_, err = e.GetSpecificOrderbook(ethltc, testExchange, asset.Spot)
if err == nil {
t.Fatal("Unexpected result")
}
err = e.UnloadExchange(testExchange)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/59235 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 403
} | [
2830,
3393,
1949,
47514,
4431,
2190,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
4230,
2271,
23502,
1155,
692,
2405,
43499,
3056,
1358,
2190,
9399,
198,
2233,
3365,
284,
8737,
1883,
3365,
11,
1973,
2190,
9399,
90,
6972,
25,
220,
16,
15,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestBroadcastDatatypeBadType(t *testing.T) {
bm, cancel := newTestBroadcast(t)
defer cancel()
_, err := bm.BroadcastDatatype(context.Background(), "ns1", &fftypes.Datatype{
Validator: fftypes.ValidatorType("wrong"),
}, false)
assert.Regexp(t, "FF10132.*validator", err)
} | explode_data.jsonl/78964 | {
"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,
43362,
45696,
20157,
17082,
929,
1155,
353,
8840,
836,
8,
341,
2233,
76,
11,
9121,
1669,
501,
2271,
43362,
1155,
340,
16867,
9121,
741,
197,
6878,
1848,
1669,
34868,
84788,
45696,
20157,
5378,
19047,
1507,
330,
4412,
16,
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 Test_bot_isSelfMessage(t *testing.T) {
cfg := fakeCfg{}
prc := &fakeProcessor{}
discord := &FakeDiscordClientSpy{}
discord.failOnClose = true
b := &bot{
cfg: cfg,
discord: discord,
prc: prc,
}
u := &discordgo.User{ID: "123"}
t.Run("should get a self message", func(t *testing.T) {
m := &discordgo.MessageCreate{
Message: &discordgo.Message{Author: u},
}
got := b.isSelfMessage(m, u)
if got != true {
t.Errorf("is should be self message got %v", got)
}
})
t.Run("should not get a self message", func(t *testing.T) {
m := &discordgo.MessageCreate{
Message: &discordgo.Message{Author: &discordgo.User{ID: "456"}},
}
got := b.isSelfMessage(m, u)
if got == true {
t.Errorf("is should not be self message got %v", got)
}
})
} | explode_data.jsonl/2140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
38883,
6892,
12092,
2052,
1155,
353,
8840,
836,
8,
1476,
50286,
1669,
12418,
42467,
16094,
25653,
66,
1669,
609,
30570,
22946,
31483,
2698,
3427,
539,
1669,
609,
52317,
23477,
539,
2959,
44027,
16094,
2698,
3427,
539,
26738,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatefulPodControlCreatePodPvcCreateFailure(t *testing.T) {
recorder := record.NewFakeRecorder(10)
set := newStatefulSet(3)
pod := newStatefulSetPod(set, 0)
fakeClient := &fake.Clientset{}
pvcIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
pvcLister := corelisters.NewPersistentVolumeClaimLister(pvcIndexer)
control := NewRealStatefulPodControl(fakeClient, nil, nil, pvcLister, recorder)
fakeClient.AddReactor("create", "persistentvolumeclaims", func(action core.Action) (bool, runtime.Object, error) {
return true, nil, apierrors.NewInternalError(errors.New("API server down"))
})
fakeClient.AddReactor("create", "pods", func(action core.Action) (bool, runtime.Object, error) {
create := action.(core.CreateAction)
return true, create.GetObject(), nil
})
if err := control.CreateStatefulPod(set, pod); err == nil {
t.Error("Failed to produce error on PVC creation failure")
}
events := collectEvents(recorder.Events)
if eventCount := len(events); eventCount != 2 {
t.Errorf("PVC create failure: got %d events, but want 2", eventCount)
}
for i := range events {
if !strings.Contains(events[i], v1.EventTypeWarning) {
t.Errorf("Found unexpected non-warning event %s", events[i])
}
}
} | explode_data.jsonl/17899 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 440
} | [
2830,
3393,
1397,
1262,
23527,
3273,
4021,
23527,
47,
7362,
4021,
17507,
1155,
353,
8840,
836,
8,
341,
67904,
1358,
1669,
3255,
7121,
52317,
47023,
7,
16,
15,
340,
8196,
1669,
36848,
1262,
1649,
7,
18,
340,
3223,
347,
1669,
36848,
126... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReleaseNoninternedString(t *testing.T) {
c := NewTestStorageClient()
var m *QueueManager
h := sync.Mutex{}
h.Lock()
m = NewQueueManager(nil, "", newEWMARate(ewmaWeight, shardUpdateDuration), config.DefaultQueueConfig, nil, nil, c, defaultFlushDeadline)
m.Start()
go func() {
for {
m.SeriesReset(1)
}
}()
for i := 1; i < 1000; i++ {
m.StoreSeries([]tsdb.RefSeries{
tsdb.RefSeries{
Ref: uint64(i),
Labels: tsdbLabels.Labels{
tsdbLabels.Label{
Name: "asdf",
Value: fmt.Sprintf("%d", i),
},
},
},
}, 0)
}
metric := client_testutil.ToFloat64(noReferenceReleases)
testutil.Assert(t, metric == 0, "expected there to be no calls to release for strings that were not already interned: %d", int(metric))
} | explode_data.jsonl/22378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
16077,
8121,
55444,
291,
703,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
2271,
5793,
2959,
741,
2405,
296,
353,
7554,
2043,
198,
9598,
1669,
12811,
99014,
31483,
9598,
31403,
2822,
2109,
284,
1532,
7554,
2043,
27907,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestShouldCheckAuthorizationMatching(t *testing.T) {
type Rule struct {
Policy string
AuthLevel authentication.Level
ExpectedMatching authorizationMatching
}
rules := []Rule{
{"bypass", authentication.NotAuthenticated, Authorized},
{"bypass", authentication.OneFactor, Authorized},
{"bypass", authentication.TwoFactor, Authorized},
{"one_factor", authentication.NotAuthenticated, NotAuthorized},
{"one_factor", authentication.OneFactor, Authorized},
{"one_factor", authentication.TwoFactor, Authorized},
{"two_factor", authentication.NotAuthenticated, NotAuthorized},
{"two_factor", authentication.OneFactor, NotAuthorized},
{"two_factor", authentication.TwoFactor, Authorized},
{"deny", authentication.NotAuthenticated, NotAuthorized},
{"deny", authentication.OneFactor, Forbidden},
{"deny", authentication.TwoFactor, Forbidden},
}
url, _ := url.ParseRequestURI("https://test.example.com")
for _, rule := range rules {
authorizer := authorization.NewAuthorizer(&schema.Configuration{
AccessControl: schema.AccessControlConfiguration{
DefaultPolicy: "deny",
Rules: []schema.ACLRule{{
Domains: []string{"test.example.com"},
Policy: rule.Policy,
}},
}})
username := ""
if rule.AuthLevel > authentication.NotAuthenticated {
username = testUsername
}
matching := isTargetURLAuthorized(authorizer, *url, username, []string{}, net.ParseIP("127.0.0.1"), []byte("GET"), rule.AuthLevel)
assert.Equal(t, rule.ExpectedMatching, matching, "policy=%s, authLevel=%v, expected=%v, actual=%v",
rule.Policy, rule.AuthLevel, rule.ExpectedMatching, matching)
}
} | explode_data.jsonl/20183 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
14996,
3973,
18124,
64430,
1155,
353,
8840,
836,
8,
341,
13158,
18100,
2036,
341,
197,
10025,
8018,
1843,
914,
198,
197,
197,
5087,
4449,
286,
16653,
25259,
198,
197,
197,
18896,
64430,
23715,
64430,
198,
197,
630,
7000,
242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveOldUnregisteredNodes(t *testing.T) {
deletedNodes := make(chan string, 10)
now := time.Now()
ng1_1 := BuildTestNode("ng1-1", 1000, 1000)
ng1_1.Spec.ProviderID = "ng1-1"
ng1_2 := BuildTestNode("ng1-2", 1000, 1000)
ng1_2.Spec.ProviderID = "ng1-2"
provider := testprovider.NewTestCloudProvider(nil, func(nodegroup string, node string) error {
deletedNodes <- fmt.Sprintf("%s/%s", nodegroup, node)
return nil
})
provider.AddNodeGroup("ng1", 1, 10, 2)
provider.AddNode("ng1", ng1_1)
provider.AddNode("ng1", ng1_2)
clusterState := clusterstate.NewClusterStateRegistry(provider, clusterstate.ClusterStateRegistryConfig{
MaxTotalUnreadyPercentage: 10,
OkTotalUnreadyCount: 1,
})
err := clusterState.UpdateNodes([]*apiv1.Node{ng1_1}, now.Add(-time.Hour))
assert.NoError(t, err)
context := &AutoscalingContext{
AutoscalingOptions: AutoscalingOptions{
UnregisteredNodeRemovalTime: 45 * time.Minute,
},
CloudProvider: provider,
ClusterStateRegistry: clusterState,
}
unregisteredNodes := clusterState.GetUnregisteredNodes()
assert.Equal(t, 1, len(unregisteredNodes))
// Nothing should be removed. The unregistered node is not old enough.
removed, err := removeOldUnregisteredNodes(unregisteredNodes, context, now.Add(-50*time.Minute))
assert.NoError(t, err)
assert.False(t, removed)
// ng1_2 should be removed.
removed, err = removeOldUnregisteredNodes(unregisteredNodes, context, now)
assert.NoError(t, err)
assert.True(t, removed)
deletedNode := getStringFromChan(deletedNodes)
assert.Equal(t, "ng1/ng1-2", deletedNode)
} | explode_data.jsonl/44989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 600
} | [
2830,
3393,
13021,
18284,
1806,
34909,
12288,
1155,
353,
8840,
836,
8,
341,
197,
26521,
12288,
1669,
1281,
35190,
914,
11,
220,
16,
15,
692,
80922,
1669,
882,
13244,
2822,
197,
968,
16,
62,
16,
1669,
7854,
2271,
1955,
445,
968,
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 TestKnativeProxyHeader(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "http://example.com/", nil)
if err != nil {
t.Fatal("Error building request:", err)
}
if h := KnativeProxyHeader(req); h != "" {
t.Errorf("KnativeProxyHeader(req)=%v, want empty string", h)
}
const want = "activator"
req.Header.Set(ProxyHeaderName, want)
if h := KnativeProxyHeader(req); h != want {
t.Errorf("KnativeProxyHeader(req)=%v, want %v", h, want)
}
req.Header.Set(ProxyHeaderName, "")
if h := KnativeProxyHeader(req); h != "" {
t.Errorf("KnativeProxyHeader(req)=%v, want empty string", h)
}
} | explode_data.jsonl/58830 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 235
} | [
2830,
3393,
42,
29738,
16219,
4047,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
1758,
75274,
19886,
20798,
1949,
11,
330,
1254,
1110,
8687,
905,
28105,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
1454,
4752,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPodNodeConstraintsPodUpdate(t *testing.T) {
ns := metav1.NamespaceDefault
var expectedError error
errPrefix := "PodUpdate"
prc := NewPodNodeConstraints(testConfig(), nodeidentifier.NewDefaultNodeIdentifier())
prc.(initializer.WantsAuthorizer).SetAuthorizer(fakeAuthorizer(t))
err := prc.(admission.InitializationValidator).ValidateInitialization()
if err != nil {
checkAdmitError(t, err, expectedError, errPrefix)
return
}
attrs := admission.NewAttributesRecord(nodeNamePod(), nodeNamePod(), kapi.Kind("Pod").WithVersion("version"), ns, "test", kapi.Resource("pods").WithVersion("version"), "", admission.Update, serviceaccount.UserInfo("", "", ""))
err = prc.(admission.MutationInterface).Admit(attrs)
checkAdmitError(t, err, expectedError, errPrefix)
} | explode_data.jsonl/37020 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
23527,
1955,
12925,
23527,
4289,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
77520,
16,
46011,
3675,
198,
2405,
3601,
1454,
1465,
198,
9859,
14335,
1669,
330,
23527,
4289,
698,
25653,
66,
1669,
1532,
23527,
1955,
12925,
8623,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOptionOrElse(t *testing.T) {
s := gs.Some[int](100)
f := gs.Some[int](1)
assert.Equal(t, s.IsDefined(), s.OrElse(f).IsDefined())
assert.Equal(t, s.Get(), s.OrElse(f).Get())
n := gs.None[int]()
assert.Equal(t, true, n.OrElse(f).IsDefined())
assert.Equal(t, 1, n.OrElse(f).Get())
} | explode_data.jsonl/32436 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
5341,
52774,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
28081,
86833,
18640,
9533,
16,
15,
15,
340,
1166,
1669,
28081,
86833,
18640,
9533,
16,
692,
6948,
12808,
1155,
11,
274,
4506,
29361,
1507,
274,
13,
52774,
955,
568,
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 Test_SendViaGet(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
query := r.URL.Query()
dnsQryParam := query.Get("dns")
require.NotEmpty(t, dnsQryParam, "expected dns query param not found")
bd, err := base64.StdEncoding.DecodeString(dnsQryParam)
require.NoError(t, err, "error decoding query param DNS")
msg := dns.Msg{}
err = msg.Unpack(bd)
require.NoError(t, err, "error unpacking request body")
require.Len(t, msg.Question, 1, "single question expected")
resp := msg
switch msg.Question[0].Name {
case notExistingDomain:
resp.Rcode = dns.RcodeNameError
case existingDomain:
resp.Rcode = dns.RcodeSuccess
default:
require.FailNow(t, "unexpected question name")
}
pack, err := resp.Pack()
require.NoError(t, err, "error packing response")
_, err = w.Write(pack)
require.NoError(t, err, "error writing response")
}))
defer ts.Close()
type args struct {
server string
msg *dns.Msg
}
tests := []struct {
name string
args args
wantRcode int
wantErr bool
}{
{
name: "NOERROR DNS resolution",
args: args{server: ts.URL, msg: question(existingDomain)},
wantRcode: dns.RcodeSuccess,
},
{
name: "NXDOMAIN DNS resolution",
args: args{server: ts.URL, msg: question(notExistingDomain)},
wantRcode: dns.RcodeNameError,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := NewClient(nil)
got, err := client.SendViaGet(context.Background(), tt.args.server, tt.args.msg)
if tt.wantErr {
require.Error(t, err, "SendViaGet() error")
} else {
require.NoError(t, err)
assert.NotNil(t, got, "SendViaGet() response")
assert.Equal(t, tt.wantRcode, got.Rcode, "SendViaGet() rcode")
}
})
}
} | explode_data.jsonl/81677 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 774
} | [
2830,
3393,
46267,
54428,
1949,
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,
27274,
1669,
435,
20893,
15685,
741,
197,
2698,
4412,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadSharedFile(t *testing.T) {
c := &config{
SharedConfigFile: TestValueEnvUCloudSharedConfigFile,
SharedCredentialFile: TestValueEnvUCloudSharedCredentialFile,
}
err := c.loadFileIfExist()
assert.NoError(t, err)
checkTestConfig(t, c)
} | explode_data.jsonl/75676 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
5879,
16997,
1703,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
1676,
515,
197,
197,
16997,
2648,
1703,
25,
257,
3393,
1130,
14359,
52,
16055,
16997,
2648,
1703,
345,
197,
197,
16997,
48265,
1703,
25,
3393,
1130,
14359,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuildSetDefaults(t *testing.T) {
tests := []struct {
build Build
expectedBuild Build
}{
{
Build{},
Build{
CrossCompile: false,
MainFile: defaultMainFile,
BinaryFile: "bin/spec",
VersionPackage: defaultVersionPackage,
GoVersions: defaultGoVersions,
Platforms: defaultPlatforms,
},
},
{
Build{
CrossCompile: true,
MainFile: "cmd/main.go",
BinaryFile: "build/app",
VersionPackage: "./cmd/version",
GoVersions: []string{"1.10", "1.11"},
Platforms: []string{"linux-amd64", "darwin-amd64", "windows-amd64"},
},
Build{
CrossCompile: true,
MainFile: "cmd/main.go",
BinaryFile: "build/app",
VersionPackage: "./cmd/version",
GoVersions: []string{"1.10", "1.11"},
Platforms: []string{"linux-amd64", "darwin-amd64", "windows-amd64"},
},
},
}
for _, tc := range tests {
tc.build.SetDefaults()
assert.Equal(t, tc.expectedBuild, tc.build)
}
} | explode_data.jsonl/62824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 489
} | [
2830,
3393,
11066,
1649,
16273,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
69371,
260,
7854,
198,
197,
42400,
11066,
7854,
198,
197,
59403,
197,
197,
515,
298,
197,
11066,
38837,
298,
197,
11066,
515,
571,
6258,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInteractionsService_UpdateRestrictionsForRepo(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
input := &InteractionRestriction{Limit: String("existing_users")}
mux.HandleFunc("/repos/o/r/interaction-limits", func(w http.ResponseWriter, r *http.Request) {
v := new(InteractionRestriction)
json.NewDecoder(r.Body).Decode(v)
testMethod(t, r, "PUT")
testHeader(t, r, "Accept", mediaTypeInteractionRestrictionsPreview)
if !reflect.DeepEqual(v, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
fmt.Fprint(w, `{"origin":"repository"}`)
})
repoInteractions, _, err := client.Interactions.UpdateRestrictionsForRepo(context.Background(), "o", "r", input.GetLimit())
if err != nil {
t.Errorf("Interactions.UpdateRestrictionsForRepo returned error: %v", err)
}
want := &InteractionRestriction{Origin: String("repository")}
if !reflect.DeepEqual(repoInteractions, want) {
t.Errorf("Interactions.UpdateRestrictionsForRepo returned %+v, want %+v", repoInteractions, want)
}
} | explode_data.jsonl/3502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
3306,
4020,
1860,
47393,
50360,
21439,
2461,
25243,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
22427,
1669,
609,
31311,
50360,
2479,
90,
16527,
25,
923,
445,
36895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestContext_LocalePrinter(t *testing.T) {
a := assert.New(t, false)
srv := newServer(a, &Options{Tag: language.SimplifiedChinese})
b := srv.Locale().Builder()
a.NotError(b.SetString(language.MustParse("cmn-hans"), "test", "测试"))
a.NotError(b.SetString(language.MustParse("cmn-hant"), "test", "測試"))
w := httptest.NewRecorder()
r, err := http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("accept-language", "cmn-hant")
r.Header.Set("accept", text.Mimetype)
ctx := srv.NewContext(w, r)
a.NotNil(ctx)
a.NotError(ctx.Marshal(http.StatusOK, ctx.Sprintf("test"), nil))
a.Equal(w.Body.String(), "測試")
w = httptest.NewRecorder()
r, err = http.NewRequest(http.MethodGet, "/path", nil)
a.NotError(err).NotNil(r)
r.Header.Set("accept-language", "cmn-hans")
r.Header.Set("accept", text.Mimetype)
ctx = srv.NewContext(w, r)
a.NotNil(ctx)
n, err := ctx.LocalePrinter.Fprintf(ctx.Response, "test")
a.NotError(err).Equal(n, len("测试"))
a.Equal(w.Body.String(), "测试")
} | explode_data.jsonl/34208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
1972,
2351,
36311,
45660,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
11,
895,
340,
1903,
10553,
1669,
501,
5475,
2877,
11,
609,
3798,
90,
5668,
25,
4128,
808,
73837,
44923,
8824,
2233,
1669,
43578,
59094,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeriveSecret(t *testing.T) {
chTranscript := cipherSuitesTLS13[0].hash.New()
chTranscript.Write(parseVector(`
payload (512 octets): 01 00 01 fc 03 03 1b c3 ce b6 bb e3 9c ff
93 83 55 b5 a5 0a db 6d b2 1b 7a 6a f6 49 d7 b4 bc 41 9d 78 76
48 7d 95 00 00 06 13 01 13 03 13 02 01 00 01 cd 00 00 00 0b 00
09 00 00 06 73 65 72 76 65 72 ff 01 00 01 00 00 0a 00 14 00 12
00 1d 00 17 00 18 00 19 01 00 01 01 01 02 01 03 01 04 00 33 00
26 00 24 00 1d 00 20 e4 ff b6 8a c0 5f 8d 96 c9 9d a2 66 98 34
6c 6b e1 64 82 ba dd da fe 05 1a 66 b4 f1 8d 66 8f 0b 00 2a 00
00 00 2b 00 03 02 03 04 00 0d 00 20 00 1e 04 03 05 03 06 03 02
03 08 04 08 05 08 06 04 01 05 01 06 01 02 01 04 02 05 02 06 02
02 02 00 2d 00 02 01 01 00 1c 00 02 40 01 00 15 00 57 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 29 00 dd 00 b8 00 b2 2c 03 5d 82 93 59 ee 5f f7 af 4e c9 00
00 00 00 26 2a 64 94 dc 48 6d 2c 8a 34 cb 33 fa 90 bf 1b 00 70
ad 3c 49 88 83 c9 36 7c 09 a2 be 78 5a bc 55 cd 22 60 97 a3 a9
82 11 72 83 f8 2a 03 a1 43 ef d3 ff 5d d3 6d 64 e8 61 be 7f d6
1d 28 27 db 27 9c ce 14 50 77 d4 54 a3 66 4d 4e 6d a4 d2 9e e0
37 25 a6 a4 da fc d0 fc 67 d2 ae a7 05 29 51 3e 3d a2 67 7f a5
90 6c 5b 3f 7d 8f 92 f2 28 bd a4 0d da 72 14 70 f9 fb f2 97 b5
ae a6 17 64 6f ac 5c 03 27 2e 97 07 27 c6 21 a7 91 41 ef 5f 7d
e6 50 5e 5b fb c3 88 e9 33 43 69 40 93 93 4a e4 d3 57 fa d6 aa
cb 00 21 20 3a dd 4f b2 d8 fd f8 22 a0 ca 3c f7 67 8e f5 e8 8d
ae 99 01 41 c5 92 4d 57 bb 6f a3 1b 9e 5f 9d`))
type args struct {
secret []byte
label string
transcript hash.Hash
}
tests := []struct {
name string
args args
want []byte
}{
{
`derive secret for handshake "tls13 derived"`,
args{
parseVector(`PRK (32 octets): 33 ad 0a 1c 60 7e c0 3b 09 e6 cd 98 93 68 0c e2
10 ad f3 00 aa 1f 26 60 e1 b2 2e 10 f1 70 f9 2a`),
"derived",
nil,
},
parseVector(`expanded (32 octets): 6f 26 15 a1 08 c7 02 c5 67 8f 54 fc 9d ba
b6 97 16 c0 76 18 9c 48 25 0c eb ea c3 57 6c 36 11 ba`),
},
{
`derive secret "tls13 c e traffic"`,
args{
parseVector(`PRK (32 octets): 9b 21 88 e9 b2 fc 6d 64 d7 1d c3 29 90 0e 20 bb
41 91 50 00 f6 78 aa 83 9c bb 79 7c b7 d8 33 2c`),
"c e traffic",
chTranscript,
},
parseVector(`expanded (32 octets): 3f bb e6 a6 0d eb 66 c3 0a 32 79 5a ba 0e
ff 7e aa 10 10 55 86 e7 be 5c 09 67 8d 63 b6 ca ab 62`),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := cipherSuitesTLS13[0]
if got := c.deriveSecret(tt.args.secret, tt.args.label, tt.args.transcript); !bytes.Equal(got, tt.want) {
t.Errorf("cipherSuiteTLS13.deriveSecret() = % x, want % x", got, tt.want)
}
})
}
} | explode_data.jsonl/71997 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1378
} | [
2830,
3393,
22171,
533,
19773,
1155,
353,
8840,
836,
8,
341,
23049,
3167,
1228,
1669,
31088,
62898,
288,
45439,
16,
18,
58,
15,
936,
8296,
7121,
741,
23049,
3167,
1228,
4073,
27762,
3781,
61528,
76272,
320,
20,
16,
17,
18491,
1415,
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... | 2 |
func Test_parseConfigFile(t *testing.T) {
expectedConfig := &serviceCheckConfig{
[]serviceCheck{
{
"test",
[]string{"test", "args"},
map[string]string{"env": "testenv"},
false,
},
},
}
if err := os.Chmod("./test/testconfig.yaml", 0o600); err != nil {
assert.Fail(t, err.Error())
}
config, err := parseConfigFile("./test/testconfig.yaml")
assert.Nil(t, err)
assert.Equal(t, expectedConfig, config)
} | explode_data.jsonl/8917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
21039,
2648,
1703,
1155,
353,
8840,
836,
8,
341,
42400,
2648,
1669,
609,
7936,
3973,
2648,
515,
197,
197,
1294,
7936,
3973,
515,
298,
197,
515,
571,
197,
1,
1944,
756,
571,
197,
1294,
917,
4913,
1944,
497,
330,
2116,
711... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLiveUpdateDiffImgMultipleContainersSameContextOnlyOneLiveUpdate(t *testing.T) {
f := newBDFixture(t, k8s.EnvGKE, container.RuntimeCrio)
defer f.TearDown()
buildContext := f.Path()
sanchoSyncs := SanchoSyncSteps(f)
sanchoSyncs[0].Source = buildContext
sanchoLU := assembleLiveUpdate(sanchoSyncs, SanchoRunSteps, false, nil, f)
sanchoTarg := model.MustNewImageTarget(SanchoRef).WithBuildDetails(model.DockerBuild{
Dockerfile: SanchoDockerfile,
BuildPath: buildContext,
})
sidecarTarg := model.MustNewImageTarget(SanchoSidecarRef).WithBuildDetails(model.DockerBuild{
Dockerfile: SanchoDockerfile,
BuildPath: buildContext,
})
tCase := testCase{
manifest: manifestbuilder.New(f, "sanchoWithSidecar").
WithK8sYAML(testyaml.SanchoSidecarYAML).
WithImageTargets(sanchoTarg, sidecarTarg).
WithLiveUpdateAtIndex(sanchoLU, 0).
Build(),
runningContainersByTarget: map[model.TargetID][]container.ID{
sanchoTarg.ID(): []container.ID{"c1"},
sidecarTarg.ID(): []container.ID{"c2"},
},
changedFiles: []string{"sancho/a.txt"},
expectDockerBuildCount: 2,
expectDockerPushCount: 2,
expectK8sDeploy: true,
}
runTestCase(t, f, tCase)
} | explode_data.jsonl/35158 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
20324,
4289,
21751,
13033,
32089,
74632,
19198,
1972,
7308,
3966,
20324,
4289,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
33,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
38,
3390,
11,
5476,
16706,
34,
10383,
340,
16867,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateAPIEndpoint(t *testing.T) {
var tests = []struct {
name string
s *kubeadm.APIEndpoint
expected bool
}{
{
name: "Valid IPv4 address / port",
s: &kubeadm.APIEndpoint{
AdvertiseAddress: "4.5.6.7",
BindPort: 6443,
},
expected: true,
},
{
name: "Valid IPv6 address / port",
s: &kubeadm.APIEndpoint{
AdvertiseAddress: "2001:db7::2",
BindPort: 6443,
},
expected: true,
},
{
name: "Invalid IPv4 address",
s: &kubeadm.APIEndpoint{
AdvertiseAddress: "1.2.34",
BindPort: 6443,
},
expected: false,
},
{
name: "Invalid IPv6 address",
s: &kubeadm.APIEndpoint{
AdvertiseAddress: "2001:db7:1",
BindPort: 6443,
},
expected: false,
},
{
name: "Invalid BindPort",
s: &kubeadm.APIEndpoint{
AdvertiseAddress: "4.5.6.7",
BindPort: 0,
},
expected: false,
},
}
for _, rt := range tests {
actual := ValidateAPIEndpoint(rt.s, nil)
if (len(actual) == 0) != rt.expected {
t.Errorf(
"%s test case failed:\n\texpected: %t\n\t actual: %t",
rt.name,
rt.expected,
(len(actual) == 0),
)
}
}
} | explode_data.jsonl/39226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 633
} | [
2830,
3393,
17926,
7082,
27380,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
1903,
286,
353,
74,
392,
3149,
76,
24922,
27380,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRetry(t *testing.T) {
siteURL := "http://localhost:8989"
closer, err := startFakeServer(":8989", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// faking digest response
if r.RequestURI == "/_api/ContextInfo" {
_, _ = fmt.Fprintf(w, `{"d":{"GetContextWebInformation":{"FormDigestValue":"FAKE","FormDigestTimeoutSeconds":120,"LibraryVersion":"FAKE"}}}`)
return
}
// retry after
if r.RequestURI == "/_api/retryafter" && r.Header.Get("X-Gosip-Retry") == "1" {
w.Header().Add("Retry-After", "1")
w.WriteHeader(http.StatusTooManyRequests)
_, _ = w.Write([]byte(`{ "error": "Body is not backed off" }`))
return
}
// ntlm retry
if r.RequestURI == "/_api/ntlm" && r.Header.Get("X-Gosip-Retry") == "" {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte(`{ "error": "NTLM force retry" }`))
return
}
// context cancel
if r.RequestURI == "/_api/contextcancel" && r.Header.Get("X-Gosip-Retry") == "" {
w.Header().Add("Retry-After", "5")
w.WriteHeader(http.StatusTooManyRequests)
_, _ = w.Write([]byte(`{ "error": "context cancel" }`))
return
}
if r.Body != nil {
defer func() { _ = r.Body.Close() }()
data, _ := ioutil.ReadAll(r.Body)
if r.RequestURI == "/_api/post/keepbody" && r.Header.Get("X-Gosip-Retry") == "1" {
if fmt.Sprintf("%s", data) != "none-empty" {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte(`{ "error": "Body is not backed off" }`))
return
}
}
}
// backoff after 2 retries
if r.Header.Get("X-Gosip-Retry") == "2" {
_, _ = fmt.Fprintf(w, `{ "result": "Cool alfter some retries" }`)
return
}
// intentional 503
w.WriteHeader(http.StatusServiceUnavailable)
_, _ = w.Write([]byte(`{ "error": "503 Retry Please" }`))
}))
if err != nil {
t.Fatal(err)
}
defer func() { _ = closer.Close() }()
t.Run("GetRequest", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
RetryPolicies: map[int]int{503: 3},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/get", nil)
if err != nil {
t.Fatal(err)
}
resp, err := client.Execute(req)
if err != nil {
t.Error(err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != 200 {
t.Error("can't retry a request")
}
})
t.Run("PostRequest", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
RetryPolicies: map[int]int{503: 3},
}
req, err := http.NewRequest("POST", client.AuthCnfg.GetSiteURL()+"/_api/post/keepbody", bytes.NewBuffer([]byte("none-empty")))
if err != nil {
t.Fatal(err)
}
resp, err := client.Execute(req)
if err != nil {
t.Error(err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != 200 {
t.Error("can't retry a request")
}
})
t.Run("PostRequestEmptyBody", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
RetryPolicies: map[int]int{503: 3},
}
req, err := http.NewRequest("POST", client.AuthCnfg.GetSiteURL()+"/_api/post", nil)
if err != nil {
t.Fatal(err)
}
resp, err := client.Execute(req)
if err != nil {
t.Error(err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != 200 {
t.Error("can't retry a request")
}
})
t.Run("PostRequestShould503", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
RetryPolicies: map[int]int{503: 1},
}
req, err := http.NewRequest("POST", client.AuthCnfg.GetSiteURL()+"/_api/post", bytes.NewBuffer([]byte("none-empty")))
if err != nil {
t.Fatal(err)
}
resp, _ := client.Execute(req)
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != 503 {
t.Error("should receive 503")
}
})
t.Run("DisableRetry", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/get", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Add("X-Gosip-NoRetry", "true")
resp, _ := client.Execute(req)
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != 503 {
t.Error("should receive 503")
}
})
t.Run("RetryAfter", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/retryafter", nil)
if err != nil {
t.Fatal(err)
}
beforeReq := time.Now()
if _, err := client.Execute(req); err != nil {
t.Error(err)
}
dur := time.Now().Sub(beforeReq)
if dur < 1*time.Second {
t.Error("retry after is ignored")
}
})
t.Run("NtlmRetry", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{
SiteURL: siteURL,
Strategy: "ntlm",
},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/ntlm", nil)
if err != nil {
t.Fatal(err)
}
if _, err := client.Execute(req); err != nil {
t.Error(err)
}
})
t.Run("ContextCancel", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/contextcancel", nil)
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithCancel(context.Background())
req = req.WithContext(ctx)
beforeReq := time.Now()
go func() {
select {
case <-time.After(900 * time.Millisecond):
cancel()
}
}()
_, _ = client.Execute(req) // should be canceled with a context after 900 milliseconds
dur := time.Now().Sub(beforeReq)
if dur > 1*time.Second {
t.Error("context canceling failed")
}
})
t.Run("ContextCancel", func(t *testing.T) {
client := &SPClient{
AuthCnfg: &AnonymousCnfg{SiteURL: siteURL},
}
req, err := http.NewRequest("GET", client.AuthCnfg.GetSiteURL()+"/_api/contextcancel_2", nil)
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithCancel(context.Background())
req = req.WithContext(ctx)
cancel()
_, err = client.Execute(req) // should be prevented due to already closed context
if err != nil && strings.Index(err.Error(), "context canceled") == -1 {
t.Error("context canceling failed")
}
})
} | explode_data.jsonl/15489 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2774
} | [
2830,
3393,
51560,
1155,
353,
8840,
836,
8,
341,
1903,
632,
3144,
1669,
330,
1254,
1110,
8301,
25,
23,
24,
23,
24,
698,
1444,
69215,
11,
1848,
1669,
1191,
52317,
5475,
18893,
23,
24,
23,
24,
497,
1758,
89164,
18552,
3622,
1758,
3750... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTxnTraceSlowestNodesSaved(t *testing.T) {
start := time.Date(2014, time.November, 28, 1, 1, 0, 0, time.UTC)
tr := &TxnData{}
tr.TxnTrace.Enabled = true
tr.TxnTrace.StackTraceThreshold = 1 * time.Hour
tr.TxnTrace.SegmentThreshold = 0
tr.TxnTrace.maxNodes = 5
durations := []int{5, 4, 6, 3, 7, 2, 8, 1, 9}
now := start
for _, d := range durations {
s := StartSegment(tr, now)
now = now.Add(time.Duration(d) * time.Second)
EndBasicSegment(tr, s, now, strconv.Itoa(d))
}
acfg := CreateAttributeConfig(sampleAttributeConfigInput, true)
attr := NewAttributes(acfg)
ht := newHarvestTraces()
ht.regular.addTxnTrace(&HarvestTrace{
TxnEvent: TxnEvent{
Start: start,
Duration: 123 * time.Second,
FinalName: "WebTransaction/Go/hello",
CleanURL: "/url",
Attrs: attr,
},
Trace: tr.TxnTrace,
})
expect := `[
1417136460000000,
123000,
"WebTransaction/Go/hello",
"/url",
[
0,
{},
{},
[
0,
123000,
"ROOT",
{},
[
[
0,
123000,
"WebTransaction/Go/hello",
{},
[
[
0,
5000,
"Custom/5",
{},
[]
],
[
9000,
15000,
"Custom/6",
{},
[]
],
[
18000,
25000,
"Custom/7",
{},
[]
],
[
27000,
35000,
"Custom/8",
{},
[]
],
[
36000,
45000,
"Custom/9",
{},
[]
]
]
]
]
],
{
"agentAttributes":{},
"userAttributes":{},
"intrinsics":{}
}
],
"",
null,
false,
null,
""
]`
expect = CompactJSONString(expect)
js, err := ht.slice()[0].MarshalJSON()
if nil != err {
t.Fatal(err)
}
if string(js) != expect {
t.Error(string(js), expect)
}
} | explode_data.jsonl/8810 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1673
} | [
2830,
3393,
31584,
77,
6550,
58289,
477,
12288,
41133,
1155,
353,
8840,
836,
8,
341,
21375,
1669,
882,
8518,
7,
17,
15,
16,
19,
11,
882,
2067,
859,
1377,
11,
220,
17,
23,
11,
220,
16,
11,
220,
16,
11,
220,
15,
11,
220,
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... | 4 |
func TestUnsubscribeThreadSafety(t *testing.T) {
count := 100000
handler1 := func(msg interface{}) {}
b := NewBroker()
subs := make([]Subscription, 0, count)
for i := 0; i < count; i++ {
subs = append(subs, b.Subscribe("topic1", handler1))
}
var wg sync.WaitGroup
wg.Add(count)
for i := 0; i < count; i++ {
i := i
go func() {
subs[i].Unsubscribe()
wg.Done()
}()
}
wg.Wait()
if len(b.(*broker).subscribers["topic1"]) != 0 {
t.Errorf("Expected %d subscribers, got %d", 0, len(b.(*broker).subscribers["topic1"]))
}
} | explode_data.jsonl/37068 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 239
} | [
2830,
3393,
1806,
9384,
6855,
73037,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
220,
16,
15,
15,
15,
15,
15,
198,
53326,
16,
1669,
2915,
8119,
3749,
28875,
5613,
2233,
1669,
1532,
65545,
2822,
1903,
15738,
1669,
1281,
10556,
33402,
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 TestExtendInterfaceType(t *testing.T) {
t.Run("extend simple interface type by field", func(t *testing.T) {
run(extendInterfaceTypeDefinition, testDefinition, `
interface Mammal {
name: String
}
extend interface Mammal {
furType: String
}
`, `
interface Mammal {
name: String
furType: String
}
extend interface Mammal {
furType: String
}
`)
})
t.Run("extend interface by implements interface", func(t *testing.T) {
run(extendInterfaceTypeDefinition, testDefinition, `
interface A {
name: String
}
extend interface A implements B {
age: Int
}
interface B {
age: Int
}
`, `
interface A implements B {
name: String
age: Int
}
extend interface A implements B {
age: Int
}
interface B {
age: Int
}
`)
})
t.Run("extend interface by implements interface and field", func(t *testing.T) {
run(extendInterfaceTypeDefinition, testDefinition, `
interface A {
name: String
}
extend interface A implements B {
field: String
age: Int
}
interface B {
age: Int
}
`, `
interface A implements B {
name: String
field: String
age: Int
}
extend interface A implements B {
field: String
age: Int
}
interface B {
age: Int
}
`)
})
t.Run("extend simple interface type by directive", func(t *testing.T) {
run(extendInterfaceTypeDefinition, testDefinition, `
interface Mammal {
name: String
}
extend interface Mammal @deprecated(reason: "some reason")
`, `
interface Mammal @deprecated(reason: "some reason") {
name: String
}
extend interface Mammal @deprecated(reason: "some reason")
`)
})
t.Run("extend interface type by complex extends", func(t *testing.T) {
run(extendInterfaceTypeDefinition, testDefinition, `
interface Mammal {
name: String
}
extend interface Mammal @deprecated(reason: "some reason") @skip(if: false) {
furType: String
age: Int
}
`, `
interface Mammal @deprecated(reason: "some reason") @skip(if: false) {
name: String
furType: String
age: Int
}
extend interface Mammal @deprecated(reason: "some reason") @skip(if: false) {
furType: String
age: Int
}
`)
})
t.Run("extend non existent interface", func(t *testing.T) {
run(extendInterfaceTypeDefinition, "", `
extend interface Entity { id: ID }
extend interface Mammal @deprecated(reason: "some reason") @skip(if: false) { name: String }
`, `
extend interface Entity { id: ID }
extend interface Mammal @deprecated(reason: "some reason") @skip(if: false) { name: String }
interface Entity { id: ID }
interface Mammal @deprecated(reason: "some reason") @skip(if: false) { name: String }
`)
})
} | explode_data.jsonl/78718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1321
} | [
2830,
3393,
72136,
5051,
929,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
25048,
4285,
3749,
943,
553,
2070,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
56742,
7,
25048,
5051,
929,
10398,
11,
1273,
10398,
11,
22074,
464,
58915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcile_OptionalWorkspacesOmitted(t *testing.T) {
names.TestingSeed()
ctx := context.Background()
cfg := config.NewStore(logtesting.TestLogger(t))
ctx = cfg.ToContext(ctx)
prs := []*v1beta1.PipelineRun{{
ObjectMeta: metav1.ObjectMeta{Name: "test-pipeline-run-success", Namespace: "foo"},
Spec: v1beta1.PipelineRunSpec{
ServiceAccountName: "test-sa",
PipelineSpec: &v1beta1.PipelineSpec{
Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{
Name: "optional-workspace",
Optional: true,
}},
Tasks: []v1beta1.PipelineTask{{
Name: "unit-test-1",
TaskSpec: &v1beta1.EmbeddedTask{TaskSpec: v1beta1.TaskSpec{
Workspaces: []v1beta1.WorkspaceDeclaration{{
Name: "ws",
Optional: true,
}},
Steps: []v1beta1.Step{{
Container: corev1.Container{
Image: "foo:latest",
},
}},
}},
Workspaces: []v1beta1.WorkspacePipelineTaskBinding{{
Name: "ws",
Workspace: "optional-workspace",
}},
}},
},
},
}}
// Unlike the tests above, we do *not* locally define our pipeline or unit-test task.
d := test.Data{
PipelineRuns: prs,
ServiceAccounts: []*corev1.ServiceAccount{{
ObjectMeta: metav1.ObjectMeta{Name: prs[0].Spec.ServiceAccountName, Namespace: "foo"},
}},
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-success", nil, false)
// Check that the expected TaskRun was created
actual := getTaskRunCreations(t, clients.Pipeline.Actions())[0]
expectedTaskRun := &v1beta1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pipeline-run-success-unit-test-1-9l9zj",
Namespace: "foo",
Annotations: map[string]string{},
Labels: map[string]string{
"tekton.dev/pipeline": "test-pipeline-run-success",
"tekton.dev/pipelineRun": "test-pipeline-run-success",
pipeline.PipelineTaskLabelKey: "unit-test-1",
pipeline.MemberOfLabelKey: v1beta1.PipelineTasks,
},
OwnerReferences: []metav1.OwnerReference{{
APIVersion: "tekton.dev/v1beta1",
Kind: "PipelineRun",
Name: "test-pipeline-run-success", Controller: &trueb,
BlockOwnerDeletion: &trueb,
}},
},
Spec: v1beta1.TaskRunSpec{
ServiceAccountName: "test-sa",
Resources: &v1beta1.TaskRunResources{},
Timeout: &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute},
TaskSpec: &v1beta1.TaskSpec{
Workspaces: []v1beta1.WorkspaceDeclaration{{
Name: "ws",
Optional: true,
}},
Steps: []v1beta1.Step{{
Container: corev1.Container{
Image: "foo:latest",
},
}},
},
},
}
if d := cmp.Diff(expectedTaskRun, actual, cmpopts.SortSlices(func(x, y v1beta1.TaskResourceBinding) bool { return x.Name < y.Name })); d != "" {
t.Errorf("expected to see TaskRun %v created. Diff %s", expectedTaskRun, diff.PrintWantGot(d))
}
// This PipelineRun is in progress now and the status should reflect that
condition := reconciledRun.Status.GetCondition(apis.ConditionSucceeded)
if condition == nil || condition.Status != corev1.ConditionUnknown {
t.Errorf("Expected PipelineRun status to be in progress, but was %v", condition)
}
if condition != nil && condition.Reason != v1beta1.PipelineRunReasonRunning.String() {
t.Errorf("Expected reason %q but was %s", v1beta1.PipelineRunReasonRunning.String(), condition.Reason)
}
if len(reconciledRun.Status.TaskRuns) != 1 {
t.Errorf("Expected PipelineRun status to include the TaskRun status item that ran immediately: %v", reconciledRun.Status.TaskRuns)
}
if _, exists := reconciledRun.Status.TaskRuns["test-pipeline-run-success-unit-test-1-9l9zj"]; !exists {
t.Errorf("Expected PipelineRun status to include TaskRun status but was %v", reconciledRun.Status.TaskRuns)
}
} | explode_data.jsonl/68307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1648
} | [
2830,
3393,
693,
40446,
457,
2232,
560,
278,
6776,
44285,
46,
5483,
1155,
353,
8840,
836,
8,
341,
93940,
8787,
287,
41471,
2822,
20985,
1669,
2266,
19047,
741,
50286,
1669,
2193,
7121,
6093,
12531,
8840,
8787,
7395,
1155,
1171,
20985,
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 TestLabelService_FindResourceLabels(t *testing.T) {
type fields struct {
LabelService influxdb.LabelService
}
type args struct {
filter influxdb.LabelMappingFilter
permissions []influxdb.Permission
}
type wants struct {
err error
labels []*influxdb.Label
}
tests := []struct {
name string
fields fields
args args
wants wants
}{
{
name: "authorized to see all labels belonging to a resource",
fields: fields{
LabelService: &mock.LabelService{
FindResourceLabelsFn: func(ctx context.Context, f influxdb.LabelMappingFilter) ([]*influxdb.Label, error) {
return []*influxdb.Label{
{
ID: 1,
OrgID: orgOneInfluxID,
},
{
ID: 2,
OrgID: orgOneInfluxID,
},
{
ID: 3,
OrgID: orgOneInfluxID,
},
}, nil
},
},
},
args: args{
filter: influxdb.LabelMappingFilter{
ResourceID: 10,
ResourceType: influxdb.BucketsResourceType,
},
permissions: []influxdb.Permission{
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.LabelsResourceType,
},
},
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.BucketsResourceType,
ID: influxdbtesting.IDPtr(10),
},
},
},
},
wants: wants{
err: nil,
labels: []*influxdb.Label{
{
ID: 1,
OrgID: orgOneInfluxID,
},
{
ID: 2,
OrgID: orgOneInfluxID,
},
{
ID: 3,
OrgID: orgOneInfluxID,
},
},
},
},
{
name: "authorized to access a single label",
fields: fields{
LabelService: &mock.LabelService{
FindResourceLabelsFn: func(ctx context.Context, f influxdb.LabelMappingFilter) ([]*influxdb.Label, error) {
return []*influxdb.Label{
{
ID: 1,
OrgID: orgOneInfluxID,
},
{
ID: 2,
OrgID: orgOneInfluxID,
},
{
ID: 3,
OrgID: orgOneInfluxID,
},
}, nil
},
},
},
args: args{
filter: influxdb.LabelMappingFilter{
ResourceID: 10,
ResourceType: influxdb.BucketsResourceType,
},
permissions: []influxdb.Permission{
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.LabelsResourceType,
ID: influxdbtesting.IDPtr(3),
},
},
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.BucketsResourceType,
ID: influxdbtesting.IDPtr(10),
},
},
},
},
wants: wants{
err: nil,
labels: []*influxdb.Label{
{
ID: 3,
OrgID: orgOneInfluxID,
},
},
},
},
{
name: "unable to access labels when missing read permission on labels",
fields: fields{
LabelService: &mock.LabelService{
FindResourceLabelsFn: func(ctx context.Context, f influxdb.LabelMappingFilter) ([]*influxdb.Label, error) {
return []*influxdb.Label{
{
ID: 1,
OrgID: orgOneInfluxID,
},
{
ID: 2,
OrgID: orgOneInfluxID,
},
{
ID: 3,
OrgID: orgOneInfluxID,
},
}, nil
},
},
},
args: args{
filter: influxdb.LabelMappingFilter{
ResourceID: 10,
ResourceType: influxdb.BucketsResourceType,
},
permissions: []influxdb.Permission{
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.BucketsResourceType,
ID: influxdbtesting.IDPtr(10),
},
},
},
},
wants: wants{
// fixme(leodido) > should we return error in this case?
},
},
{
name: "unable to access labels when missing read permission on filtering resource",
fields: fields{
LabelService: &mock.LabelService{
FindResourceLabelsFn: func(ctx context.Context, f influxdb.LabelMappingFilter) ([]*influxdb.Label, error) {
return []*influxdb.Label{
{
ID: 1,
OrgID: orgOneInfluxID,
},
{
ID: 2,
OrgID: orgOneInfluxID,
},
{
ID: 3,
OrgID: orgOneInfluxID,
},
}, nil
},
},
},
args: args{
filter: influxdb.LabelMappingFilter{
ResourceID: 10,
ResourceType: influxdb.BucketsResourceType,
},
permissions: []influxdb.Permission{
{
Action: influxdb.ReadAction,
Resource: influxdb.Resource{
Type: influxdb.LabelsResourceType,
},
},
},
},
wants: wants{
err: &errors.Error{
Msg: "read:orgs/020f755c3c083000/buckets/000000000000000a is unauthorized",
Code: errors.EUnauthorized,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := NewAuthedLabelService(tt.fields.LabelService, orgSvc)
ctx := context.Background()
ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions))
labels, err := s.FindResourceLabels(ctx, tt.args.filter)
influxdbtesting.ErrorsEqual(t, err, tt.wants.err)
if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" {
t.Errorf("labels are different -got/+want\ndiff %s", diff)
}
})
}
} | explode_data.jsonl/35728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2748
} | [
2830,
3393,
2476,
1860,
95245,
4783,
23674,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
82126,
1860,
52852,
1999,
4679,
1860,
198,
197,
532,
13158,
2827,
2036,
341,
197,
50108,
414,
52852,
1999,
4679,
6807,
5632,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestArtifactoryPublishRendersPropertiesGoTemplates(t *testing.T) {
const godelYML = `exclude:
names:
- "\\..+"
- "vendor"
paths:
- "godel"
`
pluginPath, err := products.Bin("dist-plugin")
require.NoError(t, err)
err = os.Setenv("TEST_ENV_VAR", "testValue")
require.NoError(t, err)
publishertester.RunAssetPublishTest(t,
pluginapitester.NewPluginProvider(pluginPath),
nil,
"artifactory",
[]publishertester.TestCase{
{
Name: "appends properties with env vars to publish URL",
Specs: []gofiles.GoFileSpec{
{
RelPath: "foo/foo.go",
Src: `package main; func main() {}`,
},
},
ConfigFiles: map[string]string{
"godel/config/godel.yml": godelYML,
"godel/config/dist-plugin.yml": `
products:
foo:
build:
main-pkg: ./foo
dist:
disters:
type: os-arch-bin
publish:
group-id: com.test.group
info:
artifactory:
config:
url: http://artifactory.domain.com
username: testUsername
password: testPassword
repository: testRepo
properties:
key1: value1
env-key: '{{ env "TEST_ENV_VAR" }}'
`,
},
Args: []string{
"--dry-run",
},
WantOutput: func(projectDir string) string {
return fmt.Sprintf(`[DRY RUN] Uploading out/dist/foo/1.0.0/os-arch-bin/foo-1.0.0-%s.tgz to http://artifactory.domain.com/artifactory/testRepo;env-key=testValue;key1=value1/com/test/group/foo/1.0.0/foo-1.0.0-%s.tgz
[DRY RUN] Uploading to http://artifactory.domain.com/artifactory/testRepo;env-key=testValue;key1=value1/com/test/group/foo/1.0.0/foo-1.0.0.pom
`, osarch.Current().String(), osarch.Current().String())
},
},
},
)
err = os.Unsetenv("TEST_ENV_VAR")
require.NoError(t, err)
} | explode_data.jsonl/63102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 883
} | [
2830,
3393,
9286,
333,
2919,
50145,
49,
14506,
7903,
10850,
51195,
1155,
353,
8840,
836,
8,
341,
4777,
342,
720,
56,
2668,
284,
1565,
32413,
510,
220,
5036,
510,
262,
481,
26468,
496,
10,
698,
262,
481,
330,
19213,
698,
220,
12716,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBingo(t *testing.T) {
input := `7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1
22 13 17 11 0
8 2 23 4 24
21 9 14 16 7
6 10 3 18 5
1 12 20 15 19
3 15 0 2 22
9 18 13 17 5
19 8 7 25 23
20 11 10 24 4
14 21 16 12 6
14 21 17 24 4
10 16 15 9 19
18 8 23 26 20
22 11 13 6 5
2 0 12 3 7`
got, err := PlayBingo(input)
want := NewBoard(2, dummyWg, dummyNumCh, dummyBingoCh, []string{
"14 21 17 24 4",
"10 16 15 9 19",
"18 8 23 26 20",
"22 11 13 6 5",
" 2 0 12 3 7",
})
if err != nil {
t.Fatal("Got an unexpected error: ", err)
}
if fmt.Sprint(got.raw) != fmt.Sprint(want.raw) {
t.Errorf("got %v, want %v", got.raw, want.raw)
}
if got.score != 4512 {
t.Errorf("got %v, want %v", got.score, 4512)
}
} | explode_data.jsonl/60986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
33,
27908,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
1565,
22,
11,
19,
11,
24,
11,
20,
11,
16,
16,
11,
16,
22,
11,
17,
18,
11,
17,
11,
15,
11,
16,
19,
11,
17,
16,
11,
17,
19,
11,
16,
15,
11,
16,
21,
11,
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... | 4 |
func TestIncomingDeck(t *testing.T) {
t.Parallel()
output := &bytes.Buffer{}
random := rand.New(rand.NewSource(1))
g, err := blackjack.NewBlackjackGame(
blackjack.WithOutput(output),
blackjack.WithDeckCount(3),
blackjack.WithRandom(random),
)
if err != nil {
t.Fatal(err)
}
want := g.Shoe
got := g.IncomingDeck()
if cmp.Equal(want, got, cmpopts.IgnoreUnexported(cards.Deck{})) {
t.Fatal(cmp.Diff(want, got))
}
} | explode_data.jsonl/5928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
97564,
39368,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
21170,
1669,
609,
9651,
22622,
16094,
83628,
1669,
10382,
7121,
37595,
7121,
3608,
7,
16,
4390,
3174,
11,
1848,
1669,
57262,
7121,
14417,
27134,
4868,
1006,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGDPRIgnoredIfZero(t *testing.T) {
rr := doPost(`{"gdpr":0,"bidders":["appnexus", "pubmatic"]}`, nil, false, nil)
assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8")
assert.Equal(t, http.StatusOK, rr.Code)
assert.ElementsMatch(t, []string{"appnexus", "pubmatic"}, parseSyncs(t, rr.Body.Bytes()))
assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes()))
} | explode_data.jsonl/21685 | {
"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,
38,
10298,
4305,
4905,
3018,
2679,
17999,
1155,
353,
8840,
836,
8,
341,
197,
634,
1669,
65156,
5809,
4913,
28584,
649,
788,
15,
1335,
65,
99129,
36799,
676,
77,
23666,
497,
330,
9585,
37244,
1341,
28350,
2092,
11,
895,
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 TestLoadTemplate(t *testing.T) {
// Setup ES
client := estest.GetTestingElasticsearch(t)
if err := client.Connect(); err != nil {
t.Fatal(err)
}
// Load template
absPath, err := filepath.Abs("../")
assert.NotNil(t, absPath)
assert.Nil(t, err)
fieldsPath := absPath + "/fields.yml"
index := "testbeat"
tmpl, err := New(version.GetDefaultVersion(), index, client.GetVersion(), TemplateConfig{})
assert.NoError(t, err)
content, err := tmpl.LoadFile(fieldsPath)
assert.NoError(t, err)
loader := &Loader{
client: client,
}
// Load template
err = loader.LoadTemplate(tmpl.GetName(), content)
assert.Nil(t, err)
// Make sure template was loaded
assert.True(t, loader.CheckTemplate(tmpl.GetName()))
// Delete template again to clean up
client.Request("DELETE", "/_template/"+tmpl.GetName(), "", nil, nil)
// Make sure it was removed
assert.False(t, loader.CheckTemplate(tmpl.GetName()))
} | explode_data.jsonl/63861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
5879,
7275,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
19287,
198,
25291,
1669,
1788,
477,
2234,
16451,
36,
51179,
1836,
1155,
340,
743,
1848,
1669,
2943,
43851,
2129,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClientGetTimeoutSuccessConcurrent(t *testing.T) {
t.Parallel()
s := startEchoServer(t, "tcp", "127.0.0.1:")
defer s.Stop()
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
testClientGetTimeoutSuccess(t, &defaultClient, "http://"+s.Addr(), 100)
}()
}
wg.Wait()
} | explode_data.jsonl/79362 | {
"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,
2959,
1949,
7636,
7188,
1109,
3231,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1903,
1669,
1191,
74994,
5475,
1155,
11,
330,
27161,
497,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
34403,
16867,
274,
30213,
2822... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIngestLoadRand(t *testing.T) {
mem := vfs.NewMem()
rng := rand.New(rand.NewSource(uint64(time.Now().UnixNano())))
cmp := DefaultComparer.Compare
randBytes := func(size int) []byte {
data := make([]byte, size)
for i := range data {
data[i] = byte(rng.Int() & 0xff)
}
return data
}
paths := make([]string, 1+rng.Intn(10))
pending := make([]FileNum, len(paths))
expected := make([]*fileMetadata, len(paths))
for i := range paths {
paths[i] = fmt.Sprint(i)
pending[i] = FileNum(rng.Int63())
expected[i] = &fileMetadata{
FileNum: pending[i],
}
func() {
f, err := mem.Create(paths[i])
require.NoError(t, err)
keys := make([]InternalKey, 1+rng.Intn(100))
for i := range keys {
keys[i] = base.MakeInternalKey(
randBytes(1+rng.Intn(10)),
0,
InternalKeyKindSet)
}
sort.Slice(keys, func(i, j int) bool {
return base.InternalCompare(cmp, keys[i], keys[j]) < 0
})
expected[i].Smallest = keys[0]
expected[i].Largest = keys[len(keys)-1]
w := sstable.NewWriter(f, sstable.WriterOptions{})
for i := range keys {
if i > 0 && base.InternalCompare(cmp, keys[i-1], keys[i]) == 0 {
// Duplicate key, ignore.
continue
}
w.Add(keys[i], nil)
}
require.NoError(t, w.Close())
meta, err := w.Metadata()
require.NoError(t, err)
expected[i].Size = meta.Size
}()
}
opts := &Options{
Comparer: DefaultComparer,
FS: mem,
}
meta, _, err := ingestLoad(opts, paths, 0, pending)
require.NoError(t, err)
for _, m := range meta {
m.CreationTime = 0
}
if diff := pretty.Diff(expected, meta); diff != nil {
t.Fatalf("%s", strings.Join(diff, "\n"))
}
} | explode_data.jsonl/40253 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 757
} | [
2830,
3393,
641,
6969,
5879,
56124,
1155,
353,
8840,
836,
8,
341,
14145,
1669,
92941,
7121,
18816,
741,
7000,
968,
1669,
10382,
7121,
37595,
7121,
3608,
8488,
21,
19,
9730,
13244,
1005,
55832,
83819,
60131,
1444,
1307,
1669,
7899,
31942,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPriorityQueue_AddUnschedulableIfNotPresent_Backoff(t *testing.T) {
q := NewTestQueue(context.Background(), newDefaultQueueSort(), WithClock(clock.NewFakeClock(time.Now())))
totalNum := 10
expectedPods := make([]v1.Pod, 0, totalNum)
for i := 0; i < totalNum; i++ {
priority := int32(i)
p := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("pod%d", i),
Namespace: fmt.Sprintf("ns%d", i),
UID: types.UID(fmt.Sprintf("upns%d", i)),
},
Spec: v1.PodSpec{
Priority: &priority,
},
}
expectedPods = append(expectedPods, p)
// priority is to make pods ordered in the PriorityQueue
q.Add(&p)
}
// Pop all pods except for the first one
for i := totalNum - 1; i > 0; i-- {
p, _ := q.Pop()
if !reflect.DeepEqual(&expectedPods[i], p.Pod) {
t.Errorf("Unexpected pod. Expected: %v, got: %v", &expectedPods[i], p)
}
}
// move all pods to active queue when we were trying to schedule them
q.MoveAllToActiveOrBackoffQueue(TestEvent, nil)
oldCycle := q.SchedulingCycle()
firstPod, _ := q.Pop()
if !reflect.DeepEqual(&expectedPods[0], firstPod.Pod) {
t.Errorf("Unexpected pod. Expected: %v, got: %v", &expectedPods[0], firstPod)
}
// mark pods[1] ~ pods[totalNum-1] as unschedulable and add them back
for i := 1; i < totalNum; i++ {
unschedulablePod := expectedPods[i].DeepCopy()
unschedulablePod.Status = v1.PodStatus{
Conditions: []v1.PodCondition{
{
Type: v1.PodScheduled,
Status: v1.ConditionFalse,
Reason: v1.PodReasonUnschedulable,
},
},
}
if err := q.AddUnschedulableIfNotPresent(newQueuedPodInfoForLookup(unschedulablePod), oldCycle); err != nil {
t.Errorf("Failed to call AddUnschedulableIfNotPresent(%v): %v", unschedulablePod.Name, err)
}
}
// Since there was a move request at the same cycle as "oldCycle", these pods
// should be in the backoff queue.
for i := 1; i < totalNum; i++ {
if _, exists, _ := q.podBackoffQ.Get(newQueuedPodInfoForLookup(&expectedPods[i])); !exists {
t.Errorf("Expected %v to be added to podBackoffQ.", expectedPods[i].Name)
}
}
} | explode_data.jsonl/68185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 875
} | [
2830,
3393,
20555,
7554,
21346,
1806,
72243,
360,
480,
2679,
2623,
21195,
64703,
1847,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1532,
2271,
7554,
5378,
19047,
1507,
501,
3675,
7554,
10231,
1507,
3085,
26104,
90911,
7121,
52317,
26104,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestUpdateDeploymentConfigOK(t *testing.T) {
mockRepositoryRegistry := test.NewDeploymentConfigRegistry()
storage := REST{registry: mockRepositoryRegistry}
channel, err := storage.Update(kapi.NewDefaultContext(), &api.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Name: "bar"},
})
if err != nil {
t.Errorf("Unexpected non-nil error: %#v", err)
}
result := <-channel
repo, ok := result.Object.(*api.DeploymentConfig)
if !ok {
t.Errorf("Expected DeploymentConfig, got %#v", result)
}
if repo.Name != "bar" {
t.Errorf("Unexpected repo returned: %#v", repo)
}
} | explode_data.jsonl/66992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
4289,
75286,
2648,
3925,
1155,
353,
8840,
836,
8,
341,
77333,
4624,
15603,
1669,
1273,
7121,
75286,
2648,
15603,
741,
197,
16172,
1669,
25414,
90,
29172,
25,
7860,
4624,
15603,
630,
71550,
11,
1848,
1669,
5819,
16689,
5969,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewCreateFormulaCmd(t *testing.T) {
cmd := NewCreateFormulaCmd(formCreator{}, inputTextMock{})
if cmd == nil {
t.Errorf("NewCreateFormulaCmd got %v", cmd)
}
if err := cmd.Execute(); err != nil {
t.Errorf("%s = %v, want %v", cmd.Use, err, nil)
}
} | explode_data.jsonl/78083 | {
"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,
3564,
4021,
52676,
15613,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
1532,
4021,
52676,
15613,
16760,
31865,
22655,
1946,
1178,
11571,
37790,
743,
5439,
621,
2092,
341,
197,
3244,
13080,
445,
3564,
4021,
52676,
15613,
2684,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOwnerNameAndID(t *testing.T) {
testCases := []struct {
cl *GerritCL
OwnerID int
OwnerName string
}{
{&GerritCL{}, -1, ""},
{&GerritCL{
Meta: &GitCommit{
Parents: []*GitCommit{
&GitCommit{
Author: &GitPerson{
Str: "Rick Sanchez <137@62eb7196-b449-3ce5-99f1-c037f21e1705>",
},
},
},
},
}, 137, "Rick Sanchez"},
}
for _, tc := range testCases {
if got := tc.cl.OwnerID(); got != tc.OwnerID {
t.Errorf("cl.OwnerID() = %d; want %d", got, tc.OwnerID)
}
if got := tc.cl.OwnerName(); got != tc.OwnerName {
t.Errorf("cl.OwnerName() = %q; want %q", got, tc.OwnerName)
}
}
} | explode_data.jsonl/66159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
13801,
675,
3036,
915,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
39407,
286,
353,
38,
615,
275,
3140,
198,
197,
197,
13801,
915,
256,
526,
198,
197,
197,
13801,
675,
914,
198,
197,
59403,
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... | 4 |
func TestDequeueMultiple(t *testing.T) {
goqueue_tests.DequeueMultiple(t, func(size int) interface {
goqueue.Owner
goqueue.Enqueuer
goqueue.Dequeuer
} {
return finite.New(size)
})
} | explode_data.jsonl/54504 | {
"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,
1912,
4584,
32089,
1155,
353,
8840,
836,
8,
341,
30680,
4584,
32509,
8934,
4584,
32089,
1155,
11,
2915,
6856,
526,
8,
3749,
341,
197,
30680,
4584,
49920,
198,
197,
30680,
4584,
22834,
591,
8801,
198,
197,
30680,
4584,
8934,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCorruptDB_Table(t *testing.T) {
h := newDbCorruptHarness(t)
defer h.close()
h.build(100)
h.compactMem()
h.compactRangeAt(0, "", "")
h.compactRangeAt(1, "", "")
h.closeDB()
h.corrupt(storage.TypeTable, -1, 100, 1)
h.openDB()
h.check(99, 99)
} | explode_data.jsonl/45791 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
10580,
6585,
3506,
42544,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
7994,
10580,
6585,
74248,
1155,
340,
16867,
305,
4653,
2822,
9598,
13239,
7,
16,
15,
15,
340,
9598,
39702,
531,
18816,
741,
9598,
39702,
531,
6046,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateMissingCAFileClusterInfo(t *testing.T) {
config := clientcmdapi.NewConfig()
config.Clusters["missing ca"] = &clientcmdapi.Cluster{
Server: "anything",
CertificateAuthority: "missing",
}
test := configValidationTest{
config: config,
expectedErrorSubstring: []string{"unable to read certificate-authority"},
}
test.testCluster("missing ca", t)
test.testConfig(t)
} | explode_data.jsonl/13491 | {
"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,
17926,
25080,
5049,
1703,
28678,
1731,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2943,
8710,
2068,
7121,
2648,
741,
25873,
21610,
14605,
1183,
30616,
2162,
1341,
284,
609,
2972,
8710,
2068,
72883,
515,
197,
92075,
25,
2290,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestZigzagTraverse(t *testing.T) {
t1 := &common.TreeNode{}
t2 := &common.TreeNode{nil, 1, nil}
t3 := &common.TreeNode{nil, 1, nil}
t3.Left = &common.TreeNode{nil, 2, nil}
t3.Left.Right = &common.TreeNode{nil, 3, nil}
t4 := &common.TreeNode{nil, 1, nil}
t4.Left = &common.TreeNode{nil, 2, nil}
t4.Right = &common.TreeNode{nil, 3, nil}
t5 := &common.TreeNode{nil, 1, nil}
t5.Left = &common.TreeNode{nil, 2, nil}
t5.Right = &common.TreeNode{nil, 3, nil}
t5.Left.Left = &common.TreeNode{nil, 4, nil}
t5.Right.Right = &common.TreeNode{nil, 5, nil}
tests := []struct {
in *common.TreeNode
expected [][]interface{}
}{
{t1, [][]interface{}{[]interface{}{0}}},
{t2, [][]interface{}{[]interface{}{1}}},
{t3, [][]interface{}{[]interface{}{1}, []interface{}{2}, []interface{}{3}}},
{t4, [][]interface{}{[]interface{}{1}, []interface{}{3, 2}}},
{t5, [][]interface{}{[]interface{}{1}, []interface{}{3, 2}, []interface{}{4, 5}}},
}
for _, tt := range tests {
common.Equal(
t,
tt.expected,
zigzagTraverse(tt.in),
)
}
} | explode_data.jsonl/58317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
57,
343,
92674,
1282,
22439,
1155,
353,
8840,
836,
8,
341,
3244,
16,
1669,
609,
5464,
836,
31583,
31483,
3244,
17,
1669,
609,
5464,
836,
31583,
90,
8385,
11,
220,
16,
11,
2092,
630,
3244,
18,
1669,
609,
5464,
836,
31583,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultiRequest(t *testing.T) {
s := marshalMultiRequest("createStorage", &CreateServerRequest{DataCenterId: "Id"})
Convey("serialize multi request", t, func() {
So(s, ShouldContainSubstring, "<tns:createStorage><request>")
})
} | explode_data.jsonl/22384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
20358,
1900,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
60771,
20358,
1900,
445,
3182,
5793,
497,
609,
4021,
5475,
1900,
90,
1043,
9392,
764,
25,
330,
764,
23625,
93070,
5617,
445,
24166,
7299,
1681,
497,
259,
11,
2915,
368... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParserTextmate(t *testing.T) {
p := newSnippetParser()
assertMarker(t, *p.parse("far{{}}boo", false, false), &text{})
assertMarker(t, *p.parse("far{{123}}boo", false, false), &text{})
assertMarker(t, *p.parse("far\\{{123}}boo", false, false), &text{})
assertMarker(t, *p.parse("far$0boo", false, false), &text{}, &placeholder{}, &text{})
assertMarker(t, *p.parse("far${123}boo", false, false), &text{}, &placeholder{}, &text{})
assertMarker(t, *p.parse("far\\${123}boo", false, false), &text{})
} | explode_data.jsonl/60279 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
6570,
1178,
18052,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
501,
87852,
6570,
741,
6948,
20613,
1155,
11,
353,
79,
4632,
445,
23559,
2979,
3417,
32993,
497,
895,
11,
895,
701,
609,
1318,
37790,
6948,
20613,
1155,
11,
353,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIngressLoadBalancing(t *testing.T) {
ctx := framework.NewContext(t)
defer ctx.Done()
ctx.RequireOrSkip(environment.Kube)
g := galley.NewOrFail(t, ctx, galley.Config{})
bookinfoNs, err := namespace.New(ctx, "istio-bookinfo", true)
if err != nil {
t.Fatalf("Could not create istio-bookinfo Namespace; err:%v", err)
}
d := bookinfo.DeployOrFail(t, ctx, bookinfo.Config{Namespace: bookinfoNs, Cfg: bookinfo.BookInfo})
g.ApplyConfigOrFail(
t,
d.Namespace(),
bookinfo.NetworkingBookinfoGateway.LoadGatewayFileWithNamespaceOrFail(t, bookinfoNs.Name()))
g.ApplyConfigOrFail(
t,
d.Namespace(),
bookinfo.GetDestinationRuleConfigFile(t, ctx).LoadWithNamespaceOrFail(t, bookinfoNs.Name()),
bookinfo.NetworkingVirtualServiceAllV1.LoadWithNamespaceOrFail(t, bookinfoNs.Name()),
)
prom := prometheus.NewOrFail(t, ctx)
ing := ingress.NewOrFail(t, ctx, ingress.Config{Istio: ist})
rangeStart := time.Now()
// Send traffic to ingress for the test duration.
wg := &sync.WaitGroup{}
wg.Add(numSendTasks + 1)
go logProgress(testDuration, wg)
for i := 0; i < numSendTasks; i++ {
go sendTraffic(testDuration, ing, wg)
}
wg.Wait()
rangeEnd := time.Now()
// Gather the CPU usage across all of the ingress gateways.
query := `sum(rate(container_cpu_usage_seconds_total{pod_name=~'istio-ingressgateway-.*'}[1m])) by (pod_name)`
v, err := prom.API().QueryRange(context.Background(), query, v1.Range{
Start: rangeStart,
End: rangeEnd,
Step: step,
})
if err != nil {
t.Fatal(err)
}
// Aggregate the per-CPU samples.
s := getCPUSamples(v, t)
// Calculate the ratio of the range to the median
rng := calcRange(s...)
med := calcMedian(s...)
ratio := rng / med
if ratio > threshold {
t.Fatalf("ratio %f > %f (range=%f, median=%f). CPU samples: %v", ratio, threshold, rng, med, s)
}
} | explode_data.jsonl/81868 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
641,
2483,
5879,
37889,
8974,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
12626,
7121,
1972,
1155,
340,
16867,
5635,
60422,
2822,
20985,
81288,
2195,
35134,
67591,
11352,
3760,
692,
3174,
1669,
15369,
3179,
7121,
46059,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestManifoldDataSource_CredentialBasic(t *testing.T) {
t.Run("with a filtered configuration", func(t *testing.T) {
conf := `
data "manifold_credential" "my-credential" {
project = "terraform"
resource = "custom-resource1-1"
key = "TOKEN_ID"
}
`
resource.Test(t, resource.TestCase{
PreCheck: testProviderPreCheck(t),
Providers: testProviders,
Steps: []resource.TestStep{
{
Config: conf,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.manifold_credential.my-credential", "id"),
resource.TestCheckResourceAttr("data.manifold_credential.my-credential", "project", "terraform"),
resource.TestCheckResourceAttr("data.manifold_credential.my-credential", "resource", "custom-resource1-1"),
testAccCheckManifoldCredential("data.manifold_credential.my-credential", "my-secret-token-id"),
),
},
},
})
})
t.Run("with a non existing key", func(t *testing.T) {
t.Run("with a default value", func(t *testing.T) {
conf := `
data "manifold_credential" "my-credential" {
project = "terraform"
resource = "custom-resource1-1"
key = "NON_EXISTING_FIELD"
default = "my-value"
}
`
resource.Test(t, resource.TestCase{
PreCheck: testProviderPreCheck(t),
Providers: testProviders,
Steps: []resource.TestStep{
{
Config: conf,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.manifold_credential.my-credential", "id"),
resource.TestCheckResourceAttr("data.manifold_credential.my-credential", "project", "terraform"),
resource.TestCheckResourceAttr("data.manifold_credential.my-credential", "resource", "custom-resource1-1"),
testAccCheckManifoldCredential("data.manifold_credential.my-credential", "my-value"),
),
},
},
})
})
})
} | explode_data.jsonl/53735 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 771
} | [
2830,
3393,
1658,
48285,
17173,
920,
30320,
15944,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4197,
264,
18293,
6546,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
67850,
1669,
22074,
691,
330,
1515,
48285,
666,
30320,
1,
330,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddIssueValueLabelErrs(t *testing.T) {
p := domain.Project{}
cucm, iucm, lucm, pucm, m := prepareMocksAndRUC()
pucm.On("FindByID", mock.AnythingOfType("uint")).Return(p, nil)
tests := []struct {
body *strings.Reader
err error
mockOn bool
}{
{
strings.NewReader("projectId=1&title=test-title&description=test-description&status=1&labels="),
errors.New("no labels assigned"),
false,
},
{
strings.NewReader("projectId=1&title=test-title&description=test-description&status=1&labels=test1,test2,test3"),
errors.New("label test1 is not valid"),
true,
},
}
for _, ts := range tests {
if ts.mockOn {
lucm.On("FindByName", mock.AnythingOfType("string")).Return(domain.Label{}, ts.err)
}
c, _ := prepareHTTP(echo.POST, "/api/issues/new", ts.body)
err := m.AddIssue(c)
assert.NotNil(t, err)
assert.Equal(t, ts.err.Error(), err.Error())
checkAssertions(t, cucm, iucm, lucm, pucm)
}
} | explode_data.jsonl/60159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 404
} | [
2830,
3393,
2212,
42006,
1130,
2476,
7747,
82,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
7947,
30944,
31483,
1444,
1754,
76,
11,
600,
1754,
76,
11,
25927,
76,
11,
281,
1754,
76,
11,
296,
1669,
10549,
72577,
3036,
49,
5459,
2822,
322... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetGroupConcatMaxLen(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
// Normal case
tk.MustExec("set global group_concat_max_len = 100")
tk.MustExec("set @@session.group_concat_max_len = 50")
result := tk.MustQuery("show global variables where variable_name='group_concat_max_len';")
result.Check(testkit.Rows("group_concat_max_len 100"))
result = tk.MustQuery("show session variables where variable_name='group_concat_max_len';")
result.Check(testkit.Rows("group_concat_max_len 50"))
result = tk.MustQuery("select @@group_concat_max_len;")
result.Check(testkit.Rows("50"))
result = tk.MustQuery("select @@global.group_concat_max_len;")
result.Check(testkit.Rows("100"))
result = tk.MustQuery("select @@session.group_concat_max_len;")
result.Check(testkit.Rows("50"))
tk.MustExec("set @@group_concat_max_len = 1024")
result = tk.MustQuery("select @@group_concat_max_len;")
result.Check(testkit.Rows("1024"))
result = tk.MustQuery("select @@global.group_concat_max_len;")
result.Check(testkit.Rows("100"))
result = tk.MustQuery("select @@session.group_concat_max_len;")
result.Check(testkit.Rows("1024"))
// Test value out of range
tk.MustExec("set @@group_concat_max_len=1")
tk.MustQuery("show warnings").Check(testkit.RowsWithSep("|", "Warning|1292|Truncated incorrect group_concat_max_len value: '1'"))
result = tk.MustQuery("select @@group_concat_max_len;")
result.Check(testkit.Rows("4"))
_, err := tk.Exec("set @@group_concat_max_len = 18446744073709551616")
require.True(t, terror.ErrorEqual(err, variable.ErrWrongTypeForVar), fmt.Sprintf("err %v", err))
// Test illegal type
_, err = tk.Exec("set @@group_concat_max_len='hello'")
require.True(t, terror.ErrorEqual(err, variable.ErrWrongTypeForVar), fmt.Sprintf("err %v", err))
} | explode_data.jsonl/5722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 710
} | [
2830,
3393,
1649,
2808,
78440,
5974,
11271,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate_KnownTypeNames_IgnoresTypeDefinitions(t *testing.T) {
testutil.ExpectFailsRule(t, graphql.KnownTypeNamesRule, `
type NotInTheSchema {
field: FooBar
}
interface FooBar {
field: NotInTheSchema
}
union U = A | B
input Blob {
field: UnknownType
}
query Foo($var: NotInTheSchema) {
user(id: $var) {
id
}
}
`, []gqlerrors.FormattedError{
testutil.RuleError(`Unknown type "NotInTheSchema".`, 12, 23),
})
} | explode_data.jsonl/59084 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 255
} | [
2830,
3393,
17926,
10102,
4169,
929,
7980,
7959,
70,
2152,
416,
929,
50542,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
81893,
37,
6209,
11337,
1155,
11,
48865,
11352,
4169,
929,
7980,
11337,
11,
22074,
414,
943,
2806,
86093,
8632,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExtractNamespaceLabelsAnnotations(t *testing.T) {
c, _ := newTestClientWithRulesAndFilters(t, ExtractionRules{}, Filters{})
testCases := []struct {
name string
shouldExtractNamespace bool
rules ExtractionRules
}{{
name: "empty-rules",
shouldExtractNamespace: false,
rules: ExtractionRules{},
}, {
name: "pod-rules",
shouldExtractNamespace: false,
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "a1",
Key: "annotation1",
From: MetadataFromPod,
},
},
Labels: []FieldExtractionRule{{
Name: "l1",
Key: "label1",
From: MetadataFromPod,
},
},
},
}, {
name: "namespace-rules-only-annotations",
shouldExtractNamespace: true,
rules: ExtractionRules{
Annotations: []FieldExtractionRule{{
Name: "a1",
Key: "annotation1",
From: MetadataFromNamespace,
},
},
},
}, {
name: "namespace-rules-only-labels",
shouldExtractNamespace: true,
rules: ExtractionRules{
Labels: []FieldExtractionRule{{
Name: "l1",
Key: "label1",
From: MetadataFromNamespace,
},
},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
c.Rules = tc.rules
assert.Equal(t, tc.shouldExtractNamespace, c.extractNamespaceLabelsAnnotations())
})
}
} | explode_data.jsonl/56860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 683
} | [
2830,
3393,
28959,
22699,
23674,
21418,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
501,
2271,
2959,
2354,
26008,
3036,
28351,
1155,
11,
94506,
26008,
22655,
45012,
37790,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
4293,
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 TestReadOrientation(t *testing.T) {
testCases := []struct {
path string
orient orientation
}{
{"testdata/orientation_0.jpg", 0},
{"testdata/orientation_1.jpg", 1},
{"testdata/orientation_2.jpg", 2},
{"testdata/orientation_3.jpg", 3},
{"testdata/orientation_4.jpg", 4},
{"testdata/orientation_5.jpg", 5},
{"testdata/orientation_6.jpg", 6},
{"testdata/orientation_7.jpg", 7},
{"testdata/orientation_8.jpg", 8},
}
for _, tc := range testCases {
f, err := os.Open(tc.path)
if err != nil {
t.Fatalf("%q: failed to open: %v", tc.path, err)
}
orient := readOrientation(f)
if orient != tc.orient {
t.Fatalf("%q: got orientation %d want %d", tc.path, orient, tc.orient)
}
}
} | explode_data.jsonl/2436 | {
"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,
4418,
22332,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
26781,
256,
914,
198,
197,
197,
14881,
16725,
198,
197,
59403,
197,
197,
4913,
92425,
5144,
1167,
367,
62,
15,
4819,
497,
220,
15,
1583,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgMsgBurnNFTValidateBasicMethod(t *testing.T) {
newMsgBurnNFT := types.NewMsgBurnNFT("", id, denom)
err := newMsgBurnNFT.ValidateBasic()
require.Error(t, err)
newMsgBurnNFT = types.NewMsgBurnNFT(address.String(), "", denom)
err = newMsgBurnNFT.ValidateBasic()
require.Error(t, err)
newMsgBurnNFT = types.NewMsgBurnNFT(address.String(), id, "")
err = newMsgBurnNFT.ValidateBasic()
require.Error(t, err)
newMsgBurnNFT = types.NewMsgBurnNFT(address.String(), id, denom)
err = newMsgBurnNFT.ValidateBasic()
require.NoError(t, err)
} | explode_data.jsonl/28178 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
6611,
6611,
66213,
45,
3994,
17926,
15944,
3523,
1155,
353,
8840,
836,
8,
341,
8638,
6611,
66213,
45,
3994,
1669,
4494,
7121,
6611,
66213,
45,
3994,
19814,
877,
11,
49744,
340,
9859,
1669,
501,
6611,
66213,
45,
3994,
47667,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsContextNotFound(t *testing.T) {
config := clientcmdapi.NewConfig()
config.CurrentContext = "anything"
err := Validate(*config)
if !IsContextNotFound(err) {
t.Errorf("Expected context not found, but got %v", err)
}
if !IsConfigurationInvalid(err) {
t.Errorf("Expected configuration invalid, but got %v", err)
}
} | explode_data.jsonl/13485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 116
} | [
2830,
3393,
3872,
1972,
10372,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2943,
8710,
2068,
7121,
2648,
741,
25873,
11517,
1972,
284,
330,
72154,
1837,
9859,
1669,
23282,
4071,
1676,
340,
743,
753,
3872,
1972,
10372,
3964,
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... | 3 |
func TestRedelegateSelfDelegation(t *testing.T) {
_, app, ctx := createTestInput()
addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0))
addrVals := simapp.ConvertAddrsToValAddrs(addrDels)
startTokens := sdk.TokensFromConsensusPower(30)
startCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), startTokens))
// add bonded tokens to pool for delegations
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
oldNotBonded := app.BankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress())
err := app.BankKeeper.SetBalances(ctx, notBondedPool.GetAddress(), oldNotBonded.Add(startCoins...))
require.NoError(t, err)
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
//create a validator with a self-delegation
validator := types.NewValidator(addrVals[0], PKs[0], types.Description{})
app.StakingKeeper.SetValidatorByConsAddr(ctx, validator)
valTokens := sdk.TokensFromConsensusPower(10)
validator, issuedShares := validator.AddTokensFromDel(valTokens)
require.Equal(t, valTokens, issuedShares.RoundInt())
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
val0AccAddr := sdk.AccAddress(addrVals[0])
selfDelegation := types.NewDelegation(val0AccAddr, addrVals[0], issuedShares)
app.StakingKeeper.SetDelegation(ctx, selfDelegation)
// create a second validator
validator2 := types.NewValidator(addrVals[1], PKs[1], types.Description{})
validator2, issuedShares = validator2.AddTokensFromDel(valTokens)
require.Equal(t, valTokens, issuedShares.RoundInt())
validator2 = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator2, true)
require.Equal(t, types.Bonded, validator2.Status)
// create a second delegation to validator 1
delTokens := sdk.TokensFromConsensusPower(10)
validator, issuedShares = validator.AddTokensFromDel(delTokens)
require.Equal(t, delTokens, issuedShares.RoundInt())
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares)
app.StakingKeeper.SetDelegation(ctx, delegation)
_, err = app.StakingKeeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], delTokens.ToDec())
require.NoError(t, err)
// end block
updates := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
require.Equal(t, 2, len(updates))
validator, found := app.StakingKeeper.GetValidator(ctx, addrVals[0])
require.True(t, found)
require.Equal(t, valTokens, validator.Tokens)
require.Equal(t, types.Unbonding, validator.Status)
} | explode_data.jsonl/82055 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 919
} | [
2830,
3393,
6033,
68,
4989,
12092,
1912,
87566,
1155,
353,
8840,
836,
8,
341,
197,
6878,
906,
11,
5635,
1669,
1855,
2271,
2505,
2822,
53183,
35,
2010,
1669,
1643,
676,
1904,
2271,
2212,
5428,
38311,
278,
11462,
11,
5635,
11,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSaveAndRetrieveStartTime_HandlesDifferentTimeZones(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
loc, err := time.LoadLocation("Asia/Shanghai")
assert.NoError(t, err)
now := time.Now().UTC()
leasedJob := addLeasedJob(t, r, "queue1", "cluster1")
startTime := now.In(loc)
jobErrors, err := r.UpdateStartTime([]*JobStartInfo{{
JobId: leasedJob.Id,
ClusterId: "cluster1",
StartTime: startTime,
}})
AssertUpdateStartTimeNoErrors(t, jobErrors, err)
runInfos, err := r.GetJobRunInfos([]string{leasedJob.Id})
assert.NoError(t, err)
diff := runInfos[leasedJob.Id].StartTime.Sub(now).Seconds()
diff = math.Abs(diff)
assert.Len(t, runInfos, 1)
assert.True(t, diff < float64(1))
})
} | explode_data.jsonl/32058 | {
"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,
8784,
3036,
87665,
40203,
2039,
20125,
69123,
1462,
57,
3154,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
71128,
11,
1848,
1669,
882,
13969,
4707,
445,
38463,
76202,
30070,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestModificationTime(t *testing.T) {
fs := NewFileStat()
fs.Log = testutil.Logger{}
fs.Files = []string{
filepath.Join(testdataDir, "log1.log"),
}
acc := testutil.Accumulator{}
acc.GatherError(fs.Gather)
tags1 := map[string]string{
"file": filepath.Join(testdataDir, "log1.log"),
}
require.True(t, acc.HasPoint("filestat", tags1, "size_bytes", int64(0)))
require.True(t, acc.HasPoint("filestat", tags1, "exists", int64(1)))
require.True(t, acc.HasInt64Field("filestat", "modification_time"))
} | explode_data.jsonl/59621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
80795,
1462,
1155,
353,
8840,
836,
8,
341,
53584,
1669,
1532,
1703,
15878,
741,
53584,
5247,
284,
1273,
1314,
12750,
16094,
53584,
52009,
284,
3056,
917,
515,
197,
17661,
2343,
22363,
8623,
691,
6184,
11,
330,
839,
16,
1665,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFloat32_IsSuperset(t *testing.T) {
testcases := []struct {
name string
s Float32
t Float32
expect bool
}{
{
name: "test Float32 IsSuperset, s is empty",
s: Float32{},
t: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
expect: false,
},
{
name: "test Float32 IsSuperset, s is empty",
s: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
t: Float32{},
expect: true,
},
{
name: "test Float32 IsSuperset, s ⊂ s",
s: map[float32]struct{}{2: {}, 1.3: {}},
t: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
expect: false,
},
{
name: "test Float32 IsSuperset, s ⊃ s",
s: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
t: map[float32]struct{}{2: {}, 1.3: {}},
expect: true,
},
{
name: "test Float32 IsSuperset, s = s",
s: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
t: map[float32]struct{}{2: {}, 1.3: {}, 4.1: {}},
expect: true,
},
{
name: "test Float32 IsSuperset, s ∩ s = Ø",
s: map[float32]struct{}{1: {}, 4.1: {}},
t: map[float32]struct{}{2: {}, 6.0: {}},
expect: false,
},
{
name: "test Float32 IsSuperset, s ∩ s ≠ Ø && s ∩ s ≠ s",
s: map[float32]struct{}{1: {}, 4.1: {}},
t: map[float32]struct{}{1: {}, 6.0: {}},
expect: false,
},
}
for _, tc := range testcases {
t.Logf("running scenario: %s", tc.name)
actual := tc.s.IsSuperset(tc.t)
if actual != tc.expect {
t.Errorf("expect retrun: %v, but got: %v", tc.expect, actual)
}
}
} | explode_data.jsonl/60119 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 864
} | [
2830,
3393,
5442,
18,
17,
31879,
10048,
44146,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
1903,
414,
13001,
18,
17,
198,
197,
3244,
414,
13001,
18,
17,
198,
197,
24952,
1807,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSelectStatement_HasWildcard(t *testing.T) {
var tests = []struct {
stmt string
wildcard bool
}{
// No wildcards
{
stmt: `SELECT value FROM cpu`,
wildcard: false,
},
// Query wildcard
{
stmt: `SELECT * FROM cpu`,
wildcard: true,
},
// No GROUP BY wildcards
{
stmt: `SELECT value FROM cpu GROUP BY host`,
wildcard: false,
},
// No GROUP BY wildcards, time only
{
stmt: `SELECT mean(value) FROM cpu where time < now() GROUP BY time(5ms)`,
wildcard: false,
},
// GROUP BY wildcard
{
stmt: `SELECT value FROM cpu GROUP BY *`,
wildcard: true,
},
// GROUP BY wildcard with time
{
stmt: `SELECT mean(value) FROM cpu where time < now() GROUP BY *,time(1m)`,
wildcard: true,
},
// GROUP BY wildcard with explicit
{
stmt: `SELECT value FROM cpu GROUP BY *,host`,
wildcard: true,
},
// GROUP BY multiple wildcards
{
stmt: `SELECT value FROM cpu GROUP BY *,*`,
wildcard: true,
},
// Combo
{
stmt: `SELECT * FROM cpu GROUP BY *`,
wildcard: true,
},
}
for i, tt := range tests {
// Parse statement.
stmt, err := influxql.NewParser(strings.NewReader(tt.stmt)).ParseStatement()
if err != nil {
t.Fatalf("invalid statement: %q: %s", tt.stmt, err)
}
// Test wildcard detection.
if w := stmt.(*influxql.SelectStatement).HasWildcard(); tt.wildcard != w {
t.Errorf("%d. %q: unexpected wildcard detection:\n\nexp=%v\n\ngot=%v\n\n", i, tt.stmt, tt.wildcard, w)
continue
}
}
} | explode_data.jsonl/24808 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 674
} | [
2830,
3393,
3379,
8636,
2039,
300,
92988,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
55822,
257,
914,
198,
197,
6692,
695,
4951,
1807,
198,
197,
59403,
197,
197,
322,
2308,
8380,
25024,
198,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestExplain(t *testing.T) {
type test struct {
name string
opts *Options
}
tests := []test{
{"unsharded", defaultTestOpts()},
{"selectsharded", defaultTestOpts()},
{"insertsharded", defaultTestOpts()},
{"updatesharded", defaultTestOpts()},
{"deletesharded", defaultTestOpts()},
{"comments", defaultTestOpts()},
{"options", &Options{
ReplicationMode: "STATEMENT",
NumShards: 4,
Normalize: false,
}},
{"target", &Options{
ReplicationMode: "ROW",
NumShards: 4,
Normalize: false,
Target: "ks_sharded/40-80",
}},
}
for _, tst := range tests {
testExplain(tst.name, tst.opts, t)
}
} | explode_data.jsonl/12768 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
840,
20772,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
2036,
341,
197,
11609,
914,
198,
197,
64734,
353,
3798,
198,
197,
532,
78216,
1669,
3056,
1944,
515,
197,
197,
4913,
359,
927,
20958,
497,
1638,
2271,
43451,
78108,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidatePortName(t *testing.T) {
testCases := []struct {
name string
valid bool
}{
{
name: "",
valid: false,
},
{
name: "simple",
valid: true,
},
{
name: "full",
valid: true,
},
{
name: "toolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolongtoolong",
valid: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if err := validatePortName(tc.name); (err == nil) != tc.valid {
t.Fatalf("got valid=%v but wanted valid=%v: %v", err == nil, tc.valid, err)
}
})
}
} | explode_data.jsonl/56916 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
17926,
7084,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
220,
8324,
298,
56322,
25,
895,
345,
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 TestPatchOptionReturnsForbidden(t *testing.T) {
t.Parallel()
Convey("Patch dimension option of a published instance returns forbidden", t, func() {
body := strings.NewReader(`[
{"op": "add", "path": "/order", "value": 0},
{"op": "add", "path": "/node_id", "value": "11"}
]`)
r, err := createRequestWithToken(http.MethodPatch, "http://localhost:21800/instances/123/dimensions/age/options/55", body)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
mockedDataStore := &storetest.StorerMock{
GetInstanceFunc: func(ctx context.Context, ID string, eTagSelector string) (*models.Instance, error) {
return &models.Instance{State: models.PublishedState}, nil
},
}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
datasetAPI.Router.ServeHTTP(w, r)
So(w.Code, ShouldEqual, http.StatusForbidden)
So(mockedDataStore.GetInstanceCalls(), ShouldHaveLength, 1)
})
} | explode_data.jsonl/20831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
43622,
5341,
16446,
69115,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
93070,
5617,
445,
43622,
12871,
2999,
315,
264,
4652,
2867,
4675,
36813,
497,
259,
11,
2915,
368,
341,
197,
35402,
1669,
9069,
68587,
5809,
964... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewReadLogsCommandWriteLinesWithDelay(t *testing.T) {
lines1 := []string{"1", "2", "3"}
lines2 := []string{"4", "5", "6"}
f, cleanup := setupTestFile(t)
defer cleanup()
appendToFile(t, f, lines1)
cmd := newReadLogsCommand()
mockLogOutputWriter := new(mockLogOutputWriter)
defer mockLogOutputWriter.AssertExpectations(t)
offset, wg := setupMockLogOutputWriterFromLines(mockLogOutputWriter, lines1, 0)
cmd.logOutputWriter = mockLogOutputWriter
mockLogStreamProvider := new(mockLogStreamProvider)
defer mockLogStreamProvider.AssertExpectations(t)
mockLogStreamProvider.On("Open").Return(f, nil)
cmd.logStreamProvider = mockLogStreamProvider
go func() {
wg.Wait()
time.Sleep(5 * time.Second)
_, wg = setupMockLogOutputWriterFromLines(mockLogOutputWriter, lines2, offset)
appendToFile(t, f, lines2)
wg.Wait()
_ = f.Close()
}()
err := cmd.readLogs()
var expectedErr *os.PathError
assert.ErrorAs(t, err, &expectedErr)
} | explode_data.jsonl/3428 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 360
} | [
2830,
3393,
3564,
4418,
51053,
4062,
7985,
16794,
2354,
20039,
1155,
353,
8840,
836,
8,
341,
78390,
16,
1669,
3056,
917,
4913,
16,
497,
330,
17,
497,
330,
18,
16707,
78390,
17,
1669,
3056,
917,
4913,
19,
497,
330,
20,
497,
330,
21,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBlobClientStat(t *testing.T) {
localNodeID := roachpb.NodeID(1)
remoteNodeID := roachpb.NodeID(2)
localExternalDir, remoteExternalDir, stopper, cleanUpFn := createTestResources(t)
defer cleanUpFn()
clock := hlc.NewClock(hlc.UnixNano, time.Nanosecond)
rpcContext := rpc.NewInsecureTestingContext(clock, stopper)
rpcContext.TestingAllowNamedRPCToAnonymousServer = true
blobClientFactory := setUpService(t, rpcContext, localNodeID, remoteNodeID, localExternalDir, remoteExternalDir)
localFileContent := []byte("local_file")
remoteFileContent := []byte("remote_file")
writeTestFile(t, filepath.Join(localExternalDir, "test/local.csv"), localFileContent)
writeTestFile(t, filepath.Join(remoteExternalDir, "test/remote.csv"), remoteFileContent)
for _, tc := range []struct {
name string
nodeID roachpb.NodeID
filename string
expectedSize int64
err string
}{
{
"stat-remote-file",
remoteNodeID,
"test/remote.csv",
int64(len(remoteFileContent)),
"",
},
{
"stat-local-file",
localNodeID,
"test/local.csv",
int64(len(localFileContent)),
"",
},
{
"stat-remote-file-does-not-exist",
remoteNodeID,
"test/doesnotexist",
0,
"no such file",
},
{
"stat-directory",
remoteNodeID,
"test",
0,
"is a directory",
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := context.TODO()
blobClient, err := blobClientFactory(ctx, tc.nodeID)
if err != nil {
t.Fatal(err)
}
resp, err := blobClient.Stat(ctx, tc.filename)
if err != nil {
if testutils.IsError(err, tc.err) {
// the correct error was returned
return
}
t.Fatal(err)
}
if resp.Filesize != tc.expectedSize {
t.Fatalf("expected size: %d got: %d", tc.expectedSize, resp)
}
})
}
} | explode_data.jsonl/82494 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 775
} | [
2830,
3393,
37985,
2959,
15878,
1155,
353,
8840,
836,
8,
341,
8854,
1955,
915,
1669,
926,
610,
16650,
21714,
915,
7,
16,
340,
197,
18147,
1955,
915,
1669,
926,
610,
16650,
21714,
915,
7,
17,
340,
8854,
25913,
6184,
11,
8699,
25913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConvertToUnix(t *testing.T) {
tests := []struct {
name string
str string
now bool
want int64
wantErr bool
}{
{
name: "RFC3339",
str: "2018-05-10T15:04:00Z",
want: 1525964640,
},
{
name: "0 value",
str: "0",
now: true,
},
{
name: "now value",
str: "now",
now: true,
},
{
name: "unknown value",
str: "3:04PM",
wantErr: true,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got, err := ConvertToUnix(tc.str)
if (err != nil) != tc.wantErr {
t.Errorf("ConvertToUnix() error = %v, wantErr %v", err, tc.wantErr)
return
}
if tc.now {
// Remove the last two digits of the unix timestamp when comparing the
// current timestamp, in case the test took more than 1 second (i.e.
// 1526399179 vs 1526399180)
if time.Now().Unix()/100 != got/100 {
t.Errorf("ConvertToUnix() = %v, want ~ %v", got, time.Now().Unix())
return
}
return
}
if got != tc.want {
t.Errorf("ConvertToUnix() = %v, want %v", got, tc.want)
}
})
}
} | explode_data.jsonl/31985 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 546
} | [
2830,
3393,
12012,
1249,
55832,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
11355,
257,
914,
198,
197,
80922,
257,
1807,
198,
197,
50780,
262,
526,
21,
19,
198,
197,
50780,
7747,
1807,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestShorten(t *testing.T) {
t.Run(
"shortening and expanding",
func(t *testing.T) {
go run()
// shorten
var body = Body{
Body: "http://www.apple.com",
}
req, err := json.Marshal(body)
require.Nil(t, err)
var dest = "http://" + addr + "/s"
res, err := http.Post(dest, "application/json", bytes.NewReader(req))
require.Nil(t, err)
require.Equal(t, http.StatusOK, res.StatusCode)
// expand
b, err := ioutil.ReadAll(res.Body)
require.Nil(t, err)
var s = Body{}
err = json.Unmarshal(b, &s)
require.Nil(t, err)
res, err = http.Get(s.Body)
require.Nil(t, err)
require.Equal(t, http.StatusOK, res.StatusCode)
},
)
} | explode_data.jsonl/81875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
12472,
268,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
1006,
197,
197,
1,
8676,
6019,
323,
23175,
756,
197,
29244,
1155,
353,
8840,
836,
8,
341,
298,
30680,
1598,
741,
298,
197,
322,
73381,
198,
298,
2405,
2487,
284,
139... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuildHostNamesForCompositeDependency(t *testing.T) {
dependencyInst := "mydep"
components := []v1alpha2.Component{
{
ObjectMeta: metav1.ObjectMeta{
Name: "mycomponent1",
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "mycomponent2",
},
},
}
expected := []string{
"mydep--mycomponent1-service",
"mydep--mycomponent2-service",
}
actual := BuildHostNamesForCompositeDependency(dependencyInst, components)
if diff := cmp.Diff(expected, actual); diff != "" {
t.Errorf("BuildHostNamesForCompositeDependency (-expected, +actual)\n%v", diff)
}
} | explode_data.jsonl/54866 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
11066,
9296,
7980,
2461,
41685,
36387,
1155,
353,
8840,
836,
8,
341,
197,
53690,
8724,
1669,
330,
2408,
14891,
698,
197,
5149,
1669,
3056,
85,
16,
7141,
17,
5119,
515,
197,
197,
515,
298,
23816,
12175,
25,
77520,
16,
80222... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewMeasurement(t *testing.T) {
want := &Measurement{
Host: "google.de",
Port: 443,
Timeout: 5,
Runs: 5,
Wait: 1,
}
got := NewMeasurement("google.de", 443, 5, 5, 1)
if want.Host != got.Host {
t.Fatalf("want: %s, got %s", want.Host, got.Host)
}
if want.Port != got.Port {
t.Fatalf("want: %d, got %d", want.Port, got.Port)
}
if want.Timeout != got.Timeout {
t.Fatalf("want: %d, got %d", want.Timeout, got.Timeout)
}
if want.Runs != got.Runs {
t.Fatalf("want: %d, got %d", want.Runs, got.Runs)
}
if want.Wait != got.Wait {
t.Fatalf("want: %d, got %d", want.Wait, got.Wait)
}
} | explode_data.jsonl/2462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
3564,
76548,
1155,
353,
8840,
836,
8,
341,
50780,
1669,
609,
76548,
515,
197,
197,
9296,
25,
262,
330,
17485,
2285,
756,
197,
98459,
25,
262,
220,
19,
19,
18,
345,
197,
197,
7636,
25,
220,
20,
345,
197,
197,
73920,
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... | 6 |
func TestIsError(t *testing.T) {
tests := []struct {
err error
code waddrmgr.ErrorCode
exp bool
}{
{
err: waddrmgr.ManagerError{
ErrorCode: waddrmgr.ErrDatabase,
},
code: waddrmgr.ErrDatabase,
exp: true,
},
{
// package should never return *ManagerError
err: &waddrmgr.ManagerError{
ErrorCode: waddrmgr.ErrDatabase,
},
code: waddrmgr.ErrDatabase,
exp: false,
},
{
err: waddrmgr.ManagerError{
ErrorCode: waddrmgr.ErrCrypto,
},
code: waddrmgr.ErrDatabase,
exp: false,
},
{
err: errors.New("not a ManagerError"),
code: waddrmgr.ErrDatabase,
exp: false,
},
}
for i, test := range tests {
got := waddrmgr.IsError(test.err, test.code)
if got != test.exp {
t.Errorf("Test %d: got %v expected %v", i, got, test.exp)
}
}
} | explode_data.jsonl/67914 | {
"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,
3872,
1454,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
9859,
220,
1465,
198,
197,
43343,
289,
6214,
48292,
98433,
198,
197,
48558,
220,
1807,
198,
197,
59403,
197,
197,
515,
298,
9859,
25,
289,
6214,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.