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 TestJobSpecsController_Create_HappyPath(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()
resp, cleanup := client.Post("/v2/specs", bytes.NewBuffer(cltest.MustReadFile(t, "testdata/hello_world_job.json")))
defer cleanup()
cltest.AssertServerResponse(t, resp, http.StatusOK)
// Check Response
var j models.JobSpec
err := cltest.ParseJSONAPIResponse(t, resp, &j)
require.NoError(t, err)
adapter1, _ := adapters.For(j.Tasks[0], app.Store.Config, app.Store.ORM)
httpGet := adapter1.BaseAdapter.(*adapters.HTTPGet)
assert.Equal(t, httpGet.GetURL(), "https://bitstamp.net/api/ticker/")
adapter2, _ := adapters.For(j.Tasks[1], app.Store.Config, app.Store.ORM)
jsonParse := adapter2.BaseAdapter.(*adapters.JSONParse)
assert.Equal(t, []string(jsonParse.Path), []string{"last"})
adapter4, _ := adapters.For(j.Tasks[3], app.Store.Config, app.Store.ORM)
signTx := adapter4.BaseAdapter.(*adapters.EthTx)
assert.Equal(t, "0x356a04bCe728ba4c62A30294A55E6A8600a320B3", signTx.ToAddress.String())
assert.Equal(t, "0x609ff1bd", signTx.FunctionSelector.String())
initr := j.Initiators[0]
assert.Equal(t, models.InitiatorWeb, initr.Type)
assert.NotEqual(t, models.AnyTime{}, j.CreatedAt)
// Check ORM
orm := app.GetStore().ORM
j, err = orm.FindJobSpec(j.ID)
require.NoError(t, err)
require.Len(t, j.Initiators, 1)
assert.Equal(t, models.InitiatorWeb, j.Initiators[0].Type)
adapter1, _ = adapters.For(j.Tasks[0], app.Store.Config, app.Store.ORM)
httpGet = adapter1.BaseAdapter.(*adapters.HTTPGet)
assert.Equal(t, httpGet.GetURL(), "https://bitstamp.net/api/ticker/")
} | explode_data.jsonl/31805 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 750
} | [
2830,
3393,
12245,
8327,
82,
2051,
34325,
2039,
11144,
1820,
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,
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 TestRouterClearTimeouts(t *testing.T) {
// Create a timeout manager
tm, err := timeout.NewManager(
&timer.AdaptiveTimeoutConfig{
InitialTimeout: 3 * time.Second,
MinimumTimeout: 3 * time.Second,
MaximumTimeout: 5 * time.Minute,
TimeoutCoefficient: 1,
TimeoutHalflife: 5 * time.Minute,
},
benchlist.NewNoBenchlist(),
"",
prometheus.NewRegistry(),
)
if err != nil {
t.Fatal(err)
}
go tm.Dispatch()
// Create a router
chainRouter := ChainRouter{}
metrics := prometheus.NewRegistry()
mc, err := message.NewCreator(metrics, true, "dummyNamespace", 10*time.Second)
assert.NoError(t, err)
assert.NoError(t, err)
err = chainRouter.Initialize(ids.EmptyNodeID, logging.NoLog{}, mc, tm, time.Millisecond, ids.Set{}, nil, HealthConfig{}, "", prometheus.NewRegistry())
assert.NoError(t, err)
// Create bootstrapper, engine and handler
ctx := snow.DefaultConsensusContextTest()
vdrs := validators.NewSet()
err = vdrs.AddWeight(ids.GenerateTestNodeID(), 1)
assert.NoError(t, err)
resourceTracker, err := tracker.NewResourceTracker(prometheus.NewRegistry(), resource.NoUsage, meter.ContinuousFactory{}, time.Second)
assert.NoError(t, err)
handler, err := handler.New(
mc,
ctx,
vdrs,
nil,
nil,
time.Second,
resourceTracker,
)
assert.NoError(t, err)
bootstrapper := &common.BootstrapperTest{
BootstrapableTest: common.BootstrapableTest{
T: t,
},
EngineTest: common.EngineTest{
T: t,
},
}
bootstrapper.Default(false)
bootstrapper.ContextF = func() *snow.ConsensusContext { return ctx }
handler.SetBootstrapper(bootstrapper)
engine := &common.EngineTest{T: t}
engine.Default(false)
engine.ContextF = func() *snow.ConsensusContext { return ctx }
handler.SetConsensus(engine)
ctx.SetState(snow.NormalOp) // assumed bootstrapping is done
chainRouter.AddChain(handler)
bootstrapper.StartF = func(startReqID uint32) error { return nil }
handler.Start(false)
// Register requests for each request type
ops := []message.Op{
message.Put,
message.Ancestors,
message.Chits,
message.Accepted,
message.AcceptedFrontier,
}
vID := ids.GenerateTestNodeID()
for i, op := range ops {
chainRouter.RegisterRequest(vID, ctx.ChainID, uint32(i), op)
}
// Clear each timeout by simulating responses to the queries
// Note: Depends on the ordering of [msgs]
var inMsg message.InboundMessage
// Put
inMsg = mc.InboundPut(ctx.ChainID, 0, ids.GenerateTestID(), nil, vID)
chainRouter.HandleInbound(inMsg)
// Ancestors
inMsg = mc.InboundAncestors(ctx.ChainID, 1, nil, vID)
chainRouter.HandleInbound(inMsg)
// Chits
inMsg = mc.InboundChits(ctx.ChainID, 2, nil, vID)
chainRouter.HandleInbound(inMsg)
// Accepted
inMsg = mc.InboundAccepted(ctx.ChainID, 3, nil, vID)
chainRouter.HandleInbound(inMsg)
// Accepted Frontier
inMsg = mc.InboundAcceptedFrontier(ctx.ChainID, 4, nil, vID)
chainRouter.HandleInbound(inMsg)
assert.Equal(t, chainRouter.timedRequests.Len(), 0)
} | explode_data.jsonl/76079 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1134
} | [
2830,
3393,
9523,
14008,
7636,
82,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
264,
9632,
6645,
198,
3244,
76,
11,
1848,
1669,
9632,
7121,
2043,
1006,
197,
197,
5,
19278,
17865,
27781,
7636,
2648,
515,
298,
197,
6341,
7636,
25,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTimer(t *testing.T) {
MockMode = true
timer := NewTimer(5 * time.Second)
done := make(chan struct{})
go func() {
<-timer.C()
done <- struct{}{}
}()
Elapse(5 * time.Second)
<-done
} | explode_data.jsonl/68925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
10105,
1155,
353,
8840,
836,
8,
341,
9209,
1176,
3636,
284,
830,
198,
51534,
1669,
1532,
10105,
7,
20,
353,
882,
32435,
340,
40495,
1669,
1281,
35190,
2036,
6257,
692,
30680,
2915,
368,
341,
197,
197,
45342,
19278,
727,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHandshakeServerCHACHA20SHA256(t *testing.T) {
test := &serverTest{
name: "CHACHA20-SHA256",
command: []string{"openssl", "s_client", "-no_ticket", "-ciphersuites", "TLS_CHACHA20_POLY1305_SHA256"},
}
runServerTestTLS13(t, test)
} | explode_data.jsonl/36331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
2314,
29661,
5475,
2149,
11873,
32,
17,
15,
33145,
17,
20,
21,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
609,
4030,
2271,
515,
197,
11609,
25,
262,
330,
2149,
11873,
32,
17,
15,
6222,
17020,
17,
20,
21,
756,
197,
4556... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFloat64Swap(t *testing.T) {
if err := quick.Check(func(old, new float64) bool {
a := NewFloat64(old)
return a.Swap(new) == old && a.Load() == new
}, nil); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/30766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
5442,
21,
19,
46179,
1155,
353,
8840,
836,
8,
341,
743,
1848,
1669,
3974,
10600,
18552,
21972,
11,
501,
2224,
21,
19,
8,
1807,
341,
197,
11323,
1669,
1532,
5442,
21,
19,
21972,
340,
197,
853,
264,
808,
21726,
1755,
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... | 2 |
func TestValidatePipelineWorkspaces_Success(t *testing.T) {
tests := []struct {
name string
workspaces []PipelineWorkspaceDeclaration
tasks []PipelineTask
}{{
name: "unused pipeline spec workspaces do not cause an error",
workspaces: []PipelineWorkspaceDeclaration{{
Name: "foo",
}, {
Name: "bar",
}},
tasks: []PipelineTask{{
Name: "foo", TaskRef: &TaskRef{Name: "foo"},
}},
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := validatePipelineWorkspaces(tt.workspaces, tt.tasks)
if err != nil {
t.Errorf("Pipeline.validatePipelineWorkspaces() returned error: %v", err)
}
})
}
} | explode_data.jsonl/26539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
17926,
34656,
6776,
44285,
87161,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
97038,
44285,
3056,
34656,
45981,
24489,
198,
197,
3244,
4604,
414,
3056,
34656,
6262,
198,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSchema_Exist(t *testing.T) {
var (
serviceId string
)
t.Run("register service and add schema", func(t *testing.T) {
log.Info("register service")
respCreateService, err := datasource.GetMetadataManager().RegisterService(getContext(), &pb.CreateServiceRequest{
Service: &pb.MicroService{
AppId: "query_schema_group_ms",
ServiceName: "query_schema_service_ms",
Version: "1.0.0",
Level: "FRONT",
Status: pb.MS_UP,
Environment: pb.ENV_DEV,
},
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, respCreateService.Response.GetCode())
serviceId = respCreateService.ServiceId
log.Info("add schemas, should pass")
resp, err := datasource.GetMetadataManager().ModifySchema(getContext(), &pb.ModifySchemaRequest{
ServiceId: serviceId,
SchemaId: "com.huawei.test.ms",
Schema: "query schema ms",
Summary: "summary_ms",
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, resp.Response.GetCode())
resp, err = datasource.GetMetadataManager().ModifySchema(getContext(), &pb.ModifySchemaRequest{
ServiceId: serviceId,
SchemaId: "com.huawei.test.no.summary.ms",
Schema: "query schema ms",
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, resp.Response.GetCode())
})
t.Run("check exists", func(t *testing.T) {
log.Info("check schema exist, should pass")
resp, err := datasource.GetMetadataManager().ExistSchema(getContext(), &pb.GetExistenceRequest{
Type: datasource.ExistTypeSchema,
ServiceId: serviceId,
SchemaId: "com.huawei.test.ms",
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, resp.Response.GetCode())
assert.Equal(t, "summary_ms", resp.Summary)
resp, err = datasource.GetMetadataManager().ExistSchema(getContext(), &pb.GetExistenceRequest{
Type: datasource.ExistTypeSchema,
ServiceId: serviceId,
SchemaId: "com.huawei.test.ms",
AppId: "()",
ServiceName: "",
Version: "()",
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, resp.Response.GetCode())
resp, err = datasource.GetMetadataManager().ExistSchema(getContext(), &pb.GetExistenceRequest{
Type: datasource.ExistTypeSchema,
ServiceId: serviceId,
SchemaId: "com.huawei.test.no.summary.ms",
})
assert.NoError(t, err)
assert.Equal(t, pb.ResponseSuccess, resp.Response.GetCode())
assert.Equal(t, "com.huawei.test.no.summary.ms", resp.SchemaId)
assert.Equal(t, "", resp.Summary)
})
} | explode_data.jsonl/49817 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1041
} | [
2830,
3393,
8632,
62,
25613,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
52934,
764,
914,
198,
197,
692,
3244,
16708,
445,
6343,
2473,
323,
912,
10802,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6725,
20132,
445,
6343,
2473,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidate1(t *testing.T) {
type args struct {
kind string
app string
validExt []string
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := Validate(tt.args.kind, tt.args.app, tt.args.validExt); (err != nil) != tt.wantErr {
t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/79923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
17926,
16,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
15314,
257,
914,
198,
197,
28236,
414,
914,
198,
197,
56322,
6756,
3056,
917,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_findShortestSubArray(t *testing.T) {
type args struct {
nums []int
}
tests := []struct {
name string
args args
want int
}{
// TODO: Add test cases.
{
name: "",
args: args{
nums: strToIntArray("[1, 2, 2, 3, 1]"),
},
want: 2,
},
{
name: "",
args: args{
nums: strToIntArray("[1,2,2,3,1,4,2]"),
},
want: 6,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := findShortestSubArray(tt.args.nums); got != tt.want {
t.Errorf("findShortestSubArray() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/70694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
21814,
12472,
477,
3136,
1857,
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,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestBuildOutboundPolicies(t *testing.T) {
assert := tassert.New(t)
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockKubeController := k8s.NewMockController(mockCtrl)
mockMeshSpec := smi.NewMockMeshSpec(mockCtrl)
mockEndpointProvider := endpoint.NewMockProvider(mockCtrl)
mc := MeshCatalog{
kubeController: mockKubeController,
meshSpec: mockMeshSpec,
endpointsProviders: []endpoint.Provider{mockEndpointProvider},
}
sourceSA := service.K8sServiceAccount{
Name: "bookbuyer",
Namespace: "bookbuyer-ns",
}
destSA := service.K8sServiceAccount{
Name: "bookstore",
Namespace: "bookstore-ns",
}
destMeshService := service.MeshService{
Name: "bookstore",
Namespace: "bookstore-ns",
}
destK8sService := tests.NewServiceFixture(destMeshService.Name, destMeshService.Namespace, map[string]string{})
trafficSpec := spec.HTTPRouteGroup{
TypeMeta: v1.TypeMeta{
APIVersion: "specs.smi-spec.io/v1alpha4",
Kind: "HTTPRouteGroup",
},
ObjectMeta: v1.ObjectMeta{
Namespace: "bookstore-ns",
Name: tests.RouteGroupName,
},
Spec: spec.HTTPRouteGroupSpec{
Matches: []spec.HTTPMatch{
{
Name: tests.BuyBooksMatchName,
PathRegex: tests.BookstoreBuyPath,
Methods: []string{"GET"},
Headers: map[string]string{
"user-agent": tests.HTTPUserAgent,
},
},
{
Name: tests.SellBooksMatchName,
PathRegex: tests.BookstoreSellPath,
Methods: []string{"GET"},
Headers: map[string]string{
"user-agent": tests.HTTPUserAgent,
},
},
},
},
}
mockMeshSpec.EXPECT().ListHTTPTrafficSpecs().Return([]*specs.HTTPRouteGroup{&trafficSpec}).AnyTimes()
mockEndpointProvider.EXPECT().GetServicesForServiceAccount(destSA).Return([]service.MeshService{destMeshService}, nil).AnyTimes()
mockEndpointProvider.EXPECT().GetID().Return("fake").AnyTimes()
mockKubeController.EXPECT().GetService(destMeshService).Return(destK8sService).AnyTimes()
trafficTarget := tests.NewSMITrafficTarget(sourceSA.Name, sourceSA.Namespace, destSA.Name, destSA.Namespace)
hostnames := []string{
"bookstore.bookstore-ns",
"bookstore.bookstore-ns.svc",
"bookstore.bookstore-ns.svc.cluster",
"bookstore.bookstore-ns.svc.cluster.local",
"bookstore.bookstore-ns:8888",
"bookstore.bookstore-ns.svc:8888",
"bookstore.bookstore-ns.svc.cluster:8888",
"bookstore.bookstore-ns.svc.cluster.local:8888",
}
bookstoreWeightedCluster := service.WeightedCluster{
ClusterName: "bookstore-ns/bookstore",
Weight: 100,
}
expected := []*trafficpolicy.OutboundTrafficPolicy{
{
Name: destMeshService.Name + "-" + destMeshService.Namespace,
Hostnames: hostnames,
Routes: []*trafficpolicy.RouteWeightedClusters{
{
HTTPRouteMatch: wildCardRouteMatch,
WeightedClusters: mapset.NewSet(bookstoreWeightedCluster),
},
},
},
}
actual := mc.buildOutboundPolicies(sourceSA, &trafficTarget)
assert.ElementsMatch(expected, actual)
} | explode_data.jsonl/69766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1255
} | [
2830,
3393,
11066,
2662,
10891,
47,
42038,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
259,
2207,
7121,
1155,
340,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
2822,
77333,
42,
3760,
2051,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSublimeSnippet(t *testing.T) {
want := snip.Snippet{
Name: "lorem",
Trigger: "lorem",
Description: "HTML - Lorem Ipsum",
Body: []string{"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."},
}
have, err := snip.ParseSublimeFile("./testdata/sublime/lorem.sublime-snippet")
if err != nil {
t.Errorf("error: %s", err)
}
err = snip.CompareSnippets(have, want)
if err != nil {
t.Errorf("error: %s", err)
}
} | explode_data.jsonl/82434 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
3136,
38943,
87852,
1155,
353,
8840,
836,
8,
341,
50780,
1669,
4131,
573,
87066,
21581,
515,
197,
21297,
25,
286,
330,
385,
1826,
756,
197,
197,
17939,
25,
257,
330,
385,
1826,
756,
197,
47414,
25,
330,
5835,
481,
46931,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAssertable_IsNotNil(t *testing.T) {
tests := []struct {
name string
actual interface{}
shouldFail bool
}{
{
name: "should assert nil",
actual: nil,
shouldFail: true,
},
{
name: "should assert non-empty string",
actual: "non-nil",
shouldFail: false,
},
{
name: "should assert not nil pointer",
actual: new(interface{}),
shouldFail: false,
},
{
name: "should assert nil pointer",
actual: f,
shouldFail: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
test := &testing.T{}
That(test, tt.actual).IsNotNil()
ThatBool(t, test.Failed()).IsEqualTo(tt.shouldFail)
})
}
} | explode_data.jsonl/53646 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
8534,
480,
31879,
96144,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
88814,
257,
3749,
16094,
197,
197,
5445,
19524,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
981... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPing(t *testing.T) {
var expectedPing = "PONG"
t.Log("We need to test the PING.")
{
t.Logf("\tChecking PING for response \"%s\"",
expectedPing)
{
str, msgType := common.Call(client, client.Ping(expectedPing, false, false, false))
if msgType != 2 {
t.Errorf("\t\tExpected msgType=2, received %d", msgType)
}
if str != expectedPing {
t.Errorf("\t\tExpected str=\"%s\", received\"%s\"", expectedPing, str)
}
if msgType == 2 && str == expectedPing {
t.Log("\t\tEverything went fine, \\ʕ◔ϖ◔ʔ/ YAY!")
}
}
}
} | explode_data.jsonl/46194 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
69883,
1155,
353,
8840,
836,
8,
1476,
2405,
3601,
69883,
284,
330,
47,
7539,
1837,
3244,
5247,
445,
1654,
1184,
311,
1273,
279,
393,
1718,
13053,
197,
515,
197,
3244,
98954,
4921,
83,
40129,
393,
1718,
369,
2033,
32328,
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... | 5 |
func TestE2E(t *testing.T) {
mux := http.NewServeMux()
currentDir, _ := os.Getwd()
setUpSpa(mux, currentDir)
restRouting := map[string]string{
"/foo": "Foo!",
"/bar": "Bar!",
}
for k, v := range restRouting {
path := k
body := v
mux.HandleFunc(path, func(writer http.ResponseWriter, request *http.Request) {
fmt.Fprintf(writer, body)
})
}
server := httptest.NewServer(mux)
defer server.Close()
// Tests for SPA (single page)
orgIndex, _ := ioutil.ReadFile(currentDir + "/testdata/index.html")
spaRouting := []string{
"/",
"/baz",
"/foo/bar",
"/bar/baz",
"/testdata/static/index.js",
"/resolver.go",
"/static/../../resolver.go",
}
for _, path := range spaRouting {
req, _ := http.NewRequest("GET", server.URL+path, nil)
res, _ := client.Do(req)
body, _ := ioutil.ReadAll(res.Body)
expected := string(orgIndex)
assert.Equal(t, expected, string(body))
assert.Equal(t, 200, res.StatusCode)
}
// Tests for SPA (resources)
orgJs, _ := ioutil.ReadFile(currentDir + "/testdata/static/index.js")
orgCSS, _ := ioutil.ReadFile(currentDir + "/testdata/assets/index.css")
resourcesRouting := map[string]string{
"/static/index.js": string(orgJs),
"/assets/index.css": string(orgCSS),
}
for path, expected := range resourcesRouting {
req, _ := http.NewRequest("GET", server.URL+path, nil)
res, _ := client.Do(req)
body, _ := ioutil.ReadAll(res.Body)
assert.Equal(t, expected, string(body))
assert.Equal(t, 200, res.StatusCode)
}
// Tests for SPA (not found resources)
notExistsRouting := []string{"/static/foo.js"}
for _, path := range notExistsRouting {
req, _ := http.NewRequest("GET", server.URL+path, nil)
res, _ := client.Do(req)
assert.Equal(t, 404, res.StatusCode)
}
// Tests for REST
for path, expected := range restRouting {
req, _ := http.NewRequest("GET", server.URL+path, nil)
res, _ := client.Do(req)
body, _ := ioutil.ReadAll(res.Body)
assert.Equal(t, expected, string(body))
assert.Equal(t, 200, res.StatusCode)
}
} | explode_data.jsonl/44961 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 833
} | [
2830,
3393,
36,
17,
36,
1155,
353,
8840,
836,
8,
341,
2109,
2200,
1669,
1758,
7121,
60421,
44,
2200,
741,
20121,
6184,
11,
716,
1669,
2643,
2234,
6377,
2822,
8196,
2324,
6406,
64,
1255,
2200,
11,
1482,
6184,
692,
197,
3927,
24701,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLayeredBuild(t *testing.T) {
fh := &FakeSTI{
BuildRequest: &api.Config{
BuilderImage: "testimage",
},
BuildResult: &api.Result{},
ExecuteError: stierr.NewContainerError("", 1, `/bin/sh: tar: not found`),
ExpectedError: true,
}
builder := newFakeSTI(fh)
builder.Build(&api.Config{BuilderImage: "testimage"})
// Verify layered build
if !fh.LayeredBuildCalled {
t.Errorf("Layered build was not called.")
}
} | explode_data.jsonl/59435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
9188,
291,
11066,
1155,
353,
8840,
836,
8,
341,
1166,
71,
1669,
609,
52317,
784,
40,
515,
197,
197,
11066,
1900,
25,
609,
2068,
10753,
515,
298,
197,
3297,
1906,
25,
330,
1944,
1805,
756,
197,
197,
1583,
197,
197,
11066,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogPartsPerCommitInSync(t *testing.T) {
require.Equal(t, 2*partsPerCommitBasic, strings.Count(logFormatWithoutRefs, "%"),
"Expected (2 * %0d) %% signs in log format string (%0d fields, %0d %%x00 separators)",
partsPerCommitBasic)
} | explode_data.jsonl/8511 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
2201,
28921,
3889,
33441,
641,
12154,
1155,
353,
8840,
836,
8,
341,
17957,
12808,
1155,
11,
220,
17,
9,
18252,
3889,
33441,
15944,
11,
9069,
6134,
12531,
4061,
26040,
82807,
11,
5962,
4461,
197,
197,
1,
18896,
320,
17,
353... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFilteredByEmptyPrefix(t *testing.T) {
name := "carotte"
ghLabel := &github.Label{
Name: &name,
}
prefixes := []string{""}
assert.True(t, FilteredBy(HasPrefix, prefixes)(ghLabel))
} | explode_data.jsonl/16589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
67310,
1359,
3522,
14335,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
330,
6918,
50011,
698,
197,
866,
2476,
1669,
609,
5204,
4679,
515,
197,
21297,
25,
609,
606,
345,
197,
630,
3223,
5060,
288,
1669,
3056,
917,
90,
3014,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewReqMessage(t *testing.T) {
m := NewReqMessage(uuid.NewString(), "test", []byte("test"))
if m.Id == "" {
t.Fatal("expected PubMessage to set id")
}
if m.Type != ReqMessage {
t.Fatalf("expected ReqMessage but got %s", m.Type)
}
} | explode_data.jsonl/63185 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
3564,
27234,
2052,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
27234,
2052,
41458,
7121,
703,
1507,
330,
1944,
497,
3056,
3782,
445,
1944,
28075,
743,
296,
6444,
621,
1591,
341,
197,
3244,
26133,
445,
7325,
22611,
2052,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetCellFormula(t *testing.T) {
f, err := OpenFile(filepath.Join("test", "Book1.xlsx"))
if !assert.NoError(t, err) {
t.FailNow()
}
f.SetCellFormula("Sheet1", "B19", "SUM(Sheet2!D2,Sheet2!D11)")
f.SetCellFormula("Sheet1", "C19", "SUM(Sheet2!D2,Sheet2!D9)")
// Test set cell formula with illegal rows number.
assert.EqualError(t, f.SetCellFormula("Sheet1", "C", "SUM(Sheet2!D2,Sheet2!D9)"), `cannot convert cell "C" to coordinates: invalid cell name "C"`)
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetCellFormula1.xlsx")))
f, err = OpenFile(filepath.Join("test", "CalcChain.xlsx"))
if !assert.NoError(t, err) {
t.FailNow()
}
// Test remove cell formula.
f.SetCellFormula("Sheet1", "A1", "")
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetCellFormula2.xlsx")))
// Test remove all cell formula.
f.SetCellFormula("Sheet1", "B1", "")
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestSetCellFormula3.xlsx")))
} | explode_data.jsonl/36964 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
1649,
3599,
52676,
1155,
353,
8840,
836,
8,
341,
1166,
11,
1848,
1669,
5264,
1703,
34793,
22363,
445,
1944,
497,
330,
7134,
16,
46838,
5455,
743,
753,
2207,
35699,
1155,
11,
1848,
8,
341,
197,
3244,
57243,
7039,
741,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBytesToFloat32(t *testing.T) {
v := float32(1.23)
fmt.Printf("original: %f\n", v)
bs := make([]byte, 4)
utils.PutFloat32(bs, v)
fmt.Printf("bs (from golang): %v\n", bs)
v1 := utils.ByteToFloat32(bs)
fmt.Printf("v1 (from golang): %v\n", v1)
v2 := BigEndianToFloat32(bs)
fmt.Printf("v2 (from cpp): %v\n", v2)
} | explode_data.jsonl/18816 | {
"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,
7078,
1249,
5442,
18,
17,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
2224,
18,
17,
7,
16,
13,
17,
18,
340,
11009,
19367,
445,
9889,
25,
1018,
69,
1699,
497,
348,
340,
93801,
1669,
1281,
10556,
3782,
11,
220,
19,
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 TestLoadMeta(t *testing.T) {
var got FieldListWithMeta
want := FieldListWithMeta{
Meta: searchMeta,
Fields: searchFieldsWithLang,
}
doc := &pb.Document{
Field: protoFields,
OrderId: proto.Int32(42),
}
if err := loadDoc(&got, doc, nil); err != nil {
t.Fatalf("loadDoc: %v", err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("\ngot %v\nwant %v", got, want)
}
} | explode_data.jsonl/27951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
5879,
12175,
1155,
353,
8840,
836,
8,
341,
2405,
2684,
8601,
852,
2354,
12175,
198,
50780,
1669,
8601,
852,
2354,
12175,
515,
197,
9209,
1915,
25,
256,
2711,
12175,
345,
197,
197,
8941,
25,
2711,
8941,
2354,
26223,
345,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetMountRefs(t *testing.T) {
tests := []struct {
mountPath string
expectedRefs []string
}{
{
mountPath: `c:\windows`,
expectedRefs: []string{`c:\windows`},
},
{
mountPath: `c:\doesnotexist`,
expectedRefs: []string{},
},
}
fm := &FakeMounter{MountPoints: []MountPoint{}}
for _, test := range tests {
if refs, err := GetMountRefs(fm, test.mountPath); err != nil || !setEquivalent(test.expectedRefs, refs) {
t.Errorf("getMountRefs(%q) = %v, error: %v; expected %v", test.mountPath, refs, err, test.expectedRefs)
}
}
} | explode_data.jsonl/48683 | {
"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,
1949,
16284,
82807,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2109,
629,
1820,
262,
914,
198,
197,
42400,
82807,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
2109,
629,
1820,
25,
262,
1565,
66,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmbyHelper_GetRecentlyAddVideoList(t *testing.T) {
//embyConfig := settings.NewEmbySettings()
//embyConfig.Enable = true
//embyConfig.AddressUrl = "http://192.168.50.252:8096"
//embyConfig.APIKey = "1"
//embyConfig.SkipWatched = false
//embyConfig.MaxRequestVideoNumber = 1000
//embyConfig.MoviePathsMapping["X:\\电影"] = "/mnt/share1/电影"
//embyConfig.MoviePathsMapping["X:\\连续剧"] = "/mnt/share1/连续剧"
//
//em := NewEmbyHelper(*embyConfig)
//movieList, seriesList, err := em.GetRecentlyAddVideoListWithNoChineseSubtitle()
//if err != nil {
// t.Fatal(err)
//}
//println(len(movieList), len(seriesList))
} | explode_data.jsonl/48284 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
2269,
1694,
5511,
13614,
45137,
2212,
10724,
852,
1155,
353,
8840,
836,
8,
1476,
197,
322,
336,
1694,
2648,
1669,
5003,
7121,
2269,
1694,
6086,
741,
197,
322,
336,
1694,
2648,
32287,
284,
830,
198,
197,
322,
336,
1694,
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... | 1 |
func TestJoinTeam(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
th.CheckCommand(t, "team", "add", th.BasicTeam.Name, th.BasicUser.Email)
profiles := th.SystemAdminClient.Must(th.SystemAdminClient.GetUsersInTeam(th.BasicTeam.Id, 0, 1000, "")).([]*model.User)
found := false
for _, user := range profiles {
if user.Email == th.BasicUser.Email {
found = true
}
}
if !found {
t.Fatal("Failed to create User")
}
} | explode_data.jsonl/65273 | {
"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,
12292,
14597,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
70479,
10600,
4062,
1155,
11,
330,
9196,
497,
330,
718,
497,
270,
48868,
14597,
2967,
11,
270,
48868,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_Define_Response(t *testing.T) {
classificationID := base.NewID("classificationID")
testAuxiliaryResponse := newAuxiliaryResponse(classificationID, nil)
require.Equal(t, auxiliaryResponse{Success: true, Error: nil, ClassificationID: classificationID}, testAuxiliaryResponse)
require.Equal(t, true, testAuxiliaryResponse.IsSuccessful())
require.Equal(t, nil, testAuxiliaryResponse.GetError())
testAuxiliaryResponse2 := newAuxiliaryResponse(classificationID, errors.IncorrectFormat)
require.Equal(t, auxiliaryResponse{Success: false, Error: errors.IncorrectFormat, ClassificationID: classificationID}, testAuxiliaryResponse2)
require.Equal(t, false, testAuxiliaryResponse2.IsSuccessful())
require.Equal(t, errors.IncorrectFormat, testAuxiliaryResponse2.GetError())
classificationIDFromResponse, Error := GetClassificationIDFromResponse(testAuxiliaryResponse)
require.Equal(t, classificationID, classificationIDFromResponse)
require.Equal(t, nil, Error)
classificationIDFromResponse2, Error := GetClassificationIDFromResponse(testAuxiliaryResponse2)
require.Equal(t, classificationID, classificationIDFromResponse2)
require.Equal(t, errors.IncorrectFormat, Error)
_, Error = GetClassificationIDFromResponse(nil)
require.Equal(t, errors.InvalidRequest, Error)
} | explode_data.jsonl/69543 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
88411,
482,
65873,
1155,
353,
8840,
836,
8,
1476,
15487,
2404,
915,
1669,
2331,
7121,
915,
445,
65381,
915,
5130,
18185,
55147,
34446,
2582,
1669,
501,
55147,
34446,
2582,
21956,
2404,
915,
11,
2092,
340,
17957,
12808,
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 TestRunnerWithScenarios(t *testing.T) {
scenariosPath := filepath.Join("test", "e2e", "testdata", "scenarios")
runner, err := NewRunner(WithScenarios(scenariosPath))
if err != nil {
t.Fatal(err)
}
if len(runner.scenarioFiles) == 0 {
t.Fatal("failed to set scenario files")
}
for _, file := range runner.scenarioFiles {
if !yamlPattern.MatchString(file) {
t.Fatalf("invalid scenario file: %s", file)
}
}
} | explode_data.jsonl/56026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
19486,
2354,
3326,
60494,
1155,
353,
8840,
836,
8,
341,
29928,
60494,
1820,
1669,
26054,
22363,
445,
1944,
497,
330,
68,
17,
68,
497,
330,
92425,
497,
330,
2388,
60494,
1138,
197,
41736,
11,
1848,
1669,
1532,
19486,
7,
235... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamespaced(t *testing.T) {
uu := []struct {
p, ns, n string
}{
{"fred/blee", "fred", "blee"},
{"blee", "", "blee"},
}
for _, u := range uu {
ns, n := client.Namespaced(u.p)
assert.Equal(t, u.ns, ns)
assert.Equal(t, u.n, n)
}
} | explode_data.jsonl/41754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
7980,
68552,
1155,
353,
8840,
836,
8,
341,
10676,
84,
1669,
3056,
1235,
341,
197,
3223,
11,
12268,
11,
308,
914,
198,
197,
59403,
197,
197,
4913,
27993,
14,
891,
68,
497,
330,
27993,
497,
330,
891,
68,
7115,
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... | 2 |
func Test_loadControllerConfig(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
configData map[string]string
expected bool
}{
{
"MaintenanceModeEnabled",
map[string]string{
"maintenanceMode": "true",
},
true,
},
{
"MaintenanceModeDisabled",
map[string]string{
"maintenanceMode": "false",
},
false,
},
{
"MaintenanceModeMissing",
map[string]string{},
false,
},
} {
t.Run(tc.name, func(t *testing.T) {
tc := tc // capture current value before going parallel
t.Parallel()
// SETUP
ctx := context.Background()
cf := fake.NewClientFactory(
newMaintenanceModeConfigMap(tc.configData),
)
// EXERCISE
result, resultErr := IsMaintenanceMode(ctx, cf)
// VERIFY
assert.NilError(t, resultErr)
assert.Equal(t, tc.expected, result)
})
}
} | explode_data.jsonl/8491 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
12411,
2051,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
11609,
981,
914,
198,
197,
25873,
1043,
2415,
14032,
30953,
198,
197,
42400,
256,
1807,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateUpstreamHealthCheck(t *testing.T) {
hc := &v1.HealthCheck{
Enable: true,
Path: "/healthz",
Interval: "4s",
Jitter: "2s",
Fails: 3,
Passes: 2,
Port: 8080,
TLS: &v1.UpstreamTLS{
Enable: true,
},
ConnectTimeout: "1s",
ReadTimeout: "1s",
SendTimeout: "1s",
Headers: []v1.Header{
{
Name: "Host",
Value: "my.service",
},
},
StatusMatch: "! 500",
}
allErrs := validateUpstreamHealthCheck(hc, field.NewPath("healthCheck"))
if len(allErrs) != 0 {
t.Errorf("validateUpstreamHealthCheck() returned errors for valid input %v", hc)
}
} | explode_data.jsonl/65870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
17926,
2324,
4027,
14542,
3973,
1155,
353,
8840,
836,
8,
341,
9598,
66,
1669,
609,
85,
16,
74980,
3973,
515,
197,
197,
11084,
25,
256,
830,
345,
197,
69640,
25,
257,
3521,
12120,
89,
756,
197,
197,
10256,
25,
330,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTrackAfterRevoke(t *testing.T) {
tc1 := SetupEngineTest(t, "rev")
defer tc1.Cleanup()
// We need two devices. Use a paperkey to sign into the second device.
// Sign up on tc1:
u := CreateAndSignupFakeUserGPG(tc1, "pgp")
t.Logf("create a paperkey")
beng := NewPaperKey(tc1.G)
ctx := &Context{
LogUI: tc1.G.UI.GetLogUI(),
LoginUI: &libkb.TestLoginUI{},
SecretUI: &libkb.TestSecretUI{},
}
err := RunEngine(beng, ctx)
require.NoError(t, err)
paperkey := beng.Passphrase()
// Redo SetupEngineTest to get a new home directory...should look like a new device.
tc2 := SetupEngineTest(t, "login")
defer tc2.Cleanup()
// Login on device tc2 using the paperkey.
t.Logf("running LoginWithPaperKey")
secUI := u.NewSecretUI()
secUI.Passphrase = paperkey
provUI := newTestProvisionUIPaper()
provLoginUI := &libkb.TestLoginUI{Username: u.Username}
ctx = &Context{
ProvisionUI: provUI,
LogUI: tc2.G.UI.GetLogUI(),
SecretUI: secUI,
LoginUI: provLoginUI,
GPGUI: &gpgtestui{},
}
eng := NewLogin(tc2.G, libkb.DeviceTypeDesktop, "", keybase1.ClientType_CLI)
err = RunEngine(eng, ctx)
require.NoError(t, err)
t.Logf("tc2 revokes tc1 device:")
err = doRevokeDevice(tc2, u, tc1.G.Env.GetDeviceID(), false, false)
require.NoError(t, err)
// Still logged in on tc1. Try to use it to track someone. It should fail
// with a KeyRevokedError.
_, _, err = runTrack(tc1, u, "t_alice")
if err == nil {
t.Fatal("expected runTrack to return an error")
}
if _, ok := err.(libkb.KeyRevokedError); !ok {
t.Errorf("expected libkb.KeyRevokedError, got %T", err)
}
} | explode_data.jsonl/40407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 665
} | [
2830,
3393,
15667,
6025,
693,
7621,
1155,
353,
8840,
836,
8,
341,
78255,
16,
1669,
18626,
4571,
2271,
1155,
11,
330,
7282,
1138,
16867,
17130,
16,
727,
60639,
2822,
197,
322,
1205,
1184,
1378,
7611,
13,
5443,
264,
5567,
792,
311,
1841... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocalTemporaryTablePointGet(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create temporary table tmp1 (id int primary key auto_increment, u int unique, v int)")
tk.MustExec("insert into tmp1 values(1, 11, 101)")
tk.MustExec("insert into tmp1 values(2, 12, 102)")
tk.MustExec("insert into tmp1 values(4, 14, 104)")
// check point get out transaction
tk.MustQuery("select * from tmp1 where id=1").Check(testkit.Rows("1 11 101"))
tk.MustQuery("select * from tmp1 where u=11").Check(testkit.Rows("1 11 101"))
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 102"))
tk.MustQuery("select * from tmp1 where u=12").Check(testkit.Rows("2 12 102"))
// check point get in transaction
tk.MustExec("begin")
tk.MustQuery("select * from tmp1 where id=1").Check(testkit.Rows("1 11 101"))
tk.MustQuery("select * from tmp1 where u=11").Check(testkit.Rows("1 11 101"))
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 102"))
tk.MustQuery("select * from tmp1 where u=12").Check(testkit.Rows("2 12 102"))
tk.MustExec("insert into tmp1 values(3, 13, 103)")
tk.MustQuery("select * from tmp1 where id=3").Check(testkit.Rows("3 13 103"))
tk.MustQuery("select * from tmp1 where u=13").Check(testkit.Rows("3 13 103"))
tk.MustExec("update tmp1 set v=999 where id=2")
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 999"))
tk.MustExec("delete from tmp1 where id=4")
tk.MustQuery("select * from tmp1 where id=4").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where u=14").Check(testkit.Rows())
tk.MustExec("commit")
// check point get after transaction
tk.MustQuery("select * from tmp1 where id=3").Check(testkit.Rows("3 13 103"))
tk.MustQuery("select * from tmp1 where u=13").Check(testkit.Rows("3 13 103"))
tk.MustQuery("select * from tmp1 where id=2").Check(testkit.Rows("2 12 999"))
tk.MustQuery("select * from tmp1 where id=4").Check(testkit.Rows())
tk.MustQuery("select * from tmp1 where u=14").Check(testkit.Rows())
} | explode_data.jsonl/5727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 763
} | [
2830,
3393,
7319,
59362,
2556,
2609,
1949,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidFactoryArgs(t *testing.T) {
handler := utiltesting.FakeHandler{
StatusCode: 500,
ResponseBody: "",
T: t,
}
server := httptest.NewServer(&handler)
defer server.Close()
client := clientset.NewForConfigOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &api.Registry.GroupOrDie(v1.GroupName).GroupVersion}})
testCases := []struct {
hardPodAffinitySymmetricWeight int
expectErr string
}{
{
hardPodAffinitySymmetricWeight: -1,
expectErr: "invalid hardPodAffinitySymmetricWeight: -1, must be in the range 0-100",
},
{
hardPodAffinitySymmetricWeight: 101,
expectErr: "invalid hardPodAffinitySymmetricWeight: 101, must be in the range 0-100",
},
}
for _, test := range testCases {
informerFactory := informers.NewSharedInformerFactory(client, 0)
factory := NewConfigFactory(
v1.DefaultSchedulerName,
client,
informerFactory.Core().V1().Nodes(),
informerFactory.Core().V1().Pods(),
informerFactory.Core().V1().PersistentVolumes(),
informerFactory.Core().V1().PersistentVolumeClaims(),
informerFactory.Core().V1().ReplicationControllers(),
informerFactory.Extensions().V1beta1().ReplicaSets(),
informerFactory.Apps().V1beta1().StatefulSets(),
informerFactory.Core().V1().Services(),
test.hardPodAffinitySymmetricWeight,
enableEquivalenceCache,
)
_, err := factory.Create()
if err == nil {
t.Errorf("expected err: %s, got nothing", test.expectErr)
}
}
} | explode_data.jsonl/13328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 638
} | [
2830,
3393,
7928,
4153,
4117,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
4094,
8840,
991,
726,
3050,
515,
197,
197,
15872,
25,
256,
220,
20,
15,
15,
345,
197,
197,
29637,
25,
8324,
197,
10261,
25,
310,
259,
345,
197,
532,
41057,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNormIntRange(t *testing.T) {
rnd := New()
min, max := 0, 0
mean, dev := 100, 50
for i := 0; i < 100; i++ {
v := rnd.NormIntRange(mean, dev)
println(v)
if v < min {
min = v
}
if v > max {
max = v
}
}
println(min, max)
println(mean-min, max-mean)
} | explode_data.jsonl/10192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
24993,
1072,
6046,
1155,
353,
8840,
836,
8,
341,
7000,
303,
1669,
1532,
741,
25320,
11,
1932,
1669,
220,
15,
11,
220,
15,
198,
2109,
5307,
11,
3483,
1669,
220,
16,
15,
15,
11,
220,
20,
15,
198,
2023,
600,
1669,
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... | 4 |
func TestKeepaliveClientResponse(t *testing.T) {
t.Parallel()
// set up GRPCServer instance
kap := &comm.KeepaliveOptions{
ServerInterval: 1 * time.Second,
ServerTimeout: 1 * time.Second,
}
testAddress := "localhost:9401"
srv, err := comm.NewGRPCServer(testAddress, comm.ServerConfig{KaOpts: kap})
assert.NoError(t, err, "Unexpected error starting GRPCServer")
go srv.Start()
defer srv.Stop()
// test that connection does not close with response to ping
connectCtx, cancel := context.WithDeadline(
context.Background(),
time.Now().Add(1*time.Second))
clientTransport, err := transport.NewClientTransport(
connectCtx,
context.Background(),
transport.TargetInfo{Addr: testAddress},
transport.ConnectOptions{},
func() {})
if err != nil {
cancel()
}
assert.NoError(t, err, "Unexpected error creating client transport")
defer clientTransport.Close()
// sleep past keepalive timeout
time.Sleep(1500 * time.Millisecond)
// try to create a stream
_, err = clientTransport.NewStream(context.Background(), &transport.CallHdr{})
assert.NoError(t, err, "Unexpected error creating stream")
} | explode_data.jsonl/38633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 382
} | [
2830,
3393,
19434,
50961,
2959,
2582,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
322,
738,
705,
14773,
4872,
5475,
2867,
198,
16463,
391,
1669,
609,
3621,
13,
19434,
50961,
3798,
515,
197,
92075,
10256,
25,
220,
16,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBigIntToBytes(t *testing.T) {
by := byte(0x01)
sz := 4
bigInt := big.NewInt(int64(by))
expected := make([]byte, sz)
expected[sz-1] = by
actual := bigIntToBytes(bigInt, sz)
require.Equal(t, expected, actual)
} | explode_data.jsonl/56394 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
87474,
1249,
7078,
1155,
353,
8840,
836,
8,
341,
197,
1694,
1669,
4922,
7,
15,
87,
15,
16,
340,
1903,
89,
1669,
220,
19,
198,
2233,
343,
1072,
1669,
2409,
7121,
1072,
1548,
21,
19,
32028,
1171,
42400,
1669,
1281,
10556,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokenRequest(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.String() != "/token" {
t.Errorf("authenticate client request URL = %q; want %q", r.URL, "/token")
}
headerAuth := r.Header.Get("Authorization")
if headerAuth != "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" {
t.Errorf("Unexpected authorization header, %v is found.", headerAuth)
}
if got, want := r.Header.Get("Content-Type"), "application/x-www-form-urlencoded"; got != want {
t.Errorf("Content-Type header = %q; want %q", got, want)
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
r.Body.Close()
}
if err != nil {
t.Errorf("failed reading request body: %s.", err)
}
if string(body) != "audience=audience1&grant_type=client_credentials&scope=scope1+scope2" {
t.Errorf("payload = %q; want %q", string(body), "grant_type=client_credentials&scope=scope1+scope2")
}
w.Header().Set("Content-Type", "application/x-www-form-urlencoded")
w.Write([]byte("access_token=90d64460d14870c08c81352a05dedd3465940a7c&token_type=bearer"))
}))
defer ts.Close()
conf := newConf(ts.URL)
tok, err := conf.Token(context.Background())
if err != nil {
t.Error(err)
}
if !tok.Valid() {
t.Fatalf("token invalid. got: %#v", tok)
}
if tok.AccessToken != "90d64460d14870c08c81352a05dedd3465940a7c" {
t.Errorf("Access token = %q; want %q", tok.AccessToken, "90d64460d14870c08c81352a05dedd3465940a7c")
}
if tok.TokenType != "bearer" {
t.Errorf("token type = %q; want %q", tok.TokenType, "bearer")
}
} | explode_data.jsonl/19413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 680
} | [
2830,
3393,
3323,
1900,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20893,
6431,
368,
961,
3521,
5839,
1,
341,
298,
3244... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestFreeingLargeNumberOfPages(t *testing.T) {
data := core.NewMemoryRws()
subject, err := core.NewPageStorage(data, noOpSync)
assertNoError(t, err)
err = subject.InitialiseDb()
assertNoError(t, err)
var toRelease []int
// write a 1-page document many times
for i := 0; i < 3000; i++ { // a single free-page can hold 1020 page ids
inputRdr := bytes.NewReader([]byte(inputData))
pageId, err := subject.WriteStream(inputRdr)
assertNoError(t, err)
assertValidPage(t, pageId)
toRelease = append(toRelease, pageId)
}
fmt.Printf("Releasing %v pages\r\n", len(toRelease))
for _, pageId := range toRelease {
i, err := subject.ReleaseChain(pageId)
assertNoError(t, err)
assertNonZero(t, i)
}
length1 := data.Len()
fmt.Printf("Storage after cycling is %v bytes\r\n", length1)
// try to re-use the pages
for i := 0; i < 1020; i++ {
inputRdr := bytes.NewReader([]byte(inputData))
pageId, err := subject.WriteStream(inputRdr) // should use the abundant free pages
assertNoError(t, err)
assertValidPage(t, pageId)
}
for i := 0; i < 10; i++ {
inputRdr := bytes.NewReader([]byte(inputData))
pageId, err := subject.WriteStream(inputRdr) // should use the abundant free pages
assertNoError(t, err)
assertValidPage(t, pageId)
}
length2 := data.Len()
fmt.Printf("Storage after re-writing data is %v bytes\r\n", length2)
if length2 >= ((length1 * 3)/2) {
t.Errorf("Looks like the pages were not re-used correctly")
}
} | explode_data.jsonl/28109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 552
} | [
2830,
3393,
10940,
287,
34253,
40619,
17713,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
6200,
7121,
10642,
49,
8915,
741,
28624,
583,
11,
1848,
1669,
6200,
7121,
2665,
5793,
2592,
11,
902,
7125,
12154,
340,
6948,
2753,
1454,
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... | 6 |
func TestFloat64SetIncr(t *testing.T) {
z := NewFloat64()
_, ok := z.Score("t")
assert.False(t, ok)
// test first insert
s, ok := z.IncrBy(1, "t")
assert.False(t, ok)
assert.Equal(t, 1.0, s)
// test regular incr
s, ok = z.IncrBy(2, "t")
assert.True(t, ok)
assert.Equal(t, 3.0, s)
} | explode_data.jsonl/24989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
5442,
21,
19,
1649,
641,
5082,
1155,
353,
8840,
836,
8,
341,
20832,
1669,
1532,
5442,
21,
19,
741,
197,
6878,
5394,
1669,
1147,
82080,
445,
83,
1138,
6948,
50757,
1155,
11,
5394,
692,
197,
322,
1273,
1156,
5656,
198,
190... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptySelectWhere(t *testing.T) {
c := newQueryConverter(nil, nil)
query, sorters, err := c.ConvertWhereOrderBy("")
assert.NoError(t, err)
assert.Nil(t, query)
assert.Nil(t, sorters)
query, sorters, err = c.ConvertWhereOrderBy("order by Id desc")
assert.NoError(t, err)
assert.Nil(t, query)
assert.Len(t, sorters, 1)
actualSorterMap, _ := sorters[0].Source()
actualSorterJson, _ := json.Marshal([]interface{}{actualSorterMap})
assert.Equal(t, `[{"Id":{"order":"desc"}}]`, string(actualSorterJson))
} | explode_data.jsonl/1321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 207
} | [
2830,
3393,
3522,
3379,
9064,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
501,
2859,
14920,
27907,
11,
2092,
692,
27274,
11,
3378,
388,
11,
1848,
1669,
272,
36179,
9064,
34605,
31764,
6948,
35699,
1155,
11,
1848,
340,
6948,
59678,
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 TestVariables_ListsAndNullability_AllowsNonNullListsOfNonNulsToContainValues(t *testing.T) {
doc := `
query q($input: [String!]!) {
nnListNN(input: $input)
}
`
params := map[string]interface{}{
"input": []interface{}{"A"},
}
expected := &graphql.Result{
Data: map[string]interface{}{
"nnListNN": `["A"]`,
},
}
ast := testutil.TestParse(t, doc)
// execute
ep := graphql.ExecuteParams{
Schema: variablesTestSchema,
AST: ast,
Args: params,
}
result := testutil.TestExecute(t, ep)
if len(result.Errors) != len(expected.Errors) {
t.Fatalf("Unexpected errors, Diff: %v", testutil.Diff(expected.Errors, result.Errors))
}
if !reflect.DeepEqual(expected, result) {
t.Fatalf("Unexpected result, Diff: %v", testutil.Diff(expected, result))
}
} | explode_data.jsonl/6462 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
22678,
27104,
82,
3036,
3280,
2897,
53629,
4241,
16834,
37848,
2124,
8121,
45,
14295,
1249,
46522,
6227,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
22074,
286,
3239,
2804,
699,
1355,
25,
508,
703,
68034,
16315,
341,
688,
108... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRedeploy(t *testing.T) {
scc := new(LifeCycleSysCC)
stub := shim.NewMockStub("lscc", scc)
if res := stub.MockInit("1", nil); res.Status != shim.OK {
fmt.Println("Init failed", string(res.Message))
t.FailNow()
}
cds, err := constructDeploymentSpec("example02", "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02", "0", [][]byte{[]byte("init"), []byte("a"), []byte("100"), []byte("b"), []byte("200")}, true)
if err != nil {
t.FailNow()
}
defer os.Remove(lscctestpath + "/example02.0")
var b []byte
if b, err = proto.Marshal(cds); err != nil || b == nil {
t.FailNow()
}
sProp2, _ := putils.MockSignedEndorserProposal2OrPanic(chainid, &pb.ChaincodeSpec{}, id)
args := [][]byte{[]byte(DEPLOY), []byte("test"), b}
if res := stub.MockInvokeWithSignedProposal("1", args, sProp2); res.Status != shim.OK {
t.FailNow()
}
//this should fail with exists error
sProp, _ := putils.MockSignedEndorserProposal2OrPanic(chainid, &pb.ChaincodeSpec{}, id)
args = [][]byte{[]byte(DEPLOY), []byte("test"), b}
res := stub.MockInvokeWithSignedProposal("1", args, sProp)
if string(res.Message) != ExistsErr("example02").Error() {
t.FailNow()
}
} | explode_data.jsonl/9384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
6033,
747,
1989,
1155,
353,
8840,
836,
8,
341,
1903,
638,
1669,
501,
4957,
1612,
44820,
32792,
3706,
340,
18388,
392,
1669,
62132,
7121,
11571,
33838,
445,
4730,
638,
497,
274,
638,
692,
743,
592,
1669,
13633,
24664,
3803,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaxBlockGasLimits(t *testing.T) {
gasGranted := uint64(10)
ante := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) {
count := tx.(txTest).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-ante")
return ctx, nil
}
txHandlerOpt := func(bapp *baseapp.BaseApp) {
legacyRouter := middleware.NewLegacyRouter()
r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
count := msg.(*msgCounter).Counter
ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler")
any, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, err
}
return &sdk.Result{
MsgResponses: []*codectypes.Any{any},
}, nil
})
legacyRouter.AddRoute(r)
txHandler := testTxHandler(
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry),
TxDecoder: testTxDecoder(encCfg.Amino),
},
ante,
)
bapp.SetTxHandler(txHandler)
}
app := setupBaseApp(t, txHandlerOpt)
app.InitChain(abci.RequestInitChain{
ConsensusParams: &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
MaxGas: 100,
},
},
})
testCases := []struct {
tx txTest
numDelivers int
gasUsedPerDeliver uint64
fail bool
failAfterDeliver int
}{
{newTxCounter(0, 0), 0, 0, false, 0},
{newTxCounter(9, 1), 2, 10, false, 0},
{newTxCounter(10, 0), 3, 10, false, 0},
{newTxCounter(10, 0), 10, 10, false, 0},
{newTxCounter(2, 7), 11, 9, false, 0},
{newTxCounter(10, 0), 10, 10, false, 0}, // hit the limit but pass
{newTxCounter(10, 0), 11, 10, true, 10},
{newTxCounter(10, 0), 15, 10, true, 10},
{newTxCounter(9, 0), 12, 9, true, 11}, // fly past the limit
}
for i, tc := range testCases {
tx := tc.tx
tx.GasLimit = gasGranted
// reset the block gas
header := tmproto.Header{Height: app.LastBlockHeight() + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
// execute the transaction multiple times
for j := 0; j < tc.numDelivers; j++ {
_, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx)
ctx := app.DeliverState().Context()
// check for failed transactions
if tc.fail && (j+1) > tc.failAfterDeliver {
require.Error(t, err, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
require.Nil(t, result, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err))
space, code, _ := sdkerrors.ABCIInfo(err, false)
require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err)
require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err)
require.True(t, ctx.BlockGasMeter().IsOutOfGas())
} else {
// check gas used and wanted
blockGasUsed := ctx.BlockGasMeter().GasConsumed()
expBlockGasUsed := tc.gasUsedPerDeliver * uint64(j+1)
require.Equal(
t, expBlockGasUsed, blockGasUsed,
fmt.Sprintf("%d,%d: %v, %v, %v, %v", i, j, tc, expBlockGasUsed, blockGasUsed, result),
)
require.NotNil(t, result, fmt.Sprintf("tc #%d; currDeliver: %d, result: %v, err: %s", i, j, result, err))
require.False(t, ctx.BlockGasMeter().IsPastLimit())
}
}
}
} | explode_data.jsonl/30043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1399
} | [
2830,
3393,
5974,
4713,
58728,
94588,
1155,
353,
8840,
836,
8,
341,
3174,
300,
55481,
1669,
2622,
21,
19,
7,
16,
15,
340,
197,
4942,
1669,
2915,
7502,
45402,
9328,
11,
9854,
45402,
81362,
11,
37453,
1807,
8,
320,
51295,
9328,
11,
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... | 1 |
func TestStatefulSet_IsCorrectlyConfigured(t *testing.T) {
_ = os.Setenv(construct.MongodbRepoUrl, "repo")
_ = os.Setenv(construct.MongodbImageEnv, "mongo")
mdb := newTestReplicaSet()
mgr := client.NewManager(&mdb)
r := NewReconciler(mgr)
res, err := r.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: mdb.Namespace, Name: mdb.Name}})
assertReconciliationSuccessful(t, res, err)
sts := appsv1.StatefulSet{}
err = mgr.GetClient().Get(context.TODO(), types.NamespacedName{Name: mdb.Name, Namespace: mdb.Namespace}, &sts)
assert.NoError(t, err)
assert.Len(t, sts.Spec.Template.Spec.Containers, 2)
agentContainer := sts.Spec.Template.Spec.Containers[1]
assert.Equal(t, construct.AgentName, agentContainer.Name)
assert.Equal(t, os.Getenv(construct.AgentImageEnv), agentContainer.Image)
expectedProbe := probes.New(construct.DefaultReadiness())
assert.True(t, reflect.DeepEqual(&expectedProbe, agentContainer.ReadinessProbe))
mongodbContainer := sts.Spec.Template.Spec.Containers[0]
assert.Equal(t, construct.MongodbName, mongodbContainer.Name)
assert.Equal(t, "repo/mongo:4.2.2", mongodbContainer.Image)
assert.Equal(t, resourcerequirements.Defaults(), agentContainer.Resources)
acVolume, err := getVolumeByName(sts, "automation-config")
assert.NoError(t, err)
assert.NotNil(t, acVolume.Secret, "automation config should be stored in a secret!")
assert.Nil(t, acVolume.ConfigMap, "automation config should be stored in a secret, not a config map!")
} | explode_data.jsonl/80674 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 553
} | [
2830,
3393,
1397,
1262,
1649,
31879,
33092,
398,
2648,
3073,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
2643,
4202,
3160,
7,
7596,
1321,
21225,
25243,
2864,
11,
330,
23476,
1138,
197,
62,
284,
2643,
4202,
3160,
7,
7596,
1321,
21225,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestList(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
l := New()
checkListPointers(t, l, []*Element{})
// Single element list
e := l.PushFront("a")
checkListPointers(t, l, []*Element{e})
l.MoveToFront(e)
checkListPointers(t, l, []*Element{e})
l.MoveToBack(e)
checkListPointers(t, l, []*Element{e})
l.Remove(e)
checkListPointers(t, l, []*Element{})
// Bigger list
e2 := l.PushFront(2)
e1 := l.PushFront(1)
e3 := l.PushBack(3)
e4 := l.PushBack("banana")
checkListPointers(t, l, []*Element{e1, e2, e3, e4})
l.Remove(e2)
checkListPointers(t, l, []*Element{e1, e3, e4})
l.MoveToFront(e3) // move from middle
checkListPointers(t, l, []*Element{e3, e1, e4})
l.MoveToFront(e1)
l.MoveToBack(e3) // move from middle
checkListPointers(t, l, []*Element{e1, e4, e3})
l.MoveToFront(e3) // move from back
checkListPointers(t, l, []*Element{e3, e1, e4})
l.MoveToFront(e3) // should be no-op
checkListPointers(t, l, []*Element{e3, e1, e4})
l.MoveToBack(e3) // move from front
checkListPointers(t, l, []*Element{e1, e4, e3})
l.MoveToBack(e3) // should be no-op
checkListPointers(t, l, []*Element{e1, e4, e3})
e2 = l.InsertBefore(e1, 2) // insert before front
checkListPointers(t, l, []*Element{e2, e1, e4, e3})
l.Remove(e2)
e2 = l.InsertBefore(e4, 2) // insert before middle
checkListPointers(t, l, []*Element{e1, e2, e4, e3})
l.Remove(e2)
e2 = l.InsertBefore(e3, 2) // insert before back
checkListPointers(t, l, []*Element{e1, e4, e2, e3})
l.Remove(e2)
e2 = l.InsertAfter(e1, 2) // insert after front
checkListPointers(t, l, []*Element{e1, e2, e4, e3})
l.Remove(e2)
e2 = l.InsertAfter(e4, 2) // insert after middle
checkListPointers(t, l, []*Element{e1, e4, e2, e3})
l.Remove(e2)
e2 = l.InsertAfter(e3, 2) // insert after back
checkListPointers(t, l, []*Element{e1, e4, e3, e2})
l.Remove(e2)
// Check standard iteration.
sum := 0
for e := l.Front(); e != nil; e = e.Next() {
if i, ok := e.Value.(int); ok {
sum += i
}
}
if sum != 4 {
t.Errorf("sum over l = %d, want 4", sum)
}
// Clear all elements by iterating
var next *Element
for e := l.Front(); e != nil; e = next {
next = e.Next()
l.Remove(e)
}
checkListPointers(t, l, []*Element{})
})
} | explode_data.jsonl/30886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1091
} | [
2830,
3393,
852,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
8810,
1669,
1532,
741,
197,
25157,
852,
2609,
388,
1155,
11,
326,
11,
29838,
1691,
6257,
692,
197,
197,
322,
11327,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorageDirDetectionWithOldVersions(t *testing.T) {
as := assert.New(t)
rwLayer, err := getRwLayerID("abcd", "/", aufsStorageDriver, []int{1, 9, 0})
as.Nil(err)
as.Equal(rwLayer, "abcd")
} | explode_data.jsonl/29968 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
5793,
6184,
54817,
2354,
18284,
69015,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
2060,
7121,
1155,
340,
7000,
86,
9188,
11,
1848,
1669,
633,
49,
86,
9188,
915,
445,
68644,
497,
64657,
7219,
82,
5793,
11349,
11,
3056,
396,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreatePostEphemeral(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.SystemAdminClient
ephemeralPost := &model.PostEphemeral{
UserID: th.BasicUser2.Id,
Post: &model.Post{ChannelId: th.BasicChannel.Id, Message: "a" + model.NewId() + "a", Props: model.StringInterface{model.PROPS_ADD_CHANNEL_MEMBER: "no good"}},
}
rpost, resp := Client.CreatePostEphemeral(ephemeralPost)
CheckNoError(t, resp)
CheckCreatedStatus(t, resp)
require.Equal(t, ephemeralPost.Post.Message, rpost.Message, "message didn't match")
require.Equal(t, 0, int(rpost.EditAt), "newly created ephemeral post shouldn't have EditAt set")
r, err := Client.DoApiPost("/posts/ephemeral", "garbage")
require.Error(t, err)
require.Equal(t, http.StatusBadRequest, r.StatusCode)
Client.Logout()
_, resp = Client.CreatePostEphemeral(ephemeralPost)
CheckUnauthorizedStatus(t, resp)
Client = th.Client
_, resp = Client.CreatePostEphemeral(ephemeralPost)
CheckForbiddenStatus(t, resp)
} | explode_data.jsonl/5236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
4021,
4133,
36,
59941,
3253,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
16620,
7210,
2959,
271,
197,
23544,
336,
3253,
4133,
1669,
609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRunStop(t *testing.T) {
stopChan := make(chan struct{})
mJob := &mock.Job{
RunFunc: func(jobData map[string]interface{}) (job.Return, error) {
t.Log("mock job start", time.Now())
<-stopChan
defer t.Log("mock job return", time.Now())
return job.Return{State: proto.STATE_FAIL}, nil
},
StopFunc: func() error {
t.Log("job.Stop called")
close(stopChan)
return nil
},
}
pJob := proto.Job{
Id: "successJob",
Type: "jtype",
Bytes: []byte{},
Retry: 1,
RetryWait: "30s", // important...the runner will sleep for 30 seconds after the job fails the first time
}
rmc := &mock.RMClient{}
jr := runner.NewRunner(pJob, mJob, "abc", 0, 0, rmc)
// Run the job and let it block.
stateChan := make(chan byte)
go func() {
ret := jr.Run(noJobData)
stateChan <- ret.FinalState
}()
// Sleep for a second to allow the runner to get to the state where it's sleeping for the
// duration of the retry delay.
time.Sleep(1 * time.Second)
err := jr.Stop()
if err != nil {
t.Errorf("err = %s, expected nil", err)
}
// RunFunc returns FAIL but Runner knows it was stopped so it changes the state
finalState := <-stateChan
if finalState != proto.STATE_STOPPED {
t.Errorf("final state = %s, expected STATE_STOPPED", proto.StateName[finalState])
}
// Make sure calling stop on an already stopped job doesn't panic.
err = jr.Stop()
if err != nil {
t.Errorf("err = %s, expected nil", err)
}
} | explode_data.jsonl/72731 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 574
} | [
2830,
3393,
6727,
10674,
1155,
353,
8840,
836,
8,
341,
62644,
46019,
1669,
1281,
35190,
2036,
37790,
2109,
12245,
1669,
609,
16712,
45293,
515,
197,
85952,
9626,
25,
2915,
28329,
1043,
2415,
14032,
31344,
28875,
320,
8799,
46350,
11,
1465... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAggregatedTradesErrors(t *testing.T) {
t.Parallel()
start, err := time.Parse(time.RFC3339, "2020-01-02T15:04:05Z")
if err != nil {
t.Fatal(err)
}
tests := []struct {
name string
args *AggregatedTradeRequestParams
}{
{
name: "get recent trades does not support custom limit",
args: &AggregatedTradeRequestParams{
Symbol: currency.NewPair(currency.BTC, currency.USDT),
Limit: 1001,
},
},
{
name: "start time and fromId cannot be both set",
args: &AggregatedTradeRequestParams{
Symbol: currency.NewPair(currency.BTC, currency.USDT),
StartTime: start,
EndTime: start.Add(75 * time.Minute),
FromID: 2,
},
},
{
name: "can't get most recent 5000 (more than 1000 not allowed)",
args: &AggregatedTradeRequestParams{
Symbol: currency.NewPair(currency.BTC, currency.USDT),
Limit: 5000,
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
_, err := b.GetAggregatedTrades(context.Background(), tt.args)
if err == nil {
t.Errorf("Binance.GetAggregatedTrades() error = %v, wantErr true", err)
return
}
})
}
} | explode_data.jsonl/76664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 514
} | [
2830,
3393,
1949,
9042,
93040,
1282,
3452,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
21375,
11,
1848,
1669,
882,
8937,
9730,
2013,
6754,
18,
18,
18,
24,
11,
330,
17,
15,
17,
15,
12,
15,
16,
12,
15,
17,
51,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDebugCallLarge(t *testing.T) {
g, after := startDebugCallWorker(t)
defer after()
// Inject a call with a large call frame.
const N = 128
var args struct {
in [N]int
out [N]int
}
fn := func(in [N]int) (out [N]int) {
for i := range in {
out[i] = in[i] + 1
}
return
}
var want [N]int
for i := range args.in {
args.in[i] = i
want[i] = i + 1
}
if _, err := runtime.InjectDebugCall(g, fn, nil, &args, debugCallTKill, false); err != nil {
t.Fatal(err)
}
if want != args.out {
t.Fatalf("want %v, got %v", want, args.out)
}
} | explode_data.jsonl/9337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
7939,
7220,
34253,
1155,
353,
8840,
836,
8,
341,
3174,
11,
1283,
1669,
1191,
7939,
7220,
21936,
1155,
340,
16867,
1283,
2822,
197,
322,
21843,
264,
1618,
448,
264,
3460,
1618,
4034,
624,
4777,
451,
284,
220,
16,
17,
23,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetPublicIp(t *testing.T) {
type args struct {
client *http.Client
}
tests := []struct {
name string
args args
want net.IP
}{
{"Should parse the IP from the body", args{mockHTTPClient(200, "200 OK", "1.1.1.1")}, net.ParseIP("1.1.1.1")},
{"Should return nil if a non valid IP is returned", args{mockHTTPClient(200, "200 OK", "invalid IP")}, nil},
{"Should return nil if a non 200 response is returned", args{mockHTTPClient(400, "400 Bad request", "Bad request")}, nil},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got, _ := GetPublicIP(tt.args.client); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetPublicIP() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/72052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
1949,
12676,
23378,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
25291,
353,
1254,
11716,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
4179,
46917,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSupportsDTypeWithFType0XFS(t *testing.T) {
testSupportsDType(t, false, "mkfs.xfs", "-m", "crc=0", "-n", "ftype=0")
} | explode_data.jsonl/24928 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 59
} | [
2830,
3393,
7916,
82,
35,
929,
2354,
37,
929,
15,
55,
8485,
1155,
353,
8840,
836,
8,
341,
18185,
7916,
82,
35,
929,
1155,
11,
895,
11,
330,
24452,
3848,
1993,
3848,
497,
6523,
76,
497,
330,
66083,
28,
15,
497,
6523,
77,
497,
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 |
func TestIsInRange(t *testing.T) {
goodValues := []struct {
value int
min int
max int
}{{1, 0, 10}, {5, 5, 20}, {25, 10, 25}}
for _, val := range goodValues {
if msgs := IsInRange(val.value, val.min, val.max); len(msgs) > 0 {
t.Errorf("expected no errors for %#v, but got %v", val, msgs)
}
}
badValues := []struct {
value int
min int
max int
}{{1, 2, 10}, {5, -4, 2}, {25, 100, 120}}
for _, val := range badValues {
if msgs := IsInRange(val.value, val.min, val.max); len(msgs) == 0 {
t.Errorf("expected errors for %#v", val)
}
}
} | explode_data.jsonl/11823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
3872,
76059,
1155,
353,
8840,
836,
8,
341,
3174,
1386,
6227,
1669,
3056,
1235,
341,
197,
16309,
526,
198,
197,
25320,
256,
526,
198,
197,
22543,
256,
526,
198,
197,
92,
2979,
16,
11,
220,
15,
11,
220,
16,
15,
2137,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSendAllDataUpdateGoesToAllStreams(t *testing.T) {
sp := &mockStreamProvider{credentialOfDesiredType: config.SDKKey("")}
store := makeMockStore(nil, nil)
es := NewEnvStreams([]StreamProvider{sp}, store, 0, ldlog.NewDisabledLoggers())
defer es.Close()
sdkKey1, sdkKey2, sdkKey3 := config.SDKKey("sdk-key1"), config.SDKKey("sdk-key2"), config.SDKKey("sdk-key3")
es.AddCredential(sdkKey1)
es.AddCredential(sdkKey2)
es.AddCredential(sdkKey3)
require.Len(t, sp.createdStreams, 3)
esp1, esp2, esp3 := sp.createdStreams[0], sp.createdStreams[1], sp.createdStreams[2]
es.RemoveCredential(sdkKey2)
es.SendAllDataUpdate(allData)
expected := [][]ldstoretypes.Collection{allData}
assert.Equal(t, expected, esp1.allDataUpdates)
assert.Len(t, esp2.allDataUpdates, 0)
assert.Equal(t, expected, esp3.allDataUpdates)
} | explode_data.jsonl/69848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
11505,
2403,
1043,
4289,
38,
7072,
1249,
2403,
73576,
1155,
353,
8840,
836,
8,
341,
41378,
1669,
609,
16712,
3027,
5179,
90,
66799,
2124,
4896,
2690,
929,
25,
2193,
46822,
1592,
39047,
630,
57279,
1669,
1281,
11571,
6093,
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 TestStub_Handling(t *testing.T) {
f := Setup()
defer f.Stop()
bindingCalled := make(chan bool)
startStub(f.App, StubSpec{
Bindings: tk.MapBindings{
term.K('a'): func(tk.Widget) { bindingCalled <- true }},
})
f.TTY.Inject(term.K('a'))
select {
case <-bindingCalled:
// OK
case <-time.After(time.Second):
t.Errorf("Handler not called after 1s")
}
} | explode_data.jsonl/1933 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
33838,
2039,
437,
2718,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
18626,
741,
16867,
282,
30213,
2822,
2233,
3961,
20960,
1669,
1281,
35190,
1807,
340,
21375,
33838,
955,
5105,
11,
66611,
8327,
515,
197,
197,
52843,
25,
1716... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNextFunctionReturnDefer(t *testing.T) {
var testcases []nextTest
ver, _ := goversion.Parse(runtime.Version())
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
testcases = []nextTest{
{5, 6},
{6, 9},
{9, 10},
}
} else {
testcases = []nextTest{
{5, 8},
{8, 9},
{9, 10},
}
}
protest.AllowRecording(t)
testseq("testnextdefer", contNext, testcases, "main.main", t)
} | explode_data.jsonl/56209 | {
"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,
5847,
5152,
5598,
1912,
802,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
23910,
3056,
3600,
2271,
271,
197,
423,
11,
716,
1669,
728,
4366,
8937,
89467,
35842,
12367,
743,
2739,
1321,
3035,
366,
220,
15,
1369,
2739,
36892,
21... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Resource_ServiceAccount_GetDesiredState(t *testing.T) {
testCases := []struct {
Obj interface{}
ExpectedName string
}{
{
Obj: &v1alpha1.KVMConfig{
Spec: v1alpha1.KVMConfigSpec{
Cluster: v1alpha1.Cluster{
ID: "al9qy",
},
},
},
ExpectedName: "al9qy",
},
{
Obj: &v1alpha1.KVMConfig{
Spec: v1alpha1.KVMConfigSpec{
Cluster: v1alpha1.Cluster{
ID: "my-cluster",
},
},
},
ExpectedName: "my-cluster",
},
}
var err error
var newResource *Resource
{
resourceConfig := DefaultConfig()
resourceConfig.K8sClient = fake.NewSimpleClientset()
resourceConfig.Logger = microloggertest.New()
newResource, err = New(resourceConfig)
if err != nil {
t.Fatal("expected", nil, "got", err)
}
}
for i, tc := range testCases {
result, err := newResource.GetDesiredState(context.TODO(), tc.Obj)
if err != nil {
t.Fatal("case", i+1, "expected", nil, "got", err)
}
name := result.(*apiv1.ServiceAccount).Name
if tc.ExpectedName != name {
t.Fatalf("case %d expected %#v got %#v", i+1, tc.ExpectedName, name)
}
}
} | explode_data.jsonl/8026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
86346,
52548,
7365,
13614,
4896,
2690,
1397,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
5261,
688,
3749,
16094,
197,
197,
18896,
675,
914,
198,
197,
59403,
197,
197,
515,
298,
197,
5261,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPoolCopyParsedDataUpdateFull(t *testing.T) {
module := `package test
p = data.a
`
data := []byte(`{"a": 123}`)
poolSize := 4
testPool := initPoolWithData(t, uint32(poolSize), module, "test/p", data)
updated := []byte(`{"a": {"x": 123, "y": "bar"}}`)
err := testPool.SetPolicyData(testPool.Policy(), updated)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
expected := `{{"result":{"y":"bar","x":123}}}`
ensurePoolResults(t, testPool, poolSize, expected)
// Change it one more time, now that all VM's in the pool have been
// initialized and exercised at least once.
updated = []byte(`{"a": [1, 2, 3]}`)
err = testPool.SetPolicyData(testPool.Policy(), updated)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
expected = `{{"result":[1,2,3]}}`
ensurePoolResults(t, testPool, poolSize, expected)
} | explode_data.jsonl/60243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 320
} | [
2830,
3393,
10551,
12106,
82959,
1043,
4289,
9432,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
1565,
1722,
1273,
17642,
3223,
284,
821,
5849,
198,
197,
3989,
8924,
1669,
3056,
3782,
5809,
4913,
64,
788,
220,
16,
17,
18,
5541,
692,
8527... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetReplicaCount(t *testing.T) {
tests := map[string]struct {
expectedOutput string
Volume VolumeInfo
}{
"Fetching ReplicaCount": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
Spec: v1alpha1.CASVolumeSpec{
Replicas: "3",
},
},
},
expectedOutput: "3",
},
"Fetching ReplicaCount when it is present in openebs.io annotations": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"openebs.io/replica-count": "3",
},
},
},
},
expectedOutput: "3",
},
"Fetching ReplicaCount when it is present in vsm.openebs.io annotations": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"vsm.openebs.io/replica-count": "3",
},
},
},
},
expectedOutput: "3",
},
"Fetching ReplicaCount when it is not present": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{},
},
},
expectedOutput: "",
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
got := tt.Volume.GetReplicaCount()
if got != tt.expectedOutput {
t.Fatalf("Test: %v Expected: %v but got: %v", name, tt.expectedOutput, got)
}
})
}
} | explode_data.jsonl/78052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 673
} | [
2830,
3393,
1949,
18327,
15317,
2507,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
42400,
5097,
914,
198,
197,
17446,
4661,
260,
20265,
1731,
198,
197,
59403,
197,
197,
1,
52416,
94036,
2507,
788,
341,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAutomationWatch_Run(t *testing.T) {
ctrl := gomock.NewController(t)
mockStore := mocks.NewMockAutomationStatusGetter(ctrl)
defer ctrl.Finish()
expected := fixture.AutomationStatus()
opts := &WatchOpts{
store: mockStore,
}
mockStore.
EXPECT().
GetAutomationStatus(opts.ProjectID).
Return(expected, nil).
Times(1)
if err := opts.Run(); err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
} | explode_data.jsonl/17096 | {
"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,
98856,
14247,
84158,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
77333,
6093,
1669,
68909,
7121,
11571,
98856,
2522,
31485,
62100,
340,
16867,
23743,
991,
18176,
2822,
42400,
1669,
12507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClimbStairs(t *testing.T) {
n1 := 2
r1 := 2
n2 := 3
r2 := 3
n3 := 7
r3 := 21
resu1 := climbStairs(n1)
resu2 := climbStairs(n2)
resu3 := climbStairs(n3)
if resu1 != r1 || resu2 != r2 || resu3 != r3 {
t.Fail()
}
} | explode_data.jsonl/8853 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
34,
4659,
65,
623,
4720,
1155,
353,
8840,
836,
8,
341,
9038,
16,
1669,
220,
17,
198,
7000,
16,
1669,
220,
17,
198,
9038,
17,
1669,
220,
18,
198,
7000,
17,
1669,
220,
18,
198,
9038,
18,
1669,
220,
22,
198,
7000,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStream_PulsarMsgStream_InsertRepackFunc(t *testing.T) {
pulsarAddress, _ := Params.Load("_PulsarAddress")
c1, c2 := funcutil.RandomString(8), funcutil.RandomString(8)
producerChannels := []string{c1, c2}
consumerChannels := []string{c1, c2}
consumerSubName := funcutil.RandomString(8)
baseMsg := BaseMsg{
BeginTimestamp: 0,
EndTimestamp: 0,
HashValues: []uint32{1, 3},
}
insertRequest := internalpb.InsertRequest{
Base: &commonpb.MsgBase{
MsgType: commonpb.MsgType_Insert,
MsgID: 1,
Timestamp: 1,
SourceID: 1,
},
CollectionName: "Collection",
PartitionName: "Partition",
SegmentID: 1,
ShardName: "1",
Timestamps: []Timestamp{1, 1},
RowIDs: []int64{1, 3},
RowData: []*commonpb.Blob{{}, {}},
}
insertMsg := &InsertMsg{
BaseMsg: baseMsg,
InsertRequest: insertRequest,
}
msgPack := MsgPack{}
msgPack.Msgs = append(msgPack.Msgs, insertMsg)
factory := ProtoUDFactory{}
pulsarClient, _ := mqclient.GetPulsarClientInstance(pulsar.ClientOptions{URL: pulsarAddress})
inputStream, _ := NewMqMsgStream(context.Background(), 100, 100, pulsarClient, factory.NewUnmarshalDispatcher())
inputStream.AsProducer(producerChannels)
inputStream.Start()
pulsarClient2, _ := mqclient.GetPulsarClientInstance(pulsar.ClientOptions{URL: pulsarAddress})
outputStream, _ := NewMqMsgStream(context.Background(), 100, 100, pulsarClient2, factory.NewUnmarshalDispatcher())
outputStream.AsConsumer(consumerChannels, consumerSubName)
outputStream.Start()
var output MsgStream = outputStream
err := (*inputStream).Produce(&msgPack)
if err != nil {
log.Fatalf("produce error = %v", err)
}
receiveMsg(output, len(msgPack.Msgs)*2)
(*inputStream).Close()
(*outputStream).Close()
} | explode_data.jsonl/55293 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 705
} | [
2830,
3393,
3027,
1088,
14295,
277,
6611,
3027,
76417,
693,
4748,
9626,
1155,
353,
8840,
836,
8,
341,
3223,
14295,
277,
4286,
11,
716,
1669,
34352,
13969,
16975,
47,
14295,
277,
4286,
1138,
1444,
16,
11,
272,
17,
1669,
2915,
1314,
267... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommittee(t *testing.T) {
val1, _ := validator.GenerateTestValidator(0)
val2, _ := validator.GenerateTestValidator(1)
val3, _ := validator.GenerateTestValidator(2)
val4, _ := validator.GenerateTestValidator(3)
committee, err := NewCommittee([]*validator.Validator{val1, val2, val3, val4}, 4, val1.Address())
assert.NoError(t, err)
assert.Equal(t, committee.Committers(), []int{0, 1, 2, 3})
} | explode_data.jsonl/35323 | {
"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,
33441,
6547,
1155,
353,
8840,
836,
8,
341,
19302,
16,
11,
716,
1669,
22935,
57582,
2271,
14256,
7,
15,
340,
19302,
17,
11,
716,
1669,
22935,
57582,
2271,
14256,
7,
16,
340,
19302,
18,
11,
716,
1669,
22935,
57582,
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... | 1 |
func TestParseOrdinal(t *testing.T) {
type ordinalTest struct { // fields exported for the comparator
Input, Kind string
Ordinal int
HasOrdinal bool
}
tests := []ordinalTest{
{"/kythe/edge/defines", "/kythe/edge/defines", 0, false},
{"/kythe/edge/kind.here", "/kythe/edge/kind.here", 0, false},
{"/kythe/edge/kind1", "/kythe/edge/kind1", 0, false},
{"kind.-1", "kind.-1", 0, false},
{"kind.3", "kind", 3, true},
{"/kythe/edge/param.0", "/kythe/edge/param", 0, true},
{"/kythe/edge/param.1", "/kythe/edge/param", 1, true},
{"%/kythe/edge/param.1", "%/kythe/edge/param", 1, true},
{"/kythe/edge/kind.1930", "/kythe/edge/kind", 1930, true},
}
for _, test := range tests {
kind, ord, ok := ParseOrdinal(test.Input)
if err := testutil.DeepEqual(test, ordinalTest{
Input: test.Input,
Kind: kind,
Ordinal: ord,
HasOrdinal: ok,
}); err != nil {
t.Errorf("ParseOrdinal(%q): %v", test.Input, err)
}
}
} | explode_data.jsonl/25933 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 429
} | [
2830,
3393,
14463,
34779,
1155,
353,
8840,
836,
8,
341,
13158,
67948,
2271,
2036,
314,
442,
5043,
34890,
369,
279,
52040,
198,
197,
66588,
11,
16840,
914,
198,
197,
197,
34779,
257,
526,
198,
197,
197,
10281,
34779,
220,
1807,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRamStoreCRUD(t *testing.T) {
key := "pod1"
testCases := []struct {
// The operations that will be executed on the storage
operations func(*store)
// The object expected to be got by the key
expected runtime.Object
}{
{
operations: func(store *store) {
store.Create(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx1"}}})
},
expected: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx1"}}},
},
{
operations: func(store *store) {
store.Create(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx1"}}})
store.Update(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx2"}}})
},
expected: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx2"}}},
},
{
operations: func(store *store) {
store.Create(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx1"}}})
store.Update(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: key, Labels: map[string]string{"app": "nginx2"}}})
store.Delete(key)
},
expected: nil,
},
}
for i, testCase := range testCases {
store := NewStore(cache.MetaNamespaceKeyFunc, cache.Indexers{}, nil)
testCase.operations(store)
obj, _, err := store.Get(key)
if err != nil {
t.Errorf("%d: failed to get object: %v", i, err)
}
if !reflect.DeepEqual(obj, testCase.expected) {
t.Errorf("%d: get unexpected object: %v", i, obj)
}
}
} | explode_data.jsonl/65623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 648
} | [
2830,
3393,
63848,
6093,
8973,
4656,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
39073,
16,
698,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
322,
576,
7525,
429,
686,
387,
15695,
389,
279,
5819,
198,
197,
197,
38163,
2915,
4071... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIngressCheckCache(t *testing.T) {
// Apply denial rule to istio-ingress, so that only request with ["x-user"] could go through.
// This is to make the test focus on ingress check cache.
t.Logf("block request through ingress if x-user header is john")
if err := applyMixerRule(ingressDenialRule); err != nil {
fatalf(t, "could not create required mixer rule: %v", err)
}
defer func() {
if err := deleteMixerRule(ingressDenialRule); err != nil {
t.Logf("could not clear rule: %v", err)
}
}()
allowRuleSync()
// Visit product page through ingress should all be denied.
visit := func() error {
url := fmt.Sprintf("%s/productpage", getIngressOrFail(t))
// Send 100 requests in a relative short time to make sure check cache will be used.
httpOptions := fhttp.HTTPOptions{
URL: url,
}
httpOptions.AddAndValidateExtraHeader("x-user: john")
opts := fhttp.HTTPRunnerOptions{
RunnerOptions: periodic.RunnerOptions{
QPS: 10,
Exactly: 100, // will make exactly 100 calls, so run for about 10 seconds
NumThreads: 5, // get the same number of calls per connection (100/5=20)
Out: os.Stderr, // only needed because of log capture issue
},
HTTPOptions: httpOptions,
}
_, err := fhttp.RunHTTPTest(&opts)
if err != nil {
return fmt.Errorf("generating traffic via fortio failed: %v", err)
}
return nil
}
testCheckCache(t, visit, "istio-ingressgateway")
} | explode_data.jsonl/81439 | {
"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,
641,
2483,
3973,
8233,
1155,
353,
8840,
836,
8,
341,
197,
322,
20552,
33913,
5912,
311,
5999,
815,
83905,
673,
11,
773,
429,
1172,
1681,
448,
4383,
87,
8694,
1341,
1410,
728,
1526,
624,
197,
322,
1096,
374,
311,
1281,
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... | 2 |
func TestEntryAddUntimedNoPipelinesInMetadata(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
nowNanos := time.Now().UnixNano()
inputMetadatas := metadata.StagedMetadatas{
metadata.StagedMetadata{
CutoverNanos: nowNanos - 100,
Tombstoned: false,
},
}
e, _, now := testEntry(ctrl, testEntryOptions{})
*now = time.Unix(0, nowNanos)
require.Equal(t, errNoPipelinesInMetadata, e.AddUntimed(testCounter, inputMetadatas))
} | explode_data.jsonl/24212 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
5874,
2212,
20250,
75485,
2753,
47,
93997,
641,
14610,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
80922,
45,
43605,
1669,
882,
13244,
1005,
55832,
83819,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestArkResourcesExist(t *testing.T) {
var (
fakeDiscoveryHelper = &arktest.FakeDiscoveryHelper{}
server = &server{
logger: arktest.NewLogger(),
discoveryHelper: fakeDiscoveryHelper,
}
)
// Ark API group doesn't exist in discovery: should error
fakeDiscoveryHelper.ResourceList = []*metav1.APIResourceList{
{
GroupVersion: "foo/v1",
APIResources: []metav1.APIResource{
{
Name: "Backups",
Kind: "Backup",
},
},
},
}
assert.Error(t, server.arkResourcesExist())
// Ark API group doesn't contain any custom resources: should error
arkAPIResourceList := &metav1.APIResourceList{
GroupVersion: v1.SchemeGroupVersion.String(),
}
fakeDiscoveryHelper.ResourceList = append(fakeDiscoveryHelper.ResourceList, arkAPIResourceList)
assert.Error(t, server.arkResourcesExist())
// Ark API group contains all custom resources: should not error
for kind := range v1.CustomResources() {
arkAPIResourceList.APIResources = append(arkAPIResourceList.APIResources, metav1.APIResource{
Kind: kind,
})
}
assert.NoError(t, server.arkResourcesExist())
// Ark API group contains some but not all custom resources: should error
arkAPIResourceList.APIResources = arkAPIResourceList.APIResources[:3]
assert.Error(t, server.arkResourcesExist())
} | explode_data.jsonl/40906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
90788,
11277,
25613,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1166,
726,
67400,
5511,
284,
609,
838,
1944,
991,
726,
67400,
5511,
16094,
197,
41057,
1060,
284,
609,
4030,
515,
298,
17060,
25,
688,
55217,
1944,
7121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPutFileToExistingFileWithoutForceReturnsErr(t *testing.T) {
beforeTest(t)
conn := _getConnection(t)
defer conn.Close()
client := agaveproto.NewSftpRelayClient(conn)
// create a temp file to put
tmpTestFilePath, err := _createTempFile("", ".bin")
if err != nil {
assert.FailNowf(t, err.Error(), "Unable to create temp test file: %s", err.Error())
}
resolvedLocalTestFilePath := _resolveTestPath(tmpTestFilePath, LocalSharedTestDir)
tmpTestFileCopyPath, err := _createTempFile("", ".copy")
if err != nil {
assert.FailNowf(t, err.Error(), "Unable to create temp test file: %s", err.Error())
}
// get the target path of the copy file path on the server
resolvedRemoteTestFilePath := _resolveTestPath(tmpTestFileCopyPath, SFTP_SHARED_TEST_DIR)
req := &agaveproto.SrvPutRequest{
SystemConfig: _createRemoteSystemConfig(),
LocalPath: resolvedLocalTestFilePath,
RemotePath: resolvedRemoteTestFilePath,
Force: false,
Append: false,
}
grpcResponse, err := client.Put(context.Background(), req)
if err != nil {
assert.Nilf(t, err, "Error while invoking remote service: %v", err)
} else {
// get the test directory stat in the local shared directory
assert.Contains(t, strings.ToLower(grpcResponse.Error), "file already exists", "Error message in response should state file already exists")
assert.Nil(t, grpcResponse.RemoteFileInfo, "Returned file info should be nil on error")
}
afterTest(t)
} | explode_data.jsonl/32557 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 502
} | [
2830,
3393,
19103,
1703,
1249,
53067,
1703,
26040,
18573,
16446,
7747,
1155,
353,
8840,
836,
8,
341,
63234,
2271,
1155,
692,
32917,
1669,
716,
52414,
1155,
340,
16867,
4534,
10421,
2822,
25291,
1669,
933,
523,
15110,
7121,
50,
25068,
6740... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAuthorizationRequest_String(t *testing.T) {
v := AuthorizationRequest{
Note: String(""),
NoteURL: String(""),
ClientID: String(""),
ClientSecret: String(""),
Fingerprint: String(""),
}
want := `github.AuthorizationRequest{Note:"", NoteURL:"", ClientID:"", ClientSecret:"", Fingerprint:""}`
if got := v.String(); got != want {
t.Errorf("AuthorizationRequest.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
18124,
1900,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
30562,
1900,
515,
197,
197,
9112,
25,
260,
923,
445,
4461,
197,
197,
9112,
3144,
25,
414,
923,
445,
4461,
197,
71724,
915,
25,
257,
923,
445,
4461,
197,
71724... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckPointSimple(t *testing.T) {
setup()
assert := require.New(t)
r := strings.NewReader(`2021-01-14T12:16:54.579+0800 INFO CheckPoint {"host": "172.16.5.140", "port": "22", "user": "tidb", "cmd": "test cmd", "stdout": "success", "stderr": ""}`)
c, err := NewCheckPoint(r)
assert.Nil(err)
ctx := NewContext(context.Background())
p := c.Acquire(ctx, map[string]interface{}{
"host": "172.16.5.140",
"port": 22,
"user": "tidb",
"cmd": "test cmd",
})
assert.NotNil(p.Hit())
assert.Equal(p.Hit()["stdout"], "success")
assert.True(p.acquired)
p1 := c.Acquire(ctx, map[string]interface{}{
"host": "172.16.5.139",
})
assert.Nil(p1.Hit())
assert.False(p1.acquired)
p1.Release(nil)
p2 := c.Acquire(ctx, map[string]interface{}{
"host": "172.16.5.138",
})
assert.Nil(p2.Hit())
assert.False(p2.acquired)
p1.Release(nil)
p.Release(nil)
p3 := c.Acquire(ctx, map[string]interface{}{
"host": "172.16.5.137",
})
assert.Nil(p3.Hit())
assert.True(p3.acquired)
p3.Release(nil)
} | explode_data.jsonl/27335 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 478
} | [
2830,
3393,
3973,
2609,
16374,
1155,
353,
8840,
836,
8,
341,
84571,
2822,
6948,
1669,
1373,
7121,
1155,
340,
7000,
1669,
9069,
68587,
5809,
17,
15,
17,
16,
12,
15,
16,
12,
16,
19,
51,
16,
17,
25,
16,
21,
25,
20,
19,
13,
20,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCounter(t *testing.T) {
counter := 0
for i := 0; i < 5000; i++ {
go func() {
counter++
}()
}
time.Sleep(1 * time.Second)
t.Logf("counter = %d", counter)
} | explode_data.jsonl/34245 | {
"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,
14099,
1155,
353,
8840,
836,
8,
341,
58261,
1669,
220,
15,
271,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
20,
15,
15,
15,
26,
600,
1027,
341,
197,
30680,
2915,
368,
341,
298,
58261,
22940,
197,
197,
69826,
197,
532,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSgpd(t *testing.T) {
rollEntry := &RollSampleGroupEntry{RollDistance: -1}
rapEntry := &RapSampleGroupEntry{NumLeadingSamplesKnown: 1, NumLeadingSamples: 12}
alstEntry := &AlstSampleGroupEntry{RollCount: 2, FirstOutputSample: 1, SampleOffset: []uint32{7000, 1234}}
unknownEntry := &UnknownSampleGroupEntry{Name: "tele", Data: []byte{0x80}}
unknownEntry2 := &UnknownSampleGroupEntry{Name: "tele", Data: []byte{0x00}}
sgpds := []*SgpdBox{
{Version: 1, GroupingType: "roll", DefaultLength: 2, SampleGroupEntries: []SampleGroupEntry{rollEntry}},
{Version: 1, GroupingType: "rap ", DefaultLength: 1, SampleGroupEntries: []SampleGroupEntry{rapEntry}},
{Version: 1, GroupingType: "alst", DefaultLength: 12, SampleGroupEntries: []SampleGroupEntry{alstEntry}},
{Version: 1, GroupingType: "tele", DefaultLength: 1, SampleGroupEntries: []SampleGroupEntry{unknownEntry, unknownEntry2}},
}
for _, sgpd := range sgpds {
boxDiffAfterEncodeAndDecode(t, sgpd)
}
} | explode_data.jsonl/14189 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
50,
70,
15360,
1155,
353,
8840,
836,
8,
1476,
197,
1100,
5874,
1669,
609,
32355,
17571,
2808,
5874,
90,
32355,
14778,
25,
481,
16,
532,
197,
4611,
5874,
1669,
609,
49,
391,
17571,
2808,
5874,
90,
4651,
69750,
39571,
48206,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParallelSender(t *testing.T) {
defer leaktest.AfterTest(t)()
s, db := startNoSplitMergeServer(t)
defer s.Stopper().Stop(context.TODO())
ctx := context.TODO()
// Split into multiple ranges.
splitKeys := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"}
for _, key := range splitKeys {
if err := db.AdminSplit(context.TODO(), key, key, hlc.MaxTimestamp /* expirationTime */); err != nil {
t.Fatal(err)
}
}
getPSCount := func() int64 {
return s.DistSender().Metrics().AsyncSentCount.Count()
}
psCount := getPSCount()
// Batch writes to each range.
if err := db.Txn(ctx, func(ctx context.Context, txn *client.Txn) error {
b := txn.NewBatch()
for _, key := range splitKeys {
b.Put(key, "val")
}
return txn.CommitInBatch(ctx, b)
}); err != nil {
t.Errorf("unexpected error on batch put: %s", err)
}
newPSCount := getPSCount()
if c := newPSCount - psCount; c < 9 {
t.Errorf("expected at least 9 parallel sends; got %d", c)
}
psCount = newPSCount
// Scan across all rows.
if rows, err := db.Scan(context.TODO(), "a", "z", 0); err != nil {
t.Fatalf("unexpected error on Scan: %s", err)
} else if l := len(rows); l != len(splitKeys) {
t.Fatalf("expected %d rows; got %d", len(splitKeys), l)
}
newPSCount = getPSCount()
if c := newPSCount - psCount; c < 9 {
t.Errorf("expected at least 9 parallel sends; got %d", c)
}
} | explode_data.jsonl/36461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 561
} | [
2830,
3393,
16547,
20381,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
1903,
11,
2927,
1669,
1191,
2753,
20193,
52096,
5475,
1155,
340,
16867,
274,
7758,
18487,
1005,
10674,
5378,
90988,
2398,
20985,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOpAdd(t *testing.T) {
assert := assert.New(t)
jl := NewEmpty()
AddOpAdd(jl)
TestCases{
{Logic: `{"+":[]}`, Data: `null`, Result: float64(0)},
{Logic: `{"+":["1"]}`, Data: `null`, Result: float64(1)},
{Logic: `{"+":[1,"-2",33]}`, Data: `null`, Result: float64(32)},
{Logic: `{"+":["a"]}`, Data: `null`, Err: true},
{Logic: `{"+":["inf"]}`, Data: `null`, Err: true},
{Logic: `{"+":[179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]}`, Data: `null`, Err: true},
}.Run(assert, jl)
} | explode_data.jsonl/43991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 490
} | [
2830,
3393,
7125,
2212,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
12428,
75,
1669,
1532,
3522,
741,
37972,
7125,
2212,
3325,
75,
340,
73866,
37302,
515,
197,
197,
90,
26751,
25,
1565,
4913,
80479,
1294,
28350,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConfig_getOptionsFromConfig(t *testing.T) {
type fields struct {
ExporterSettings configmodels.ExporterSettings
AccessToken string
Realm string
IngestURL string
APIURL string
Timeout time.Duration
Headers map[string]string
SendCompatibleMetrics bool
TranslationRules []translation.Rule
SyncHostMetadata bool
}
tests := []struct {
name string
fields fields
want *exporterOptions
wantErr bool
}{
{
name: "Test URL overrides",
fields: fields{
Realm: "us0",
AccessToken: "access_token",
IngestURL: "https://ingest.us1.signalfx.com/",
APIURL: "https://api.us1.signalfx.com/",
},
want: &exporterOptions{
ingestURL: &url.URL{
Scheme: "https",
Host: "ingest.us1.signalfx.com",
Path: "/",
},
apiURL: &url.URL{
Scheme: "https",
Host: "api.us1.signalfx.com",
Path: "/",
},
httpTimeout: 5 * time.Second,
token: "access_token",
},
wantErr: false,
},
{
name: "Test URL from Realm",
fields: fields{
Realm: "us0",
AccessToken: "access_token",
Timeout: 10 * time.Second,
},
want: &exporterOptions{
ingestURL: &url.URL{
Scheme: "https",
Host: "ingest.us0.signalfx.com",
Path: "",
},
apiURL: &url.URL{
Scheme: "https",
Host: "api.us0.signalfx.com",
},
httpTimeout: 10 * time.Second,
token: "access_token",
},
wantErr: false,
},
{
name: "Test empty realm and API URL",
fields: fields{
AccessToken: "access_token",
Timeout: 10 * time.Second,
IngestURL: "https://ingest.us1.signalfx.com/",
},
want: nil,
wantErr: true,
},
{
name: "Test empty realm and Ingest URL",
fields: fields{
AccessToken: "access_token",
Timeout: 10 * time.Second,
APIURL: "https://api.us1.signalfx.com/",
},
want: nil,
wantErr: true,
},
{
name: "Test invalid URLs",
fields: fields{
AccessToken: "access_token",
Timeout: 10 * time.Second,
APIURL: "https://api us1 signalfx com/",
IngestURL: "https://api us1 signalfx com/",
},
want: nil,
wantErr: true,
},
{
name: "Test empty config",
want: nil,
wantErr: true,
},
{
name: "Test invalid translation rules",
fields: fields{
Realm: "us0",
AccessToken: "access_token",
SendCompatibleMetrics: true,
TranslationRules: []translation.Rule{
{
Action: translation.ActionRenameDimensionKeys,
},
},
},
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{
ExporterSettings: tt.fields.ExporterSettings,
AccessToken: tt.fields.AccessToken,
Realm: tt.fields.Realm,
IngestURL: tt.fields.IngestURL,
APIURL: tt.fields.APIURL,
Timeout: tt.fields.Timeout,
Headers: tt.fields.Headers,
SendCompatibleMetrics: tt.fields.SendCompatibleMetrics,
TranslationRules: tt.fields.TranslationRules,
SyncHostMetadata: tt.fields.SyncHostMetadata,
}
got, err := cfg.getOptionsFromConfig()
if (err != nil) != tt.wantErr {
t.Errorf("getOptionsFromConfig() error = %v, wantErr %v", err, tt.wantErr)
return
}
require.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/60396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1805
} | [
2830,
3393,
2648,
3062,
3798,
3830,
2648,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
88025,
6086,
414,
2193,
6507,
81077,
261,
6086,
198,
197,
197,
37649,
1843,
914,
198,
197,
197,
64290,
338,
914,
198,
197,
70167... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddPadding( t *testing.T ) {
// input-result data items
dataItems := []TestDataItem{
{ []byte("YELLOW SUBMARINE"),20,[]byte("YELLOW SUBMARINE\x04\x04\x04\x04")},
{ []byte("YELLOW SUBMARINE"),15,[]byte("YELLOW SUBMARINE\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04")},
{ []byte("YELLOW SUBMARINE"),16,[]byte("YELLOW SUBMARINE")},
{ []byte("YELLOW SUBMARINE"),4,[]byte("YELLOW SUBMARINE")},
{ []byte("YELLOW SUBMARINE"),5,[]byte("YELLOW SUBMARINE\x04\x04\x04\x04")},
}
for _, item := range dataItems {
result := AddPadding(item.block, item.blockSize)
if len(result) != len(item.expectedOutputBlock) {
t.Errorf( "addPadding() with args %v %v : FAILED, expected value '%v', but got '%v'", (item.block), item.blockSize, (item.expectedOutputBlock), result)
} else {
t.Logf( "addPadding() with args %v %v : PASSED, expected an error and got an error '%v'", (item.block), item.blockSize, (item.expectedOutputBlock))
}
}
} | explode_data.jsonl/2428 | {
"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,
2212,
21616,
7,
259,
353,
8840,
836,
873,
1476,
197,
322,
1946,
53838,
821,
3589,
198,
8924,
4353,
1669,
3056,
83920,
1234,
515,
197,
197,
90,
3056,
3782,
445,
97029,
16140,
60661,
3981,
3975,
17,
15,
11,
1294,
3782,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMigrateAuthToSAML(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
resp, err := th.Client.MigrateAuthToSaml("email", map[string]string{"1": "a"}, true)
require.Error(t, err)
CheckForbiddenStatus(t, resp)
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
resp, err = client.MigrateAuthToSaml("email", map[string]string{"1": "a"}, true)
require.Error(t, err)
CheckNotImplementedStatus(t, resp)
})
} | explode_data.jsonl/47569 | {
"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,
44,
34479,
5087,
1249,
50,
31102,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
34653,
11,
1848,
1669,
270,
11716,
1321,
34479,
5087,
1249,
50,
9467,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseCloudTrailValidationMessage(t *testing.T) {
notification := "CloudTrail validation message."
s3Objects, err := ParseNotification(notification)
require.NoError(t, err)
require.Equal(t, 0, len(s3Objects))
} | explode_data.jsonl/14770 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
14463,
16055,
74096,
13799,
2052,
1155,
353,
8840,
836,
8,
341,
197,
18553,
1669,
330,
16055,
74096,
10519,
1943,
2217,
1903,
18,
11543,
11,
1848,
1669,
14775,
11196,
54880,
340,
17957,
35699,
1155,
11,
1848,
340,
17957,
12808... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIterateRange(t *testing.T) {
type record struct {
key string
value string
}
records := []record{
{"abc", "123"},
{"low", "high"},
{"fan", "456"},
{"foo", "a"},
{"foobaz", "c"},
{"good", "bye"},
{"foobang", "d"},
{"foobar", "b"},
{"food", "e"},
{"foml", "f"},
}
keys := make([]string, len(records))
for i, r := range records {
keys[i] = r.key
}
sort.Strings(keys)
var tree *IAVLTree = NewIAVLTree(0, nil)
// insert all the data
for _, r := range records {
updated := tree.Set([]byte(r.key), []byte(r.value))
if updated {
t.Error("should have not been updated")
}
}
// test traversing the whole node works... in order
viewed := []string{}
tree.Iterate(func(key []byte, value []byte) bool {
viewed = append(viewed, string(key))
return false
})
if len(viewed) != len(keys) {
t.Error("not the same number of keys as expected")
}
for i, v := range viewed {
if v != keys[i] {
t.Error("Keys out of order", v, keys[i])
}
}
trav := traverser{}
tree.IterateRange([]byte("foo"), []byte("goo"), true, trav.view)
expectTraverse(t, trav, "foo", "food", 5)
trav = traverser{}
tree.IterateRange(nil, []byte("flap"), true, trav.view)
expectTraverse(t, trav, "abc", "fan", 2)
trav = traverser{}
tree.IterateRange([]byte("foob"), nil, true, trav.view)
expectTraverse(t, trav, "foobang", "low", 6)
trav = traverser{}
tree.IterateRange([]byte("very"), nil, true, trav.view)
expectTraverse(t, trav, "", "", 0)
// make sure backwards also works...
trav = traverser{}
tree.IterateRange([]byte("fooba"), []byte("food"), false, trav.view)
expectTraverse(t, trav, "food", "foobang", 4)
// make sure backwards also works...
trav = traverser{}
tree.IterateRange([]byte("g"), nil, false, trav.view)
expectTraverse(t, trav, "low", "good", 2)
} | explode_data.jsonl/5015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 756
} | [
2830,
3393,
8537,
349,
6046,
1155,
353,
8840,
836,
8,
341,
13158,
3255,
2036,
341,
197,
23634,
256,
914,
198,
197,
16309,
914,
198,
197,
630,
197,
26203,
1669,
3056,
8548,
515,
197,
197,
4913,
13683,
497,
330,
16,
17,
18,
7115,
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 TestJobDoubleSubmit(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
job1 := addTestJobWithClientId(t, r, "queue1", "my-job-1")
job2 := addTestJobWithClientId(t, r, "queue1", "my-job-1")
assert.Equal(t, job1.Id, job2.Id)
})
} | explode_data.jsonl/32034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
12245,
7378,
8890,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
68577,
16,
1669,
912,
2271,
12245,
2354,
94116,
1155,
11,
435,
11,
330,
4584,
16,
497,
330,
2408,
69948,
12,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTypeFieldOutOfRangePanic(t *testing.T) {
typ := TypeOf(struct{ X int }{10})
testIndices := [...]struct {
i int
mustPanic bool
}{
0: {-2, true},
1: {0, false},
2: {1, true},
3: {1 << 10, true},
}
for i, tt := range testIndices {
recoveredErr := fieldIndexRecover(typ, tt.i)
if tt.mustPanic {
if recoveredErr == nil {
t.Errorf("#%d: fieldIndex %d expected to panic", i, tt.i)
}
} else {
if recoveredErr != nil {
t.Errorf("#%d: got err=%v, expected no panic", i, recoveredErr)
}
}
}
} | explode_data.jsonl/29628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
929,
1877,
46608,
47,
31270,
1155,
353,
8840,
836,
8,
341,
25314,
1669,
3990,
2124,
6163,
90,
1599,
526,
335,
90,
16,
15,
3518,
18185,
31941,
1669,
48179,
1235,
341,
197,
8230,
260,
526,
198,
197,
2109,
590,
47,
31270,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsNetworkStatsError(t *testing.T) {
isNetStatsErr := isNetworkStatsError(fmt.Errorf("no such file or directory"))
if isNetStatsErr {
// Expect it to not be a net stats error
t.Error("Error incorrectly reported as network stats error")
}
isNetStatsErr = isNetworkStatsError(fmt.Errorf("open /sys/class/net/veth2f5f3e4/statistics/tx_bytes: no such file or directory"))
if !isNetStatsErr {
// Expect this to be a net stats error
t.Error("Error incorrectly reported as non network stats error")
}
} | explode_data.jsonl/398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
3872,
12320,
16635,
1454,
1155,
353,
8840,
836,
8,
341,
19907,
6954,
16635,
7747,
1669,
374,
12320,
16635,
1454,
28197,
13080,
445,
2152,
1741,
1034,
476,
6220,
5455,
743,
374,
6954,
16635,
7747,
341,
197,
197,
322,
32085,
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 TestFixedBackoff(t *testing.T) {
if backoff, _ := NewFixedBackoff(12); backoff.delayMillis != 12 || backoff.NextDelayMillis(31) != 12 {
t.FailNow()
}
if backoff, err := NewFixedBackoff(-1); err == nil || backoff != nil {
t.FailNow()
}
} | explode_data.jsonl/26473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
13520,
3707,
1847,
1155,
353,
8840,
836,
8,
341,
743,
1182,
1847,
11,
716,
1669,
1532,
13520,
3707,
1847,
7,
16,
17,
1215,
1182,
1847,
40620,
17897,
961,
220,
16,
17,
1369,
1182,
1847,
18501,
20039,
17897,
7,
18,
16,
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... | 5 |
func TestUpdateChainIdVersion(t *testing.T) {
g := GetMainNetGenesis()
b := g.Block().GetHeader().GetChainID()
cid0 := new(ChainID)
cid0.Read(b)
if cid0.Version != 0 {
t.Errorf("version mismatch: 0 expected, but got %d", cid0.Version)
t.Log(cid0.ToJSON())
}
updatedCID := MakeChainId(b, 0)
if !bytes.Equal(b, updatedCID) {
t.Error("chainid is not equal")
}
updatedCID = MakeChainId(b, 1)
cid1 := new(ChainID)
cid1.Read(updatedCID)
if cid1.Version != 1 {
t.Errorf("version mismatch: 1 expected, but got %d", cid1.Version)
t.Log(cid1.ToJSON())
}
} | explode_data.jsonl/47848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
4289,
18837,
764,
5637,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
2126,
6202,
6954,
84652,
741,
2233,
1669,
342,
28477,
1005,
1949,
4047,
1005,
1949,
18837,
915,
741,
1444,
307,
15,
1669,
501,
7,
18837,
915,
340,
1444,
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... | 4 |
func TestBuildConfigWithSecrets(t *testing.T) {
url, err := git.Parse("https://github.com/openshift/origin.git")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
source := &SourceRef{URL: url, Secrets: []buildv1.SecretBuildSource{
{Secret: corev1.LocalObjectReference{Name: "foo"}, DestinationDir: "/var"},
{Secret: corev1.LocalObjectReference{Name: "bar"}},
}}
build := &BuildRef{Source: source}
config, err := build.BuildConfig()
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
secrets := config.Spec.Source.Secrets
if got := len(secrets); got != 2 {
t.Errorf("expected 2 source secrets in build config, got %d", got)
}
} | explode_data.jsonl/17581 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
11066,
2648,
2354,
19773,
82,
1155,
353,
8840,
836,
8,
341,
19320,
11,
1848,
1669,
16345,
8937,
445,
2428,
1110,
5204,
905,
14,
24175,
47833,
14,
8611,
32799,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
53859,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContext2Plan_outputContainsTargetedResource(t *testing.T) {
m := testModule(t, "plan-untargeted-resource-output")
p := testProvider("aws")
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
Targets: []addrs.Targetable{
addrs.RootModuleInstance.Child("mod", addrs.NoKey).Resource(
addrs.ManagedResourceMode, "aws_instance", "a",
),
},
})
_, err := ctx.Plan()
if err != nil {
t.Fatalf("err: %s", err)
}
} | explode_data.jsonl/28709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
1972,
17,
20485,
7645,
23805,
6397,
291,
4783,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
12,
3850,
1284,
291,
74790,
59524,
1138,
3223,
1669,
1273,
5179,
445,
8635,
1138,
3223,
98063,
24911,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReceivePostingIsFull(t *testing.T) {
const bufferSize = 1500
c := newTestContext(t, 20000, bufferSize, localLinkAddr)
defer c.cleanup()
// Complete first posted buffer before flushing it from the tx pipe.
first := queue.DecodeRxBufferHeader(pollPull(t, &c.rxq.tx, time.After(time.Second), "Timeout waiting for first buffer to be posted"))
c.pushRxCompletion(first.Size, []queue.RxBuffer{first})
c.rxq.rx.Flush()
syscall.Write(c.rxCfg.EventFD, []byte{1, 0, 0, 0, 0, 0, 0, 0})
// Check that packet is received.
c.waitForPackets(1, time.After(time.Second), "Timeout waiting for completed packet")
// Complete another buffer.
second := queue.DecodeRxBufferHeader(pollPull(t, &c.rxq.tx, time.After(time.Second), "Timeout waiting for second buffer to be posted"))
c.pushRxCompletion(second.Size, []queue.RxBuffer{second})
c.rxq.rx.Flush()
syscall.Write(c.rxCfg.EventFD, []byte{1, 0, 0, 0, 0, 0, 0, 0})
// Check that no packet is received yet, as the worker is blocked trying
// to repost.
select {
case <-time.After(500 * time.Millisecond):
case <-c.packetCh:
t.Fatalf("Unexpected packet received")
}
// Flush tx queue, which will allow the first buffer to be reposted,
// and the second completion to be pulled.
c.rxq.tx.Flush()
syscall.Write(c.rxCfg.EventFD, []byte{1, 0, 0, 0, 0, 0, 0, 0})
// Check that second packet completes.
c.waitForPackets(1, time.After(time.Second), "Timeout waiting for second completed packet")
} | explode_data.jsonl/4240 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 525
} | [
2830,
3393,
14742,
81652,
3872,
9432,
1155,
353,
8840,
836,
8,
341,
4777,
65158,
284,
220,
16,
20,
15,
15,
198,
1444,
1669,
501,
2271,
1972,
1155,
11,
220,
17,
15,
15,
15,
15,
11,
65158,
11,
2205,
3939,
13986,
340,
16867,
272,
876... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTimestamp(t *testing.T) {
now := time.Now()
cases := []struct{ in, expected string }{
{"0", "-62167305600"}, // 0 gets parsed year 0
// Partial RFC3339 strings get parsed with second precision
{"2006-01-02T15:04:05.999999999+07:00", "1136189045"},
{"2006-01-02T15:04:05.999999999Z", "1136214245"},
{"2006-01-02T15:04:05.999999999", "1136214245"},
{"2006-01-02T15:04:05", "1136214245"},
{"2006-01-02T15:04", "1136214240"},
{"2006-01-02T15", "1136214000"},
{"2006-01-02T", "1136160000"},
{"2006-01-02", "1136160000"},
{"2006", "1136073600"},
{"2015-05-13T20:39:09Z", "1431549549"},
// unix timestamps returned as is
{"1136073600", "1136073600"},
// Durations
{"1m", fmt.Sprintf("%d", now.Add(-1*time.Minute).Unix())},
{"1.5h", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix())},
{"1h30m", fmt.Sprintf("%d", now.Add(-90*time.Minute).Unix())},
// String fallback
{"invalid", "invalid"},
}
for _, c := range cases {
o := GetTimestamp(c.in, now)
if o != c.expected {
t.Fatalf("wrong value for '%s'. expected:'%s' got:'%s'", c.in, c.expected, o)
}
}
} | explode_data.jsonl/4179 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 505
} | [
2830,
3393,
1949,
20812,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
13244,
741,
1444,
2264,
1669,
3056,
1235,
90,
304,
11,
3601,
914,
335,
515,
197,
197,
4913,
15,
497,
6523,
21,
17,
16,
21,
22,
18,
15,
20,
21,
15,
15,
1434... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReplaceObjxMap(t *testing.T) {
v := &Value{data: [](Map){(Map)(New(1)), (Map)(New(1)), (Map)(New(1)), (Map)(New(1)), (Map)(New(1)), (Map)(New(1))}}
rawArr := v.MustObjxMapSlice()
replaced := v.ReplaceObjxMap(func(index int, val Map) Map {
if index < len(rawArr)-1 {
return rawArr[index+1]
}
return rawArr[0]
})
replacedArr := replaced.MustObjxMapSlice()
if assert.Equal(t, 6, len(replacedArr)) {
assert.Equal(t, replacedArr[0], rawArr[1])
assert.Equal(t, replacedArr[1], rawArr[2])
assert.Equal(t, replacedArr[2], rawArr[3])
assert.Equal(t, replacedArr[3], rawArr[4])
assert.Equal(t, replacedArr[4], rawArr[5])
assert.Equal(t, replacedArr[5], rawArr[0])
}
} | explode_data.jsonl/23398 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 327
} | [
2830,
3393,
23107,
5261,
87,
2227,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
39444,
2227,
6098,
7,
2227,
2376,
3564,
7,
16,
5731,
320,
2227,
2376,
3564,
7,
16,
5731,
320,
2227,
2376,
3564,
7,
16,
5731,
320... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_GetDepth(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
for i := 0; i < 1000; i++ {
v := NewStream()
depth := uint16(i)
v.SetDepth(depth)
assert(v.GetDepth()).Equals(depth)
v.Release()
}
})
} | explode_data.jsonl/21180 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
3027,
13614,
19776,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSave(t *testing.T) {
testCases := []saveTestCase{
saveTestCase{
name: "Save config",
config: &latest.Config{
Version: "latest",
Default: "myDefault",
},
expectedConfigFile: latest.Config{
Version: "latest",
Default: "myDefault",
},
},
}
dir, err := ioutil.TempDir("", "test")
if err != nil {
t.Fatalf("Error creating temporary directory: %v", err)
}
wdBackup, err := os.Getwd()
if err != nil {
t.Fatalf("Error getting current working directory: %v", err)
}
err = os.Chdir(dir)
if err != nil {
t.Fatalf("Error changing working directory: %v", err)
}
defer func() {
//Delete temp folder
err = os.Chdir(wdBackup)
if err != nil {
t.Fatalf("Error changing dir back: %v", err)
}
err = os.RemoveAll(dir)
if err != nil {
t.Fatalf("Error removing dir: %v", err)
}
}()
homedir, err := homedir.Dir()
assert.NilError(t, err, "Error getting Homedir")
DevSpaceProvidersConfigPath, err = filepath.Rel(homedir, filepath.Join(dir, "providers.yaml"))
assert.NilError(t, err, "Error setting config path")
for _, testCase := range testCases {
loader := NewLoader()
err := loader.Save(testCase.config)
if testCase.expectedErr == "" {
assert.NilError(t, err, "Error in testCase %s", testCase.name)
} else {
assert.Error(t, err, testCase.expectedErr, "Wrong or no error in testCase %s", testCase.name)
}
fileContent, err := ioutil.ReadFile("providers.yaml")
assert.NilError(t, err, "Error reading file in testCase %s", testCase.name)
expectedAsYaml, err := yaml.Marshal(testCase.expectedConfigFile)
assert.NilError(t, err, "Error parsing expection to yaml in testCase %s", testCase.name)
assert.Equal(t, string(fileContent), string(expectedAsYaml), "Unexpected config file in testCase %s", testCase.name)
}
} | explode_data.jsonl/54492 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 705
} | [
2830,
3393,
8784,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
6628,
16458,
515,
197,
49230,
16458,
515,
298,
11609,
25,
330,
8784,
2193,
756,
298,
25873,
25,
609,
19350,
10753,
515,
571,
77847,
25,
330,
19350,
756,
571,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBaseNotifier(t *testing.T) {
Convey("default constructor for notifiers", t, func() {
bJSON := simplejson.New()
model := &models.AlertNotification{
Uid: "1",
Name: "name",
Type: "email",
Settings: bJSON,
}
Convey("can parse false value", func() {
bJSON.Set("uploadImage", false)
base := NewNotifierBase(model)
So(base.UploadImage, ShouldBeFalse)
})
Convey("can parse true value", func() {
bJSON.Set("uploadImage", true)
base := NewNotifierBase(model)
So(base.UploadImage, ShouldBeTrue)
})
Convey("default value should be true for backwards compatibility", func() {
base := NewNotifierBase(model)
So(base.UploadImage, ShouldBeTrue)
})
Convey("default value should be false for backwards compatibility", func() {
base := NewNotifierBase(model)
So(base.DisableResolveMessage, ShouldBeFalse)
})
})
} | explode_data.jsonl/58804 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
3978,
64729,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2258,
4692,
369,
537,
11836,
497,
259,
11,
2915,
368,
341,
197,
2233,
5370,
1669,
4285,
2236,
7121,
2822,
197,
19727,
1669,
609,
6507,
40143,
11196,
515,
298,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKernelArgumentsValidate(t *testing.T) {
tests := []struct {
in KernelArguments
out string
}{
// Ensure that ValidateWithContext prevents duplicate entries
// in ShouldExist & ShouldNotExist
{
KernelArguments{
ShouldExist: []KernelArgument{
"foo",
"bar",
},
ShouldNotExist: []KernelArgument{
"baz",
"foo",
},
},
"error at $.shouldNotExist.1: duplicate entry defined\n",
},
}
for i, test := range tests {
r := validate.ValidateWithContext(test.in, nil)
if test.out != r.String() {
t.Errorf("#%d: bad error: want %q, got %q", i, test.out, r.String())
}
}
} | explode_data.jsonl/69743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
26343,
19139,
17926,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
220,
36603,
19139,
198,
197,
13967,
914,
198,
197,
59403,
197,
197,
322,
29279,
429,
23282,
91101,
27934,
22513,
10695,
198,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServer_resultsURL(t *testing.T) {
type fields struct {
cert string
privkey string
jobs chan Job
results chan result
url string
resultsDir string
prefix string
}
tests := []struct {
name string
fields fields
want string
}{
{"ok", fields{resultsDir: "/res/", url: "https://endless.lol"}, "https://endless.lol/" + results + "/"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &Server{
cert: tt.fields.cert,
privkey: tt.fields.privkey,
jobs: tt.fields.jobs,
results: tt.fields.results,
url: tt.fields.url,
resultsDir: tt.fields.resultsDir,
prefix: tt.fields.prefix,
}
if got := s.resultsURL(); got != tt.want {
t.Errorf("Server.resultsURL() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/63409 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
5475,
13576,
3144,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
1444,
529,
981,
914,
198,
197,
71170,
792,
262,
914,
198,
197,
12428,
5481,
981,
26023,
12011,
198,
197,
55497,
262,
26023,
1102,
198,
197,
1932... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsNull(t *testing.T) {
t.Parallel()
resource.Require(t, resource.UnitTest)
wiTbl := workitem.WorkItemStorage{}.TableName()
expect(t, c.IsNull("system.assignees"), `(`+workitem.Column(wiTbl, "fields")+`->>'system.assignees' IS NULL)`, []interface{}{}, nil)
expect(t, c.IsNull("ID"), `(`+workitem.Column(wiTbl, "id")+` IS NULL)`, []interface{}{}, nil)
expect(t, c.IsNull("Type"), `(`+workitem.Column(wiTbl, "type")+` IS NULL)`, []interface{}{}, nil)
expect(t, c.IsNull("Version"), `(`+workitem.Column(wiTbl, "version")+` IS NULL)`, []interface{}{}, nil)
expect(t, c.IsNull("Number"), `(`+workitem.Column(wiTbl, "number")+` IS NULL)`, []interface{}{}, nil)
expect(t, c.IsNull("SpaceID"), `(`+workitem.Column(wiTbl, "space_id")+` IS NULL)`, []interface{}{}, nil)
} | explode_data.jsonl/36708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
98593,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50346,
81288,
1155,
11,
5101,
25159,
2271,
340,
6692,
83589,
2024,
1669,
975,
1203,
28748,
1234,
5793,
46391,
33227,
741,
24952,
1155,
11,
272,
66275,
445,
8948,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandshakeClientX25519(t *testing.T) {
config := testConfig.Clone()
config.CurvePreferences = []CurveID{X25519}
test := &clientTest{
name: "X25519-ECDHE",
args: []string{"-cipher", "ECDHE-RSA-AES128-GCM-SHA256", "-curves", "X25519"},
config: config,
}
runClientTestTLS12(t, test)
runClientTestTLS13(t, test)
} | explode_data.jsonl/27700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
2314,
29661,
2959,
55,
17,
20,
20,
16,
24,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
1273,
2648,
64463,
741,
25873,
727,
73047,
14306,
284,
3056,
31325,
915,
90,
55,
17,
20,
20,
16,
24,
630,
18185,
1669,
609,
2972,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_cmpl(t *testing.T) {
tt(t, func() {
vm := New()
test := func(src string, expect ...interface{}) {
program, err := parser.ParseFile(nil, "", src, 0)
is(err, nil)
{
program := cmpl_parse(program)
value := vm.runtime.cmpl_evaluate_nodeProgram(program, false)
if len(expect) > 0 {
is(value, expect[0])
}
}
}
test(``, Value{})
test(`var abc = 1; abc;`, 1)
test(`var abc = 1 + 1; abc;`, 2)
test(`1 + 2;`, 3)
})
} | explode_data.jsonl/9317 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
43619,
500,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1155,
11,
2915,
368,
341,
197,
54879,
1669,
1532,
2822,
197,
18185,
1669,
2915,
14705,
914,
11,
1720,
2503,
4970,
28875,
341,
298,
197,
14906,
11,
1848,
1669,
6729,
8937,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUserWithWallet_ExistingUser(t *testing.T) {
setupTest()
srv := test.RandServerAddress(t)
rt := sdkrouter.New(map[string]string{"a": srv})
url, cleanup := dummyAPI(srv)
defer cleanup()
u, err := GetUserWithSDKServer(rt, url, "abc", "")
assert.NoError(t, err)
assert.NotNil(t, u)
assert.EqualValues(t, dummyUserID, u.ID)
count, err := models.Users().CountG()
require.NoError(t, err)
assert.EqualValues(t, 1, count)
} | explode_data.jsonl/1632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
1949,
1474,
2354,
38259,
62,
53067,
1474,
1155,
353,
8840,
836,
8,
341,
84571,
2271,
741,
1903,
10553,
1669,
1273,
2013,
437,
5475,
4286,
1155,
340,
55060,
1669,
45402,
9937,
7121,
9147,
14032,
30953,
4913,
64,
788,
43578,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInteropTLS(t *testing.T) {
a := assertions.New(t)
config := &component.Config{
ServiceBase: config.ServiceBase{
TLS: tlsconfig.Config{
ServerAuth: tlsconfig.ServerAuth{
Certificate: "testdata/servercert.pem",
Key: "testdata/serverkey.pem",
},
Client: tlsconfig.Client{
RootCA: "testdata/serverca.pem",
},
},
Interop: config.InteropServer{
ListenTLS: ":9188",
SenderClientCA: config.SenderClientCA{
Source: "directory",
Directory: "testdata",
},
},
},
}
mockInterop := &mockInterop{}
c := component.MustNew(test.GetLogger(t), config)
c.RegisterInterop(mockInterop)
test.Must(nil, c.Start())
defer c.Close()
certPool := x509.NewCertPool()
certContent, err := ioutil.ReadFile("testdata/serverca.pem")
a.So(err, should.BeNil)
certPool.AppendCertsFromPEM(certContent)
client := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,
GetClientCertificate: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) {
cert, err := tls.LoadX509KeyPair("testdata/clientcert.pem", "testdata/clientkey.pem")
if err != nil {
return nil, err
}
return &cert, nil
},
},
},
}
// Correct SenderID.
{
req := &interop.JoinReq{
NsJsMessageHeader: interop.NsJsMessageHeader{
MessageHeader: interop.MessageHeader{
MessageType: interop.MessageTypeJoinReq,
ProtocolVersion: "1.1",
},
SenderID: interop.NetID{0x0, 0x0, 0x1},
ReceiverID: interop.EUI64{0x42, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
},
MACVersion: interop.MACVersion(ttnpb.MAC_V1_0_3),
}
buf, err := json.Marshal(req)
a.So(err, should.BeNil)
res, err := client.Post("https://localhost:9188", "application/json", bytes.NewReader(buf))
a.So(err, should.BeNil)
a.So(res.StatusCode, should.Equal, http.StatusOK)
}
// Wrong SenderID.
{
req := &interop.JoinReq{
NsJsMessageHeader: interop.NsJsMessageHeader{
MessageHeader: interop.MessageHeader{
MessageType: interop.MessageTypeJoinReq,
ProtocolVersion: "1.1",
},
SenderID: interop.NetID{0x0, 0x0, 0x2},
ReceiverID: interop.EUI64{0x42, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
},
MACVersion: interop.MACVersion(ttnpb.MAC_V1_0_3),
}
buf, err := json.Marshal(req)
a.So(err, should.BeNil)
res, err := client.Post("https://localhost:9188", "application/json", bytes.NewReader(buf))
a.So(err, should.BeNil)
a.So(res.StatusCode, should.Equal, http.StatusOK)
var msg interop.ErrorMessage
if !a.So(json.NewDecoder(res.Body).Decode(&msg), should.BeNil) {
t.FailNow()
}
a.So(msg.Result.ResultCode, should.Resemble, interop.ResultUnknownSender)
}
} | explode_data.jsonl/64333 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1263
} | [
2830,
3393,
94000,
45439,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
54836,
7121,
1155,
692,
25873,
1669,
609,
8571,
10753,
515,
197,
91619,
3978,
25,
2193,
13860,
3978,
515,
298,
10261,
7268,
25,
55026,
1676,
10753,
515,
571,
92075,
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... | 2 |
func TestGenerateProgram(t *testing.T) {
t.Parallel()
test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "go",
Extension: "go",
OutputFile: "main.go",
Check: func(t *testing.T, path string, dependencies codegen.StringSet) {
Check(t, path, dependencies, "../../../../../../../sdk")
},
GenProgram: GenerateProgram,
TestCases: test.PulumiPulumiProgramTests,
})
} | explode_data.jsonl/61959 | {
"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,
31115,
10690,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18185,
8787,
10690,
2078,
4370,
1155,
345,
197,
18185,
80254,
2078,
4370,
3798,
515,
298,
197,
13806,
25,
256,
330,
3346,
756,
298,
197,
12049,
25,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.