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 TestNewRunCommandCompletion(t *testing.T) {
var scripts []string
f := newFakeKoolRun([]builder.Command{}, nil)
f.parser.(*parser.FakeParser).MockScripts = []string{"testing_script"}
cmd := NewRunCommand(f)
scripts, _ = cmd.ValidArgsFunction(cmd, []string{}, "")
if len(scripts) != 1 || scripts[0] != "testing_script" {
t.Errorf("expecting suggestions [testing_script], got %v", scripts)
}
scripts, _ = cmd.ValidArgsFunction(cmd, []string{}, "tes")
if len(scripts) != 1 || scripts[0] != "testing_script" {
t.Errorf("expecting suggestions [testing_script], got %v", scripts)
}
scripts, _ = cmd.ValidArgsFunction(cmd, []string{}, "invalid")
if len(scripts) != 0 {
t.Errorf("expecting no suggestion, got %v", scripts)
}
scripts, _ = cmd.ValidArgsFunction(cmd, []string{"testing_script"}, "")
if scripts != nil {
t.Errorf("expecting no suggestion, got %v", scripts)
}
} | explode_data.jsonl/60861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
3564,
6727,
4062,
33190,
1155,
353,
8840,
836,
8,
341,
2405,
19502,
3056,
917,
198,
1166,
1669,
501,
52317,
42,
1749,
6727,
10556,
17850,
12714,
22655,
2092,
340,
1166,
25617,
41399,
9657,
991,
726,
6570,
568,
11571,
44942,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransferLeaseToLaggingNode(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
ctx := context.Background()
clusterArgs := base.TestClusterArgs{
ServerArgsPerNode: map[int]base.TestServerArgs{
0: {
ScanMaxIdleTime: time.Millisecond,
StoreSpecs: []base.StoreSpec{{
InMemory: true, Attributes: roachpb.Attributes{Attrs: []string{"n1"}},
}},
},
1: {
ScanMaxIdleTime: time.Millisecond,
StoreSpecs: []base.StoreSpec{{
InMemory: true, Attributes: roachpb.Attributes{Attrs: []string{"n2"}},
}},
},
2: {
ScanMaxIdleTime: time.Millisecond,
StoreSpecs: []base.StoreSpec{{
InMemory: true, Attributes: roachpb.Attributes{Attrs: []string{"n3"}},
}},
},
},
}
tc := testcluster.StartTestCluster(t,
len(clusterArgs.ServerArgsPerNode), clusterArgs)
defer tc.Stopper().Stop(ctx)
if err := tc.WaitForFullReplication(); err != nil {
t.Fatal(err)
}
// Get the system.comments' range and lease holder
var rangeID roachpb.RangeID
var leaseHolderNodeID uint64
s := sqlutils.MakeSQLRunner(tc.Conns[0])
s.Exec(t, "insert into system.comments values(0,0,0,'abc')")
s.QueryRow(t,
"select range_id, lease_holder from "+
"[show ranges from table system.comments] limit 1",
).Scan(&rangeID, &leaseHolderNodeID)
remoteNodeID := uint64(1)
if leaseHolderNodeID == 1 {
remoteNodeID = 2
}
log.Infof(ctx, "RangeID %d, RemoteNodeID %d, LeaseHolderNodeID %d",
rangeID, remoteNodeID, leaseHolderNodeID)
leaseHolderSrv := tc.Servers[leaseHolderNodeID-1]
leaseHolderStoreID := leaseHolderSrv.GetFirstStoreID()
leaseHolderStore, err := leaseHolderSrv.Stores().GetStore(leaseHolderStoreID)
if err != nil {
t.Fatal(err)
}
// Start delaying Raft messages to the remote node
remoteSrv := tc.Servers[remoteNodeID-1]
remoteStoreID := remoteSrv.GetFirstStoreID()
remoteStore, err := remoteSrv.Stores().GetStore(remoteStoreID)
if err != nil {
t.Fatal(err)
}
remoteStore.Transport().Listen(
remoteStoreID,
delayingRaftMessageHandler{remoteStore, leaseHolderNodeID, rangeID},
)
workerReady := make(chan bool)
// Create persistent range load.
tc.Stopper().RunWorker(ctx, func(ctx context.Context) {
s = sqlutils.MakeSQLRunner(tc.Conns[remoteNodeID-1])
workerReady <- true
for {
s.Exec(t, fmt.Sprintf("update system.comments set comment='abc' "+
"where type=0 and object_id=0 and sub_id=0"))
select {
case <-ctx.Done():
return
case <-tc.Stopper().ShouldQuiesce():
return
case <-time.After(queryInterval):
}
}
})
<-workerReady
// Wait until we see remote making progress
leaseHolderRepl, err := leaseHolderStore.GetReplica(rangeID)
if err != nil {
t.Fatal(err)
}
var remoteRepl *kvserver.Replica
testutils.SucceedsSoon(t, func() error {
remoteRepl, err = remoteStore.GetReplica(rangeID)
return err
})
testutils.SucceedsSoon(t, func() error {
status := leaseHolderRepl.RaftStatus()
progress := status.Progress[uint64(remoteRepl.ReplicaID())]
if progress.Match > 0 {
return nil
}
return errors.Errorf(
"remote is not making progress: %+v", progress.Match,
)
})
// Wait until we see the remote replica lagging behind
for {
// Ensure that the replica on the remote node is lagging.
status := leaseHolderRepl.RaftStatus()
progress := status.Progress[uint64(remoteRepl.ReplicaID())]
if progress.State == tracker.StateReplicate &&
(status.Commit-progress.Match) > 0 {
break
}
time.Sleep(13 * time.Millisecond)
}
// Set the zone preference for the replica to show that it has to be moved
// to the remote node.
desc, zone := leaseHolderRepl.DescAndZone()
newZone := *zone
newZone.LeasePreferences = []zonepb.LeasePreference{
{
Constraints: []zonepb.Constraint{
{
Type: zonepb.Constraint_REQUIRED,
Value: fmt.Sprintf("n%d", remoteNodeID),
},
},
},
}
// By now the lease holder may have changed.
testutils.SucceedsSoon(t, func() error {
leaseBefore, _ := leaseHolderRepl.GetLease()
log.Infof(ctx, "Lease before transfer %+v\n", leaseBefore)
if uint64(leaseBefore.Replica.NodeID) == remoteNodeID {
log.Infof(
ctx,
"Lease successfully transferred to desired node %d\n",
remoteNodeID,
)
return nil
}
currentSrv := tc.Servers[leaseBefore.Replica.NodeID-1]
leaseStore, err := currentSrv.Stores().GetStore(currentSrv.GetFirstStoreID())
if err != nil {
return err
}
leaseRepl, err := leaseStore.GetReplica(rangeID)
if err != nil {
return err
}
transferred, err := leaseStore.FindTargetAndTransferLease(
ctx, leaseRepl, desc, &newZone)
if err != nil {
return err
}
if !transferred {
return errors.Errorf("unable to transfer")
}
return errors.Errorf("Repeat check for correct leaseholder")
})
} | explode_data.jsonl/54895 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1880
} | [
2830,
3393,
21970,
2304,
519,
1249,
43,
351,
3173,
1955,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
20985,
1669,
2266,
19047,
741,
197,
18855,
4117,
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... | 5 |
func TestFilterSetsErrorOnPipeIfFilterFuncReturnsError(t *testing.T) {
t.Parallel()
p := script.Echo("hello").Filter(func(io.Reader, io.Writer) error {
return errors.New("oh no")
})
io.ReadAll(p)
if p.Error() == nil {
t.Error("no error")
}
} | explode_data.jsonl/51474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
5632,
30175,
1454,
1925,
34077,
2679,
5632,
9626,
16446,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
5316,
5142,
958,
445,
14990,
1827,
5632,
18552,
37258,
47431,
11,
6399,
47838,
8,
1465,
341,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLambdaCall(t *testing.T) {
skill := Skill{
ApplicationID: "amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe",
OnLaunch: func(req *LaunchRequest, res *ResponseEnvelope) {
res.Response.SetSimpleCard("title", "test")
},
SkipValidation: true,
Verbose: true,
}
skillHandler := skill.GetLambdaSkillHandler()
launchRequestReader, err := os.Open("../resources/lambda_launch_request.json")
if err != nil {
t.Error("Error reading input file", err)
}
var event map[string]interface{}
json.NewDecoder(launchRequestReader).Decode(&event)
result, err := skillHandler(context.TODO(), event)
assert.NoError(t, err)
// result is a Outgoing response object
responseEnvelope := result.(*ResponseEnvelope)
assert.Equal(t, &Card{Type: "Simple", Title: "title", Content: "test"}, responseEnvelope.Response.Card)
} | explode_data.jsonl/29504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
58266,
7220,
1155,
353,
8840,
836,
8,
341,
1903,
10851,
1669,
27482,
515,
197,
78329,
915,
25,
330,
309,
20308,
16,
68645,
35478,
12,
4122,
1601,
13,
15,
15,
15,
15,
15,
15,
1737,
15,
291,
12,
15,
15,
15,
15,
25747,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInValidCollectionName(t *testing.T) {
validNames := []string{"collection1", "collection_2"}
inValidNames := []string{"collection.1", "collection%2", ""}
for _, name := range validNames {
assert.NoError(t, validateCollectionName(name), "Testing for name = "+name)
}
for _, name := range inValidNames {
assert.Error(t, validateCollectionName(name), "Testing for name = "+name)
}
} | explode_data.jsonl/42515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
641,
4088,
6482,
675,
1155,
353,
8840,
836,
8,
341,
56322,
7980,
1669,
3056,
917,
4913,
13421,
16,
497,
330,
13421,
62,
17,
16707,
17430,
4088,
7980,
1669,
3056,
917,
4913,
13421,
13,
16,
497,
330,
13421,
4,
17,
497,
159... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVolumeClaimAllowsUserToAdd(t *testing.T) {
// prepare
otelcol := v1alpha1.OpenTelemetryCollector{
Spec: v1alpha1.OpenTelemetryCollectorSpec{
Mode: "statefulset",
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{{
ObjectMeta: metav1.ObjectMeta{
Name: "added-volume",
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{"ReadWriteOnce"},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{"storage": resource.MustParse("1Gi")},
},
},
}},
},
}
cfg := config.New()
// test
volumeClaims := VolumeClaimTemplates(cfg, otelcol)
// verify that volume claim replaces
assert.Len(t, volumeClaims, 1)
// check that it's the added volume
assert.Equal(t, "added-volume", volumeClaims[0].Name)
// check the access mode is correct
assert.Equal(t, corev1.PersistentVolumeAccessMode("ReadWriteOnce"), volumeClaims[0].Spec.AccessModes[0])
//check the storage is correct
assert.Equal(t, resource.MustParse("1Gi"), volumeClaims[0].Spec.Resources.Requests["storage"])
} | explode_data.jsonl/30075 | {
"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,
18902,
45544,
79595,
1474,
52113,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
198,
197,
40785,
2074,
1669,
348,
16,
7141,
16,
12953,
6639,
35958,
53694,
515,
197,
7568,
992,
25,
348,
16,
7141,
16,
12953,
6639,
35958,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_validGeometry(t *testing.T) {
tests := []struct {
geom string
expected bool
}{
{
geom: "line", expected: true,
},
{
geom: "step", expected: true,
},
{
geom: "stacked", expected: true,
},
{
geom: "monotoneX", expected: true,
},
{
geom: "bar", expected: true,
},
{
geom: "rando", expected: false,
},
{
geom: "not a valid geom", expected: false,
},
}
for _, tt := range tests {
fn := func(t *testing.T) {
isValid := len(validGeometry(tt.geom)) == 0
assert.Equal(t, tt.expected, isValid)
}
t.Run(tt.geom, fn)
}
} | explode_data.jsonl/50599 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
8337,
20787,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
197,
41916,
257,
914,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
41916,
25,
330,
1056,
497,
3601,
25,
830,
345,
197,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestChainedCall(t *testing.T) {
result, err := ParseExpr("foo.bar(1)[0](1).baz")
if err != nil {
t.Fatal(err)
}
exp := NewExpr(RefTerm(
CallTerm(
RefTerm(
CallTerm(
RefTerm(VarTerm("foo"), StringTerm("bar")),
IntNumberTerm(1)),
IntNumberTerm(0)),
IntNumberTerm(1)),
StringTerm("baz")))
if !result.Equal(exp) {
t.Fatalf("expected %v but got: %v", exp, result)
}
} | explode_data.jsonl/50478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
1143,
2627,
7220,
1155,
353,
8840,
836,
8,
341,
9559,
11,
1848,
1669,
14775,
16041,
445,
7975,
22001,
7,
16,
6620,
15,
9533,
16,
568,
42573,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
48558,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrimitivePutBool(t *testing.T) {
client := newPrimitiveClient()
a, b := true, false
result, err := client.PutBool(context.Background(), BooleanWrapper{FieldTrue: &a, FieldFalse: &b}, nil)
if err != nil {
t.Fatalf("PutBool: %v", err)
}
if s := result.RawResponse.StatusCode; s != http.StatusOK {
t.Fatalf("unexpected status code %d", s)
}
} | explode_data.jsonl/61677 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 136
} | [
2830,
3393,
33313,
19103,
11233,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
33313,
2959,
741,
11323,
11,
293,
1669,
830,
11,
895,
198,
9559,
11,
1848,
1669,
2943,
39825,
11233,
5378,
19047,
1507,
6992,
11542,
90,
1877,
2514,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPut(t *testing.T) {
q := New()
q.Put(`test`)
q.Put(2)
assert.Equal(t, 2, q.Len())
s := q.Get().(string)
assert.Equal(t, `test`, s)
assert.Equal(t, 1, q.Len())
i := q.Get().(int)
assert.Equal(t, 2, i)
assert.True(t, q.Empty())
} | explode_data.jsonl/81678 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
19103,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1532,
741,
18534,
39825,
5809,
1944,
24183,
18534,
39825,
7,
17,
340,
6948,
12808,
1155,
11,
220,
17,
11,
2804,
65819,
2398,
1903,
1669,
2804,
2234,
1005,
7,
917,
340,
6948... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTriggerSpecValidation(t *testing.T) {
tests := []struct {
name string
ts *TriggerSpec
want *apis.FieldError
}{{
name: "invalid trigger spec",
ts: &TriggerSpec{},
want: func() *apis.FieldError {
var errs *apis.FieldError
fe := apis.ErrMissingField("broker")
errs = errs.Also(fe)
fe = apis.ErrGeneric("expected at least one, got none", "subscriber.ref", "subscriber.uri")
errs = errs.Also(fe)
return errs
}(),
}, {
name: "missing broker",
ts: &TriggerSpec{
Broker: "",
Filter: validAttributesFilter,
Subscriber: validSubscriber,
},
want: func() *apis.FieldError {
fe := apis.ErrMissingField("broker")
return fe
}(),
}, {
name: "missing attributes keys, match all",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: &TriggerFilter{
Attributes: TriggerFilterAttributes{},
},
Subscriber: validSubscriber,
},
want: &apis.FieldError{},
}, {
name: "invalid attribute name, start with number",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: &TriggerFilter{
Attributes: TriggerFilterAttributes{
"0invalid": "my-value",
},
},
Subscriber: validSubscriber,
},
want: &apis.FieldError{
Message: "Invalid attribute name: \"0invalid\"",
Paths: []string{"filter.attributes"},
},
}, {
name: "invalid attribute name, capital letters",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: &TriggerFilter{
Attributes: TriggerFilterAttributes{
"invALID": "my-value",
},
},
Subscriber: validSubscriber,
},
want: &apis.FieldError{
Message: "Invalid attribute name: \"invALID\"",
Paths: []string{"filter.attributes"},
},
}, {
name: "missing subscriber",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: validAttributesFilter,
},
want: apis.ErrGeneric("expected at least one, got none", "subscriber.ref", "subscriber.uri"),
}, {
name: "missing subscriber.ref.name",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: validAttributesFilter,
Subscriber: invalidSubscriber,
},
want: apis.ErrMissingField("subscriber.ref.name"),
}, {
name: "missing broker",
ts: &TriggerSpec{
Broker: "",
Filter: validAttributesFilter,
Subscriber: validSubscriber,
},
want: apis.ErrMissingField("broker"),
}, {
name: "valid empty filter",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: validEmptyFilter,
Subscriber: validSubscriber,
},
want: &apis.FieldError{},
}, {
name: "valid SourceAndType filter",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: validAttributesFilter,
Subscriber: validSubscriber,
},
want: &apis.FieldError{},
}, {
name: "valid Attributes filter",
ts: &TriggerSpec{
Broker: "test_broker",
Filter: validAttributesFilter,
Subscriber: validSubscriber,
},
want: &apis.FieldError{},
}}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := test.ts.Validate(context.TODO())
if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" {
t.Errorf("%s: Validate TriggerSpec (-want, +got) = %v", test.name, diff)
}
})
}
} | explode_data.jsonl/23591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1345
} | [
2830,
3393,
17939,
8327,
13799,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
57441,
256,
353,
17939,
8327,
198,
197,
50780,
353,
13725,
17087,
1454,
198,
197,
15170,
515,
197,
11609,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConsolidateSpans(t *testing.T) {
defer leaktest.AfterTest(t)()
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
testData := []struct {
s string
// expected value
e string
}{
{
s: "[/1 - /2] [/3 - /5] [/7 - /9]",
e: "[/1 - /5] [/7 - /9]",
},
{
s: "[/1 - /2] (/3 - /5] [/7 - /9]",
e: "[/1 - /2] (/3 - /5] [/7 - /9]",
},
{
s: "[/1 - /2) [/3 - /5] [/7 - /9]",
e: "[/1 - /2) [/3 - /5] [/7 - /9]",
},
{
s: "[/1 - /2) (/3 - /5] [/7 - /9]",
e: "[/1 - /2) (/3 - /5] [/7 - /9]",
},
{
s: "[/1/1 - /1/3] [/1/4 - /2]",
e: "[/1/1 - /2]",
},
{
s: "[/1/1/5 - /1/1/3] [/1/1/2 - /1/1/1]",
e: "[/1/1/5 - /1/1/1]",
},
{
s: "[/1/1/5 - /1/1/3] [/1/2/2 - /1/2/1]",
e: "[/1/1/5 - /1/1/3] [/1/2/2 - /1/2/1]",
},
{
s: "[/1 - /2] [/3 - /4] [/5 - /6] [/8 - /9] [/10 - /11] [/12 - /13] [/15 - /16]",
e: "[/1 - /6] [/8 - /13] [/15 - /16]",
},
{
// Test that consolidating two spans preserves the correct type of ending
// boundary (#38878).
s: "[/1 - /2] [/3 - /5)",
e: "[/1 - /5)",
},
}
kc := testKeyContext(1, 2, -3)
for i, tc := range testData {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
spans := parseSpans(&evalCtx, tc.s)
var c Constraint
c.Init(kc, &spans)
c.ConsolidateSpans(kc.EvalCtx)
if res := c.Spans.String(); res != tc.e {
t.Errorf("expected %s got %s", tc.e, res)
}
})
}
} | explode_data.jsonl/59310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
15220,
5192,
349,
6406,
596,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
18388,
1669,
10652,
50133,
16451,
28678,
6086,
741,
93413,
23684,
1669,
4916,
50133,
16451,
54469,
1972,
5895,
692,
1818... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetStackAPIVersion(t *testing.T) {
var tests = []struct {
description string
groups *metav1.APIGroupList
err bool
expectedStack StackVersion
}{
{"no stack api", makeGroups(), true, ""},
{"v1beta1", makeGroups(groupVersion{"compose.docker.com", []string{"v1beta1"}}), false, StackAPIV1Beta1},
}
for _, test := range tests {
version, err := getAPIVersion(test.groups)
if test.err {
assert.ErrorContains(t, err, "")
} else {
assert.NilError(t, err)
}
assert.Check(t, is.Equal(test.expectedStack, version))
}
} | explode_data.jsonl/43872 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
1949,
4336,
7082,
5637,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
42407,
256,
914,
198,
197,
44260,
82,
286,
353,
4059,
402,
16,
24922,
2808,
852,
198,
197,
9859,
1843,
1807,
198,
197,
42400,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestParse_NewDunningEventNotification(t *testing.T) {
result := MustParseFile("testdata/new_dunning_event_notification.xml")
if n, ok := result.(*webhooks.NewDunningEventNotification); !ok {
t.Fatalf("unexpected type: %T, result", n)
} else if diff := cmp.Diff(n, &webhooks.NewDunningEventNotification{
Type: webhooks.NewDunningEvent,
Account: webhooks.Account{
XMLName: xml.Name{Local: "account"},
Code: "1",
Username: "verena",
Email: "verena@example.com",
FirstName: "Verena",
LastName: "Example",
CompanyName: "Company, Inc.",
},
Invoice: webhooks.ChargeInvoice{
XMLName: xml.Name{Local: "invoice"},
UUID: "424a9d4a2174b4f39bc776426aa19c32",
SubscriptionUUIDs: []string{"4110792b3b01967d854f674b7282f542"},
State: "past_due",
Origin: "renewal",
Currency: "USD",
CreatedAt: recurly.NewTime(MustParseTime("2018-01-09T16:47:43Z")),
UpdatedAt: recurly.NewTime(MustParseTime("2018-02-12T16:50:23Z")),
DueOn: recurly.NewTime(MustParseTime("2018-02-09T16:47:43Z")),
BalanceInCents: 4000,
InvoiceNumber: 1813,
TotalInCents: 4500,
SubtotalInCents: 4500,
SubTotalBeforeDiscountInCents: 4500,
CustomerNotes: "Thanks for your business!",
NetTerms: recurly.NewInt(30),
CollectionMethod: recurly.CollectionMethodManual,
},
Subscription: recurly.Subscription{
XMLName: xml.Name{Local: "subscription"},
Plan: recurly.NestedPlan{
Code: "gold",
Name: "Gold",
},
UUID: "4110792b3b01967d854f674b7282f542",
State: "active",
Quantity: 1,
TotalAmountInCents: 4500,
ActivatedAt: recurly.NewTime(MustParseTime("2017-11-09T16:47:30Z")),
CurrentPeriodStartedAt: recurly.NewTime(MustParseTime("2018-02-09T16:47:30Z")),
CurrentPeriodEndsAt: recurly.NewTime(MustParseTime("2018-03-09T16:47:30Z")),
},
}); diff != "" {
t.Fatal(diff)
}
} | explode_data.jsonl/76121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1223
} | [
2830,
3393,
14463,
39582,
35,
11216,
1556,
11196,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
15465,
14463,
1703,
445,
92425,
25376,
814,
11216,
6748,
34296,
9028,
1138,
743,
308,
11,
5394,
1669,
1102,
41399,
2911,
38560,
7121,
35,
11216,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestOneGroupSnapshot(t *testing.T) {
defer resetTest()
name := "test-group-snap"
namespace := "test"
selectors := map[string]string{"app": "mysql"}
preRuleName := "mysql-pre-snap"
postRuleName := "mysql-post-snap"
restoreNamespaces := []string{namespace, "prod"}
createGroupSnapshotAndVerify(t, name, namespace,
selectors, preRuleName, postRuleName, restoreNamespaces, nil, 99)
expected := fmt.Sprintf("NAME STATUS STAGE SNAPSHOTS CREATED\n"+
"%s 0 \n", name)
cmdArgs := []string{"get", "groupsnapshots", "-n", namespace, name}
testCommon(t, cmdArgs, nil, expected, false)
} | explode_data.jsonl/20426 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
3966,
2808,
15009,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
2271,
741,
11609,
1669,
330,
1944,
4351,
1331,
6861,
698,
56623,
1669,
330,
1944,
698,
38010,
1087,
1669,
2415,
14032,
30953,
4913,
676,
788,
330,
12272,
16707,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDrainHTTPRequestBodyNil(t *testing.T) {
req, err := http.NewRequest("POST", "/", nil)
if err != nil {
t.Errorf("cannot create new request: %v", err)
return
}
body, err := drainHTTPRequestBody(req)
if err == nil || err != io.EOF {
t.Errorf("Error should be %v, received %v", io.EOF, err)
}
if body != nil {
t.Errorf("Drained body should be nil, received %v", body)
}
} | explode_data.jsonl/42544 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
8847,
466,
9230,
33334,
19064,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
1758,
75274,
445,
2946,
497,
64657,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
33260,
1855,
501,
1681,
25,
1018,
85,
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... | 5 |
func Test_DeployHandler_Execution_Errors_Release_LockError(t *testing.T) {
release := MockRelease()
awsc := MockAwsClients(release)
state_machine := createTestStateMachine(t, awsc)
uidStr := fmt.Sprintf("{\"uuid\":\"%v\"}", *release.ReleaseID)
awsc.S3.AddGetObject(*release.ReleaseLockPath(), uidStr, nil)
exec, err := state_machine.Execute(release)
assert.Error(t, err)
assert.Regexp(t, "LockExistsError", exec.LastOutputJSON)
assert.Regexp(t, "Lock Already Exists", exec.LastOutputJSON)
assert.Equal(t, []string{
"Validate",
"Lock",
"FailureClean",
}, exec.Path())
t.Run("no locks acquired in dynamodb", func(t *testing.T) {
assert.Equal(t, 0, len(awsc.DynamoDB.PutItemInputs))
})
} | explode_data.jsonl/62297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
90680,
1989,
3050,
62,
20294,
93623,
1087,
85573,
2351,
1176,
1454,
1155,
353,
8840,
836,
8,
341,
17200,
1623,
1669,
14563,
16077,
741,
197,
672,
2388,
1669,
14563,
47359,
47174,
5801,
1623,
692,
24291,
38695,
1669,
1855,
2271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestImageRef_HasProfile__False(t *testing.T) {
Startup(nil)
img, err := NewImageFromFile(resources + "jpg-24bit.jpg")
require.NoError(t, err)
defer img.Close()
assert.False(t, img.HasProfile())
} | explode_data.jsonl/38826 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
1906,
3945,
2039,
300,
8526,
563,
4049,
1155,
353,
8840,
836,
8,
341,
197,
39076,
27907,
692,
39162,
11,
1848,
1669,
1532,
1906,
43633,
52607,
488,
330,
17974,
12,
17,
19,
4489,
4819,
1138,
17957,
35699,
1155,
11,
1848,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTablePropertyCollectorErrors(t *testing.T) {
var testcases map[string]func(w *Writer) error = map[string]func(w *Writer) error{
"add a#0,1 failed": func(w *Writer) error {
return w.Set([]byte("a"), []byte("b"))
},
"add c#0,0 failed": func(w *Writer) error {
return w.Delete([]byte("c"))
},
"add d#0,15 failed": func(w *Writer) error {
return w.DeleteRange([]byte("d"), []byte("e"))
},
"add f#0,2 failed": func(w *Writer) error {
return w.Merge([]byte("f"), []byte("g"))
},
"finish failed": func(w *Writer) error {
return w.Close()
},
}
for e, fun := range testcases {
mem := vfs.NewMem()
f, err := mem.Create("foo")
require.NoError(t, err)
var opts WriterOptions
opts.TablePropertyCollectors = append(opts.TablePropertyCollectors,
func() TablePropertyCollector {
return errorPropCollector{}
})
w := NewWriter(f, opts)
require.Regexp(t, e, fun(w))
}
} | explode_data.jsonl/40346 | {
"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,
2556,
3052,
53694,
13877,
1155,
353,
8840,
836,
8,
1476,
2405,
1273,
23910,
2415,
14032,
60,
2830,
3622,
353,
6492,
8,
1465,
284,
2415,
14032,
60,
2830,
3622,
353,
6492,
8,
1465,
515,
197,
197,
1,
718,
264,
2,
15,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGroupsYamls(t *testing.T) {
var server = mockPluginsServer(t, "testdata/groups/two_plugins/group.yaml", GroupType)
defer server.Close()
var groups Groups
r, err := groups.Encode(server.URL, "/test")
if err != nil {
t.Fatalf("expected nil but got %v", err)
}
if 1 != len(r.Groups) {
t.Fatalf("expected %d but got %v", 1, len(r.Groups))
}
} | explode_data.jsonl/1913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
22173,
56,
309,
4730,
1155,
353,
8840,
836,
8,
341,
2405,
3538,
284,
7860,
45378,
5475,
1155,
11,
330,
92425,
77685,
5523,
1126,
45658,
53389,
33406,
497,
5737,
929,
340,
16867,
3538,
10421,
741,
2405,
5203,
34580,
198,
7000... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatDbFails(t *testing.T) {
resetStats()
r, clean, err := redistest.CreateRedis()
assert.Nil(t, err)
defer clean()
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
for i := 0; i < 20; i++ {
var str string
err = c.QueryRow(&str, "name", func(conn sqlx.SqlConn, v interface{}) error {
return errors.New("db failed")
})
assert.NotNil(t, err)
}
assert.Equal(t, uint64(20), atomic.LoadUint64(&stats.Total))
assert.Equal(t, uint64(0), atomic.LoadUint64(&stats.Hit))
assert.Equal(t, uint64(20), atomic.LoadUint64(&stats.DbFails))
} | explode_data.jsonl/64127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
15878,
7994,
37,
6209,
1155,
353,
8840,
836,
8,
341,
70343,
16635,
741,
7000,
11,
4240,
11,
1848,
1669,
2518,
380,
477,
7251,
48137,
741,
6948,
59678,
1155,
11,
1848,
340,
16867,
4240,
2822,
1444,
1669,
1532,
1955,
9701,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOnlyLocalLoadBalancing(t *testing.T) {
ipt := iptablestest.NewFake()
fp := NewFakeProxier(ipt)
svcName := "svc1"
svcIP := net.IPv4(10, 20, 30, 41)
svc := proxy.ServicePortName{NamespacedName: types.NamespacedName{Namespace: "ns1", Name: svcName}, Port: "80"}
svcInfo := newFakeServiceInfo(svc, svcIP, 80, api.ProtocolTCP, true)
fp.serviceMap[svc] = typeLoadBalancer(svcInfo)
nonLocalEp := "10.180.0.1:80"
localEp := "10.180.2.1:80"
fp.endpointsMap[svc] = []*endpointsInfo{{nonLocalEp, false}, {localEp, true}}
fp.syncProxyRules()
proto := strings.ToLower(string(api.ProtocolTCP))
fwChain := string(serviceFirewallChainName(svc, proto))
lbChain := string(serviceLBChainName(svc, proto))
nonLocalEpChain := string(servicePortEndpointChainName(svc, strings.ToLower(string(api.ProtocolTCP)), nonLocalEp))
localEpChain := string(servicePortEndpointChainName(svc, strings.ToLower(string(api.ProtocolTCP)), localEp))
kubeSvcRules := ipt.GetRules(string(kubeServicesChain))
if !hasJump(kubeSvcRules, fwChain, svcInfo.loadBalancerStatus.Ingress[0].IP, "") {
errorf(fmt.Sprintf("Failed to find jump to firewall chain %v", fwChain), kubeSvcRules, t)
}
fwRules := ipt.GetRules(fwChain)
if !hasJump(fwRules, lbChain, "", "") {
errorf(fmt.Sprintf("Failed to find jump from firewall chain %v to svc chain %v", fwChain, lbChain), fwRules, t)
}
if hasJump(fwRules, string(KubeMarkMasqChain), "", "") {
errorf(fmt.Sprintf("Found jump from fw chain %v to MASQUERADE", fwChain), fwRules, t)
}
lbRules := ipt.GetRules(lbChain)
if hasJump(lbRules, nonLocalEpChain, "", "") {
errorf(fmt.Sprintf("Found jump from lb chain %v to non-local ep %v", lbChain, nonLocalEp), lbRules, t)
}
if !hasJump(lbRules, localEpChain, "", "") {
errorf(fmt.Sprintf("Didn't find jump from lb chain %v to local ep %v", lbChain, nonLocalEp), lbRules, t)
}
} | explode_data.jsonl/9296 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 729
} | [
2830,
3393,
7308,
7319,
5879,
37889,
8974,
1155,
353,
8840,
836,
8,
341,
8230,
417,
1669,
66068,
480,
267,
477,
7121,
52317,
741,
65219,
1669,
1532,
52317,
1336,
87,
1268,
1956,
417,
340,
1903,
7362,
675,
1669,
330,
58094,
16,
698,
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... | 6 |
func TestTablePartition(t *testing.T) {
definitions := []model.PartitionDefinition{
{
ID: 41,
Name: model.NewCIStr("p1"),
LessThan: []string{"16"},
},
{
ID: 42,
Name: model.NewCIStr("p2"),
LessThan: []string{"32"},
},
{
ID: 43,
Name: model.NewCIStr("p3"),
LessThan: []string{"64"},
},
{
ID: 44,
Name: model.NewCIStr("p4"),
LessThan: []string{"128"},
},
{
ID: 45,
Name: model.NewCIStr("p5"),
LessThan: []string{"maxvalue"},
},
}
is := MockPartitionInfoSchema(definitions)
// is1 equals to is without maxvalue partition.
definitions1 := make([]model.PartitionDefinition, len(definitions)-1)
copy(definitions1, definitions)
is1 := MockPartitionInfoSchema(definitions1)
isChoices := []infoschema.InfoSchema{is, is1}
var (
input []struct {
SQL string
IsIdx int
}
output []string
)
planSuiteUnexportedData.GetTestCases(t, &input, &output)
s := createPlannerSuite()
ctx := context.Background()
for i, ca := range input {
comment := fmt.Sprintf("for %s", ca.SQL)
stmt, err := s.p.ParseOneStmt(ca.SQL, "", "")
require.NoError(t, err, comment)
testdata.OnRecord(func() {
})
p, _, err := BuildLogicalPlanForTest(ctx, s.ctx, stmt, isChoices[ca.IsIdx])
require.NoError(t, err)
p, err = logicalOptimize(context.TODO(), flagDecorrelate|flagPrunColumns|flagPrunColumnsAgain|flagPredicatePushDown|flagPartitionProcessor, p.(LogicalPlan))
require.NoError(t, err)
planString := ToString(p)
testdata.OnRecord(func() {
output[i] = planString
})
require.Equal(t, output[i], ToString(p), fmt.Sprintf("for %v", ca))
}
} | explode_data.jsonl/50210 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
2556,
49978,
1155,
353,
8840,
836,
8,
341,
7452,
4054,
82,
1669,
3056,
2528,
52250,
680,
10398,
515,
197,
197,
515,
298,
29580,
25,
981,
220,
19,
16,
345,
298,
21297,
25,
257,
1614,
7121,
34,
1637,
376,
445,
79,
16,
44... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnwrappingURLError(t *testing.T) {
urlErr := &url.Error{
Op: "GET",
URL: "a",
Err: errors.New("test error thing"),
}
require.Error(t, urlErr)
wrappedErr := fmt.Errorf("%w: test error", urlErr)
err := markRPCServerError(wrappedErr)
require.Error(t, err)
require.Regexp(t, expectedErrMsgForRPC, err)
} | explode_data.jsonl/46750 | {
"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,
1806,
18718,
3629,
1511,
94618,
1155,
353,
8840,
836,
8,
341,
19320,
7747,
1669,
609,
1085,
6141,
515,
197,
197,
7125,
25,
220,
330,
3806,
756,
197,
79055,
25,
330,
64,
756,
197,
197,
7747,
25,
5975,
7121,
445,
1944,
146... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCircularMean(t *testing.T) {
for i, test := range []struct {
x []float64
wts []float64
ans float64
}{
// Values compared against scipy.
{
x: []float64{0, 2 * math.Pi},
ans: 0,
},
{
x: []float64{0, 0.5 * math.Pi},
ans: 0.78539816339744,
},
{
x: []float64{-1.5 * math.Pi, 0.5 * math.Pi, 2.5 * math.Pi},
wts: []float64{1, 2, 3},
ans: 0.5 * math.Pi,
},
{
x: []float64{0, 0.5 * math.Pi},
wts: []float64{1, 2},
ans: 1.10714871779409,
},
} {
c := CircularMean(test.x, test.wts)
if math.Abs(c-test.ans) > 1e-14 {
t.Errorf("Circular mean mismatch case %d: Expected %v, Found %v", i, test.ans, c)
}
}
if !panics(func() { CircularMean(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("CircularMean did not panic with x, wts length mismatch")
}
} | explode_data.jsonl/1759 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
82440,
18783,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
256,
3056,
3649,
21,
19,
198,
197,
6692,
2576,
3056,
3649,
21,
19,
198,
197,
43579,
2224,
21,
19,
198,
197,
59403,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_findNumberOfLIS(t *testing.T) {
type args struct {
nums []int
}
tests := []struct {
name string
args args
wantAns int
}{
{"", args{[]int{1, 3, 5, 4, 7}}, 2},
{"", args{[]int{2, 2, 2, 2, 2}}, 5},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotAns := findNumberOfLIS(tt.args.nums); gotAns != tt.wantAns {
t.Errorf("findNumberOfLIS() = %v, want %v", gotAns, tt.wantAns)
}
})
}
} | explode_data.jsonl/74297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
21814,
40619,
43,
1637,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22431,
82,
3056,
396,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
31215,
262,
2827,
198,
197,
50780,
69599... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewTusHandler(t *testing.T) {
auther, err := wallet.NewOauthAuthenticator(config.GetOauthProviderURL(), config.GetOauthClientID(), config.GetInternalAPIHost(), nil)
require.NoError(t, err)
successTestCases := []struct {
name string
fn func() (auth.Authenticator, auth.Provider, tusd.Config, string)
}{
{
name: "WithExistingDirectory",
fn: func() (auth.Authenticator, auth.Provider, tusd.Config, string) {
uploadPath := t.TempDir()
return auther, mockAuthProvider, newTusTestCfg(uploadPath), uploadPath
},
},
{
name: "WithNewDirectory",
fn: func() (auth.Authenticator, auth.Provider, tusd.Config, string) {
uploadPath := filepath.Join(t.TempDir(), "new_dir")
return auther, mockAuthProvider, newTusTestCfg(uploadPath), uploadPath
},
},
}
t.Run("Success", func(t *testing.T) {
t.Parallel()
for _, test := range successTestCases {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
h, err := NewTusHandler(test.fn())
assert.Nil(t, err)
assert.NotNil(t, h)
})
}
})
errorTestCases := []struct {
name string
fn func() (auth.Authenticator, auth.Provider, tusd.Config, string)
wantErr error
}{
{
name: "WithNilAuthProvider",
fn: func() (auth.Authenticator, auth.Provider, tusd.Config, string) {
uploadPath := t.TempDir()
return nil, nil, newTusTestCfg(uploadPath), uploadPath
},
},
{
name: "WithRestrictedDirectoryAccess",
fn: func() (auth.Authenticator, auth.Provider, tusd.Config, string) {
if err := os.Mkdir("test_dir", 0444); err != nil { // read only
t.Fatal(err)
}
t.Cleanup(func() {
if err := os.Remove("test_dir"); err != nil {
t.Fatal(err)
}
})
uploadPath := filepath.Join("test_dir", "new_dir")
return auther, mockAuthProvider, newTusTestCfg(uploadPath), uploadPath
},
wantErr: os.ErrPermission,
},
}
t.Run("Error", func(t *testing.T) {
t.Parallel()
for _, test := range errorTestCases {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
_, err := NewTusHandler(test.fn())
assert.NotNil(t, err)
if test.wantErr != nil {
if err = errors.Unwrap(err); !errors.Is(err, test.wantErr) {
t.Fatalf("expecting error: %+v, got: %+v", test.wantErr, err)
}
}
})
}
})
} | explode_data.jsonl/57950 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1023
} | [
2830,
3393,
3564,
51,
355,
3050,
1155,
353,
8840,
836,
8,
341,
78011,
261,
11,
1848,
1669,
15085,
7121,
46,
3242,
5087,
61393,
8754,
2234,
46,
3242,
5179,
3144,
1507,
2193,
2234,
46,
3242,
2959,
915,
1507,
2193,
2234,
11569,
7082,
929... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestScopedExternalModuleExclusion(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/index.js": `
import { Foo } from '@scope/foo';
import { Bar } from '@scope/foo/bar';
export const foo = new Foo();
export const bar = new Bar();
`,
},
entryPaths: []string{"/index.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
ExternalModules: config.ExternalModules{
NodeModules: map[string]bool{
"@scope/foo": true,
},
},
},
})
} | explode_data.jsonl/38524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
39437,
25913,
3332,
840,
8957,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
1252,
2857,
788,
22074,
571,
21918,
314,
33428,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetWindow(t *testing.T) {
Convey("Test non-empty notification package", t, func() {
from, to, err := notificationsPackage.GetWindow()
So(err, ShouldBeNil)
So(from, ShouldEqual, 11)
So(to, ShouldEqual, 179)
})
Convey("Test empty notification package", t, func() {
emptyNotificationPackage := NotificationPackage{}
_, _, err := emptyNotificationPackage.GetWindow()
So(err, ShouldResemble, fmt.Errorf("not enough data to resolve package window"))
})
} | explode_data.jsonl/29086 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
1949,
4267,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2271,
2477,
39433,
11540,
6328,
497,
259,
11,
2915,
368,
341,
197,
42727,
11,
311,
11,
1848,
1669,
21969,
13100,
2234,
4267,
741,
197,
76912,
3964,
11,
12260,
343... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntry_SelectedText(t *testing.T) {
e, window := setupImageTest(false)
defer teardownImageTest(window)
c := window.Canvas()
c.Focus(e)
e.SetText("Testing")
test.AssertImageMatches(t, "entry/select_initial.png", c.Capture())
// move right, press & hold shift and move right
typeKeys(e, fyne.KeyRight, keyShiftLeftDown, fyne.KeyRight, fyne.KeyRight)
assert.Equal(t, "es", e.SelectedText())
test.AssertImageMatches(t, "entry/select_selected.png", c.Capture())
// release shift
typeKeys(e, keyShiftLeftUp)
// press shift and move
typeKeys(e, keyShiftLeftDown, fyne.KeyRight)
assert.Equal(t, "est", e.SelectedText())
test.AssertImageMatches(t, "entry/select_add_selection.png", c.Capture())
// release shift and move right
typeKeys(e, keyShiftLeftUp, fyne.KeyRight)
assert.Equal(t, "", e.SelectedText())
test.AssertImageMatches(t, "entry/select_move_wo_shift.png", c.Capture())
// press shift and move left
typeKeys(e, keyShiftLeftDown, fyne.KeyLeft, fyne.KeyLeft)
assert.Equal(t, "st", e.SelectedText())
test.AssertImageMatches(t, "entry/select_select_left.png", c.Capture())
} | explode_data.jsonl/57322 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 414
} | [
2830,
3393,
5874,
38290,
1178,
1155,
353,
8840,
836,
8,
341,
7727,
11,
3241,
1669,
6505,
1906,
2271,
3576,
340,
16867,
49304,
1906,
2271,
15906,
340,
1444,
1669,
3241,
54121,
2822,
1444,
40141,
2026,
340,
7727,
92259,
445,
16451,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_keepConversationsUnreadCounts(t *testing.T) {
db, _, dispose := GetInMemoryTestDB(t, GetInMemoryTestDBOptsNoInit)
defer dispose()
log := zap.NewNop()
res := keepConversationsLocalData(db.db, nil)
require.Empty(t, res)
require.NoError(t, db.db.Exec("CREATE TABLE `conversations` (`public_key` text,`type` integer,`is_open` numeric,`display_name` text,`link` text,`unread_count` integer,`last_update` integer,`contact_public_key` text,`account_member_public_key` text,`local_device_public_key` text,`created_date` integer,`reply_options_cid` text,PRIMARY KEY (`public_key`))").Error)
res = keepConversationsLocalData(db.db, log)
require.Empty(t, res)
require.NoError(t, db.db.Exec(`INSERT INTO conversations (public_key, is_open, unread_count) VALUES ("pk_1", true, 1000)`).Error)
require.NoError(t, db.db.Exec(`INSERT INTO conversations (public_key, is_open, unread_count) VALUES ("pk_2", false, 2000)`).Error)
require.NoError(t, db.db.Exec(`INSERT INTO conversations (public_key, is_open, unread_count) VALUES ("pk_3", true, 3000)`).Error)
res = keepConversationsLocalData(db.db, log)
expectedValues := map[string]*messengertypes.LocalConversationState{
"pk_1": {IsOpen: true, UnreadCount: 1000},
"pk_2": {IsOpen: false, UnreadCount: 2000},
"pk_3": {IsOpen: true, UnreadCount: 3000},
}
require.Len(t, res, len(expectedValues))
for _, found := range res {
expected, ok := expectedValues[found.PublicKey]
require.True(t, ok)
require.Equal(t, expected.UnreadCount, found.UnreadCount)
require.Equal(t, expected.IsOpen, found.IsOpen)
}
} | explode_data.jsonl/3228 | {
"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,
50293,
1109,
72995,
1806,
878,
63731,
1155,
353,
8840,
836,
8,
341,
20939,
11,
8358,
27390,
1669,
2126,
641,
10642,
2271,
3506,
1155,
11,
2126,
641,
10642,
2271,
3506,
43451,
2753,
3803,
340,
16867,
27390,
2822,
6725,
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... | 2 |
func TestDomains_RetrievePageByNumber(t *testing.T) {
setup()
defer teardown()
jBlob := `
{
"domains": [{"id":1},{"id":2}],
"links":{
"pages":{
"next":"http://example.com/v2/domains/?page=3",
"prev":"http://example.com/v2/domains/?page=1",
"last":"http://example.com/v2/domains/?page=3",
"first":"http://example.com/v2/domains/?page=1"
}
},
"meta":{
"total":2
}
}`
mux.HandleFunc("/v2/domains", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, jBlob)
})
opt := &ListOptions{Page: 2}
_, resp, err := client.Domains.List(ctx, opt)
if err != nil {
t.Fatal(err)
}
checkCurrentPage(t, resp, 2)
} | explode_data.jsonl/22670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
74713,
2568,
295,
45004,
2665,
1359,
2833,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
12428,
37985,
1669,
22074,
197,
515,
197,
197,
1,
59621,
788,
61753,
307,
788,
16,
36828,
307,
788,
17,
64054,
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... | 1 |
func TestJobSpecsController_Show(t *testing.T) {
t.Parallel()
rpcClient, gethClient, _, assertMocksCalled := cltest.NewEthMocksWithStartupAssertions(t)
defer assertMocksCalled()
app, cleanup := cltest.NewApplication(t,
eth.NewClientWith(rpcClient, gethClient),
)
defer cleanup()
require.NoError(t, app.Start())
client := app.NewHTTPClient()
j := setupJobSpecsControllerShow(t, app)
resp, cleanup := client.Get("/v2/specs/" + j.ID.String())
defer cleanup()
cltest.AssertServerResponse(t, resp, http.StatusOK)
var respJob presenters.JobSpec
require.NoError(t, cltest.ParseJSONAPIResponse(t, resp, &respJob))
require.Len(t, j.Initiators, 1)
require.Len(t, respJob.Initiators, 1)
require.Len(t, respJob.Errors, 1)
assert.Equal(t, j.Initiators[0].Schedule, respJob.Initiators[0].Schedule, "should have the same schedule")
} | explode_data.jsonl/31818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
12245,
8327,
82,
2051,
79665,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
3992,
2959,
11,
633,
71,
2959,
11,
8358,
2060,
72577,
20960,
1669,
1185,
1944,
7121,
65390,
11571,
16056,
39076,
90206,
1155,
340,
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 TestCapability_StorageToCapability(t *testing.T) {
assert := assert.New(t)
for _, storageType := range net.OSInfo_StorageType_value {
os := &stubOS{storageType: storageType}
_, err := storageToCapability(os)
assert.Nil(err)
}
// test error case
c, err := storageToCapability(&stubOS{storageType: -1})
assert.Equal(Capability_Invalid, c)
assert.Equal(capStorageConv, err)
// test unused caps
c, err = storageToCapability(&stubOS{storageType: stubOSMagic})
assert.Equal(Capability_Unused, c)
assert.Nil(err)
c, err = storageToCapability(nil)
assert.Equal(Capability_Unused, c)
assert.Nil(err)
} | explode_data.jsonl/74083 | {
"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,
63746,
62,
5793,
1249,
63746,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
2023,
8358,
5819,
929,
1669,
2088,
4179,
57054,
1731,
62,
5793,
929,
3142,
341,
197,
25078,
1669,
609,
59398,
3126,
90,
16172,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInSlice(t *testing.T) {
sl := []string{"A", "b"}
if !InSlice("A", sl) {
t.Error("should be true")
}
if InSlice("B", sl) {
t.Error("should be false")
}
} | explode_data.jsonl/1732 | {
"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,
641,
33236,
1155,
353,
8840,
836,
8,
341,
78626,
1669,
3056,
917,
4913,
32,
497,
330,
65,
16707,
743,
753,
641,
33236,
445,
32,
497,
1739,
8,
341,
197,
3244,
6141,
445,
5445,
387,
830,
1138,
197,
532,
743,
758,
33236,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDockerStatsToContainerStats(t *testing.T) {
numCores = 4
inputJsonFile, _ := filepath.Abs("./windows_test_stats.json")
jsonBytes, _ := ioutil.ReadFile(inputJsonFile)
dockerStat := &types.StatsJSON{}
json.Unmarshal([]byte(jsonBytes), dockerStat)
containerStats, err := dockerStatsToContainerStats(dockerStat)
assert.NoError(t, err, "converting container stats failed")
require.NotNil(t, containerStats, "containerStats should not be nil")
netStats := containerStats.networkStats
assert.NotNil(t, netStats, "networkStats should not be nil")
validateNetworkMetrics(t, netStats)
assert.Equal(t, uint64(2500), containerStats.cpuUsage,
"unexpected value for cpuUsage", containerStats.cpuUsage)
assert.Equal(t, uint64(3), containerStats.storageReadBytes,
"unexpected value for storageReadBytes", containerStats.storageReadBytes)
assert.Equal(t, uint64(15), containerStats.storageWriteBytes,
"Unexpected value for storageWriteBytes", containerStats.storageWriteBytes)
} | explode_data.jsonl/43689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
35,
13659,
16635,
1249,
4502,
16635,
1155,
353,
8840,
836,
8,
341,
22431,
34,
4589,
284,
220,
19,
198,
22427,
5014,
1703,
11,
716,
1669,
26054,
33255,
13988,
27077,
4452,
15381,
4323,
1138,
30847,
7078,
11,
716,
1669,
43144,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegisterAndRetrieveProxy(t *testing.T) {
// register a proxy and retrieve it.
var facade = facade.GetInstance(func() interfaces.IFacade {
return &facade.Facade{}
})
facade.RegisterProxy(&proxy.Proxy{Name: "colors", Data: []string{"red", "green", "blue"}})
var proxy = facade.RetrieveProxy("colors").(*proxy.Proxy)
// retrieve data from proxy
var data = proxy.Data.([]string)
// test assertions
if data == nil {
t.Error("Expecting data not nil")
}
if len(data) != 3 {
t.Error("Expecting len(data) == 3")
}
if data[0] != "red" {
t.Error("Expecting data[0] == 'red'")
}
if data[1] != "green" {
t.Error("Expecting data[1] == 'green'")
}
if data[2] != "blue" {
t.Error("Expecting data[2] == 'blue'")
}
} | explode_data.jsonl/21993 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
8690,
3036,
87665,
16219,
1155,
353,
8840,
836,
8,
341,
197,
322,
4161,
264,
13291,
323,
17179,
432,
624,
2405,
61616,
284,
61616,
53048,
18552,
368,
24099,
2447,
55331,
341,
197,
853,
609,
22185,
1021,
991,
580,
1021,
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 TestClusterInfra(t *testing.T) {
testutil.SkipIfNoCreds(t)
const bootstrapImage = "https://some_s3_path"
validateBootstrap = func(burl string, _ header) error {
if burl != bootstrapImage {
return fmt.Errorf("got %v, want %v", burl, bootstrapImage)
}
return nil
}
var schema = infra.Schema{
"labels": make(pool.Labels),
"cluster": new(runner.Cluster),
"tls": new(tls.Certs),
"logger": new(log.Logger),
"session": new(session.Session),
"user": new(infra2.User),
"bootstrap": new(infra2.BootstrapImage),
"reflow": new(infra2.ReflowVersion),
"sshkey": new(infra2.SshKey),
}
for _, tt := range []struct {
b string
name, rv string
spot bool
}{
{`
labels: kv
tls: tls,file=/tmp/ca
logger: logger
session: awssession
user: user
bootstrap: bootstrapimage,uri=` + bootstrapImage + `
reflow: reflowversion,version=abcdef
cluster: ec2cluster
ec2cluster:
maxinstances: 1
disktype: dt
diskspace: 10
ami: foo
region: bar
securitygroup: blah
sshkey: key
`,
"default", "abcdef", false},
} {
config, err := schema.Unmarshal([]byte(tt.b))
if err != nil {
t.Fatal(err)
}
var cluster runner.Cluster
config.Must(&cluster)
ec2cluster, ok := cluster.(*Cluster)
if !ok {
t.Fatalf("%v is not an ec2cluster", reflect.TypeOf(cluster))
}
if got, want := ec2cluster.Name, tt.name; got != want {
t.Errorf("got %v, want %v", got, want)
}
if got, want := ec2cluster.Spot, tt.spot; got != want {
t.Errorf("got %v, want %v", got, want)
}
if got, want := ec2cluster.ReflowVersion, tt.rv; got != want {
t.Errorf("got %v, want %v", got, want)
}
}
} | explode_data.jsonl/42284 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 879
} | [
2830,
3393,
28678,
19433,
956,
1155,
353,
8840,
836,
8,
341,
18185,
1314,
57776,
2679,
2753,
34,
53369,
1155,
340,
4777,
26925,
1906,
284,
330,
2428,
1110,
14689,
643,
18,
2638,
698,
197,
7067,
45511,
284,
2915,
1883,
1085,
914,
11,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRemittanceOriginatorTagError(t *testing.T) {
ro := mockRemittanceOriginator()
ro.tag = "{9999}"
require.EqualError(t, ro.Validate(), fieldError("tag", ErrValidTagForType, ro.tag).Error())
} | explode_data.jsonl/32954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
6590,
87191,
13298,
850,
5668,
1454,
1155,
353,
8840,
836,
8,
341,
197,
299,
1669,
7860,
6590,
87191,
13298,
850,
741,
197,
299,
12399,
284,
13868,
24,
24,
24,
24,
42273,
17957,
12808,
1454,
1155,
11,
926,
47667,
1507,
207... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBebopValidatePitchWhenCentered(t *testing.T) {
gobottest.Assert(t, ValidatePitch(16383.5, 32767.0), 50)
} | explode_data.jsonl/68982 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 49
} | [
2830,
3393,
33,
3065,
453,
17926,
47071,
4498,
9392,
291,
1155,
353,
8840,
836,
8,
341,
3174,
674,
1716,
477,
11711,
1155,
11,
23282,
47071,
7,
16,
21,
18,
23,
18,
13,
20,
11,
220,
18,
17,
22,
21,
22,
13,
15,
701,
220,
20,
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 |
func TestReplaceAppendAllowDuplicates(t *testing.T) {
cases := []struct {
name string
esVersion *common.Version
content map[string]interface{}
expected map[string]interface{}
isErrExpected bool
}{
{
name: "ES < 7.10.0: set to true",
esVersion: common.MustNewVersion("7.9.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": true,
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
},
},
},
},
isErrExpected: false,
},
{
name: "ES < 7.10.0: set to false",
esVersion: common.MustNewVersion("7.9.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"if": "ctx?.host?.hostname != null && ((ctx?.related?.hosts instanceof List && !ctx?.related?.hosts.contains(ctx?.host?.hostname)) || ctx?.related?.hosts != ctx?.host?.hostname)",
},
},
},
},
isErrExpected: false,
},
{
name: "ES == 7.10.0",
esVersion: common.MustNewVersion("7.10.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
},
},
},
},
isErrExpected: false,
},
{
name: "ES > 7.10.0",
esVersion: common.MustNewVersion("8.0.0"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
},
},
},
},
isErrExpected: false,
},
{
name: "ES < 7.10.0: existing if",
esVersion: common.MustNewVersion("7.7.7"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
"if": "ctx?.host?.hostname != null",
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"if": "ctx?.host?.hostname != null && ((ctx?.related?.hosts instanceof List && !ctx?.related?.hosts.contains(ctx?.host?.hostname)) || ctx?.related?.hosts != ctx?.host?.hostname)",
},
},
}},
isErrExpected: false,
},
{
name: "ES < 7.10.0: existing if with contains",
esVersion: common.MustNewVersion("7.7.7"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"allow_duplicates": false,
"if": "!ctx?.related?.hosts.contains(ctx?.host?.hostname)",
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"value": "{{host.hostname}}",
"if": "!ctx?.related?.hosts.contains(ctx?.host?.hostname)",
},
},
}},
isErrExpected: false,
},
{
name: "ES < 7.10.0: no value",
esVersion: common.MustNewVersion("7.7.7"),
content: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
"allow_duplicates": false,
},
},
}},
expected: map[string]interface{}{
"processors": []interface{}{
map[string]interface{}{
"append": map[string]interface{}{
"field": "related.hosts",
},
},
}},
isErrExpected: false,
},
}
for _, test := range cases {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
err := AdaptPipelineForCompatibility(*test.esVersion, "foo-pipeline", test.content, logp.NewLogger(logName))
if test.isErrExpected {
assert.Error(t, err)
} else {
require.NoError(t, err)
assert.Equal(t, test.expected, test.content, test.name)
}
})
}
} | explode_data.jsonl/61779 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2902
} | [
2830,
3393,
23107,
23877,
18605,
76851,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
78966,
5637,
257,
353,
5464,
35842,
198,
197,
27751,
981,
2415,
14032,
31344,
16094,
197,
42400,
41... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewOffer(t *testing.T) {
t.Parallel()
_, err := b.NewOffer("BTC", 1, 1, 1, "loan")
if err == nil {
t.Error("Test Failed - NewOffer() error")
}
} | explode_data.jsonl/79958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
3564,
39462,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
6878,
1848,
1669,
293,
7121,
39462,
445,
59118,
497,
220,
16,
11,
220,
16,
11,
220,
16,
11,
330,
38329,
1138,
743,
1848,
621,
2092,
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
] | 2 |
func TestCraftSweepAllTxUnknownWitnessType(t *testing.T) {
t.Parallel()
utxoSource := newMockUtxoSource(testUtxos)
coinSelectLocker := &mockCoinSelectionLocker{}
utxoLocker := newMockOutpointLocker()
_, err := CraftSweepAllTx(
0, 100, nil, coinSelectLocker, utxoSource, utxoLocker, nil, nil,
)
// Since passed in a p2wsh output, which is unknown, we should fail to
// map the output to a witness type.
if err == nil {
t.Fatalf("sweep tx should have failed: %v", err)
}
// At this point, we'll now verify that all outputs were initially
// locked, and then also unlocked since we weren't able to find a
// witness type for the last output.
assertUtxosLockedAndUnlocked(t, utxoLocker, testUtxos)
} | explode_data.jsonl/37470 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
38849,
50,
48542,
2403,
31584,
13790,
98413,
929,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
332,
40822,
3608,
1669,
501,
11571,
52,
3998,
78,
3608,
8623,
52,
3998,
436,
340,
197,
7160,
3379,
87253,
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... | 2 |
func TestGetTotalRewards(t *testing.T) {
ctx, _, keeper, _, _ := CreateTestInputDefault(t, false, 1000)
valCommission := sdk.DecCoins{
sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(5).Quo(sdk.NewDec(4))),
sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))),
}
keeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, valCommission)
keeper.SetValidatorOutstandingRewards(ctx, valOpAddr2, valCommission)
expectedRewards := valCommission.MulDec(sdk.NewDec(2))
totalRewards := keeper.GetTotalRewards(ctx)
require.Equal(t, expectedRewards, totalRewards)
} | explode_data.jsonl/54424 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
1949,
7595,
58465,
2347,
1155,
353,
8840,
836,
8,
341,
20985,
11,
8358,
53416,
11,
8358,
716,
1669,
4230,
2271,
2505,
3675,
1155,
11,
895,
11,
220,
16,
15,
15,
15,
692,
19302,
73750,
1669,
45402,
22442,
69602,
515,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPrimitivePutDateTimeRFC1123(t *testing.T) {
client := newPrimitiveClient()
f, _ := time.Parse(time.RFC1123, "Mon, 01 Jan 0001 00:00:00 GMT")
n, _ := time.Parse(time.RFC1123, "Mon, 18 May 2015 11:38:00 GMT")
result, err := client.PutDateTimeRFC1123(context.Background(), Datetimerfc1123Wrapper{
Field: &f,
Now: &n,
}, nil)
if err != nil {
t.Fatalf("PutDateTimeRFC1123: %v", err)
}
if s := result.RawResponse.StatusCode; s != http.StatusOK {
t.Fatalf("unexpected status code %d", s)
}
} | explode_data.jsonl/61689 | {
"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,
33313,
19103,
7689,
64371,
16,
16,
17,
18,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
33313,
2959,
741,
1166,
11,
716,
1669,
882,
8937,
9730,
2013,
6754,
16,
16,
17,
18,
11,
330,
11095,
11,
220,
15,
16,
4350,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestManager(t *testing.T) {
t.Run("manager_creation", func(t *testing.T) {
m := NewManager(nil)
require.NotNil(t, m.tracker)
})
t.Run("manager_get_tx", func(t *testing.T) {
m := NewManager(nil)
tx, err := m.GetTx(nil)
require.Nil(t, tx)
require.Equal(t, ErrTxCtxMissing, err)
})
} | explode_data.jsonl/3304 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
2043,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
13297,
46163,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2109,
1669,
1532,
2043,
27907,
340,
197,
17957,
93882,
1155,
11,
296,
5427,
9683,
340,
197,
3518,
3244,
1670... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewRegistrar(t *testing.T) {
//system channel
confSys := genesisconfig.Load(genesisconfig.SampleInsecureSoloProfile, configtest.GetDevConfigDir())
genesisBlockSys := encoder.New(confSys).GenesisBlock()
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
assert.NoError(t, err)
// This test checks to make sure the orderer can come up if it cannot find any chains
t.Run("No chains", func(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "registrar_test-")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
lf, err := fileledger.New(tmpdir, &disabled.Provider{})
require.NoError(t, err)
consenters := make(map[string]consensus.Consenter)
consenters["etcdraft"] = &mockConsenter{}
var manager *Registrar
assert.NotPanics(t, func() {
manager = NewRegistrar(localconfig.TopLevel{}, lf, mockCrypto(), &disabled.Provider{}, cryptoProvider)
manager.Initialize(consenters)
}, "Should not panic when starting without a system channel")
require.NotNil(t, manager)
list := manager.ChannelList()
assert.Equal(t, types.ChannelList{}, list)
info, err := manager.ChannelInfo("my-channel")
assert.EqualError(t, err, types.ErrChannelNotExist.Error())
assert.Equal(t, types.ChannelInfo{}, info)
})
// This test checks to make sure that the orderer refuses to come up if there are multiple system channels
t.Run("Multiple system chains - failure", func(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "registrar_test-")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
lf, err := fileledger.New(tmpdir, &disabled.Provider{})
require.NoError(t, err)
for _, id := range []string{"foo", "bar"} {
rl, err := lf.GetOrCreate(id)
assert.NoError(t, err)
err = rl.Append(encoder.New(confSys).GenesisBlockForChannel(id))
assert.NoError(t, err)
}
consenters := make(map[string]consensus.Consenter)
consenters[confSys.Orderer.OrdererType] = &mockConsenter{}
assert.Panics(t, func() {
NewRegistrar(localconfig.TopLevel{}, lf, mockCrypto(), &disabled.Provider{}, cryptoProvider).Initialize(consenters)
}, "Two system channels should have caused panic")
})
// This test essentially brings the entire system up and is ultimately what main.go will replicate
t.Run("Correct flow with system channel", func(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "registrar_test-")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
lf, rl := newLedgerAndFactory(tmpdir, "testchannelid", genesisBlockSys)
consenters := make(map[string]consensus.Consenter)
consenters[confSys.Orderer.OrdererType] = &mockConsenter{}
manager := NewRegistrar(localconfig.TopLevel{}, lf, mockCrypto(), &disabled.Provider{}, cryptoProvider)
manager.Initialize(consenters)
chainSupport := manager.GetChain("Fake")
assert.Nilf(t, chainSupport, "Should not have found a chain that was not created")
chainSupport = manager.GetChain("testchannelid")
assert.NotNilf(t, chainSupport, "Should have gotten chain which was initialized by ledger")
list := manager.ChannelList()
require.NotNil(t, list.SystemChannel)
assert.Equal(
t,
types.ChannelList{
SystemChannel: &types.ChannelInfoShort{Name: "testchannelid", URL: ""},
Channels: nil},
list,
)
info, err := manager.ChannelInfo("testchannelid")
assert.NoError(t, err)
assert.Equal(t,
types.ChannelInfo{Name: "testchannelid", URL: "", ClusterRelation: "none", Status: "active", Height: 1},
info,
)
testMessageOrderAndRetrieval(confSys.Orderer.BatchSize.MaxMessageCount, "testchannelid", chainSupport, rl, t)
})
} | explode_data.jsonl/37984 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1295
} | [
2830,
3393,
3564,
70252,
1155,
353,
8840,
836,
8,
341,
197,
322,
8948,
5496,
198,
67850,
32792,
1669,
59366,
1676,
13969,
36884,
13774,
1676,
76266,
641,
25132,
89299,
8526,
11,
2193,
1944,
2234,
14592,
2648,
6184,
2398,
82281,
13774,
471... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRenterPayoutsPreTax(t *testing.T) {
// Initialize inputs
var host HostDBEntry
var period types.BlockHeight
var baseCollateral types.Currency
var expectedStorage uint64
// Set currency values to trigger underflow check
funding := types.NewCurrency64(10)
txnFee := types.NewCurrency64(5)
basePrice := types.NewCurrency64(5)
// Check for underflow condition
_, _, _, err := RenterPayoutsPreTax(host, funding, txnFee, basePrice, baseCollateral, period, expectedStorage)
if err == nil {
t.Fatal("Expected underflow error but got nil")
}
// Confirm no underflow
funding = types.NewCurrency64(11)
renterPayout, hostPayout, hostCollateral, err := RenterPayoutsPreTax(host, funding, txnFee, basePrice, baseCollateral, period, expectedStorage)
if err != nil {
t.Fatal(err)
}
if renterPayout.Cmp(types.ZeroCurrency) < 0 {
t.Fatal("Negative currency returned for renter payout", renterPayout)
}
if hostPayout.Cmp(types.ZeroCurrency) < 0 {
t.Fatal("Negative currency returned for host payout", hostPayout)
}
if hostCollateral.Cmp(types.ZeroCurrency) < 0 {
t.Fatal("Negative currency returned for host collateral", hostCollateral)
}
} | explode_data.jsonl/63362 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
49,
1950,
47,
1407,
82,
4703,
31349,
1155,
353,
8840,
836,
8,
341,
197,
322,
9008,
11127,
198,
2405,
3468,
16102,
3506,
5874,
198,
2405,
4168,
4494,
28477,
3640,
198,
2405,
2331,
15265,
19165,
4494,
77186,
198,
2405,
3601,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvokeCmd(t *testing.T) {
defer viper.Reset()
defer resetFlags()
resetFlags()
mockCF, err := getMockChaincodeCmdFactory()
assert.NoError(t, err, "Error getting mock chaincode command factory")
//错误情况0:未指定channelid
cmd := invokeCmd(mockCF)
addFlags(cmd)
args := []string{"-n", "example02", "-c", "{\"Args\": [\"invoke\",\"a\",\"b\",\"10\"]}"}
cmd.SetArgs(args)
err = cmd.Execute()
assert.Error(t, err, "'peer chaincode invoke' command should have returned error when called without -C flag")
//成功案例
cmd = invokeCmd(mockCF)
addFlags(cmd)
args = []string{"-n", "example02", "-c", "{\"Args\": [\"invoke\",\"a\",\"b\",\"10\"]}", "-C", "mychannel"}
cmd.SetArgs(args)
err = cmd.Execute()
assert.NoError(t, err, "Run chaincode invoke cmd error")
//设置错误情况的超时
viper.Set("peer.client.connTimeout", 10*time.Millisecond)
//错误案例1:没有订购方终结点
t.Logf("Start error case 1: no orderer endpoints")
getEndorserClient := common.GetEndorserClientFnc
getOrdererEndpointOfChain := common.GetOrdererEndpointOfChainFnc
getBroadcastClient := common.GetBroadcastClientFnc
getDefaultSigner := common.GetDefaultSignerFnc
getDeliverClient := common.GetDeliverClientFnc
getPeerDeliverClient := common.GetPeerDeliverClientFnc
defer func() {
common.GetEndorserClientFnc = getEndorserClient
common.GetOrdererEndpointOfChainFnc = getOrdererEndpointOfChain
common.GetBroadcastClientFnc = getBroadcastClient
common.GetDefaultSignerFnc = getDefaultSigner
common.GetDeliverClientFnc = getDeliverClient
common.GetPeerDeliverClientFnc = getPeerDeliverClient
}()
common.GetEndorserClientFnc = func(string, string) (pb.EndorserClient, error) {
return mockCF.EndorserClients[0], nil
}
common.GetOrdererEndpointOfChainFnc = func(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error) {
return []string{}, nil
}
cmd = invokeCmd(nil)
addFlags(cmd)
args = []string{"-n", "example02", "-c", "{\"Args\": [\"invoke\",\"a\",\"b\",\"10\"]}", "-C", "mychannel"}
cmd.SetArgs(args)
err = cmd.Execute()
assert.Error(t, err)
//错误案例2:Get背书客户端返回错误
t.Logf("Start error case 2: getEndorserClient returns error")
common.GetEndorserClientFnc = func(string, string) (pb.EndorserClient, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
//错误案例3:GetDeliverClient返回错误
t.Logf("Start error case 3: getDeliverClient returns error")
common.GetDeliverClientFnc = func(string, string) (pb.Deliver_DeliverClient, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
//错误案例4:GetPeerDeliverClient返回错误
t.Logf("Start error case 4: getPeerDeliverClient returns error")
common.GetPeerDeliverClientFnc = func(string, string) (api.PeerDeliverClient, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
//错误案例5:GetDefaultSignerFnc返回错误
t.Logf("Start error case 5: getDefaultSignerFnc returns error")
common.GetEndorserClientFnc = func(string, string) (pb.EndorserClient, error) {
return mockCF.EndorserClients[0], nil
}
common.GetPeerDeliverClientFnc = func(string, string) (api.PeerDeliverClient, error) {
return mockCF.DeliverClients[0], nil
}
common.GetDefaultSignerFnc = func() (msp.SigningIdentity, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
common.GetDefaultSignerFnc = common.GetDefaultSigner
//错误情况6:GetOrderEndPointToChainFnc返回错误
t.Logf("Start error case 6: getOrdererEndpointOfChainFnc returns error")
common.GetEndorserClientFnc = func(string, string) (pb.EndorserClient, error) {
return mockCF.EndorserClients[0], nil
}
common.GetOrdererEndpointOfChainFnc = func(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
//错误案例7:GetBroadcastClient返回错误
t.Logf("Start error case 7: getBroadcastClient returns error")
common.GetOrdererEndpointOfChainFnc = func(chainID string, signer msp.SigningIdentity, endorserClient pb.EndorserClient) ([]string, error) {
return []string{"localhost:9999"}, nil
}
common.GetBroadcastClientFnc = func() (common.BroadcastClient, error) {
return nil, errors.New("error")
}
err = cmd.Execute()
assert.Error(t, err)
//成功案例
t.Logf("Start success case")
common.GetBroadcastClientFnc = func() (common.BroadcastClient, error) {
return mockCF.BroadcastClient, nil
}
err = cmd.Execute()
assert.NoError(t, err)
} | explode_data.jsonl/70890 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1831
} | [
2830,
3393,
17604,
15613,
1155,
353,
8840,
836,
8,
341,
16867,
95132,
36660,
741,
16867,
7585,
9195,
2822,
70343,
9195,
741,
77333,
9650,
11,
1848,
1669,
633,
11571,
18837,
1851,
15613,
4153,
741,
6948,
35699,
1155,
11,
1848,
11,
330,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClient_Readdir(t *testing.T) {
if !isTestManual {
t.Skipf("%s not set", envNameTestManual)
}
path := "/tmp"
fh, err := testClient.Opendir(path)
if err != nil {
t.Fatal(err)
}
nodes, err := testClient.Readdir(fh)
if err != nil {
t.Fatal(err)
}
t.Logf("List of files inside the %s:\n", path)
for x, node := range nodes {
fi, _ := node.Info()
t.Logf("%02d: %s %+v\n", x, fi.Mode().String(), node.Name())
}
} | explode_data.jsonl/66416 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
2959,
50693,
44525,
1155,
353,
8840,
836,
8,
341,
743,
753,
285,
2271,
52092,
341,
197,
3244,
57776,
69,
4430,
82,
537,
738,
497,
6105,
675,
2271,
52092,
340,
197,
630,
26781,
1669,
3521,
5173,
698,
1166,
71,
11,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestStrategicMerge(t *testing.T) {
tests := []struct {
obj runtime.Object
dataStruct runtime.Object
fragment string
expected runtime.Object
expectErr bool
}{
{
obj: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "c1",
Image: "red-image",
},
{
Name: "c2",
Image: "blue-image",
},
},
},
},
dataStruct: &corev1.Pod{},
fragment: fmt.Sprintf(`{ "apiVersion": "%s", "spec": { "containers": [ { "name": "c1", "image": "green-image" } ] } }`,
schema.GroupVersion{Group: "", Version: "v1"}.String()),
expected: &corev1.Pod{
TypeMeta: metav1.TypeMeta{
Kind: "Pod",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "c1",
Image: "green-image",
},
{
Name: "c2",
Image: "blue-image",
},
},
},
},
},
{
obj: &corev1.Pod{},
dataStruct: &corev1.Pod{},
fragment: "invalid json",
expected: &corev1.Pod{},
expectErr: true,
},
{
obj: &corev1.Service{},
dataStruct: &corev1.Pod{},
fragment: `{ "apiVersion": "badVersion" }`,
expectErr: true,
},
}
codec := runtime.NewCodec(scheme.DefaultJSONEncoder(),
scheme.Codecs.UniversalDecoder(scheme.Scheme.PrioritizedVersionsAllGroups()...))
for i, test := range tests {
out, err := StrategicMerge(codec, test.obj, test.fragment, test.dataStruct)
if !test.expectErr {
if err != nil {
t.Errorf("testcase[%d], unexpected error: %v", i, err)
} else if !apiequality.Semantic.DeepEqual(test.expected, out) {
t.Errorf("\n\ntestcase[%d]\nexpected:\n%s", i, diff.ObjectReflectDiff(test.expected, out))
}
}
if test.expectErr && err == nil {
t.Errorf("testcase[%d], unexpected non-error", i)
}
}
} | explode_data.jsonl/38771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1020
} | [
2830,
3393,
2580,
89367,
52096,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22671,
286,
15592,
8348,
198,
197,
8924,
9422,
15592,
8348,
198,
197,
1166,
6017,
256,
914,
198,
197,
42400,
256,
15592,
8348,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestRegisterAndRemoveCommandAndSendNotification(t *testing.T) {
// Create the Facade, register the FacadeTestCommand to
// handle 'FacadeTest' events
var facade = facade.GetInstance(func() interfaces.IFacade { return &facade.Facade{} })
facade.RegisterCommand("FacadeTestNote", func() interfaces.ICommand { return &FacadeTestCommand{} })
facade.RemoveCommand("FacadeTestNote")
// Send notification. The Command associated with the event
// (FacadeTestCommand) will NOT be invoked, and will NOT multiply
// the vo.input value by 2
var vo = FacadeTestVO{Input: 32}
facade.SendNotification("FacadeTestNote", &vo, "")
// test assertions
if vo.Result == 64 {
t.Error("Expecting vo.result != 64")
}
} | explode_data.jsonl/21992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
8690,
3036,
13021,
4062,
3036,
11505,
11196,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
279,
16945,
1021,
11,
4161,
279,
16945,
1021,
2271,
4062,
311,
198,
197,
322,
3705,
364,
55331,
2271,
6,
4357,
198,
2405,
61616,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidateCache(t *testing.T) {
// load sourcemap from file and decode
//
// TODO(axw) this should be done without decoding,
// or moved to a separate integration test package.
data, err := loader.LoadData("../testdata/sourcemap/payload.json")
assert.NoError(t, err)
decoded, err := modeldecoder.DecodeSourcemap(data)
require.NoError(t, err)
event := decoded.(*model.Sourcemap)
t.Run("withSourcemapStore", func(t *testing.T) {
// collect logs
require.NoError(t, logp.DevelopmentSetup(logp.ToObserverOutput()))
// create sourcemap store
client, err := estest.NewElasticsearchClient(estest.NewTransport(t, http.StatusOK, nil))
require.NoError(t, err)
store, err := sourcemap.NewStore(client, "foo", time.Minute)
require.NoError(t, err)
// transform with sourcemap store
event.Transform(context.Background(), &transform.Config{RUM: transform.RUMConfig{SourcemapStore: store}})
logCollection := logp.ObserverLogs().TakeAll()
assert.Equal(t, 2, len(logCollection))
// first sourcemap was added
for i, entry := range logCollection {
assert.Equal(t, logs.Sourcemap, entry.LoggerName)
assert.Equal(t, zapcore.DebugLevel, entry.Level)
if i == 0 {
assert.Contains(t, entry.Message, "Added id service_1_js/bundle.js. Cache now has 1 entries.")
} else {
assert.Contains(t, entry.Message, "Removed id service_1_js/bundle.js. Cache now has 0 entries.")
}
}
})
t.Run("noSourcemapStore", func(t *testing.T) {
// collect logs
require.NoError(t, logp.DevelopmentSetup(logp.ToObserverOutput()))
// transform with no sourcemap store
event.Transform(context.Background(), &transform.Config{RUM: transform.RUMConfig{}})
logCollection := logp.ObserverLogs().TakeAll()
assert.Equal(t, 1, len(logCollection))
for _, entry := range logCollection {
assert.Equal(t, logs.Sourcemap, entry.LoggerName)
assert.Equal(t, zapcore.ErrorLevel, entry.Level)
assert.Contains(t, entry.Message, "cache cannot be invalidated")
}
})
} | explode_data.jsonl/41732 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 718
} | [
2830,
3393,
641,
7067,
8233,
1155,
353,
8840,
836,
8,
341,
197,
322,
2795,
20282,
66,
42040,
504,
1034,
323,
16895,
198,
197,
2289,
197,
322,
5343,
41922,
86,
8,
419,
1265,
387,
2814,
2041,
47116,
345,
197,
322,
476,
7726,
311,
264,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestList_PopFronts(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
l := New()
a1 := []interface{}{1, 2, 3, 4}
l.PushFronts(a1)
i1 := l.PopFronts(2)
t.Assert(i1, []interface{}{4, 3})
t.Assert(l.Len(), 2)
})
} | explode_data.jsonl/30900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
852,
1088,
453,
23395,
82,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
8810,
1669,
1532,
741,
197,
11323,
16,
1669,
3056,
4970,
6257,
90,
16,
11,
220,
17,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClearAnalysisDiagnostics(t *testing.T) {
WithOptions(
ProxyFiles(workspaceProxy),
WorkspaceFolders("pkg/inner"),
).Run(t, workspaceModule, func(t *testing.T, env *Env) {
env.OpenFile("pkg/main.go")
env.Await(
env.DiagnosticAtRegexp("pkg/main2.go", "fmt.Print"),
)
env.CloseBuffer("pkg/main.go")
env.Await(
EmptyDiagnostics("pkg/main2.go"),
)
})
} | explode_data.jsonl/37360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 167
} | [
2830,
3393,
14008,
26573,
35,
18938,
1155,
353,
8840,
836,
8,
341,
197,
74238,
1006,
197,
197,
16219,
10809,
98517,
16219,
1326,
197,
197,
45981,
92779,
445,
30069,
14,
4382,
4461,
197,
568,
6727,
1155,
11,
27514,
3332,
11,
2915,
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 TestLevelDataNotStruct(t *testing.T) {
checkLevelReadError(t, DataStructNotFound, 10, 0, 0, 3, 0, 4, 'D', 'a', 't', 'a', 1, 2, 3, 4, 0, 0)
} | explode_data.jsonl/79914 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
4449,
1043,
2623,
9422,
1155,
353,
8840,
836,
8,
341,
25157,
4449,
4418,
1454,
1155,
11,
2885,
9422,
10372,
11,
220,
16,
15,
11,
220,
15,
11,
220,
15,
11,
220,
18,
11,
220,
15,
11,
220,
19,
11,
364,
35,
516,
364,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFromFabricBlock(t *testing.T) {
t.Parallel()
fabBlock, err := getBlock("./mock/genesis.pb")
assert.NoError(t, err)
block, err := FromFabricBlock(fabBlock)
assert.NoError(t, err)
assert.NotNil(t, block.Data)
assert.NotNil(t, block.Metadata)
assert.NotNil(t, block.OrderersSignatures)
} | explode_data.jsonl/40036 | {
"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,
3830,
81731,
4713,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1166,
370,
4713,
11,
1848,
1669,
633,
4713,
13988,
16712,
14,
77894,
37916,
1138,
6948,
35699,
1155,
11,
1848,
692,
47996,
11,
1848,
1669,
5542,
81731... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTRaft_VoteOnce(t *testing.T) {
// cluster = {0, 1, 2}
// ts[0] vote once with differnt Committer/VotedFor settings.
lid := NewLeaderId
type wt struct {
hasVoteReplies bool
err error
higherTerm int64
}
cases := []struct {
name string
committers []*LeaderId
votedFors []*LeaderId
logs [][]string
candidate *LeaderId
want wt
}{
{name: "2emptyVoter/term-0",
candidate: lid(0, 0),
want: wt{
hasVoteReplies: false,
err: ErrStaleTermId,
higherTerm: 0,
},
},
{name: "2emptyVoter/term-1",
candidate: lid(1, 0),
want: wt{
hasVoteReplies: true,
err: nil,
higherTerm: -1,
},
},
{name: "reject-by-one/stalelog",
committers: []*LeaderId{nil, lid(2, 0)},
votedFors: []*LeaderId{nil, lid(2, 1)},
candidate: lid(1, 0),
want: wt{
hasVoteReplies: true,
err: nil,
higherTerm: -1,
},
},
{name: "reject-by-one/higherTerm",
committers: []*LeaderId{nil, nil, lid(0, 0)},
votedFors: []*LeaderId{nil, nil, lid(5, 2)},
candidate: lid(1, 0),
want: wt{
hasVoteReplies: true,
err: nil,
higherTerm: -1,
},
},
{name: "reject-by-two/stalelog",
committers: []*LeaderId{nil, lid(2, 0), lid(0, 0)},
votedFors: []*LeaderId{nil, lid(2, 1), lid(2, 2)},
candidate: lid(1, 0),
want: wt{
hasVoteReplies: false,
err: ErrStaleLog,
higherTerm: 2,
},
},
{name: "reject-by-two/stalelog-higherTerm",
committers: []*LeaderId{nil, lid(2, 0), lid(0, 0)},
votedFors: []*LeaderId{nil, lid(2, 1), lid(5, 2)},
logs: [][]string{nil, nil, []string{"x=0"}},
candidate: lid(1, 0),
want: wt{
hasVoteReplies: false,
err: ErrStaleLog,
higherTerm: 5,
},
},
{name: "reject-by-two/higherTerm",
votedFors: []*LeaderId{nil, lid(3, 1), lid(5, 2)},
candidate: lid(1, 0),
want: wt{
hasVoteReplies: false,
err: ErrStaleTermId,
higherTerm: 5,
},
},
}
for _, c := range cases {
withCluster(t, c.name,
[]int64{0, 1, 2},
func(t *testing.T, ts []*TRaft) {
ta := require.New(t)
for i, cmt := range c.committers {
if cmt != nil {
ts[i].Status[int64(i)].Committer = cmt
}
}
for i, v := range c.votedFors {
if v != nil {
ts[i].Status[int64(i)].VotedFor = v
}
}
for i, ls := range c.logs {
for _, l := range ls {
ts[i].addLogs(l)
}
}
voted, err, higher := ElectOnce(
c.candidate,
ExportLogStatus(ts[0].Status[0]),
ts[0].Config.Clone(),
)
if c.want.hasVoteReplies {
ta.NotNil(voted)
} else {
ta.Nil(voted)
}
ta.Equal(c.want.err, errors.Cause(err))
ta.Equal(c.want.higherTerm, higher)
})
}
} | explode_data.jsonl/17378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1564
} | [
2830,
3393,
2378,
64,
723,
2334,
1272,
12522,
1155,
353,
8840,
836,
8,
1476,
197,
322,
10652,
284,
314,
15,
11,
220,
16,
11,
220,
17,
532,
197,
322,
10591,
58,
15,
60,
6910,
3055,
448,
1745,
406,
9205,
465,
27233,
9253,
2461,
5003... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApiTest_ErrorIfMockInvocationsDoNotMatchTimes(t *testing.T) {
getUser := apitest.NewMock().
Get("http://localhost:8080").
RespondWith().
Status(http.StatusOK).
Times(2).
End()
verifier := mocks.NewVerifier()
verifier.FailFn = func(t apitest.TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
assert.Equal(t, "mock was not invoked expected times", failureMessage)
return true
}
res := apitest.New().
Mocks(getUser).
Verifier(verifier).
Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = getUserData()
w.WriteHeader(http.StatusOK)
})).
Get("/").
Expect(t).
Status(http.StatusOK).
End()
unmatchedMocks := res.UnmatchedMocks()
assert.Equal(t, true, len(unmatchedMocks) > 0)
assert.Equal(t, "http://localhost:8080", unmatchedMocks[0].URL.String())
} | explode_data.jsonl/54820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
6563,
2271,
28651,
2679,
11571,
15174,
55199,
5404,
2623,
8331,
18889,
1155,
353,
8840,
836,
8,
341,
10366,
1474,
1669,
1443,
97105,
7121,
11571,
25829,
197,
37654,
445,
1254,
1110,
8301,
25,
23,
15,
23,
15,
38609,
197,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestZoneLimit(t *testing.T) {
zoneLimit := features.New("PodNetworking/ZoneLimit").WithLabel("env", "trunking").
Setup(func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
podENI := &v1beta1.PodENI{
ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: config.Namespace()},
Spec: v1beta1.PodENISpec{
Allocations: []v1beta1.Allocation{
{
AllocationType: v1beta1.AllocationType{
Type: v1beta1.IPAllocTypeFixed,
ReleaseStrategy: v1beta1.ReleaseStrategyNever,
},
IPv4: "127.0.0.1",
},
},
Zone: "foo",
},
Status: v1beta1.PodENIStatus{},
}
if err := config.Client().Resources().Create(ctx, podENI); err != nil {
t.Fatal(err)
}
t.Logf("podENI created %#v", podENI)
pn := newPodNetworking(defaultPodNetworkingName, nil, nil, &metav1.LabelSelector{
MatchLabels: map[string]string{"trunking-pod": "true"},
}, nil)
pn.Spec.AllocationType = v1beta1.AllocationType{
Type: v1beta1.IPAllocTypeFixed,
ReleaseStrategy: v1beta1.ReleaseStrategyNever,
}
if err := config.Client().Resources().Create(ctx, pn); err != nil {
t.Fatal(err)
}
t.Logf("podNetworking created %#v", pn)
return ctx
}).
Assess("podNetworking status ready", func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
err := WaitPodNetworkingReady(defaultPodNetworkingName, config.Client())
if err != nil {
t.Fatal(err)
}
t.Logf("podNetworking %s status is ready", defaultPodNetworkingName)
return ctx
}).
Setup(func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
p := newPod(config.Namespace(), podName, map[string]string{"trunking-pod": "true"}, nil)
p.OwnerReferences = append(p.OwnerReferences, metav1.OwnerReference{
Kind: "StatefulSet",
Name: "foo",
UID: "foo",
APIVersion: "foo",
})
p.Spec.Affinity = &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{
{
MatchExpressions: []corev1.NodeSelectorRequirement{
{
Key: "user-config",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"bar1", "bar2"},
},
{
Key: "topology.kubernetes.io/zone",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"bar1"},
},
},
},
{
MatchFields: []corev1.NodeSelectorRequirement{
{
Key: "metadata.name",
Operator: corev1.NodeSelectorOpIn,
Values: []string{"bar1"},
},
},
},
},
},
PreferredDuringSchedulingIgnoredDuringExecution: nil,
},
}
err := config.Client().Resources().Create(ctx, p)
if err != nil {
t.Fatal(err)
}
t.Logf("pod created %#v", p)
return ctx
}).
Assess("pod have NodeSelectorTerms", func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
pod := corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: config.Namespace()},
}
err := wait.For(conditions.New(config.Client().Resources()).ResourceMatch(&pod, func(object k8s.Object) bool {
p := object.(*corev1.Pod)
if !terwayTypes.PodUseENI(p) {
return false
}
if p.Annotations[terwayTypes.PodNetworking] != defaultPodNetworkingName {
return false
}
return true
}), wait.WithTimeout(time.Second*5))
if err != nil {
t.Fatal(err)
}
for _, term := range pod.Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
t.Logf("MatchFields %d MatchExpressions %d", len(term.MatchFields), len(term.MatchExpressions))
found := false
for _, match := range term.MatchExpressions {
if match.Key == "topology.kubernetes.io/zone" && match.Values[0] == "foo" {
found = true
}
}
if !found {
t.Errorf("node affinity config is not satisfy")
}
}
return ctx
}).
Teardown(func(ctx context.Context, t *testing.T, config *envconf.Config) context.Context {
_ = config.Client().Resources().Delete(ctx, &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: config.Namespace()},
})
_ = config.Client().Resources().Delete(ctx, &v1beta1.PodNetworking{
ObjectMeta: metav1.ObjectMeta{Name: defaultPodNetworkingName, Namespace: config.Namespace()},
})
_ = config.Client().Resources().Delete(ctx, &v1beta1.PodENI{
ObjectMeta: metav1.ObjectMeta{Name: podName, Namespace: config.Namespace()},
})
return ctx
}).
Feature()
testenv.Test(t, zoneLimit)
} | explode_data.jsonl/4261 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2167
} | [
2830,
3393,
15363,
16527,
1155,
353,
8840,
836,
8,
341,
197,
8684,
16527,
1669,
4419,
7121,
445,
23527,
78007,
14,
15363,
16527,
1827,
2354,
2476,
445,
3160,
497,
330,
376,
3122,
287,
38609,
197,
197,
21821,
18552,
7502,
2266,
9328,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRepositoryCreate(t *testing.T) {
for k, v := range samples {
err := sr.Create(v)
if k != 3 {
if err != nil {
t.Fatalf("sr.Create: %d %v", k, err)
}
} else {
if err != repo.ErrInvalidID {
t.Fatalf("sr.Create != repo.ErrInvalidID")
}
}
}
} | explode_data.jsonl/75692 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
4624,
4021,
1155,
353,
8840,
836,
8,
341,
2023,
595,
11,
348,
1669,
2088,
10469,
341,
197,
9859,
1669,
18962,
7251,
3747,
340,
197,
743,
595,
961,
220,
18,
341,
298,
743,
1848,
961,
2092,
341,
571,
3244,
30762,
445,
1509... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateCSIVolumeSource(t *testing.T) {
testCases := []struct {
name string
csi *core.CSIPersistentVolumeSource
errtype field.ErrorType
errfield string
}{
{
name: "all required fields ok",
csi: &core.CSIPersistentVolumeSource{Driver: "test-driver", VolumeHandle: "test-123", ReadOnly: true},
},
{
name: "with default values ok",
csi: &core.CSIPersistentVolumeSource{Driver: "test-driver", VolumeHandle: "test-123"},
},
{
name: "missing driver name",
csi: &core.CSIPersistentVolumeSource{VolumeHandle: "test-123"},
errtype: field.ErrorTypeRequired,
errfield: "driver",
},
{
name: "missing volume handle",
csi: &core.CSIPersistentVolumeSource{Driver: "my-driver"},
errtype: field.ErrorTypeRequired,
errfield: "volumeHandle",
},
{
name: "driver name: ok no punctuations",
csi: &core.CSIPersistentVolumeSource{Driver: "comgooglestoragecsigcepd", VolumeHandle: "test-123"},
},
{
name: "driver name: ok dot only",
csi: &core.CSIPersistentVolumeSource{Driver: "io.kubernetes.storage.csi.flex", VolumeHandle: "test-123"},
},
{
name: "driver name: ok dash only",
csi: &core.CSIPersistentVolumeSource{Driver: "io-kubernetes-storage-csi-flex", VolumeHandle: "test-123"},
},
{
name: "driver name: ok underscore only",
csi: &core.CSIPersistentVolumeSource{Driver: "io_kubernetes_storage_csi_flex", VolumeHandle: "test-123"},
},
{
name: "driver name: ok dot underscores",
csi: &core.CSIPersistentVolumeSource{Driver: "io.kubernetes.storage_csi.flex", VolumeHandle: "test-123"},
},
{
name: "driver name: ok beginnin with number",
csi: &core.CSIPersistentVolumeSource{Driver: "2io.kubernetes.storage_csi.flex", VolumeHandle: "test-123"},
},
{
name: "driver name: ok ending with number",
csi: &core.CSIPersistentVolumeSource{Driver: "io.kubernetes.storage_csi.flex2", VolumeHandle: "test-123"},
},
{
name: "driver name: ok dot dash underscores",
csi: &core.CSIPersistentVolumeSource{Driver: "io.kubernetes-storage.csi_flex", VolumeHandle: "test-123"},
},
{
name: "driver name: invalid length 0",
csi: &core.CSIPersistentVolumeSource{Driver: "", VolumeHandle: "test-123"},
errtype: field.ErrorTypeRequired,
errfield: "driver",
},
{
name: "driver name: invalid length 1",
csi: &core.CSIPersistentVolumeSource{Driver: "a", VolumeHandle: "test-123"},
errtype: field.ErrorTypeInvalid,
errfield: "driver",
},
{
name: "driver name: invalid length > 63",
csi: &core.CSIPersistentVolumeSource{Driver: "comgooglestoragecsigcepdcomgooglestoragecsigcepdcomgooglestoragecsigcepdcomgooglestoragecsigcepd", VolumeHandle: "test-123"},
errtype: field.ErrorTypeTooLong,
errfield: "driver",
},
{
name: "driver name: invalid start char",
csi: &core.CSIPersistentVolumeSource{Driver: "_comgooglestoragecsigcepd", VolumeHandle: "test-123"},
errtype: field.ErrorTypeInvalid,
errfield: "driver",
},
{
name: "driver name: invalid end char",
csi: &core.CSIPersistentVolumeSource{Driver: "comgooglestoragecsigcepd/", VolumeHandle: "test-123"},
errtype: field.ErrorTypeInvalid,
errfield: "driver",
},
{
name: "driver name: invalid separators",
csi: &core.CSIPersistentVolumeSource{Driver: "com/google/storage/csi~gcepd", VolumeHandle: "test-123"},
errtype: field.ErrorTypeInvalid,
errfield: "driver",
},
}
defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIPersistentVolume, true)()
for i, tc := range testCases {
errs := validateCSIPersistentVolumeSource(tc.csi, field.NewPath("field"))
if len(errs) > 0 && tc.errtype == "" {
t.Errorf("[%d: %q] unexpected error(s): %v", i, tc.name, errs)
} else if len(errs) == 0 && tc.errtype != "" {
t.Errorf("[%d: %q] expected error type %v", i, tc.name, tc.errtype)
} else if len(errs) >= 1 {
if errs[0].Type != tc.errtype {
t.Errorf("[%d: %q] expected error type %v, got %v", i, tc.name, tc.errtype, errs[0].Type)
} else if !strings.HasSuffix(errs[0].Field, "."+tc.errfield) {
t.Errorf("[%d: %q] expected error on field %q, got %q", i, tc.name, tc.errfield, errs[0].Field)
}
}
}
} | explode_data.jsonl/1004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1783
} | [
2830,
3393,
17926,
6412,
3090,
4661,
3608,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
1444,
6321,
414,
353,
2153,
727,
50,
3298,
13931,
18902,
3608,
198,
197,
9859,
1313,
220,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestTable_revalidateSyncRecord(t *testing.T) {
transport := newPingRecorder()
tab, db := newTestTable(transport)
<-tab.initDone
defer db.Close()
defer tab.close()
// Insert a node.
var r enr.Record
r.Set(enr.IP(net.IP{127, 0, 0, 1}))
id := enode.ID{1}
n1 := wrapNode(enode.SignNull(&r, id))
tab.addSeenNode(n1)
// Update the node record.
r.Set(enr.WithEntry("foo", "bar"))
n2 := enode.SignNull(&r, id)
transport.updateRecord(n2)
tab.doRevalidate(make(chan struct{}, 1))
intable := tab.getNode(id)
if !reflect.DeepEqual(intable, n2) {
t.Fatalf("table contains old record with seq %d, want seq %d", intable.Seq(), n2.Seq())
}
} | explode_data.jsonl/11771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
2556,
1288,
7067,
12154,
6471,
1155,
353,
8840,
836,
8,
341,
197,
26445,
1669,
501,
69883,
47023,
741,
58149,
11,
2927,
1669,
501,
2271,
2556,
7,
26445,
340,
197,
45342,
6192,
8271,
17453,
198,
16867,
2927,
10421,
741,
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... | 2 |
func Test_docs_delete_by_query_216848930c2d344fe0bed0daa70c35b9(t *testing.T) {
es, _ := elasticsearch.NewDefaultClient()
// tag:216848930c2d344fe0bed0daa70c35b9[]
res, err := es.Tasks.List(
es.Tasks.List.WithActions("*/delete/byquery"),
es.Tasks.List.WithDetailed(true),
)
fmt.Println(res, err)
if err != nil { // SKIP
t.Fatalf("Error getting the response: %s", err) // SKIP
} // SKIP
defer res.Body.Close() // SKIP
// end:216848930c2d344fe0bed0daa70c35b9[]
} | explode_data.jsonl/45503 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
49692,
11353,
3710,
5738,
62,
17,
16,
21,
23,
19,
23,
24,
18,
15,
66,
17,
67,
18,
19,
19,
1859,
15,
2721,
15,
3235,
64,
22,
15,
66,
18,
20,
65,
24,
1155,
353,
8840,
836,
8,
341,
78966,
11,
716,
1669,
655,
27791,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewContractAddress(t *testing.T) {
key, _ := HexToECDSA(testPrivHex)
addr := common.HexToAddress(testAddrHex)
genAddr := PubkeyToAddress(key.PublicKey)
// sanity check before using addr to create contract address
checkAddr(t, genAddr, addr)
caddr0 := CreateAddress(addr, 0)
caddr1 := CreateAddress(addr, 1)
caddr2 := CreateAddress(addr, 2)
checkAddr(t, common.HexToAddress("63c530cd952041e4b66dba97835bb9cb927545229e"), caddr0)
checkAddr(t, common.HexToAddress("63a1cadbfd0f9ed9977e98905fe68b2529b2c8dbd2"), caddr1)
checkAddr(t, common.HexToAddress("633b60a6495edf652e5d3306698f98e2d10d252422"), caddr2)
} | explode_data.jsonl/43270 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
3564,
14067,
4286,
1155,
353,
8840,
836,
8,
341,
23634,
11,
716,
1669,
27228,
1249,
7498,
72638,
8623,
32124,
20335,
340,
53183,
1669,
4185,
91538,
1249,
4286,
8623,
13986,
20335,
340,
82281,
13986,
1669,
22611,
792,
1249,
428... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObserve(t *testing.T) {
type want struct {
cr *v1beta1.SecurityGroup
result managed.ExternalObservation
err error
}
cases := map[string]struct {
args
want
}{
"SuccessfulAvailable": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDescribe: func(ctx context.Context, input *awsec2.DescribeSecurityGroupsInput, opts []func(*awsec2.Options)) (*awsec2.DescribeSecurityGroupsOutput, error) {
return &awsec2.DescribeSecurityGroupsOutput{
SecurityGroups: []awsec2types.SecurityGroup{{}},
}, nil
},
},
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}),
withExternalName(sgID)),
},
want: want{
cr: sg(withExternalName(sgID),
withConditions(xpv1.Available())),
result: managed.ExternalObservation{
ResourceExists: true,
ResourceUpToDate: true,
},
},
},
"MultipleSGs": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDescribe: func(ctx context.Context, input *awsec2.DescribeSecurityGroupsInput, opts []func(*awsec2.Options)) (*awsec2.DescribeSecurityGroupsOutput, error) {
return &awsec2.DescribeSecurityGroupsOutput{
SecurityGroups: []awsec2types.SecurityGroup{{}, {}},
}, nil
},
},
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}),
withExternalName(sgID)),
},
want: want{
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}),
withExternalName(sgID)),
err: errors.New(errMultipleItems),
},
},
"DescribeFailure": {
args: args{
sg: &fake.MockSecurityGroupClient{
MockDescribe: func(ctx context.Context, input *awsec2.DescribeSecurityGroupsInput, opts []func(*awsec2.Options)) (*awsec2.DescribeSecurityGroupsOutput, error) {
return nil, errBoom
},
},
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}),
withExternalName(sgID)),
},
want: want{
cr: sg(withStatus(v1beta1.SecurityGroupObservation{
SecurityGroupID: sgID,
}),
withExternalName(sgID)),
err: awsclient.Wrap(errBoom, errDescribe),
},
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
e := &external{kube: tc.kube, sg: tc.sg}
o, err := e.Observe(context.Background(), tc.args.cr)
if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
if diff := cmp.Diff(tc.want.cr, tc.args.cr, test.EquateConditions()); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
if diff := cmp.Diff(tc.want.result, o); diff != "" {
t.Errorf("r: -want, +got:\n%s", diff)
}
})
}
} | explode_data.jsonl/79620 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1234
} | [
2830,
3393,
4121,
13267,
1155,
353,
8840,
836,
8,
341,
13158,
1366,
2036,
341,
197,
91492,
257,
353,
85,
16,
19127,
16,
21567,
2808,
198,
197,
9559,
8975,
5121,
15342,
37763,
367,
198,
197,
9859,
262,
1465,
198,
197,
630,
1444,
2264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSMTPHello(t *testing.T) {
c, err := LoadFile("testdata/conf.good.yml")
if err != nil {
t.Fatalf("Error parsing %s: %s", "testdata/conf.good.yml", err)
}
const refValue = "host.example.org"
var hostName = c.Global.SMTPHello
if hostName != refValue {
t.Errorf("Invalid SMTP Hello hostname: %s\nExpected: %s", hostName, refValue)
}
} | explode_data.jsonl/72919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
58198,
9707,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
8893,
1703,
445,
92425,
59241,
59569,
33936,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
22314,
1018,
82,
25,
1018,
82,
497,
330,
92425,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRegister1(t *testing.T) {
testRegisterWithFrontEnd(func() lib.Reactor { return NewFrontEnd() }, 5000.0, t,
3,
[]lib.Fault{
lib.Fault{
Kind: "omission",
Args: lib.Omission{From: "frontend", To: "register2", At: 3},
},
})
} | explode_data.jsonl/79903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
8690,
16,
1155,
353,
8840,
836,
8,
341,
18185,
8690,
2354,
23395,
3727,
18552,
368,
3051,
2817,
5621,
314,
470,
1532,
23395,
3727,
368,
2470,
220,
20,
15,
15,
15,
13,
15,
11,
259,
345,
197,
197,
18,
345,
197,
197,
1294... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObjectComprehensions(t *testing.T) {
nestedTerm := `[{"x": {a[i]: b[i] | xs = {"foo":{"a": ["baz", j]} | q[p]; p.a != "bar"; j = "foo"}; xs[j].a[k] = "foo"}}]`
nestedExpected := ArrayTerm(
ObjectTerm(Item(
StringTerm("x"),
ObjectComprehensionTerm(
RefTerm(VarTerm("a"), VarTerm("i")),
RefTerm(VarTerm("b"), VarTerm("i")),
NewBody(
Equality.Expr(
VarTerm("xs"),
ObjectComprehensionTerm(
StringTerm("foo"),
ObjectTerm(Item(StringTerm("a"), ArrayTerm(StringTerm("baz"), VarTerm("j")))),
NewBody(
NewExpr(RefTerm(VarTerm("q"), VarTerm("p"))),
NotEqual.Expr(RefTerm(VarTerm("p"), StringTerm("a")), StringTerm("bar")),
Equality.Expr(VarTerm("j"), StringTerm("foo")),
),
),
),
Equality.Expr(
RefTerm(VarTerm("xs"), VarTerm("j"), StringTerm("a"), VarTerm("k")),
StringTerm("foo"),
),
),
),
)),
)
assertParseOneTerm(t, "nested", nestedTerm, nestedExpected)
assertParseOneTerm(t, "ambiguous or", "{ 1+2: 3 | 4}", ObjectComprehensionTerm(
CallTerm(RefTerm(VarTerm("plus")), NumberTerm("1"), NumberTerm("2")),
NumberTerm("3"),
MustParseBody("4"),
))
} | explode_data.jsonl/50466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 555
} | [
2830,
3393,
1190,
1092,
30782,
4664,
1155,
353,
8840,
836,
8,
341,
9038,
9980,
17249,
1669,
77644,
4913,
87,
788,
314,
64,
989,
5669,
293,
989,
60,
760,
11943,
284,
5212,
7975,
22317,
64,
788,
4383,
42573,
497,
502,
13989,
760,
2804,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSelectorMatches(t *testing.T) {
expectMatch(t, "", Set{"x": "y"})
expectMatch(t, "x=y", Set{"x": "y"})
expectMatch(t, "x=y,z=w", Set{"x": "y", "z": "w"})
expectMatch(t, "x!=y,z!=w", Set{"x": "z", "z": "a"})
expectMatch(t, "notin=in", Set{"notin": "in"}) // in and notin in exactMatch
expectMatch(t, "x", Set{"x": "z"})
expectMatch(t, "!x", Set{"y": "z"})
expectMatch(t, "x>1", Set{"x": "2"})
expectMatch(t, "x<1", Set{"x": "0"})
expectNoMatch(t, "x=z", Set{})
expectNoMatch(t, "x=y", Set{"x": "z"})
expectNoMatch(t, "x=y,z=w", Set{"x": "w", "z": "w"})
expectNoMatch(t, "x!=y,z!=w", Set{"x": "z", "z": "w"})
expectNoMatch(t, "x", Set{"y": "z"})
expectNoMatch(t, "!x", Set{"x": "z"})
expectNoMatch(t, "x>1", Set{"x": "0"})
expectNoMatch(t, "x<1", Set{"x": "2"})
labelset := Set{
"foo": "bar",
"baz": "blah",
}
expectMatch(t, "foo=bar", labelset)
expectMatch(t, "baz=blah", labelset)
expectMatch(t, "foo=bar,baz=blah", labelset)
expectNoMatch(t, "foo=blah", labelset)
expectNoMatch(t, "baz=bar", labelset)
expectNoMatch(t, "foo=bar,foobar=bar,baz=blah", labelset)
} | explode_data.jsonl/29766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 572
} | [
2830,
3393,
5877,
42470,
1155,
353,
8840,
836,
8,
341,
24952,
8331,
1155,
11,
7342,
2573,
4913,
87,
788,
330,
88,
23625,
24952,
8331,
1155,
11,
330,
87,
29368,
497,
2573,
4913,
87,
788,
330,
88,
23625,
24952,
8331,
1155,
11,
330,
87... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJNISDK(t *testing.T) {
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
system_shared_libs: [],
stl: "none",
sdk_version: "current",
}
android_test {
name: "app_platform",
jni_libs: ["libjni"],
platform_apis: true,
}
android_test {
name: "app_sdk",
jni_libs: ["libjni"],
sdk_version: "current",
}
android_test {
name: "app_force_platform",
jni_libs: ["libjni"],
sdk_version: "current",
jni_uses_platform_apis: true,
}
android_test {
name: "app_force_sdk",
jni_libs: ["libjni"],
platform_apis: true,
jni_uses_sdk_apis: true,
}
cc_library {
name: "libvendorjni",
system_shared_libs: [],
stl: "none",
vendor: true,
}
android_test {
name: "app_vendor",
jni_libs: ["libvendorjni"],
sdk_version: "current",
vendor: true,
}
`)
testCases := []struct {
name string
sdkJNI bool
vendorJNI bool
}{
{name: "app_platform"},
{name: "app_sdk", sdkJNI: true},
{name: "app_force_platform"},
{name: "app_force_sdk", sdkJNI: true},
{name: "app_vendor", vendorJNI: true},
}
platformJNI := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_shared").
Output("libjni.so").Output.String()
sdkJNI := ctx.ModuleForTests("libjni", "android_arm64_armv8-a_sdk_shared").
Output("libjni.so").Output.String()
vendorJNI := ctx.ModuleForTests("libvendorjni", "android_arm64_armv8-a_shared").
Output("libvendorjni.so").Output.String()
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput("jnilibs.zip")
if len(jniLibZip.Implicits) != 1 {
t.Fatalf("expected exactly one jni library, got %q", jniLibZip.Implicits.Strings())
}
gotJNI := jniLibZip.Implicits[0].String()
if test.sdkJNI {
if gotJNI != sdkJNI {
t.Errorf("expected SDK JNI library %q, got %q", sdkJNI, gotJNI)
}
} else if test.vendorJNI {
if gotJNI != vendorJNI {
t.Errorf("expected platform JNI library %q, got %q", vendorJNI, gotJNI)
}
} else {
if gotJNI != platformJNI {
t.Errorf("expected platform JNI library %q, got %q", platformJNI, gotJNI)
}
}
})
}
t.Run("jni_uses_platform_apis_error", func(t *testing.T) {
testJavaError(t, `jni_uses_platform_apis: can only be set for modules that set sdk_version`, `
android_test {
name: "app_platform",
platform_apis: true,
jni_uses_platform_apis: true,
}
`)
})
t.Run("jni_uses_sdk_apis_error", func(t *testing.T) {
testJavaError(t, `jni_uses_sdk_apis: can only be set for modules that do not set sdk_version`, `
android_test {
name: "app_sdk",
sdk_version: "current",
jni_uses_sdk_apis: true,
}
`)
})
} | explode_data.jsonl/58492 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1337
} | [
2830,
3393,
41,
45,
1637,
18301,
1155,
353,
8840,
836,
8,
341,
20985,
11,
716,
1669,
1273,
15041,
1155,
11,
12527,
1224,
1856,
8164,
35,
7124,
2461,
2271,
45632,
52924,
7257,
3989,
197,
63517,
39461,
341,
298,
11609,
25,
330,
2740,
79... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientErrorsCanBeCaused(t *testing.T) {
rootErr := fmt.Errorf("some root cause")
httpClient := &http.Client{
Transport: &failingTransport{rootErr},
}
client := NewHaberdasherJSONClient("", httpClient)
_, err := client.MakeHat(context.Background(), &Size{Inches: 1})
if err == nil {
t.Errorf("JSON MakeHat err is unexpectedly nil")
}
cause := errCause(err)
if cause != rootErr {
t.Errorf("JSON MakeHat err cause is %q, want %q", cause, rootErr)
}
client = NewHaberdasherProtobufClient("", httpClient)
_, err = client.MakeHat(context.Background(), &Size{Inches: 1})
if err == nil {
t.Errorf("Protobuf MakeHat err is unexpectedly nil")
}
cause = errCause(err)
if cause != rootErr {
t.Errorf("Protobuf MakeHat err cause is %q, want %q", cause, rootErr)
}
} | explode_data.jsonl/619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
2959,
13877,
69585,
22571,
2591,
1155,
353,
8840,
836,
8,
341,
33698,
7747,
1669,
8879,
13080,
445,
14689,
3704,
5240,
1138,
28080,
2959,
1669,
609,
1254,
11716,
515,
197,
197,
27560,
25,
609,
69,
14277,
27560,
90,
2888,
774... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTimeMillisLogicalTypeUnionEncode(t *testing.T) {
schema := `{"type": ["null", {"type": "int", "logicalType": "time-millis"}]}`
testBinaryEncodeFail(t, schema, "test", "cannot transform to binary time-millis, expected time.Duration, received string")
testBinaryCodecPass(t, schema, 66904022*time.Millisecond, []byte("\x02\xac\xff\xe6\x3f"))
} | explode_data.jsonl/12008 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
1462,
17897,
64312,
929,
32658,
32535,
1155,
353,
8840,
836,
8,
341,
1903,
3416,
1669,
1565,
4913,
1313,
788,
4383,
2921,
497,
5212,
1313,
788,
330,
396,
497,
330,
30256,
929,
788,
330,
1678,
1448,
56212,
9207,
13989,
3989,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOcToInternal(t *testing.T) {
ocNode := &occommon.Node{}
ocResource1 := &ocresource.Resource{Labels: map[string]string{"resource-attr": "resource-attr-val-1"}}
ocResource2 := &ocresource.Resource{Labels: map[string]string{"resource-attr": "resource-attr-val-2"}}
startTime := timestamppb.New(testdata.TestSpanStartTime)
eventTime := timestamppb.New(testdata.TestSpanEventTime)
endTime := timestamppb.New(testdata.TestSpanEndTime)
ocSpan1 := &octrace.Span{
Name: &octrace.TruncatableString{Value: "operationA"},
StartTime: startTime,
EndTime: endTime,
TimeEvents: &octrace.Span_TimeEvents{
TimeEvent: []*octrace.Span_TimeEvent{
{
Time: eventTime,
Value: &octrace.Span_TimeEvent_Annotation_{
Annotation: &octrace.Span_TimeEvent_Annotation{
Description: &octrace.TruncatableString{Value: "event-with-attr"},
Attributes: &octrace.Span_Attributes{
AttributeMap: map[string]*octrace.AttributeValue{
"span-event-attr": {
Value: &octrace.AttributeValue_StringValue{
StringValue: &octrace.TruncatableString{Value: "span-event-attr-val"},
},
},
},
DroppedAttributesCount: 2,
},
},
},
},
{
Time: eventTime,
Value: &octrace.Span_TimeEvent_Annotation_{
Annotation: &octrace.Span_TimeEvent_Annotation{
Description: &octrace.TruncatableString{Value: "event"},
Attributes: &octrace.Span_Attributes{
DroppedAttributesCount: 2,
},
},
},
},
},
DroppedAnnotationsCount: 1,
},
Attributes: &octrace.Span_Attributes{
DroppedAttributesCount: 1,
},
Status: &octrace.Status{Message: "status-cancelled", Code: 1},
}
// TODO: Create another unit test fully covering ocSpanToInternal
ocSpanZeroedParentID := proto.Clone(ocSpan1).(*octrace.Span)
ocSpanZeroedParentID.ParentSpanId = []byte{0, 0, 0, 0, 0, 0, 0, 0}
ocSpan2 := &octrace.Span{
Name: &octrace.TruncatableString{Value: "operationB"},
StartTime: startTime,
EndTime: endTime,
Links: &octrace.Span_Links{
Link: []*octrace.Span_Link{
{
Attributes: &octrace.Span_Attributes{
AttributeMap: map[string]*octrace.AttributeValue{
"span-link-attr": {
Value: &octrace.AttributeValue_StringValue{
StringValue: &octrace.TruncatableString{Value: "span-link-attr-val"},
},
},
},
DroppedAttributesCount: 4,
},
},
{
Attributes: &octrace.Span_Attributes{
DroppedAttributesCount: 4,
},
},
},
DroppedLinksCount: 3,
},
}
ocSpan3 := &octrace.Span{
Name: &octrace.TruncatableString{Value: "operationC"},
StartTime: startTime,
EndTime: endTime,
Resource: ocResource2,
Attributes: &octrace.Span_Attributes{
AttributeMap: map[string]*octrace.AttributeValue{
"span-attr": {
Value: &octrace.AttributeValue_StringValue{
StringValue: &octrace.TruncatableString{Value: "span-attr-val"},
},
},
},
DroppedAttributesCount: 5,
},
}
tests := []struct {
name string
td pdata.Traces
node *occommon.Node
resource *ocresource.Resource
spans []*octrace.Span
}{
{
name: "empty",
td: pdata.NewTraces(),
},
{
name: "one-empty-resource-spans",
td: testdata.GenerateTracesOneEmptyResourceSpans(),
node: ocNode,
},
{
name: "no-libraries",
td: testdata.GenerateTracesNoLibraries(),
resource: ocResource1,
},
{
name: "one-span-no-resource",
td: testdata.GenerateTracesOneSpanNoResource(),
node: ocNode,
resource: &ocresource.Resource{},
spans: []*octrace.Span{ocSpan1},
},
{
name: "one-span",
td: testdata.GenerateTracesOneSpan(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpan1},
},
{
name: "one-span-zeroed-parent-id",
td: testdata.GenerateTracesOneSpan(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpanZeroedParentID},
},
{
name: "one-span-one-nil",
td: testdata.GenerateTracesOneSpan(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpan1, nil},
},
{
name: "two-spans-same-resource",
td: testdata.GenerateTracesTwoSpansSameResource(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpan1, nil, ocSpan2},
},
{
name: "two-spans-same-resource-one-different",
td: testdata.GenerateTracesTwoSpansSameResourceOneDifferent(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpan1, ocSpan2, ocSpan3},
},
{
name: "two-spans-and-separate-in-the-middle",
td: testdata.GenerateTracesTwoSpansSameResourceOneDifferent(),
node: ocNode,
resource: ocResource1,
spans: []*octrace.Span{ocSpan1, ocSpan3, ocSpan2},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.EqualValues(t, test.td, OCToTraces(test.node, test.resource, test.spans))
})
}
} | explode_data.jsonl/53773 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2422
} | [
2830,
3393,
46,
66,
1249,
11569,
1155,
353,
8840,
836,
8,
341,
197,
509,
1955,
1669,
609,
509,
5464,
21714,
16094,
197,
509,
4783,
16,
1669,
609,
509,
9233,
20766,
90,
23674,
25,
2415,
14032,
30953,
4913,
9233,
12,
2991,
788,
330,
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... | 1 |
func TestTagMissingValue(t *testing.T) {
var opts = struct {
Value bool `short:`
}{}
assertParseFail(t, ErrTag, "expected `\"' to start tag value at end of tag (in `short:`)", &opts, "")
} | explode_data.jsonl/44076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
5668,
25080,
1130,
1155,
353,
8840,
836,
8,
972,
2405,
12185,
284,
2036,
972,
197,
47399,
1807,
1565,
8676,
18736,
319,
197,
15170,
2570,
6948,
14463,
19524,
1155,
11,
15495,
5668,
11,
330,
7325,
1565,
2105,
6,
311,
1191,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestDriverPublishesError(t *testing.T) {
testAdaptor := newAioTestAdaptor()
pin := "456"
drivers := []DriverAndEventer{
NewGroveSoundSensorDriver(testAdaptor, pin),
NewGroveLightSensorDriver(testAdaptor, pin),
NewGrovePiezoVibrationSensorDriver(testAdaptor, pin),
NewGroveRotaryDriver(testAdaptor, pin),
}
for _, driver := range drivers {
sem := make(chan struct{}, 1)
// send error
returnErr := func() (val int, err error) {
err = errors.New("read error")
return
}
testAdaptor.TestAdaptorAnalogRead(returnErr)
gobottest.Assert(t, driver.Start(), nil)
// expect error
driver.Once(driver.Event(Error), func(data interface{}) {
gobottest.Assert(t, data.(error).Error(), "read error")
close(sem)
})
select {
case <-sem:
case <-time.After(time.Second):
t.Errorf("%s Event \"Error\" was not published", getType(driver))
}
// Cleanup
driver.Halt()
}
} | explode_data.jsonl/1452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 350
} | [
2830,
3393,
11349,
50145,
288,
1454,
1155,
353,
8840,
836,
8,
341,
18185,
2589,
32657,
1669,
501,
32,
815,
2271,
2589,
32657,
741,
3223,
258,
1669,
330,
19,
20,
21,
1837,
2698,
81,
1945,
1669,
3056,
11349,
3036,
1556,
261,
515,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadBlockIndexEquals(t *testing.T) {
defer os.RemoveAll("temp")
testDB := dbm.NewDB("testdb", "leveldb", "temp")
store := NewStore(testDB)
block := config.GenesisBlock()
txStatus := bc.NewTransactionStatus()
expectBlockIndex := state.NewBlockIndex()
var parent *state.BlockNode
for block.Height <= 100 {
if err := store.SaveBlock(block, txStatus); err != nil {
t.Fatal(err)
}
if block.Height != 0 {
parent = expectBlockIndex.GetNode(&block.PreviousBlockHash)
}
node, err := state.NewBlockNode(&block.BlockHeader, parent)
if err != nil {
t.Fatal(err)
}
expectBlockIndex.AddNode(node)
block.PreviousBlockHash = block.Hash()
block.Height++
}
index, err := store.LoadBlockIndex(100)
if err != nil {
t.Fatal(err)
}
if !testutil.DeepEqual(expectBlockIndex, index) {
t.Errorf("got block index:%v, expect block index:%v", index, expectBlockIndex)
}
} | explode_data.jsonl/49975 | {
"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,
5879,
4713,
1552,
4315,
1155,
353,
8840,
836,
8,
341,
16867,
2643,
84427,
445,
3888,
1138,
18185,
3506,
1669,
2927,
76,
7121,
3506,
445,
1944,
1999,
497,
330,
3449,
783,
65,
497,
330,
3888,
1138,
57279,
1669,
1532,
6093,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestRestoreSnapshot(t *testing.T) {
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
snapshot := Snapshot{Name: SnapshotName}
if err := c.RestoreSnapshot(snapshot, ContainerRestoreName); err != nil {
t.Errorf(err.Error())
}
} | explode_data.jsonl/2743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
56284,
15009,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
4502,
75145,
675,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
1903,
9601,
1669,
68697,
63121,
25,
68697,
675,
532,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestUpdateOrderbook(t *testing.T) {
t.Parallel()
cp := currency.NewPairWithDelimiter(currency.BTC.String(), currency.USDT.String(), "/")
_, err := f.UpdateOrderbook(context.Background(), cp, asset.Spot)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
4289,
4431,
2190,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
52018,
1669,
11413,
7121,
12443,
2354,
91098,
90475,
1785,
7749,
6431,
1507,
11413,
67672,
10599,
6431,
1507,
3521,
1138,
197,
6878,
1848,
1669,
282,
1668... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewOrQuery_Next(t *testing.T) {
sl := datastruct.NewSkipList(datastruct.DefaultMaxLevel)
sl.Add(document.DocId(1), 1)
sl.Add(document.DocId(3), 2)
sl.Add(document.DocId(6), 2)
sl.Add(document.DocId(10), 1)
sl1 := datastruct.NewSkipList(datastruct.DefaultMaxLevel)
sl1.Add(document.DocId(1), [1]byte{})
sl1.Add(document.DocId(4), [1]byte{})
sl1.Add(document.DocId(6), [1]byte{})
sl1.Add(document.DocId(9), [1]byte{})
sl1.Add(document.DocId(10), [1]byte{})
sl1.Add(document.DocId(94), [1]byte{})
sl1.Add(document.DocId(944), [1]byte{})
sl2 := datastruct.NewSkipList(datastruct.DefaultMaxLevel)
sl2.Add(document.DocId(2), [1]byte{})
sl2.Add(document.DocId(5), [1]byte{})
sl2.Add(document.DocId(6), [1]byte{})
sl2.Add(document.DocId(8), [1]byte{})
Convey("or query next(one query)", t, func() {
a := NewOrQuery([]Query{NewTermQuery(sl.Iterator())}, []check.Checker{
check.NewChecker(sl.Iterator(), 1, operation.EQ, nil, false),
})
testCase := []document.DocId{1, 10}
for _, expect := range testCase {
v, e := a.Current()
a.Next()
So(v, ShouldEqual, expect)
So(e, ShouldBeNil)
}
v, e := a.Current()
a.Next()
So(v, ShouldEqual, 0)
So(e, ShouldNotBeNil)
})
Convey("or query next (three queries)", t, func() {
a := NewOrQuery([]Query{NewTermQuery(sl2.Iterator()), NewTermQuery(sl.Iterator()), NewTermQuery(sl1.Iterator())}, nil)
expectVec := []document.DocId{
1, 2, 3, 4, 5, 6, 8, 9, 10, 94, 944,
}
for _, expect := range expectVec {
v, e := a.Current()
So(v, ShouldEqual, expect)
So(e, ShouldBeNil)
a.Next()
}
a.Next()
v, e := a.Current()
So(v, ShouldEqual, 0)
So(e, ShouldNotBeNil)
})
} | explode_data.jsonl/43259 | {
"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,
3564,
2195,
2859,
1604,
427,
1155,
353,
8840,
836,
8,
341,
78626,
1669,
821,
1235,
7121,
35134,
852,
2592,
1235,
13275,
5974,
4449,
692,
78626,
1904,
15290,
42452,
764,
7,
16,
701,
220,
16,
340,
78626,
1904,
15290,
42452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDNSTruncated(t *testing.T) {
// Google DNS
address := "8.8.8.8:53"
u, err := AddressToUpstream(address, Options{Timeout: timeout})
if err != nil {
t.Fatalf("error while creating an upstream: %s", err)
}
req := new(dns.Msg)
req.SetQuestion("unit-test2.dns.adguard.com.", dns.TypeTXT)
req.RecursionDesired = true
res, err := u.Exchange(req)
if err != nil {
t.Fatalf("error while making a request: %s", err)
}
if res.Truncated {
t.Fatalf("response must NOT be truncated")
}
} | explode_data.jsonl/19773 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
31264,
784,
81,
38007,
1155,
353,
8840,
836,
8,
341,
197,
322,
5085,
27598,
198,
63202,
1669,
330,
23,
13,
23,
13,
23,
13,
23,
25,
20,
18,
698,
10676,
11,
1848,
1669,
9177,
1249,
2324,
4027,
15434,
11,
14566,
90,
7636,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateCertificates(t *testing.T) {
route := &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Name: "observatorium-api",
Namespace: namespace,
},
Spec: routev1.RouteSpec{
Host: "apiServerURL",
},
}
mco := getMco()
s := scheme.Scheme
mcov1beta2.SchemeBuilder.AddToScheme(s)
routev1.AddToScheme(s)
c := fake.NewFakeClient(route)
err := CreateObservabilityCerts(c, s, mco)
if err != nil {
t.Fatalf("CreateObservabilityCerts: (%v)", err)
}
err = CreateObservabilityCerts(c, s, mco)
if err != nil {
t.Fatalf("Rerun CreateObservabilityCerts: (%v)", err)
}
err, _ = createCASecret(c, s, mco, true, serverCACerts, serverCACertifcateCN)
if err != nil {
t.Fatalf("Failed to renew server ca certificates: (%v)", err)
}
err = createCertSecret(c, s, mco, true, grafanaCerts, false, grafanaCertificateCN, nil, nil, nil)
if err != nil {
t.Fatalf("Failed to renew server certificates: (%v)", err)
}
} | explode_data.jsonl/82271 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 398
} | [
2830,
3393,
4021,
97140,
1155,
353,
8840,
836,
8,
341,
7000,
2133,
1669,
609,
8966,
85,
16,
58004,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
22764,
65744,
23904,
756,
298,
90823,
25,
4473,
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... | 5 |
func TestCLITimeout(t *testing.T) {
defer leaktest.AfterTest(t)()
c := newCLITest(cliTestParams{})
defer c.cleanup()
// Wrap the meat of the test in a retry loop. Setting a timeout like this is
// racy as the operation may have succeeded by the time the scheduler gives
// the timeout a chance to have an effect. We specify --all to include some
// slower to access virtual tables in the query.
testutils.SucceedsSoon(t, func() error {
out, err := c.RunWithCapture("node status 1 --all --timeout 1ns")
if err != nil {
t.Fatal(err)
}
const exp = `node status 1 --all --timeout 1ns
pq: query execution canceled due to statement timeout
`
if out != exp {
err := errors.Errorf("unexpected output:\n%q\nwanted:\n%q", out, exp)
t.Log(err)
return err
}
return nil
})
} | explode_data.jsonl/33197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
3140,
952,
545,
411,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
1444,
1669,
501,
3140,
952,
477,
70249,
2271,
4870,
37790,
16867,
272,
87689,
2822,
197,
322,
42187,
279,
13041,
315,
279,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTaskTemplateConnectInputToActionTemplate(t *testing.T) {
tt := &TaskTemplate{
DataPipeTemplates: []DataPipeTemplate{},
}
expectDataPipeTemplate := DataPipeTemplate{
TaskInputName: "in1",
DestActionName: "Action1",
DestInputName: "in2",
}
err := tt.ConnectInputToActionTemplate("in1", "Action1", "in2")
assert.Nil(t, err)
assert.Equal(t, 1, len(tt.DataPipeTemplates))
assert.Equal(t, expectDataPipeTemplate, tt.DataPipeTemplates[0])
} | explode_data.jsonl/19602 | {
"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,
6262,
7275,
14611,
2505,
1249,
2512,
7275,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
609,
6262,
7275,
515,
197,
40927,
34077,
51195,
25,
3056,
1043,
34077,
7275,
38837,
197,
630,
24952,
1043,
34077,
7275,
1669,
2885,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue15725(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
tk.MustExec("insert into t values(2)")
tk.MustQuery("select * from t where (not not a) = a").Check(testkit.Rows())
tk.MustQuery("select * from t where (not not not not a) = a").Check(testkit.Rows())
} | explode_data.jsonl/65522 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
42006,
16,
20,
22,
17,
20,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUsedArg(t *testing.T) {
tc := requireTestCase(t, `
"".split(s,$)
`)
comps := requireCompletions(t, tc, KWArgs{}, CallPatterns{})
for _, c := range comps {
for _, ph := range c.Snippet.Placeholders() {
arg := c.Snippet.Text[ph.Begin:ph.End]
assert.NotEqual(t, "sep", arg)
}
}
} | explode_data.jsonl/56041 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
22743,
2735,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
1373,
16458,
1155,
11,
22074,
69355,
6960,
1141,
4779,
340,
197,
63,
692,
32810,
1690,
1669,
1373,
1092,
10819,
908,
1155,
11,
17130,
11,
71915,
4117,
22655,
7143,
5765... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientRegister(t *testing.T) {
cs := createClientStore()
info := createClientInfo()
clientID := info.ID
hbInbox := info.HbInbox
// Register a new one
sc, err := cs.register(info)
if err != nil {
t.Fatalf("Error on register: %v", err)
}
if sc == nil {
t.Fatal("Unable to register client")
}
// Verify it's in the list of clients
c := cs.lookup(clientID)
if c == nil {
t.Fatal("Expected client to be registered")
}
// Verify the created client
func() {
c.RLock()
defer c.RUnlock()
if c.info.ID != clientID {
t.Fatalf("Expected client id to be %v, got %v", clientID, c.info.ID)
}
if c.info.HbInbox != hbInbox {
t.Fatalf("Expected client hbInbox to be %v, got %v", hbInbox, c.info.HbInbox)
}
if c.hbt != nil {
t.Fatal("Did not expect timer to be set")
}
if c.fhb != 0 {
t.Fatalf("Expected fhb to be 0, got %v", c.fhb)
}
if len(c.subs) != 0 {
t.Fatalf("Expected subs count to be 0, got %v", len(c.subs))
}
}()
// Try to register with same clientID, should get an error
secondCli, err := cs.register(&spb.ClientInfo{ID: clientID, HbInbox: hbInbox})
if secondCli != nil || err != ErrInvalidClient {
t.Fatalf("Expected to get no client and an error, got %v err=%v", secondCli, err)
}
} | explode_data.jsonl/37756 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 533
} | [
2830,
3393,
2959,
8690,
1155,
353,
8840,
836,
8,
341,
71899,
1669,
1855,
2959,
6093,
2822,
27043,
1669,
1855,
2959,
1731,
741,
25291,
915,
1669,
3546,
9910,
198,
9598,
65,
641,
2011,
1669,
3546,
3839,
65,
641,
2011,
271,
197,
322,
845... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGlobalScopeAndVariables(t *testing.T) {
runTest(t, "consts", func(client *daptest.Client, fixture protest.Fixture) {
runDebugSessionWithBPs(t, client, "launch",
// Launch
func() {
client.LaunchRequestWithArgs(map[string]interface{}{
"mode": "exec", "program": fixture.Path, "showGlobalVariables": true,
})
},
// Breakpoints are set within the program
fixture.Source, []int{},
[]onBreakpoint{{
// Stop at line 36
execute: func() {
client.StackTraceRequest(1, 0, 20)
stack := client.ExpectStackTraceResponse(t)
checkStackFrames(t, stack, "main.main", 36, 1000, 3, 3)
client.ScopesRequest(1000)
scopes := client.ExpectScopesResponse(t)
checkScope(t, scopes, 0, "Arguments", 1000)
checkScope(t, scopes, 1, "Locals", 1001)
checkScope(t, scopes, 2, "Globals (package main)", 1002)
client.VariablesRequest(1002)
client.ExpectVariablesResponse(t)
// The program has no user-defined globals.
// Depending on the Go version, there might
// be some runtime globals (e.g. main..inittask)
// so testing for the total number is too fragile.
// Step into pkg.AnotherMethod()
client.StepInRequest(1)
client.ExpectStepInResponse(t)
client.ExpectStoppedEvent(t)
client.StackTraceRequest(1, 0, 20)
stack = client.ExpectStackTraceResponse(t)
checkStackFrames(t, stack, "", 13, 1000, 4, 4)
client.ScopesRequest(1000)
scopes = client.ExpectScopesResponse(t)
checkScope(t, scopes, 0, "Arguments", 1000)
checkScope(t, scopes, 1, "Locals", 1001)
checkScope(t, scopes, 2, "Globals (package github.com/go-delve/delve/_fixtures/internal/dir0/pkg)", 1002)
client.VariablesRequest(1002)
globals := client.ExpectVariablesResponse(t)
checkChildren(t, globals, "Globals", 1)
ref := checkVarExact(t, globals, 0, "SomeVar", "github.com/go-delve/delve/_fixtures/internal/dir0/pkg.SomeVar", "github.com/go-delve/delve/_fixtures/internal/dir0/pkg.SomeType {X: 0}", "github.com/go-delve/delve/_fixtures/internal/dir0/pkg.SomeType", hasChildren)
if ref > 0 {
client.VariablesRequest(ref)
somevar := client.ExpectVariablesResponse(t)
checkChildren(t, somevar, "SomeVar", 1)
// TODO(polina): unlike main.p, this prefix won't work
checkVarExact(t, somevar, 0, "X", "github.com/go-delve/delve/_fixtures/internal/dir0/pkg.SomeVar.X", "0", "float64", noChildren)
}
},
disconnect: false,
}})
})
} | explode_data.jsonl/17321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1056
} | [
2830,
3393,
11646,
10803,
3036,
22678,
1155,
353,
8840,
836,
8,
341,
56742,
2271,
1155,
11,
330,
95773,
497,
2915,
12805,
353,
91294,
1944,
11716,
11,
12507,
8665,
991,
12735,
8,
341,
197,
56742,
7939,
5283,
2354,
33,
20420,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGocloak_ListAddRemoveOptionalClientScopes(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)
token := GetAdminToken(t, client)
defer ClearRealmCache(t, client)
scope := ClientScope{
Protocol: "openid-connect",
ClientScopeAttributes: &ClientScopeAttributes{
IncludeInTokenScope: "true",
},
}
tearDown, scopeID := CreateClientScope(t, client, &scope)
defer tearDown()
scopesBeforeAdding, err := client.GetClientsOptionalScopes(token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID)
assert.NoError(t, err, "GetClientsOptionalScopes failed")
err = client.AddOptionalScopeToClient(
token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID,
scopeID)
assert.NoError(t, err, "AddOptionalScopeToClient failed")
scopesAfterAdding, err := client.GetClientsOptionalScopes(token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID)
assert.NoError(t, err, "GetClientsOptionalScopes failed")
assert.NotEqual(t, len(scopesAfterAdding), len(scopesBeforeAdding), "scope should have been added")
err = client.RemoveOptionalScopeFromClient(
token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID,
scopeID)
assert.NoError(t, err, "RemoveOptionalScopeFromClient failed")
scopesAfterRemoving, err := client.GetClientsOptionalScopes(token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID)
assert.NoError(t, err, "GetClientsOptionalScopes failed")
assert.Equal(t, len(scopesBeforeAdding), len(scopesAfterRemoving), "scope should have been removed")
} | explode_data.jsonl/79527 | {
"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,
38,
509,
385,
585,
27104,
2212,
13021,
15309,
2959,
3326,
18523,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
1669,
2126,
2648,
1155,
340,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
43947,
1669,
2126,
72... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderCancelFulfillment(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("POST", fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/1/fulfillments/2/cancel.json", client.pathPrefix),
httpmock.NewBytesResponder(200, loadFixture("fulfillment.json")))
returnedFulfillment, err := client.Order.CancelFulfillment(1, 2)
if err != nil {
t.Errorf("Order.CancelFulfillment() returned error: %v", err)
}
FulfillmentTests(t, *returnedFulfillment)
} | explode_data.jsonl/18005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
4431,
9269,
37,
86516,
478,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
28080,
16712,
19983,
30884,
445,
2946,
497,
8879,
17305,
445,
2428,
1110,
824,
9267,
453,
12618,
8675,
1437,
905,
12627,
82,
82818,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHoverIntLiteral(t *testing.T) {
testenv.NeedsGo1Point(t, 13)
const source = `
-- main.go --
package main
var (
bigBin = 0b1001001
)
var hex = 0xe34e
func main() {
}
`
Run(t, source, func(t *testing.T, env *Env) {
env.OpenFile("main.go")
hexExpected := "58190"
got, _ := env.Hover("main.go", env.RegexpSearch("main.go", "hex"))
if got != nil && !strings.Contains(got.Value, hexExpected) {
t.Errorf("Hover: missing expected field '%s'. Got:\n%q", hexExpected, got.Value)
}
binExpected := "73"
got, _ = env.Hover("main.go", env.RegexpSearch("main.go", "bigBin"))
if got != nil && !strings.Contains(got.Value, binExpected) {
t.Errorf("Hover: missing expected field '%s'. Got:\n%q", binExpected, got.Value)
}
})
} | explode_data.jsonl/68798 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 323
} | [
2830,
3393,
34379,
1072,
17350,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
2067,
68,
6767,
10850,
16,
2609,
1155,
11,
220,
16,
18,
340,
4777,
2530,
284,
22074,
313,
1887,
18002,
39514,
1722,
1887,
271,
947,
2399,
2233,
343,
28794,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestVStreamCopyWithDifferentFilters(t *testing.T) {
if testing.Short() {
t.Skip()
}
execStatements(t, []string{
"create table t1(id1 int, id2 int, id3 int, primary key(id1))",
"create table t2a(id1 int, id2 int, primary key(id1))",
"create table t2b(id1 varchar(20), id2 int, primary key(id1))",
})
defer execStatements(t, []string{
"drop table t1",
"drop table t2a",
"drop table t2b",
})
engine.se.Reload(context.Background())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
filter := &binlogdatapb.Filter{
Rules: []*binlogdatapb.Rule{{
Match: "/t2.*",
}, {
Match: "t1",
Filter: "select id1, id2 from t1",
}},
}
execStatements(t, []string{
"insert into t1(id1, id2, id3) values (1, 2, 3)",
"insert into t2a(id1, id2) values (1, 4)",
"insert into t2b(id1, id2) values ('b', 6)",
"insert into t2b(id1, id2) values ('a', 5)",
})
var expectedEvents = []string{
"type:BEGIN",
"type:FIELD field_event:{table_name:\"t1\" fields:{name:\"id1\" type:INT32 table:\"t1\" org_table:\"t1\" database:\"vttest\" org_name:\"id1\" column_length:11 charset:63} fields:{name:\"id2\" type:INT32 table:\"t1\" org_table:\"t1\" database:\"vttest\" org_name:\"id2\" column_length:11 charset:63}}",
"type:GTID",
"type:ROW row_event:{table_name:\"t1\" row_changes:{after:{lengths:1 lengths:1 values:\"12\"}}}",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t1\" lastpk:{rows:{lengths:1 values:\"1\"}}}}",
"type:COMMIT",
"type:BEGIN",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t1\"} completed:true}",
"type:COMMIT",
"type:BEGIN",
"type:FIELD field_event:{table_name:\"t2a\" fields:{name:\"id1\" type:INT32 table:\"t2a\" org_table:\"t2a\" database:\"vttest\" org_name:\"id1\" column_length:11 charset:63} fields:{name:\"id2\" type:INT32 table:\"t2a\" org_table:\"t2a\" database:\"vttest\" org_name:\"id2\" column_length:11 charset:63}}",
"type:ROW row_event:{table_name:\"t2a\" row_changes:{after:{lengths:1 lengths:1 values:\"14\"}}}",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t2a\" lastpk:{rows:{lengths:1 values:\"1\"}}}}",
"type:COMMIT",
"type:BEGIN",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t2a\"} completed:true}",
"type:COMMIT",
"type:BEGIN",
"type:FIELD field_event:{table_name:\"t2b\" fields:{name:\"id1\" type:VARCHAR table:\"t2b\" org_table:\"t2b\" database:\"vttest\" org_name:\"id1\" column_length:80 charset:45} fields:{name:\"id2\" type:INT32 table:\"t2b\" org_table:\"t2b\" database:\"vttest\" org_name:\"id2\" column_length:11 charset:63}}",
"type:ROW row_event:{table_name:\"t2b\" row_changes:{after:{lengths:1 lengths:1 values:\"a5\"}}}",
"type:ROW row_event:{table_name:\"t2b\" row_changes:{after:{lengths:1 lengths:1 values:\"b6\"}}}",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t2b\" lastpk:{rows:{lengths:1 values:\"b\"}}}}",
"type:COMMIT",
"type:BEGIN",
"type:LASTPK last_p_k_event:{table_last_p_k:{table_name:\"t2b\"} completed:true}",
"type:COMMIT",
}
var allEvents []*binlogdatapb.VEvent
var wg sync.WaitGroup
wg.Add(1)
ctx2, cancel2 := context.WithDeadline(ctx, time.Now().Add(10*time.Second))
defer cancel2()
var errGoroutine error
go func() {
defer wg.Done()
engine.Stream(ctx2, "", nil, filter, func(evs []*binlogdatapb.VEvent) error {
for _, ev := range evs {
if ev.Type == binlogdatapb.VEventType_HEARTBEAT {
continue
}
allEvents = append(allEvents, ev)
}
if len(allEvents) == len(expectedEvents) {
log.Infof("Got %d events as expected", len(allEvents))
for i, ev := range allEvents {
ev.Timestamp = 0
if ev.Type == binlogdatapb.VEventType_FIELD {
for j := range ev.FieldEvent.Fields {
ev.FieldEvent.Fields[j].Flags = 0
}
ev.FieldEvent.Keyspace = ""
ev.FieldEvent.Shard = ""
}
if ev.Type == binlogdatapb.VEventType_ROW {
ev.RowEvent.Keyspace = ""
ev.RowEvent.Shard = ""
}
got := ev.String()
want := expectedEvents[i]
if !strings.HasPrefix(got, want) {
errGoroutine = fmt.Errorf("Event %d did not match, want %s, got %s", i, want, got)
return errGoroutine
}
}
return io.EOF
}
return nil
})
}()
wg.Wait()
if errGoroutine != nil {
t.Fatalf(errGoroutine.Error())
}
} | explode_data.jsonl/10404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1955
} | [
2830,
3393,
53,
3027,
12106,
2354,
69123,
28351,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
532,
67328,
93122,
1155,
11,
3056,
917,
515,
197,
197,
1,
3182,
1965,
259,
16,
3724,
16,
526,
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... | 9 |
func Test_Repository(t *testing.T) {
if r := memory.Repository(nil); r != nil {
t.Error("the parent repository should be nil:", r)
}
inner := &mocks.Repo{}
if r := memory.Repository(inner); r != nil {
t.Error("the parent repository should be nil:", r)
}
repo := memory.NewRepo()
outer := &mocks.Repo{ParentRepo: repo}
if r := memory.Repository(outer); r != repo {
t.Error("the parent repository should be correct:", r)
}
} | explode_data.jsonl/62899 | {
"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,
62,
4624,
1155,
353,
8840,
836,
8,
341,
743,
435,
1669,
4938,
25170,
27907,
1215,
435,
961,
2092,
341,
197,
3244,
6141,
445,
1782,
2681,
12542,
1265,
387,
2092,
12147,
435,
340,
197,
630,
197,
4382,
1669,
609,
16712,
82,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCheckSavepointError(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
ctx := context.Background()
httpmock.RegisterResponder("GET", fakeSavepointURL, nil)
client := getTestJobManagerClient()
resp, err := client.CheckSavepointStatus(ctx, testURL, "1", "2")
assert.Nil(t, resp)
assert.NotNil(t, err)
assert.True(t, strings.HasPrefix(err.Error(), "CheckSavepointStatus call failed with status FAILED"))
} | explode_data.jsonl/32363 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
3973,
8784,
2768,
1454,
1155,
353,
8840,
836,
8,
341,
28080,
16712,
14140,
731,
741,
16867,
1758,
16712,
8934,
16856,
3036,
14828,
741,
20985,
1669,
2266,
19047,
741,
28080,
16712,
19983,
30884,
445,
3806,
497,
12418,
8784,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterOutTerminatedPods(t *testing.T) {
testKubelet := newTestKubelet(t)
kubelet := testKubelet.kubelet
pods := newTestPods(5)
pods[0].Status.Phase = api.PodFailed
pods[1].Status.Phase = api.PodSucceeded
pods[2].Status.Phase = api.PodRunning
pods[3].Status.Phase = api.PodPending
expected := []*api.Pod{pods[2], pods[3], pods[4]}
kubelet.podManager.SetPods(pods)
actual := kubelet.filterOutTerminatedPods(pods)
if !reflect.DeepEqual(expected, actual) {
t.Errorf("expected %#v, got %#v", expected, actual)
}
} | explode_data.jsonl/43345 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
5632,
2662,
21209,
51199,
23527,
82,
1155,
353,
8840,
836,
8,
341,
18185,
42,
3760,
1149,
1669,
501,
2271,
42,
3760,
1149,
1155,
340,
16463,
3760,
1149,
1669,
1273,
42,
3760,
1149,
5202,
3760,
1149,
198,
3223,
29697,
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... | 2 |
func TestNewCiid(t *testing.T) {
type args struct {
id string
}
tests := []struct {
name string
args args
wantCiid Ciid
}{
{
"simpleMiid",
args{"msA/1.1%22s"},
&StdCiid{
miid: &StdMiid{
sn: "msA",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
},
{
"simpleMiid2",
args{"SS/1.2/YY%0s"},
&StdCiid{
miid: &StdMiid{
sn: "SS",
vn: "1.2",
va: "YY",
t: 0,
},
ciids: nil,
},
},
{
"fullMiid",
args{"msA/1.1/feature-branch-22aabbcc%22s"},
&StdCiid{
miid: &StdMiid{
sn: "msA",
vn: "1.1",
va: "feature-branch-22aabbcc",
t: 22,
},
ciids: nil,
},
},
{
"emptyMiid",
args{""},
&StdCiid{
miid: &StdMiid{
sn: "",
vn: "",
va: "",
t: 0,
},
ciids: nil,
},
},
{
"fullMiidOneCiid",
args{"msA/1.1/feature-branch-22aabbcc%22s(msB/1.1%22s)"},
&StdCiid{
miid: &StdMiid{
sn: "msA",
vn: "1.1",
va: "feature-branch-22aabbcc",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "msB",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
},
},
},
{
"fullMiidTwoCiid",
args{"msA/1.1/feature-branch-22aabbcc%22s(msB/1.1%22s+msC/1.1%22s)"},
&StdCiid{
miid: &StdMiid{
sn: "msA",
vn: "1.1",
va: "feature-branch-22aabbcc",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "msB",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
&StdCiid{
miid: &StdMiid{
sn: "msC",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
},
},
},
{
"complexFunc",
args{"A/1.1%22s(B/1.1%22s(C/1.1%22s+D/1.1%22s)+D/1.1%22s(E/1.1%22s)"},
&StdCiid{
miid: &StdMiid{
sn: "A",
vn: "1.1",
va: "",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "B",
vn: "1.1",
va: "",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "C",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
&StdCiid{
miid: &StdMiid{
sn: "D",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
},
},
&StdCiid{
miid: &StdMiid{
sn: "D",
vn: "1.1",
va: "",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "E",
vn: "1.1",
va: "",
t: 22,
},
ciids: nil,
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotCiid := NewStdCiid(tt.args.id); !reflect.DeepEqual(gotCiid, tt.wantCiid) {
t.Errorf("NewCiid() = %#v, want %#v", gotCiid, tt.wantCiid)
}
})
}
} | explode_data.jsonl/64799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2177
} | [
2830,
3393,
3564,
34,
54483,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
15710,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
31215,
257,
2827,
198,
197,
50780,
34,
54483,
31644,
307,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetDefaultBuilder(t *testing.T) {
color.Disable(true)
defer color.Disable(false)
spec.Run(t, "Commands", testSetDefaultBuilderCommand, spec.Random(), spec.Report(report.Terminal{}))
} | explode_data.jsonl/378 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
1649,
3675,
3297,
1155,
353,
8840,
836,
8,
341,
21481,
10166,
480,
3715,
340,
16867,
1894,
10166,
480,
3576,
340,
98100,
16708,
1155,
11,
330,
30479,
497,
1273,
1649,
3675,
3297,
4062,
11,
1398,
26709,
1507,
1398,
25702,
451... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFunc(t *testing.T) {
t.Parallel()
var called bool
testVal := 42.0
testErr := errors.New("test")
r := reducer.Func(func(data []float64) (float64, error) {
called = true
return testVal, testErr
})
called = false
_, err := r.Reduce(nil)
require.False(t, called)
require.EqualError(t, err, reducer.ErrSliceEmpty.Error())
called = false
val, err := r.Reduce([]float64{42})
require.True(t, called)
require.Equal(t, testErr, err)
require.Equal(t, testVal, val)
} | explode_data.jsonl/4717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
9626,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
2598,
1807,
198,
18185,
2208,
1669,
220,
19,
17,
13,
15,
198,
18185,
7747,
1669,
5975,
7121,
445,
1944,
5130,
7000,
1669,
37004,
69845,
18552,
2592,
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... | 1 |
func TestReverse(t *testing.T) {
type args struct {
img image.Image
}
tests := []struct {
name string
args args
want image.Image
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Reverse(tt.args.img); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Reverse() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/64987 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
45695,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
39162,
2168,
7528,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
2168,
7528,
198,
197,
59403,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetAccountInfo(t *testing.T) {
if !areTestAPIKeysSet() {
t.Skip("skipping test: api keys not set")
}
t.Parallel()
items := asset.Items{
asset.CoinMarginedFutures,
asset.USDTMarginedFutures,
asset.Spot,
asset.Margin,
}
for i := range items {
assetType := items[i]
t.Run(fmt.Sprintf("Update info of account [%s]", assetType.String()), func(t *testing.T) {
_, err := b.UpdateAccountInfo(context.Background(), assetType)
if err != nil {
t.Error(err)
}
})
}
} | explode_data.jsonl/76668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
1949,
7365,
1731,
1155,
353,
8840,
836,
8,
341,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
6330,
6894,
537,
738,
1138,
197,
532,
3244,
41288,
7957,
741,
46413,
1669,
9329,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.