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 TestContext2Plan_orphan(t *testing.T) {
m := testModule(t, "plan-orphan")
p := testProvider("aws")
p.DiffFn = testDiffFn
s := MustShimLegacyState(&State{
Modules: []*ModuleState{
&ModuleState{
Path: rootModulePath,
Resources: map[string]*ResourceState{
"aws_instance.baz": &ResourceState{
Type: "aws_instance",
Primary: &InstanceState{
ID: "bar",
},
},
},
},
},
})
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
State: s,
})
plan, diags := ctx.Plan()
if diags.HasErrors() {
t.Fatalf("unexpected errors: %s", diags.Err())
}
schema := p.GetSchemaReturn.ResourceTypes["aws_instance"]
ty := schema.ImpliedType()
if len(plan.Changes.Resources) != 2 {
t.Fatal("expected 2 changes, got", len(plan.Changes.Resources))
}
for _, res := range plan.Changes.Resources {
ric, err := res.Decode(ty)
if err != nil {
t.Fatal(err)
}
switch i := ric.Addr.String(); i {
case "aws_instance.baz":
if res.Action != plans.Delete {
t.Fatalf("resource %s should be removed", i)
}
case "aws_instance.foo":
if res.Action != plans.Create {
t.Fatalf("resource %s should be created", i)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
"id": cty.UnknownVal(cty.String),
"num": cty.NumberIntVal(2),
"type": cty.StringVal("aws_instance"),
}), ric.After)
default:
t.Fatal("unknown instance:", i)
}
}
} | explode_data.jsonl/28697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 684
} | [
2830,
3393,
1972,
17,
20485,
8734,
9943,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
26511,
9943,
1138,
3223,
1669,
1273,
5179,
445,
8635,
1138,
3223,
98063,
24911,
284,
1273,
21751,
24911,
198,
1903,
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... | 9 |
func TestGatherHealthCheck(t *testing.T) {
expectedFields := map[string]interface{}{
"check_name": "foo.health",
"status": "passing",
"passing": 1,
"critical": 0,
"warning": 0,
"service_id": "foo.123",
}
expectedTags := map[string]string{
"node": "localhost",
"service_name": "foo",
"check_id": "foo.health123",
"bar": "bar",
"env:sandbox": "env:sandbox",
"tagkey:value:stillvalue": "tagkey:value:stillvalue",
}
var acc testutil.Accumulator
consul := &Consul{}
consul.GatherHealthCheck(&acc, sampleChecks)
acc.AssertContainsTaggedFields(t, "consul_health_checks", expectedFields, expectedTags)
} | explode_data.jsonl/6888 | {
"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,
38,
1856,
14542,
3973,
1155,
353,
8840,
836,
8,
341,
42400,
8941,
1669,
2415,
14032,
31344,
67066,
197,
197,
1,
2028,
1269,
788,
330,
7975,
38107,
756,
197,
197,
1,
2829,
788,
257,
330,
6385,
287,
756,
197,
197,
1,
6385,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReply(t *testing.T) {
for _, rt := range replyTests {
if rt.actual.err != rt.expected.err {
t.Errorf("%s returned err %v, want %v", rt.name, rt.actual.err, rt.expected.err)
continue
}
if !reflect.DeepEqual(rt.actual.v, rt.expected.v) {
t.Errorf("%s=%+v, want %+v", rt.name, rt.actual.v, rt.expected.v)
}
}
} | explode_data.jsonl/443 | {
"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,
20841,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
16677,
1669,
2088,
9851,
18200,
341,
197,
743,
16677,
68120,
18441,
961,
16677,
56835,
18441,
341,
298,
3244,
13080,
4430,
82,
5927,
1848,
1018,
85,
11,
1366,
1018,
85,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCurrentWindowHandle(t *testing.T) {
ctx := context.Background()
driver, err := CreateSession(ctx, wdAddress(), 3, nil)
if err != nil {
t.Fatal(err)
}
defer driver.Quit(ctx)
if handle, err := driver.CurrentWindowHandle(ctx); err != nil {
t.Fatal(err)
} else if handle == "" {
t.Fatal(`Got "" handle, expected non-empty string`)
}
} | explode_data.jsonl/68739 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
5405,
4267,
6999,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
33652,
11,
1848,
1669,
4230,
5283,
7502,
11,
45404,
4286,
1507,
220,
18,
11,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestTaskStackConfig_StackName(t *testing.T) {
taskInput := deploy.CreateTaskResourcesInput{
Name: "my-task",
}
task := &taskStackConfig{
CreateTaskResourcesInput: &taskInput,
}
got := task.StackName()
require.Equal(t, got, fmt.Sprintf("task-%s", testTaskName))
} | explode_data.jsonl/16274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
6262,
4336,
2648,
62,
4336,
675,
1155,
353,
8840,
836,
8,
341,
49115,
2505,
1669,
10517,
7251,
6262,
11277,
2505,
515,
197,
21297,
25,
256,
330,
2408,
52579,
756,
197,
630,
49115,
1669,
609,
8202,
4336,
2648,
515,
197,
755... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExit(t *testing.T) {
protest.AllowRecording(t)
withTestProcess("continuetestprog", t, func(p *proc.Target, fixture protest.Fixture) {
err := p.Continue()
pe, ok := err.(proc.ErrProcessExited)
if !ok {
t.Fatalf("Continue() returned unexpected error type %s", err)
}
if pe.Status != 0 {
t.Errorf("Unexpected error status: %d", pe.Status)
}
if pe.Pid != p.Pid() {
t.Errorf("Unexpected process id: %d", pe.Pid)
}
})
} | explode_data.jsonl/56197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
15339,
1155,
353,
8840,
836,
8,
341,
197,
776,
1944,
29081,
52856,
1155,
340,
46948,
2271,
7423,
445,
21319,
13807,
477,
32992,
497,
259,
11,
2915,
1295,
353,
15782,
35016,
11,
12507,
8665,
991,
12735,
8,
341,
197,
9859,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractRootCertExpiryTimestamp(t *testing.T) {
cert, key, err := pkiutil.GenCertKeyFromOptions(pkiutil.CertOptions{
Host: "citadel.testing.istio.io",
NotBefore: time.Now(),
TTL: time.Second * 5,
Org: "MyOrg",
IsCA: true,
IsSelfSigned: true,
IsServer: true,
RSAKeySize: 512,
})
if err != nil {
t.Errorf("failed to gen cert for Citadel self signed cert %v", err)
}
kb, err := pkiutil.NewVerifiedKeyCertBundleFromPem(cert, key, nil, cert)
if err != nil {
t.Errorf("failed to create key cert bundle %v", err)
}
ca := &mockca.FakeCA{
KeyCertBundle: kb,
}
testCases := []struct {
name string
ttlRange []float64
sleep int
}{
{
name: "ttl-valid",
ttlRange: []float64{3, 5},
sleep: 3,
},
{
name: "ttl-valid-3s-less",
ttlRange: []float64{0, 2},
sleep: 3,
},
}
for _, tc := range testCases {
sec := extractRootCertExpiryTimestamp(ca) - float64(time.Now().Unix())
if sec < tc.ttlRange[0] || sec > tc.ttlRange[1] {
t.Errorf("[%v] Failed, expect within range [%v, %v], got %v", tc.name, tc.ttlRange[0], tc.ttlRange[1], sec)
}
if tc.sleep != 0 {
time.Sleep(time.Duration(tc.sleep) * time.Second)
}
}
} | explode_data.jsonl/53134 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 595
} | [
2830,
3393,
28959,
8439,
36934,
840,
48209,
20812,
1155,
353,
8840,
836,
8,
341,
1444,
529,
11,
1376,
11,
1848,
1669,
281,
6642,
1314,
65384,
36934,
1592,
3830,
3798,
1295,
6642,
1314,
727,
529,
3798,
515,
197,
197,
9296,
25,
260,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestPi(t *testing.T) {
g1 := new(bn256.G2).ScalarBaseMult(big.NewInt(2))
g2 := new(bn256.G2).ScalarBaseMult(big.NewInt(3))
g3 := new(bn256.G2).ScalarBaseMult(big.NewInt(5))
gammas := Gammas([]*bn256.G2{g1, g2, g3})
pi1 := gammas.Pi(big.NewInt(1))
pi2 := gammas.Pi(big.NewInt(2))
pi1Exp := new(bn256.G2).Add(g1, g2)
pi1Exp = new(bn256.G2).Add(pi1Exp, g3)
pi2Exp := new(bn256.G2).Add(g1, new(bn256.G2).ScalarMult(g2, big.NewInt(2)))
pi2Exp = new(bn256.G2).Add(pi2Exp, new(bn256.G2).ScalarMult(g3, big.NewInt(4)))
assert.DeepEqual(t, pi1, pi1Exp, G2Comparer)
assert.DeepEqual(t, pi2, pi2Exp, G2Comparer)
} | explode_data.jsonl/60071 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
34767,
1155,
353,
8840,
836,
8,
341,
3174,
16,
1669,
501,
1883,
77,
17,
20,
21,
1224,
17,
568,
20639,
3978,
40404,
75616,
7121,
1072,
7,
17,
1171,
3174,
17,
1669,
501,
1883,
77,
17,
20,
21,
1224,
17,
568,
20639,
3978,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoCompressionOverlap(t *testing.T) {
clientHello := &clientHelloMsg{
vers: 0x0301,
cipherSuites: []uint16{TLS_RSA_WITH_RC4_128_SHA},
compressionMethods: []uint8{0xff},
}
testClientHelloFailure(t, clientHello, "client does not support uncompressed connections")
} | explode_data.jsonl/80547 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
2753,
81411,
82171,
1155,
353,
8840,
836,
8,
341,
25291,
9707,
1669,
609,
2972,
9707,
6611,
515,
197,
197,
3004,
25,
2290,
220,
15,
87,
15,
18,
15,
16,
345,
197,
1444,
10558,
62898,
288,
25,
981,
3056,
2496,
16,
21,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewTaskEngineRestoreFromCheckpoint(t *testing.T) {
ctrl, credentialsManager, _, imageManager, _,
dockerClient, stateManagerFactory, saveableOptionFactory, execCmdMgr := setup(t)
defer ctrl.Finish()
ec2MetadataClient := mock_ec2.NewMockEC2MetadataClient(ctrl)
cfg := getTestConfig()
cfg.Checkpoint = config.BooleanDefaultFalse{Value: config.ExplicitlyEnabled}
cfg.Cluster = testCluster
mockPauseLoader := mock_pause.NewMockLoader(ctrl)
ec2MetadataClient.EXPECT().InstanceID().Return(testEC2InstanceID, nil)
dataClient, cleanup := newTestDataClient(t)
defer cleanup()
// Populate boldtb with test data.
populateBoltDB(dataClient, t)
ctx, cancel := context.WithCancel(context.TODO())
// Cancel the context to cancel async routines
defer cancel()
agent := &ecsAgent{
ctx: ctx,
cfg: &cfg,
dataClient: dataClient,
dockerClient: dockerClient,
stateManagerFactory: stateManagerFactory,
ec2MetadataClient: ec2MetadataClient,
pauseLoader: mockPauseLoader,
saveableOptionFactory: saveableOptionFactory,
}
state := dockerstate.NewTaskEngineState()
_, instanceID, err := agent.newTaskEngine(eventstream.NewEventStream("events", ctx),
credentialsManager, state, imageManager, execCmdMgr)
assert.NoError(t, err)
assert.Equal(t, testEC2InstanceID, instanceID)
require.NotNil(t, agent.latestSeqNumberTaskManifest)
s := &savedData{
availabilityZone: agent.availabilityZone,
cluster: cfg.Cluster,
containerInstanceARN: agent.containerInstanceARN,
ec2InstanceID: instanceID,
latestTaskManifestSeqNum: *agent.latestSeqNumberTaskManifest,
}
checkLoadedData(state, s, t)
} | explode_data.jsonl/41587 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 662
} | [
2830,
3393,
3564,
6262,
4571,
56284,
3830,
92688,
1155,
353,
8840,
836,
8,
341,
84381,
11,
16387,
2043,
11,
8358,
2168,
2043,
11,
716,
345,
197,
2698,
13659,
2959,
11,
1584,
2043,
4153,
11,
3581,
480,
5341,
4153,
11,
3883,
15613,
2556... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPivotCacheRecordsMarshalUnmarshal(t *testing.T) {
v := sml.NewPivotCacheRecords()
buf, _ := xml.Marshal(v)
v2 := sml.NewPivotCacheRecords()
xml.Unmarshal(buf, v2)
} | explode_data.jsonl/67973 | {
"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,
47,
16084,
8233,
25876,
55438,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
274,
1014,
7121,
47,
16084,
8233,
25876,
741,
26398,
11,
716,
1669,
8396,
37271,
3747,
340,
5195,
17,
1669,
274,
1014,
7121,
47,
16084,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParsePointUnicodeString(t *testing.T) {
test(t, `cpu,host=serverA,region=us-east value="wè" 1000000000`,
NewTestPoint(
"cpu",
models.NewTags(map[string]string{
"host": "serverA",
"region": "us-east",
}),
models.Fields{
"value": "wè",
},
time.Unix(1, 0)),
)
} | explode_data.jsonl/16943 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
14463,
2609,
33920,
703,
1155,
353,
8840,
836,
8,
341,
18185,
1155,
11,
1565,
16475,
11,
3790,
28,
4030,
32,
11,
3943,
28,
355,
39507,
897,
428,
86,
4458,
1,
220,
16,
15,
15,
15,
15,
15,
15,
15,
15,
15,
12892,
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 TestIngressGateway503DuringRuleChange(t *testing.T) {
istioNamespace := tc.Kube.IstioSystemNamespace()
ingressGatewayServiceName := tc.Kube.IstioIngressGatewayService()
gateway := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{"testdata/networking/v1alpha3/ingressgateway.yaml"},
kubeconfig: tc.Kube.KubeConfig,
}
// Add subsets
newDestRule := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{maybeAddTLSForDestinationRule(tc, "testdata/networking/v1alpha3/rule-503test-destinationrule-c.yaml")},
kubeconfig: tc.Kube.KubeConfig,
}
// route to subsets
newVirtService := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{"testdata/networking/v1alpha3/rule-503test-virtualservice.yaml"},
kubeconfig: tc.Kube.KubeConfig,
}
addMoreSubsets := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{maybeAddTLSForDestinationRule(tc, "testdata/networking/v1alpha3/rule-503test-destinationrule-c-add-subset.yaml")},
kubeconfig: tc.Kube.KubeConfig,
}
routeToNewSubsets := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{"testdata/networking/v1alpha3/rule-503test-update-virtualservice.yaml"},
kubeconfig: tc.Kube.KubeConfig,
}
deleteOldSubsets := &deployableConfig{
Namespace: tc.Kube.Namespace,
YamlFiles: []string{maybeAddTLSForDestinationRule(tc, "testdata/networking/v1alpha3/rule-503test-destinationrule-c-del-subset.yaml")},
kubeconfig: tc.Kube.KubeConfig,
}
var resp ClientResponse
var err error
var fatalError bool
if err = gateway.Setup(); err != nil {
t.Fatal(err)
}
defer gateway.Teardown()
log.Infof("Adding new subsets v1,v2")
// these functions have built in sleep. So we don't have to add any extra sleep here
if err = newDestRule.Setup(); err != nil {
t.Fatal(err)
}
defer newDestRule.Teardown()
log.Infof("routing to v1,v2")
if err = newVirtService.Setup(); err != nil {
t.Fatal(err)
}
defer newVirtService.Teardown()
time.Sleep(2 * time.Second)
var wg sync.WaitGroup
for cluster := range tc.Kube.Clusters {
wg.Add(1)
go func() {
defer wg.Done()
reqURL := fmt.Sprintf("http://%s.%s/c", ingressGatewayServiceName, istioNamespace)
// 500 requests @20 qps = 25s. This is the minimum required to cover all rule changes below.
resp = ClientRequest(cluster, "t", reqURL, 500, "-key Host -val uk.bookinfo.com -qps 20")
}()
}
log.Infof("Adding new subsets v3,v4")
if err = addMoreSubsets.Setup(); err != nil {
fatalError = true
goto cleanup
}
time.Sleep(2 * time.Second)
log.Infof("routing to v3,v4")
if err = routeToNewSubsets.Setup(); err != nil {
fatalError = true
goto cleanup
}
time.Sleep(2 * time.Second)
log.Infof("deleting old subsets v1,v2")
if err = deleteOldSubsets.Setup(); err != nil {
fatalError = true
goto cleanup
}
cleanup:
wg.Wait()
if fatalError {
t.Fatal(err)
} else {
//log.Infof("Body: %s, response codes: %v", resp.Body, resp.Code)
if len(resp.Code) > 0 {
count := make(map[string]int)
for _, elt := range resp.Code {
count[elt] = count[elt] + 1
}
if count["200"] != len(resp.Code) {
// have entries other than 200
t.Errorf("Got non 200 status code while changing rules: %v", count)
} else {
log.Infof("No 503s were encountered while changing rules (total %d requests)", len(resp.Code))
}
} else {
t.Errorf("Could not parse response codes from the client")
}
}
} | explode_data.jsonl/15610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1406
} | [
2830,
3393,
641,
2483,
40709,
20,
15,
18,
16014,
11337,
4072,
1155,
353,
8840,
836,
8,
341,
197,
380,
815,
22699,
1669,
17130,
11352,
3760,
2447,
267,
815,
2320,
22699,
741,
197,
287,
673,
40709,
1860,
675,
1669,
17130,
11352,
3760,
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 TestBlockForWork(t *testing.T) {
//t.Log("TestBlockForWork")
if !build.POOL {
return
}
pt, err := newPoolTester(t.Name(), 0)
defer pt.Close()
if err != nil {
t.Fatal(err)
}
b := pt.mpool.blockForWork()
if b.MinerPayouts[0].Value.String() != "299999000000000000000000000000" {
t.Fatal(errors.New(fmt.Sprintf("wrong block payout value: %s", b.MinerPayouts[0].Value.String())))
}
if b.MinerPayouts[0].UnlockHash.String() != tPoolWallet {
t.Fatal(errors.New(fmt.Sprintf("wrong block miner address: %s", b.MinerPayouts[0].UnlockHash.String())))
}
if len(b.Transactions) != 0 {
t.Fatal(errors.New(fmt.Sprintf("wrong tx number %d", len(b.Transactions))))
}
} | explode_data.jsonl/71182 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 284
} | [
2830,
3393,
4713,
2461,
6776,
1155,
353,
8840,
836,
8,
341,
197,
322,
83,
5247,
445,
2271,
4713,
2461,
6776,
1138,
743,
753,
5834,
84973,
1930,
341,
197,
853,
198,
197,
532,
60796,
11,
1848,
1669,
501,
10551,
58699,
1155,
2967,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnsureLoggedInUnauthenticated(t *testing.T) {
r := getRouter(false)
r.GET("/", setLoggedIn(false), EnsureLoggedIn(), func(c *gin.Context) {
// Use the setLoggedIn middleware to set the is_logged_in flag to false
// Since we aren't logged in, this handler should not be executed.
// If it is, then the EnsureLoggedIn middleware isn't working as expected
t.Fail()
})
// Use the helper method to execute process the request and test
// the HTTP status code
testMiddlewareRequest(t, r, http.StatusUnauthorized)
} | explode_data.jsonl/57771 | {
"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,
64439,
28559,
1806,
57707,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
633,
9523,
3576,
340,
7000,
17410,
35460,
738,
28559,
3576,
701,
29279,
28559,
1507,
2915,
1337,
353,
8163,
9328,
8,
341,
197,
197,
322,
5443,
279,
738,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccKeycloakOpenidClient_excludeSessionStateFromAuthResponse(t *testing.T) {
realmName := "terraform-" + acctest.RandString(10)
clientId := "terraform-" + acctest.RandString(10)
resource.Test(t, resource.TestCase{
ProviderFactories: testAccProviderFactories,
PreCheck: func() { testAccPreCheck(t) },
CheckDestroy: testAccCheckKeycloakOpenidClientDestroy(),
Steps: []resource.TestStep{
{
Config: testKeycloakOpenidClient_omitExcludeSessionStateFromAuthResponse(realmName, clientId, "plain"),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientHasExcludeSessionStateFromAuthResponse("keycloak_openid_client.client", false),
testAccCheckKeycloakOpenidClientHasPkceCodeChallengeMethod("keycloak_openid_client.client", "plain"),
),
},
{
Config: testKeycloakOpenidClient_excludeSessionStateFromAuthResponse(realmName, clientId, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientHasExcludeSessionStateFromAuthResponse("keycloak_openid_client.client", false),
testAccCheckKeycloakOpenidClientHasPkceCodeChallengeMethod("keycloak_openid_client.client", ""),
),
},
{
Config: testKeycloakOpenidClient_excludeSessionStateFromAuthResponse(realmName, clientId, true),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientHasExcludeSessionStateFromAuthResponse("keycloak_openid_client.client", true),
testAccCheckKeycloakOpenidClientHasPkceCodeChallengeMethod("keycloak_openid_client.client", ""),
),
},
{
Config: testKeycloakOpenidClient_excludeSessionStateFromAuthResponse(realmName, clientId, false),
Check: resource.ComposeTestCheckFunc(
testAccCheckKeycloakOpenidClientHasExcludeSessionStateFromAuthResponse("keycloak_openid_client.client", false),
testAccCheckKeycloakOpenidClientHasPkceCodeChallengeMethod("keycloak_openid_client.client", ""),
),
},
},
})
} | explode_data.jsonl/52139 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 717
} | [
2830,
3393,
14603,
1592,
88751,
5002,
307,
2959,
88668,
5283,
1397,
3830,
5087,
2582,
1155,
353,
8840,
836,
8,
341,
17200,
7673,
675,
1669,
330,
61385,
27651,
488,
1613,
67880,
2013,
437,
703,
7,
16,
15,
340,
25291,
764,
1669,
330,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnconfinedSeccompProfileWithDockerV110(t *testing.T) {
dm, fakeDocker := newTestDockerManagerWithVersion("1.10.1", "1.22")
pod := makePod("foo4", &api.PodSpec{
Containers: []api.Container{
{Name: "bar4"},
},
})
pod.Annotations = map[string]string{
api.SeccompPodAnnotationKey: "unconfined",
}
runSyncPod(t, dm, fakeDocker, pod, nil, false)
verifyCalls(t, fakeDocker, []string{
// Create pod infra container.
"create", "start", "inspect_container", "inspect_container",
// Create container.
"create", "start", "inspect_container",
})
fakeDocker.Lock()
if len(fakeDocker.Created) != 2 ||
!matchString(t, "/k8s_POD\\.[a-f0-9]+_foo4_new_", fakeDocker.Created[0]) ||
!matchString(t, "/k8s_bar4\\.[a-f0-9]+_foo4_new_", fakeDocker.Created[1]) {
t.Errorf("unexpected containers created %v", fakeDocker.Created)
}
fakeDocker.Unlock()
newContainer, err := fakeDocker.InspectContainer(fakeDocker.Created[1])
if err != nil {
t.Fatalf("unexpected error %v", err)
}
assert.Contains(t, newContainer.HostConfig.SecurityOpt, "seccomp:unconfined", "Pods created with a secccomp annotation of unconfined should have seccomp:unconfined.")
} | explode_data.jsonl/31188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 460
} | [
2830,
3393,
1806,
6135,
1589,
1514,
638,
14435,
8526,
2354,
35,
13659,
53,
16,
16,
15,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
12418,
35,
13659,
1669,
501,
2271,
35,
13659,
2043,
2354,
5637,
445,
16,
13,
16,
15,
13,
16,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncrementAfterDeleteKeyStringValueInt(t *testing.T) {
const key1 = ""
const key2 = "x"
m := make(map[string]int)
m[key1] = 99
delete(m, key1)
m[key2] += 1
if n2 := m[key2]; n2 != 1 {
t.Errorf("incremented 0 to %d", n2)
}
} | explode_data.jsonl/19931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
38311,
6025,
6435,
1592,
82696,
1072,
1155,
353,
8840,
836,
8,
341,
4777,
1376,
16,
284,
8389,
4777,
1376,
17,
284,
330,
87,
1837,
2109,
1669,
1281,
9147,
14032,
63025,
340,
2109,
8157,
16,
60,
284,
220,
24,
24,
198,
156... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMsgBuy(t *testing.T) {
_, _, a1 := testdata.KeyTestPubAddr()
tests := map[string]struct {
src MsgBuy
expErr bool
}{
"valid": {
src: MsgBuy{
Buyer: a1.String(),
Orders: []*MsgBuy_Order{
{
Quantity: "1.5",
BidPrice: &sdk.Coin{
Denom: "uregen",
Amount: sdk.NewInt(20),
},
DisableAutoRetire: true,
DisablePartialFill: true,
},
},
},
expErr: false,
},
"invalid: bad owner address": {
src: MsgBuy{
Buyer: "foobar",
Orders: []*MsgBuy_Order{
{
Quantity: "1.5",
BidPrice: &sdk.Coin{
Denom: "uregen",
Amount: sdk.NewInt(20),
},
DisableAutoRetire: true,
DisablePartialFill: true,
},
},
},
expErr: true,
},
"invalid: bad quantity": {
src: MsgBuy{
Buyer: a1.String(),
Orders: []*MsgBuy_Order{
{
Quantity: "-1.5",
BidPrice: &sdk.Coin{
Denom: "uregen",
Amount: sdk.NewInt(20),
},
DisableAutoRetire: true,
DisablePartialFill: true,
},
},
},
expErr: true,
},
"invalid: bad bid price": {
src: MsgBuy{
Buyer: a1.String(),
Orders: []*MsgBuy_Order{
{
Quantity: "1.5",
BidPrice: &sdk.Coin{
Denom: "uregen",
Amount: sdk.NewInt(-20),
},
DisableAutoRetire: true,
DisablePartialFill: true,
},
},
},
expErr: true,
},
}
for msg, test := range tests {
t.Run(msg, func(t *testing.T) {
err := test.src.ValidateBasic()
if test.expErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
} | explode_data.jsonl/65137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 921
} | [
2830,
3393,
6611,
17482,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
264,
16,
1669,
1273,
691,
9610,
2271,
29162,
13986,
2822,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
41144,
262,
24205,
17482,
198,
197,
48558,
7747,
1807,
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 TestJobSpecsController_Create_CaseInsensitiveTypes(t *testing.T) {
t.Parallel()
app, cleanup := cltest.NewApplication()
defer cleanup()
j := cltest.FixtureCreateJobViaWeb(t, app, "../internal/fixtures/web/caseinsensitive_hello_world_job.json")
adapter1, _ := adapters.For(j.Tasks[0], app.Store)
httpGet := adapter1.BaseAdapter.(*adapters.HTTPGet)
assert.Equal(t, httpGet.URL.String(), "https://bitstamp.net/api/ticker/")
adapter2, _ := adapters.For(j.Tasks[1], app.Store)
jsonParse := adapter2.BaseAdapter.(*adapters.JSONParse)
assert.Equal(t, []string(jsonParse.Path), []string{"last"})
assert.Equal(t, "ethbytes32", j.Tasks[2].Type.String())
adapter4, _ := adapters.For(j.Tasks[3], app.Store)
signTx := adapter4.BaseAdapter.(*adapters.EthTx)
assert.Equal(t, "0x356a04bCe728ba4c62A30294A55E6A8600a320B3", signTx.Address.String())
assert.Equal(t, "0x609ff1bd", signTx.FunctionSelector.String())
assert.Equal(t, models.InitiatorWeb, j.Initiators[0].Type)
assert.Equal(t, models.InitiatorRunAt, j.Initiators[1].Type)
} | explode_data.jsonl/53687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 416
} | [
2830,
3393,
12245,
8327,
82,
2051,
34325,
920,
519,
75293,
4173,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
28236,
11,
21290,
1669,
1185,
1944,
7121,
4988,
741,
16867,
21290,
2822,
12428,
1669,
1185,
1944,
991,
12735,
4021,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNew(t *testing.T) {
as := assert.New(t)
defer os.Remove("./test.data")
c := NewDB("./test.data")
t.Run("not found", func(t *testing.T) {
v, err := c.Get("k")
as.Equal(nil, err)
t.Log(v)
as.Empty(v)
})
t.Run("exist set ttl get", func(t *testing.T) {
as.Nil(c.Set("k", "v", 1*time.Second))
v, err := c.Get("k")
as.Nil(err)
t.Log(v)
as.Equal("v", v)
})
t.Run("expired", func(t *testing.T) {
as.Nil(c.Set("k", "vf", 1*time.Second))
time.Sleep(1 * time.Second)
v, err := c.Get("k")
as.Equal(nil, err)
t.Log(v)
as.Empty(v)
})
t.Run("ttl", func(t *testing.T) {
as.Nil(c.Set("k", "v", 1*time.Second))
ttl, err := c.TTL("k")
as.Nil(err)
t.Log(ttl)
as.True(ttl <= 1*time.Second && ttl >= 1*time.Second-100*time.Millisecond, ttl)
})
t.Run("expire", func(t *testing.T) {
as.Nil(c.Set("k", "v", 1*time.Second))
ttl, err := c.TTL("k")
as.Nil(err)
t.Log(ttl)
as.True(ttl <= 1*time.Second && ttl >= 1*time.Second-100*time.Millisecond)
as.Nil(c.Expire("k", 1*time.Minute))
ttl, err = c.TTL("k")
as.Nil(err)
t.Log(ttl)
as.True(ttl <= 1*time.Minute && ttl >= 1*time.Minute-100*time.Millisecond)
})
t.Run("range", func(t *testing.T) {
os.Remove("./test")
c = NewDB("./test")
for i := 0; i < 10; i++ {
j := strconv.Itoa(i)
as.Nil(c.Set(j, j, 1*time.Minute), i)
}
kvs, err := c.Range()
as.Nil(err)
for _, v := range kvs {
t.Log(v)
as.Equal(v.Key, v.Val)
}
as.Len(kvs, 10)
})
} | explode_data.jsonl/55219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 804
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
60451,
1669,
2060,
7121,
1155,
340,
16867,
2643,
13270,
13988,
1944,
2196,
5130,
1444,
1669,
1532,
3506,
13988,
1944,
2196,
5130,
3244,
16708,
445,
1921,
1730,
497,
2915,
1155,
353,
8840,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue4191_InfiniteGetTimeout(t *testing.T) {
if runtime.GOOS == "plan9" {
t.Skip("skipping test; see https://golang.org/issue/7237")
}
defer afterTest(t)
const debug = false
mux := NewServeMux()
mux.HandleFunc("/get", func(w ResponseWriter, r *Request) {
io.Copy(w, neverEnding('a'))
})
ts := httptest.NewServer(mux)
timeout := 100 * time.Millisecond
client := &Client{
Transport: &Transport{
Dial: func(n, addr string) (net.Conn, error) {
conn, err := net.Dial(n, addr)
if err != nil {
return nil, err
}
conn.SetDeadline(time.Now().Add(timeout))
if debug {
conn = NewLoggingConn("client", conn)
}
return conn, nil
},
DisableKeepAlives: true,
},
}
getFailed := false
nRuns := 5
if testing.Short() {
nRuns = 1
}
for i := 0; i < nRuns; i++ {
if debug {
println("run", i+1, "of", nRuns)
}
sres, err := client.Get(ts.URL + "/get")
if err != nil {
if !getFailed {
// Make the timeout longer, once.
getFailed = true
t.Logf("increasing timeout")
i--
timeout *= 10
continue
}
t.Errorf("Error issuing GET: %v", err)
break
}
_, err = io.Copy(ioutil.Discard, sres.Body)
if err == nil {
t.Errorf("Unexpected successful copy")
break
}
}
if debug {
println("tests complete; waiting for handlers to finish")
}
ts.Close()
} | explode_data.jsonl/4897 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 607
} | [
2830,
3393,
42006,
19,
16,
24,
16,
25972,
25722,
1949,
7636,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
10393,
24,
1,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
26,
1490,
3703,
1110,
70,
37287,
2659,
14,
111... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsRangeSet(t *testing.T) {
b := New(80)
if b.IsRangeSet(0, b.Len()) {
t.Errorf("IsRangeSet failed, should not have found range #0-#%d", b.Len())
}
b.SetRange(40, 55)
if !b.IsRangeSet(40, 55) {
t.Error("IsRangeSet failed, should have found range #40-#55")
}
if b.IsRangeSet(40, 56) {
t.Error("IsRangeSet failed, should not have found range #40-#56")
}
if b.IsRangeSet(0, b.Len()) {
t.Errorf("IsRangeSet failed, should not have found range #0-#%d", b.Len())
}
} | explode_data.jsonl/73896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
3872,
6046,
1649,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
1532,
7,
23,
15,
692,
743,
293,
4506,
6046,
1649,
7,
15,
11,
293,
65819,
2140,
341,
197,
3244,
13080,
445,
3872,
6046,
1649,
4641,
11,
1265,
537,
614,
1730,
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 TestWithParamAsJsonList(t *testing.T) {
cancel, controller := newController()
defer cancel()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
// Test list expansion
ctx := context.Background()
wf := unmarshalWF(withParamAsJsonList)
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
pods, err := listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 4, len(pods.Items))
} | explode_data.jsonl/70992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
2354,
2001,
2121,
5014,
852,
1155,
353,
8840,
836,
8,
341,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
741,
6692,
8316,
746,
1669,
6461,
1418,
69,
2972,
746,
18979,
45926,
73,
53,
16,
7141,
16,
1005,
6776,
38140,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTemplate(t *testing.T) {
expectedResult := asMap(t, `{
"address_space": ["10.0.1.0/24"],
"dns_servers": ["8.8.8.8"]
}`)
expectedSubnet0 := asMap(t, `{
"name": "Web-Tier",
"address_prefixes": [
"10.0.1.0/26"
]
}`)
expectedSubnet1 := asMap(t, `{
"address_prefixes": [
"10.0.1.64/26"
]
}`)
expectedSubnet2 := asMap(t, `{
"address_prefixes": [
"10.0.1.128/26"
]
}`)
expectedSubnet3 := asMap(t, `{
"address_prefixes": [
"10.0.1.192/27"
]
}`)
expectedSubnet4 := asMap(t, `{
"name": "GatewaySubnet",
"address_prefixes": [
"10.0.1.224/28"
]
}`)
testFixture := infratests.UnitTestFixture{
GoTest: t,
TfOptions: tfOptions,
Workspace: name + random.UniqueId(),
PlanAssertions: nil,
ExpectedResourceCount: count,
ExpectedResourceAttributeValues: infratests.ResourceDescription{
"module.network.azurerm_virtual_network.main": expectedResult,
"module.network.azurerm_subnet.main[0]": expectedSubnet0,
"module.network.azurerm_subnet.main[1]": expectedSubnet1,
"module.network.azurerm_subnet.main[2]": expectedSubnet2,
"module.network.azurerm_subnet.main[3]": expectedSubnet3,
"module.network.azurerm_subnet.main[4]": expectedSubnet4,
},
}
infratests.RunUnitTests(&testFixture)
} | explode_data.jsonl/42639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 664
} | [
2830,
3393,
7275,
1155,
353,
8840,
836,
8,
1476,
42400,
2077,
1669,
438,
2227,
1155,
11,
1565,
515,
197,
197,
1,
4995,
14663,
788,
4383,
16,
15,
13,
15,
13,
16,
13,
15,
14,
17,
19,
8097,
197,
197,
44917,
4412,
67507,
788,
4383,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInjectorExtractorOptions(t *testing.T) {
tracer, tc := NewTracer("x", NewConstSampler(true), NewNullReporter(),
TracerOptions.Injector("dummy", &dummyPropagator{}),
TracerOptions.Extractor("dummy", &dummyPropagator{}),
)
defer tc.Close()
sp := tracer.StartSpan("x")
c := &dummyCarrier{}
err := tracer.Inject(sp.Context(), "dummy", []int{})
assert.Equal(t, opentracing.ErrInvalidCarrier, err)
err = tracer.Inject(sp.Context(), "dummy", c)
assert.NoError(t, err)
assert.True(t, c.ok)
c.ok = false
_, err = tracer.Extract("dummy", []int{})
assert.Equal(t, opentracing.ErrInvalidCarrier, err)
_, err = tracer.Extract("dummy", c)
assert.Equal(t, opentracing.ErrSpanContextNotFound, err)
c.ok = true
_, err = tracer.Extract("dummy", c)
assert.NoError(t, err)
} | explode_data.jsonl/44650 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 334
} | [
2830,
3393,
61836,
56118,
3798,
1155,
353,
8840,
836,
8,
341,
25583,
9584,
11,
17130,
1669,
1532,
1282,
9584,
445,
87,
497,
1532,
19167,
66048,
3715,
701,
1532,
3280,
52766,
3148,
197,
197,
1282,
9584,
3798,
41046,
269,
445,
31390,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_LoadInstallationFiles(t *testing.T) {
localInstallation := Installation{
Options: &Options{
IsLocal: true,
fromLocalSources: false,
configVersion: "master-6dba1d2c",
bucket: developmentBucket,
},
}
m, err := localInstallation.loadInstallationFiles()
require.NoError(t, err)
require.Equal(t, 3, len(m))
clusterInstallation := Installation{
Options: &Options{
IsLocal: false,
fromLocalSources: false,
configVersion: "master-6dba1d2c",
bucket: developmentBucket,
},
}
m, err = clusterInstallation.loadInstallationFiles()
require.NoError(t, err)
require.Equal(t, 2, len(m))
f, err := loadStringContent(m)
require.NoError(t, err)
require.Equal(t, 2, len(f))
} | explode_data.jsonl/64707 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
19553,
55453,
10809,
1155,
353,
8840,
836,
8,
341,
8854,
55453,
1669,
39145,
515,
197,
197,
3798,
25,
609,
3798,
515,
298,
197,
3872,
7319,
25,
688,
830,
345,
298,
42727,
7319,
32200,
25,
895,
345,
298,
25873,
5637,
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 TestClusterScope_DeleteVCN(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
vcnClient := mock_vcn.NewMockClient(mockCtrl)
tags := make(map[string]string)
tags["CreatedBy"] = "OCIClusterAPIProvider"
tags["ClusterUUID"] = "a"
vcnClient.EXPECT().GetVcn(gomock.Any(), gomock.Eq(core.GetVcnRequest{
VcnId: common.String("normal_id"),
})).
Return(core.GetVcnResponse{
Vcn: core.Vcn{
Id: common.String("normal_id"),
FreeformTags: tags,
},
}, nil)
vcnClient.EXPECT().GetVcn(gomock.Any(), gomock.Eq(core.GetVcnRequest{
VcnId: common.String("error_delete_vcn"),
})).
Return(core.GetVcnResponse{
Vcn: core.Vcn{
Id: common.String("error_delete_vcn"),
FreeformTags: tags,
},
}, nil)
vcnClient.EXPECT().GetVcn(gomock.Any(), gomock.Eq(core.GetVcnRequest{VcnId: common.String("error")})).
Return(core.GetVcnResponse{}, errors.New("some error in GetVcn"))
vcnClient.EXPECT().GetVcn(gomock.Any(), gomock.Eq(core.GetVcnRequest{VcnId: common.String("vcn_deleted")})).
Return(core.GetVcnResponse{}, errors.New("not found"))
vcnClient.EXPECT().DeleteVcn(gomock.Any(), gomock.Eq(core.DeleteVcnRequest{
VcnId: common.String("normal_id"),
})).
Return(core.DeleteVcnResponse{}, nil)
vcnClient.EXPECT().DeleteVcn(gomock.Any(), gomock.Eq(core.DeleteVcnRequest{
VcnId: common.String("error_delete_vcn"),
})).
Return(core.DeleteVcnResponse{}, errors.New("some error in DeleteVcn"))
tests := []struct {
name string
spec infrastructurev1beta1.OCIClusterSpec
wantErr bool
expectedError string
}{
{
name: "delete vcn is successful",
spec: infrastructurev1beta1.OCIClusterSpec{
NetworkSpec: infrastructurev1beta1.NetworkSpec{
Vcn: infrastructurev1beta1.VCN{
ID: common.String("normal_id"),
},
},
},
wantErr: false,
},
{
name: "vcn already deleted",
spec: infrastructurev1beta1.OCIClusterSpec{
NetworkSpec: infrastructurev1beta1.NetworkSpec{
Vcn: infrastructurev1beta1.VCN{
ID: common.String("vcn_deleted"),
},
},
},
wantErr: false,
},
{
name: "delete vcn error when calling get vcn",
spec: infrastructurev1beta1.OCIClusterSpec{
NetworkSpec: infrastructurev1beta1.NetworkSpec{
Vcn: infrastructurev1beta1.VCN{
ID: common.String("error"),
},
},
},
wantErr: true,
expectedError: "some error in GetVcn",
},
{
name: "delete vcn error when calling delete vcn",
spec: infrastructurev1beta1.OCIClusterSpec{
NetworkSpec: infrastructurev1beta1.NetworkSpec{
Vcn: infrastructurev1beta1.VCN{
ID: common.String("error_delete_vcn"),
},
},
},
wantErr: true,
expectedError: "failed to delete vcn: some error in DeleteVcn",
},
}
l := log.FromContext(context.Background())
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ociCluster := infrastructurev1beta1.OCICluster{
ObjectMeta: metav1.ObjectMeta{
UID: "a",
},
Spec: tt.spec,
}
s := &ClusterScope{
VCNClient: vcnClient,
OCICluster: &ociCluster,
Cluster: &clusterv1.Cluster{
ObjectMeta: metav1.ObjectMeta{
UID: "a",
},
},
Logger: &l,
}
err := s.DeleteVCN(context.Background())
if (err != nil) != tt.wantErr {
t.Errorf("DeleteVCN() error = %v, wantErr %v", err, tt.wantErr)
}
if err != nil {
if err.Error() != tt.expectedError {
t.Errorf("DeleteVCN() expected error = %s, actual error %s", tt.expectedError, err.Error())
}
}
})
}
} | explode_data.jsonl/52631 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1609
} | [
2830,
3393,
28678,
10803,
57418,
11287,
45,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
741,
5195,
14271,
2959,
1669,
7860,
2273,
14271,
7121,
11571,
2959,
30389... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestState_UpdateRplBanlist(t *testing.T) {
t.Parallel()
st := setupNewState()
ev := &irc.Event{
Name: irc.RPL_BANLIST,
Sender: network,
Args: []string{st.selfUser.Nick(), channels[0],
nicks[0] + "!*@*", nicks[1], "1367197165",
},
}
st.addChannel(channels[0])
ch, _ := st.Channel(channels[0])
if got, exp := ch.HasBan(nicks[0]+"!*@*"), false; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
st.Update(ev)
ch, _ = st.Channel(channels[0])
if got, exp := ch.HasBan(nicks[0]+"!*@*"), true; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
} | explode_data.jsonl/32113 | {
"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,
1397,
47393,
49,
500,
50241,
1607,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18388,
1669,
6505,
3564,
1397,
2822,
74837,
1669,
609,
2437,
6904,
515,
197,
21297,
25,
256,
79923,
2013,
2916,
1668,
1093,
22852,
345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCid(t *testing.T) {
data := []byte("yet another data")
block := NewBlock(data)
c := block.Cid()
if !bytes.Equal(block.Multihash(), c.Hash()) {
t.Error("key contains wrong data")
}
} | explode_data.jsonl/74316 | {
"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,
34,
307,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
445,
46392,
2441,
821,
1138,
47996,
1669,
1532,
4713,
2592,
340,
1444,
1669,
2504,
727,
307,
2822,
743,
753,
9651,
12808,
18682,
53515,
6996,
988,
1507,
272,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateFilterSortCategoriesss(t *testing.T) {
type args struct {
category FilterSortCategoryType
filter FilterSortDataType
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "valid type",
args: args{
category: FilterSortCategoryTypeFacility,
filter: FilterSortDataTypeName,
},
wantErr: false,
},
{
name: "invalid category type",
args: args{
category: FilterSortCategoryType("invalid"),
filter: FilterSortDataTypeName,
},
wantErr: true,
},
{
name: "invalid filter sorts type",
args: args{
category: FilterSortCategoryTypeFacility,
filter: FilterSortDataType("invalid"),
},
wantErr: true,
},
{
name: "invalid filter not in category",
args: args{
category: FilterSortCategoryTypeFacility,
filter: FilterSortDataTypeCreatedAt,
},
wantErr: true,
},
{
name: "empty params passed",
args: args{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := ValidateFilterSortCategories(tt.args.category, tt.args.filter); (err != nil) != tt.wantErr {
t.Errorf("ValidateFilterSortCategories() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/58359 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 541
} | [
2830,
3393,
17926,
5632,
10231,
34,
31234,
433,
82,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
75370,
12339,
10231,
6746,
929,
198,
197,
50108,
256,
12339,
10231,
22653,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTestTLSExtensionsVerifyServer(t *testing.T) {
extendVerify := map[string]interface{}{
"name": "client",
"cn": "server",
}
clientInfo := &certInfo{
CommonName: extendVerify["name"].(string),
Curve: "RSA",
}
testCases := []struct {
Info *certInfo
Pass func(resp *http.Response, err error) bool
}{
{
Info: &certInfo{
CommonName: extendVerify["cn"].(string),
Curve: clientInfo.Curve,
DNS: "www.pass.com",
},
Pass: pass,
},
{
Info: &certInfo{
CommonName: "invalid server",
Curve: clientInfo.Curve,
DNS: "www.fail.com",
},
Pass: fail,
},
}
var filterChains []v2.FilterChain
for i, tc := range testCases {
cfg, err := tc.Info.CreateCertConfig()
if err != nil {
t.Errorf("#%d %v", i, err)
return
}
fc := v2.FilterChain{
TLS: *cfg,
}
filterChains = append(filterChains, fc)
}
lc := &v2.Listener{}
lc.FilterChains = filterChains
ctxMng, err := NewTLSServerContextManager(lc, nil, log.StartLogger)
if err != nil {
t.Errorf("create context manager failed %v", err)
return
}
server := MockServer{
Mng: ctxMng,
t: t,
}
server.GoListenAndServe(t)
defer server.Close()
time.Sleep(time.Second) //wait server start
clientConfig, err := clientInfo.CreateCertConfig()
if err != nil {
t.Errorf("create client certificate error %v", err)
return
}
clientConfig.Type = testType
clientConfig.ExtendVerify = extendVerify
for i, tc := range testCases {
clientConfig.ServerName = tc.Info.DNS
cltMng, err := NewTLSClientContextManager(clientConfig, nil)
if err != nil {
t.Errorf("create client context manager failed %v", err)
return
}
resp, err := MockClient(t, server.Addr, cltMng)
if !tc.Pass(resp, err) {
t.Errorf("#%d verify failed", i)
}
}
// insecure skip will skip even if it is registered
skipConfig := &v2.TLSConfig{
Status: true,
Type: clientConfig.Type,
CACert: clientConfig.CACert,
CertChain: clientConfig.CertChain,
PrivateKey: clientConfig.PrivateKey,
InsecureSkip: true,
}
for i, tc := range testCases {
skipConfig.ServerName = tc.Info.DNS
skipMng, err := NewTLSClientContextManager(skipConfig, nil)
if err != nil {
t.Errorf("create client context manager failed %v", err)
return
}
resp, err := MockClient(t, server.Addr, skipMng)
// ignore the case, must be pass
if !pass(resp, err) {
t.Errorf("#%d skip verify failed", i)
}
}
} | explode_data.jsonl/1524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1056
} | [
2830,
3393,
2271,
45439,
31282,
32627,
5475,
1155,
353,
8840,
836,
8,
341,
197,
25048,
32627,
1669,
2415,
14032,
31344,
67066,
197,
197,
31486,
788,
330,
2972,
756,
197,
197,
1,
14271,
788,
256,
330,
4030,
756,
197,
532,
25291,
1731,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestConfigIsValidDefaultAlgorithms(t *testing.T) {
c1 := Config{}
c1.SetDefaults()
*c1.SamlSettings.Enable = true
*c1.SamlSettings.Verify = false
*c1.SamlSettings.Encrypt = false
*c1.SamlSettings.IdpUrl = "http://test.url.com"
*c1.SamlSettings.IdpDescriptorUrl = "http://test.url.com"
*c1.SamlSettings.IdpCertificateFile = "certificatefile"
*c1.SamlSettings.EmailAttribute = "Email"
*c1.SamlSettings.UsernameAttribute = "Username"
err := c1.SamlSettings.isValid()
if err != nil {
t.Fatal("SAMLSettings validation should pass with default settings")
}
} | explode_data.jsonl/50673 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
2648,
55470,
3675,
2101,
18980,
1155,
353,
8840,
836,
8,
341,
1444,
16,
1669,
5532,
16094,
1444,
16,
4202,
16273,
2822,
197,
39091,
16,
808,
9467,
6086,
32287,
284,
830,
198,
197,
39091,
16,
808,
9467,
6086,
54853,
284,
89... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckDurations(t *testing.T) {
cases := map[checkCase]checkCase{
checkCase{100, 300000, 500, 300000}: {100, 300000, 500, 300000},
checkCase{0, 300000, 500, 300000}: {100, 300000, 500, 300000},
checkCase{100, 300000, 0, 300000}: {100, 300000, 500, 300000},
checkCase{300000, 300000, 500, 300000}: {100, 300000, 500, 300000},
checkCase{100, 300000, 300000, 300000}: {100, 300000, 500, 300000},
}
var cnf Config
for tCase, eCase := range cases {
cnf = Config{
BuilderPodTickDurationMSec: tCase.podTick,
BuilderPodWaitDurationMSec: tCase.podWait,
ObjectStorageTickDurationMSec: tCase.storageTick,
ObjectStorageWaitDurationMSec: tCase.storageWait,
}
cnf.CheckDurations()
if cnf.BuilderPodTickDurationMSec != eCase.podTick {
t.Fatalf("expected %v but %v was returned (%v)", eCase.podTick, cnf.BuilderPodTickDurationMSec, tCase)
}
if cnf.BuilderPodWaitDurationMSec != eCase.podWait {
t.Fatalf("expected %v but %v was returned (%v)", eCase.podWait, cnf.BuilderPodWaitDurationMSec, tCase)
}
if cnf.ObjectStorageTickDurationMSec != eCase.storageTick {
t.Fatalf("expected %v but %v was returned (%v)", eCase.storageTick, cnf.ObjectStorageTickDurationMSec, tCase)
}
if cnf.ObjectStorageWaitDurationMSec != eCase.storageWait {
t.Fatalf("expected %v but %v was returned (%v)", eCase.storageWait, cnf.ObjectStorageWaitDurationMSec, tCase)
}
}
} | explode_data.jsonl/29371 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 570
} | [
2830,
3393,
3973,
35,
21449,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
58,
2028,
4207,
60,
2028,
4207,
515,
197,
25157,
4207,
90,
16,
15,
15,
11,
220,
18,
15,
15,
15,
15,
15,
11,
220,
20,
15,
15,
11,
220,
18,
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... | 6 |
func TestRepo(t *testing.T) {
kiteco := localpath.Absolute(filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "kiteco", "kiteco"))
s, err := NewStorage(StorageOptions{})
require.NoError(t, err)
var noCache []Commit
for i := 0; i < 3; i++ {
repo, err := Open(kiteco, DefaultComputedCommitsLimit, s)
require.NoError(t, err)
var batch []Commit
for j := 0; j < 10; j++ {
commit, err := repo.Next(kitectx.Background())
require.NoError(t, err)
batch = append(batch, commit)
if i == 0 {
noCache = append(noCache, commit)
continue
}
require.Equal(t, noCache[j], commit)
}
err = repo.Save(s)
require.NoError(t, err)
}
} | explode_data.jsonl/57213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
25243,
1155,
353,
8840,
836,
8,
341,
16463,
632,
1015,
1669,
2205,
2343,
38604,
34793,
22363,
9638,
64883,
445,
98733,
4827,
3975,
330,
3548,
497,
330,
5204,
905,
497,
330,
74,
632,
1015,
497,
330,
74,
632,
1015,
5455,
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... | 4 |
func TestConcurrentIngest(t *testing.T) {
mem := vfs.NewMem()
d, err := Open("", &Options{
FS: mem,
})
require.NoError(t, err)
// Create an sstable with 2 keys. This is necessary to trigger the overlap
// bug because an sstable with a single key will not have overlap in internal
// key space and the sequence number assignment had already guaranteed
// correct ordering.
src := func(i int) string {
return fmt.Sprintf("ext%d", i)
}
f, err := mem.Create(src(0))
require.NoError(t, err)
w := sstable.NewWriter(f, sstable.WriterOptions{})
require.NoError(t, w.Set([]byte("a"), nil))
require.NoError(t, w.Set([]byte("b"), nil))
require.NoError(t, w.Close())
// Make N copies of the sstable.
errCh := make(chan error, 5)
for i := 1; i < cap(errCh); i++ {
require.NoError(t, vfs.Copy(d.opts.FS, src(0), src(i)))
}
// Perform N ingestions concurrently.
for i := 0; i < cap(errCh); i++ {
go func(i int) {
err := d.Ingest([]string{src(i)})
if err == nil {
if _, err = d.opts.FS.Stat(src(i)); os.IsNotExist(err) {
err = nil
}
}
errCh <- err
}(i)
}
for i := 0; i < cap(errCh); i++ {
require.NoError(t, <-errCh)
}
require.NoError(t, d.Close())
} | explode_data.jsonl/40263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
1109,
3231,
641,
6969,
1155,
353,
8840,
836,
8,
341,
14145,
1669,
92941,
7121,
18816,
741,
2698,
11,
1848,
1669,
5264,
19814,
609,
3798,
515,
197,
197,
8485,
25,
1833,
345,
197,
3518,
17957,
35699,
1155,
11,
1848,
692,
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 TestTxNotifierFutureSpendDispatch(t *testing.T) {
t.Parallel()
hintCache := newMockHintCache()
n := chainntnfs.NewTxNotifier(
10, chainntnfs.ReorgSafetyLimit, hintCache, hintCache,
)
// We'll start off by registering for a spend notification of an
// outpoint.
op := wire.OutPoint{Index: 1}
ntfn, err := n.RegisterSpend(&op, testRawScript, 1)
if err != nil {
t.Fatalf("unable to register spend ntfn: %v", err)
}
// We should not receive a notification as the outpoint has not been
// spent yet.
select {
case <-ntfn.Event.Spend:
t.Fatal("received unexpected spend notification")
default:
}
// Construct the details of the spending transaction of the outpoint
// above. We'll include it in the next block, which should trigger a
// spend notification.
spendTx := wire.NewMsgTx(2)
spendTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: op,
SignatureScript: testSigScript,
})
spendTxHash := spendTx.TxHash()
block := btcutil.NewBlock(&wire.MsgBlock{
Transactions: []*wire.MsgTx{spendTx},
})
err = n.ConnectTip(block.Hash(), 11, block.Transactions())
if err != nil {
t.Fatalf("unable to connect block: %v", err)
}
if err := n.NotifyHeight(11); err != nil {
t.Fatalf("unable to dispatch notifications: %v", err)
}
expectedSpendDetails := &chainntnfs.SpendDetail{
SpentOutPoint: &op,
SpenderTxHash: &spendTxHash,
SpendingTx: spendTx,
SpenderInputIndex: 0,
SpendingHeight: 11,
}
// Ensure that the details of the notification match as expected.
select {
case spendDetails := <-ntfn.Event.Spend:
assertSpendDetails(t, spendDetails, expectedSpendDetails)
default:
t.Fatal("expected to receive spend details")
}
// Finally, we'll ensure that if the spending transaction has also been
// spent, then we don't receive another spend notification.
prevOut := wire.OutPoint{Hash: spendTxHash, Index: 0}
spendOfSpend := wire.NewMsgTx(2)
spendOfSpend.AddTxIn(&wire.TxIn{
PreviousOutPoint: prevOut,
SignatureScript: testSigScript,
})
block = btcutil.NewBlock(&wire.MsgBlock{
Transactions: []*wire.MsgTx{spendOfSpend},
})
err = n.ConnectTip(block.Hash(), 12, block.Transactions())
if err != nil {
t.Fatalf("unable to connect block: %v", err)
}
if err := n.NotifyHeight(12); err != nil {
t.Fatalf("unable to dispatch notifications: %v", err)
}
select {
case <-ntfn.Event.Spend:
t.Fatal("received unexpected spend notification")
default:
}
} | explode_data.jsonl/67714 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 889
} | [
2830,
3393,
31584,
64729,
24206,
50,
3740,
11283,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
9598,
396,
8233,
1669,
501,
11571,
26987,
8233,
741,
9038,
1669,
8781,
406,
77,
3848,
7121,
31584,
64729,
1006,
197,
197,
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... | 9 |
func TestBind(t *testing.T) {
e, err := swagx.Endpoints("/api/", &Foo{}, time.Second)
assert.Nil(t, err)
assert.Len(t, e, 1)
assert.Equal(t, "/api/Public", e[0].Path)
} | explode_data.jsonl/66341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
9950,
1155,
353,
8840,
836,
8,
341,
7727,
11,
1848,
1669,
2021,
351,
87,
18569,
7706,
4283,
2068,
28105,
609,
40923,
22655,
882,
32435,
340,
6948,
59678,
1155,
11,
1848,
340,
6948,
65819,
1155,
11,
384,
11,
220,
16,
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 |
func TestErrorDuringStartup(t *testing.T) {
// Don't use the normal connection setup, this is intended to
// blow up in the startup packet from a non-existent user.
db, err := openTestConnConninfo("user=thisuserreallydoesntexist")
if err != nil {
t.Fatal(err)
}
defer db.Close()
_, err = db.Begin()
if err == nil {
t.Fatal("expected error")
}
e, ok := err.(*Error)
if !ok {
t.Fatalf("expected Error, got %#v", err)
} else if e.Code.Name() != "invalid_authorization_specification" && e.Code.Name() != "invalid_password" {
t.Fatalf("expected invalid_authorization_specification or invalid_password, got %s (%+v)", e.Code.Name(), err)
}
} | explode_data.jsonl/73481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
1454,
16014,
39076,
1155,
353,
8840,
836,
8,
341,
197,
322,
4320,
944,
990,
279,
4622,
3633,
6505,
11,
419,
374,
10602,
311,
198,
197,
322,
12244,
705,
304,
279,
20567,
10151,
504,
264,
2477,
59828,
1196,
624,
20939,
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 TestValidateSource(t *testing.T) {
t.Run("empty", func(t *testing.T) {
source := ""
_, errors := ValidateSource(source, "")
assert.NotEqual(t, 0, len(errors))
})
t.Run("invalid", func(t *testing.T) {
source := "SAMJKTZVW5UOHCDK5INYJNORF2HRKYI72M5XSZCBYAHQHR34FFR4Z6G4"
_, errors := ValidateSource(source, "")
assert.NotEqual(t, 0, len(errors))
})
t.Run("valid", func(t *testing.T) {
source := "GBA4EX43M25UPV4WIE6RRMQOFTWXZZRIPFAI5VPY6Z2ZVVXVWZ6NEOOB"
_, errors := ValidateSource(source, "")
assert.Equal(t, 0, len(errors))
})
} | explode_data.jsonl/22687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
17926,
3608,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3194,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
47418,
1669,
8389,
197,
197,
6878,
5975,
1669,
23282,
3608,
12437,
11,
14676,
197,
6948,
15000,
2993,
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... | 1 |
func TestNewDoguRequeueHandler(t *testing.T) {
// given
reporter := &mocks.StatusReporter{}
fakeClient := fake.NewClientBuilder().WithScheme(&runtime.Scheme{}).Build()
// when
handler := NewDoguRequeueHandler(fakeClient, reporter)
// then
assert.NotNil(t, handler)
assert.Implements(t, (*RequeueHandler)(nil), handler)
} | explode_data.jsonl/65071 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
3564,
48940,
84,
693,
4584,
3050,
1155,
353,
8840,
836,
8,
341,
197,
322,
2661,
198,
69931,
261,
1669,
609,
16712,
82,
10538,
52766,
16094,
1166,
726,
2959,
1669,
12418,
7121,
2959,
3297,
1005,
2354,
28906,
2099,
22255,
9271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIndexedVirtualGeneratedColumnTruncate(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t(a int, b tinyint as(a+100) unique key)")
tk.MustExec("insert ignore into t values(200, default)")
tk.MustExec("update t set a=1 where a=200")
tk.MustExec("admin check table t")
tk.MustExec("delete from t")
tk.MustExec("insert ignore into t values(200, default)")
tk.MustExec("admin check table t")
tk.MustExec("insert ignore into t values(200, default) on duplicate key update a=100")
tk.MustExec("admin check table t")
tk.MustExec("delete from t")
tk.MustExec("admin check table t")
tk.MustExec("begin")
tk.MustExec("insert ignore into t values(200, default)")
tk.MustExec("update t set a=1 where a=200")
tk.MustExec("admin check table t")
tk.MustExec("delete from t")
tk.MustExec("insert ignore into t values(200, default)")
tk.MustExec("admin check table t")
tk.MustExec("insert ignore into t values(200, default) on duplicate key update a=100")
tk.MustExec("admin check table t")
tk.MustExec("delete from t")
tk.MustExec("admin check table t")
tk.MustExec("commit")
tk.MustExec("admin check table t")
} | explode_data.jsonl/65537 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 437
} | [
2830,
3393,
69941,
33026,
15741,
2933,
1282,
26900,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
324... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_PushMetrics(t *testing.T) {
invalidTypeBatch := testdata.GenerateMetricsMetricTypeInvalid()
// success cases
intSumBatch := testdata.GenerateMetricsManyMetricsSameResource(10)
sumBatch := getMetricsFromMetricList(validMetrics1[validSum], validMetrics2[validSum])
intGaugeBatch := getMetricsFromMetricList(validMetrics1[validIntGauge], validMetrics2[validIntGauge])
doubleGaugeBatch := getMetricsFromMetricList(validMetrics1[validDoubleGauge], validMetrics2[validDoubleGauge])
histogramBatch := getMetricsFromMetricList(validMetrics1[validHistogram], validMetrics2[validHistogram])
summaryBatch := getMetricsFromMetricList(validMetrics1[validSummary], validMetrics2[validSummary])
// len(BucketCount) > len(ExplicitBounds)
unmatchedBoundBucketHistBatch := getMetricsFromMetricList(validMetrics2[unmatchedBoundBucketHist])
// fail cases
emptyDoubleGaugeBatch := getMetricsFromMetricList(invalidMetrics[emptyGauge])
emptyCumulativeSumBatch := getMetricsFromMetricList(invalidMetrics[emptyCumulativeSum])
emptyCumulativeHistogramBatch := getMetricsFromMetricList(invalidMetrics[emptyCumulativeHistogram])
emptySummaryBatch := getMetricsFromMetricList(invalidMetrics[emptySummary])
checkFunc := func(t *testing.T, r *http.Request, expected int) {
body, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatal(err)
}
buf := make([]byte, len(body))
dest, err := snappy.Decode(buf, body)
assert.Equal(t, "0.1.0", r.Header.Get("x-prometheus-remote-write-version"))
assert.Equal(t, "snappy", r.Header.Get("content-encoding"))
assert.Equal(t, "opentelemetry-collector/1.0", r.Header.Get("User-Agent"))
assert.NotNil(t, r.Header.Get("tenant-id"))
require.NoError(t, err)
wr := &prompb.WriteRequest{}
ok := proto.Unmarshal(dest, wr)
require.Nil(t, ok)
assert.EqualValues(t, expected, len(wr.Timeseries))
}
tests := []struct {
name string
md *pdata.Metrics
reqTestFunc func(t *testing.T, r *http.Request, expected int)
expectedTimeSeries int
httpResponseCode int
returnErr bool
}{
{
"invalid_type_case",
&invalidTypeBatch,
nil,
0,
http.StatusAccepted,
true,
},
{
"intSum_case",
&intSumBatch,
checkFunc,
2,
http.StatusAccepted,
false,
},
{
"doubleSum_case",
&sumBatch,
checkFunc,
2,
http.StatusAccepted,
false,
},
{
"doubleGauge_case",
&doubleGaugeBatch,
checkFunc,
2,
http.StatusAccepted,
false,
},
{
"intGauge_case",
&intGaugeBatch,
checkFunc,
2,
http.StatusAccepted,
false,
},
{
"histogram_case",
&histogramBatch,
checkFunc,
12,
http.StatusAccepted,
false,
},
{
"summary_case",
&summaryBatch,
checkFunc,
10,
http.StatusAccepted,
false,
},
{
"unmatchedBoundBucketHist_case",
&unmatchedBoundBucketHistBatch,
checkFunc,
5,
http.StatusAccepted,
false,
},
{
"5xx_case",
&unmatchedBoundBucketHistBatch,
checkFunc,
5,
http.StatusServiceUnavailable,
true,
},
{
"emptyGauge_case",
&emptyDoubleGaugeBatch,
checkFunc,
0,
http.StatusAccepted,
true,
},
{
"emptyCumulativeSum_case",
&emptyCumulativeSumBatch,
checkFunc,
0,
http.StatusAccepted,
true,
},
{
"emptyCumulativeHistogram_case",
&emptyCumulativeHistogramBatch,
checkFunc,
0,
http.StatusAccepted,
true,
},
{
"emptySummary_case",
&emptySummaryBatch,
checkFunc,
0,
http.StatusAccepted,
true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if tt.reqTestFunc != nil {
tt.reqTestFunc(t, r, tt.expectedTimeSeries)
}
w.WriteHeader(tt.httpResponseCode)
}))
defer server.Close()
cfg := &Config{
ExporterSettings: config.NewExporterSettings(config.NewID(typeStr)),
Namespace: "",
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: server.URL,
// We almost read 0 bytes, so no need to tune ReadBufferSize.
ReadBufferSize: 0,
WriteBufferSize: 512 * 1024,
},
RemoteWriteQueue: RemoteWriteQueue{NumConsumers: 5},
}
assert.NotNil(t, cfg)
// c, err := config.HTTPClientSettings.ToClient()
// assert.Nil(t, err)
buildInfo := component.BuildInfo{
Description: "OpenTelemetry Collector",
Version: "1.0",
}
prwe, nErr := NewPRWExporter(cfg, buildInfo)
require.NoError(t, nErr)
require.NoError(t, prwe.Start(context.Background(), componenttest.NewNopHost()))
err := prwe.PushMetrics(context.Background(), *tt.md)
if tt.returnErr {
assert.Error(t, err)
return
}
assert.NoError(t, err)
})
}
} | explode_data.jsonl/78813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2136
} | [
2830,
3393,
1088,
1116,
27328,
1155,
353,
8840,
836,
8,
1476,
197,
11808,
929,
21074,
1669,
1273,
691,
57582,
27328,
54310,
929,
7928,
2822,
197,
322,
2393,
5048,
198,
2084,
9190,
21074,
1669,
1273,
691,
57582,
27328,
8441,
27328,
19198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerragruntGenerateBlockNestedOverwrite(t *testing.T) {
t.Parallel()
generateTestCase := filepath.Join(TEST_FIXTURE_CODEGEN_PATH, "generate-block", "nested", "child_overwrite")
cleanupTerraformFolder(t, generateTestCase)
cleanupTerragruntFolder(t, generateTestCase)
runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", generateTestCase))
// If the state file was written as bar.tfstate, that means it overwrite the parent config
assert.False(t, fileIsInFolder(t, "foo.tfstate", generateTestCase))
assert.True(t, fileIsInFolder(t, "bar.tfstate", generateTestCase))
// Also check to make sure the child config generate block was included
assert.True(t, fileIsInFolder(t, "random_file.txt", generateTestCase))
} | explode_data.jsonl/10163 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 270
} | [
2830,
3393,
51402,
68305,
3850,
31115,
4713,
71986,
1918,
4934,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3174,
13220,
16458,
1669,
26054,
22363,
50320,
42635,
41486,
10020,
11085,
7944,
11,
330,
19366,
9425,
497,
330,
59271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalUnmarshalNames(t *testing.T) {
v := Names{}
bts, err := v.MarshalMsg(nil)
if err != nil {
t.Fatal(err)
}
left, err := v.UnmarshalMsg(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
}
left, err = msgp.Skip(bts)
if err != nil {
t.Fatal(err)
}
if len(left) > 0 {
t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
}
} | explode_data.jsonl/4500 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
55438,
1806,
27121,
7980,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
34875,
16094,
2233,
2576,
11,
1848,
1669,
348,
37271,
6611,
27907,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
35257,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestReceivedInvalidSegmentCountIncrement(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(789, 30000, nil)
stats := c.Stack().Stats()
want := stats.TCP.InvalidSegmentsReceived.Value() + 1
vv := c.BuildSegment(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: seqnum.Value(790),
AckNum: c.IRS.Add(1),
RcvWnd: 30000,
})
tcpbuf := vv.First()[header.IPv4MinimumSize:]
tcpbuf[header.TCPDataOffset] = ((header.TCPMinimumSize - 1) / 4) << 4
c.SendSegment(vv)
if got := stats.TCP.InvalidSegmentsReceived.Value(); got != want {
t.Errorf("got stats.TCP.InvalidSegmentsReceived.Value() = %v, want = %v", got, want)
}
} | explode_data.jsonl/22318 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
23260,
7928,
21086,
2507,
38311,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
741,
1444,
7251,
21146,
7,
22,
23,
24,
11,
220,
18,
15,
15,
15,
15,
11,
2092... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetadataNotAvailable(t *testing.T) {
c := ec2metadata.New(unit.Session)
c.Handlers.Send.Clear()
c.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = &http.Response{
StatusCode: int(0),
Status: http.StatusText(int(0)),
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}
r.Error = awserr.New(request.ErrCodeRequestError, "send request failed", nil)
r.Retryable = aws.Bool(true) // network errors are retryable
})
if c.Available() {
t.Fatalf("expect not available")
}
} | explode_data.jsonl/17841 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
14610,
2623,
16485,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
11942,
17,
17637,
7121,
24144,
20674,
340,
1444,
35308,
9254,
20176,
13524,
741,
1444,
35308,
9254,
20176,
34981,
3707,
18552,
2601,
353,
2035,
9659,
8,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDockerConfig(t *testing.T) {
t.Run("good matchers; custom docker options", func(t *testing.T) {
expectFinder, err := cgroup.NewContainerIDFinder([]string{"/docker/<id>"})
require.NoError(t, err)
p := newTestPlugin(t, withConfig(t, `
docker_socket_path = "unix:///socket_path"
docker_version = "1.20"
container_id_cgroup_matchers = [
"/docker/<id>",
]
`))
require.NotNil(t, p.docker)
require.Equal(t, "unix:///socket_path", p.docker.(*dockerclient.Client).DaemonHost())
require.Equal(t, "1.20", p.docker.(*dockerclient.Client).ClientVersion())
require.Equal(t, expectFinder, p.containerIDFinder)
})
t.Run("good legacy config", func(t *testing.T) {
p := New()
cfg := &spi.ConfigureRequest{
Configuration: `
cgroup_prefix = "/docker2"
cgroup_container_index = 2
`,
}
_, err := doConfigure(t, p, cfg)
require.NoError(t, err)
require.Equal(t, &legacyContainerIDFinder{
log: p.log,
cgroupPrefix: "/docker2",
cgroupContainerIndex: 3,
}, p.containerIDFinder)
})
t.Run("bad matcher", func(t *testing.T) {
p := New()
cfg := &spi.ConfigureRequest{
Configuration: `
container_id_cgroup_matchers = [
"/docker/",
]`,
}
_, err := doConfigure(t, p, cfg)
require.Error(t, err)
require.Contains(t, err.Error(), `must contain the container id token "<id>" exactly once`)
})
t.Run("bad legacy config", func(t *testing.T) {
p := New()
cfg := &spi.ConfigureRequest{
Configuration: `
cgroup_prefix = "/docker2"
`,
}
_, err := doConfigure(t, p, cfg)
require.Error(t, err)
require.Contains(t, err.Error(), "cgroup_prefix and cgroup_container_index must be specified together")
})
t.Run("bad hcl", func(t *testing.T) {
p := New()
cfg := &spi.ConfigureRequest{
Configuration: `
container_id_cgroup_matchers = [
"/docker/"`,
}
_, err := doConfigure(t, p, cfg)
require.Error(t, err)
require.Contains(t, err.Error(), "error parsing list, expected comma or list end")
})
} | explode_data.jsonl/28001 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 824
} | [
2830,
3393,
35,
13659,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
18536,
2432,
388,
26,
2526,
26588,
2606,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
24952,
42300,
11,
1848,
1669,
272,
4074,
7121,
4502,
915,
42300,
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 TestUnauthorizedOAuth(t *testing.T) {
defer seq()()
setDefaultConfig()
testServer := mocked.RunMockTestService()
ipdServer := mocked.RunMockOAuthIDP()
server := server.Run(t)
defer server.Shutdown(context.TODO())
defer ipdServer.Shutdown(context.TODO())
defer testServer.Shutdown(context.TODO())
requestAndTest(t, &testDefinition{
Method: "GET",
URL: "http://localhost:3000/",
StatusCode: http.StatusTemporaryRedirect,
})
} | explode_data.jsonl/23185 | {
"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,
51181,
57850,
1155,
353,
8840,
836,
8,
341,
16867,
12981,
368,
2822,
8196,
3675,
2648,
2822,
18185,
5475,
1669,
46149,
16708,
11571,
2271,
1860,
741,
46531,
67,
5475,
1669,
46149,
16708,
11571,
57850,
915,
47,
741,
41057,
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 TestClone_NoneExisting(t *testing.T) {
// Initialize the git repo.
repoDir, cleanup := initRepo(t)
defer cleanup()
expCommit := runCmd(t, repoDir, "git", "rev-parse", "HEAD")
dataDir, cleanup2 := TempDir(t)
defer cleanup2()
wd := &events.FileWorkspace{
DataDir: dataDir,
CheckoutMerge: false,
TestingOverrideHeadCloneURL: fmt.Sprintf("file://%s", repoDir),
}
cloneDir, err := wd.Clone(nil, models.Repo{}, models.Repo{}, models.PullRequest{
HeadBranch: "branch",
}, "default")
Ok(t, err)
// Use rev-parse to verify at correct commit.
actCommit := runCmd(t, cloneDir, "git", "rev-parse", "HEAD")
Equals(t, expCommit, actCommit)
} | explode_data.jsonl/17056 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
37677,
52523,
53067,
1155,
353,
8840,
836,
8,
341,
197,
322,
9008,
279,
16345,
15867,
624,
17200,
5368,
6184,
11,
21290,
1669,
2930,
25243,
1155,
340,
16867,
21290,
741,
48558,
33441,
1669,
1598,
15613,
1155,
11,
15867,
6184,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMultiConf(t *testing.T) {
module := "LoggerConfig"
funcname := "MultiConf()"
_ = module
_ = funcname
type test struct {
name string
conf LoggerConfig
want *LoggerBuilder
}
tests := []test{
{
name: "default MultiConf()",
conf: MultiConf(),
want: &LoggerBuilder{
Out: os.Stderr,
Prefix: "log",
Sub: "",
Fmt: TextColorLevelFirst,
SkipExit: false,
LevelFilter: 0,
},
},
{
name: "MultiConf() w/ SkipExit, JSON format, and StdOut config",
conf: MultiConf(SkipExit, WithFormat(FormatJSON), StdOut),
want: &LoggerBuilder{
Out: os.Stderr,
Prefix: "",
Sub: "",
Fmt: FormatJSON,
SkipExit: true,
LevelFilter: 0,
},
},
{
name: "MultiConf() w/ SkipExit, Level filter, and custom prefix",
conf: MultiConf(SkipExit, FilterInfo, WithPrefix("test")),
want: &LoggerBuilder{
Out: nil,
Prefix: "test",
Sub: "",
Fmt: nil,
SkipExit: true,
LevelFilter: 2,
},
},
}
var init = func(test test) *LoggerBuilder {
builder := &LoggerBuilder{}
MultiConf(test.conf).Apply(builder)
return builder
}
var verify = func(idx int, test test) {
builder := init(test)
if !reflect.DeepEqual(*builder, *test.want) {
t.Errorf(
"#%v -- FAILED -- [%s] [%s] -- output mismatch error: wanted %v ; got %v -- action: %s",
idx,
module,
funcname,
*test.want,
*builder,
test.name,
)
return
}
t.Logf(
"#%v -- PASSED -- [%s] [%s] -- action: %s",
idx,
module,
funcname,
test.name,
)
}
for idx, test := range tests {
verify(idx, test)
}
} | explode_data.jsonl/2589 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 849
} | [
2830,
3393,
20358,
15578,
1155,
353,
8840,
836,
8,
341,
54020,
1669,
330,
7395,
2648,
698,
29244,
606,
1669,
330,
20358,
15578,
368,
1837,
197,
62,
284,
4688,
198,
197,
62,
284,
2915,
606,
271,
13158,
1273,
2036,
341,
197,
11609,
914,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOpsGenieDeprecatedTeamSpecified(t *testing.T) {
_, err := LoadFile("testdata/conf.opsgenie-default-apikey-old-team.yml")
if err == nil {
t.Fatalf("Expected an error parsing %s: %s", "testdata/conf.opsgenie-default-apikey-old-team.yml", err)
}
const expectedErr = `yaml: unmarshal errors:
line 18: field teams not found in type config.plain`
if err.Error() != expectedErr {
t.Errorf("Expected: %s\nGot: %s", expectedErr, err.Error())
}
} | explode_data.jsonl/72925 | {
"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,
38904,
9967,
645,
51344,
14597,
8327,
1870,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
8893,
1703,
445,
92425,
59241,
12029,
1991,
61558,
13672,
23904,
792,
6284,
42842,
33936,
1138,
743,
1848,
621,
2092,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetFileContentTypePickle(t *testing.T) {
file := `../testdata/files/test6.pkl`
fileType, err := GetFileContentType(file)
if err != nil {
t.Log("Error -> ", err)
t.Fail()
}
if fileType != "application/pickle" {
t.Log(fileType)
t.Fail()
}
} | explode_data.jsonl/24011 | {
"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,
1949,
1703,
29504,
47,
25606,
1155,
353,
8840,
836,
8,
341,
17661,
1669,
1565,
1244,
92425,
33220,
12697,
21,
49478,
3989,
17661,
929,
11,
1848,
1669,
2126,
1703,
29504,
4866,
692,
743,
1848,
961,
2092,
341,
197,
3244,
5247,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAlreadySetUp(t *testing.T) {
testcases := []struct {
flow string
success bool
}{
{
// Good note
flow: fmt.Sprintf("cookie=0x0, duration=4.796s, table=253, n_packets=0, n_bytes=0, actions=note:00.%02x.00.00.00.00", ruleVersion),
success: true,
},
{
// Wrong version
flow: fmt.Sprintf("cookie=0x0, duration=4.796s, table=253, n_packets=0, n_bytes=0, actions=note:00.%02x.00.00.00.00", ruleVersion-1),
success: false,
},
{
// Wrong table
flow: fmt.Sprintf("cookie=0x0, duration=4.796s, table=10, n_packets=0, n_bytes=0, actions=note:00.%02x.00.00.00.00", ruleVersion),
success: false,
},
{
// No note
flow: "cookie=0x0, duration=4.796s, table=253, n_packets=0, n_bytes=0, actions=goto_table:50",
success: false,
},
}
for i, tc := range testcases {
ovsif := ovs.NewFake(Br0)
if err := ovsif.AddBridge("fail_mode=secure", "protocols=OpenFlow13"); err != nil {
t.Fatalf("(%d) unexpected error from AddBridge: %v", i, err)
}
oc := NewOVSController(ovsif, 0, true, "172.17.0.4")
/* In order to test AlreadySetUp the vxlan port has to be added, we are not testing AddPort here */
_, err := ovsif.AddPort("vxlan0", 1, "type=vxlan", `options:remote_ip="flow"`, `options:key="flow"`, fmt.Sprintf("options:dst_port=%d", 4789))
if err != nil {
t.Fatalf("(%d) unexpected error from AddPort: %v", i, err)
}
otx := ovsif.NewTransaction()
otx.AddFlow(tc.flow)
if err := otx.Commit(); err != nil {
t.Fatalf("(%d) unexpected error from AddFlow: %v", i, err)
}
if success := oc.AlreadySetUp(4789); success != tc.success {
t.Fatalf("(%d) unexpected setup value %v (expected %v)", i, success, tc.success)
}
}
} | explode_data.jsonl/51152 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 759
} | [
2830,
3393,
38370,
79831,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
1166,
10303,
262,
914,
198,
197,
30553,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
322,
7684,
5185,
198,
298,
1166,
10303,
25,
262,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test_GetPrice(t *testing.T) {
server := "https://sero-light-node.ririniannian.com/"
price, err := getPrice(server)
require.NoError(t, err)
t.Logf("now price is %f", price)
} | explode_data.jsonl/52543 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
13614,
6972,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
330,
2428,
1110,
799,
78,
17709,
39054,
1746,
404,
6591,
1020,
1103,
905,
29555,
87119,
11,
1848,
1669,
89332,
21421,
340,
17957,
35699,
1155,
11,
1848,
340,
3244,
9895... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCellValue(t *testing.T) {
// Test get cell value without r attribute of the row.
f := NewFile()
delete(f.Sheet, "xl/worksheets/sheet1.xml")
f.XLSX["xl/worksheets/sheet1.xml"] = []byte(`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData><row r="3"><c t="str"><v>A3</v></c></row><row><c t="str"><v>A4</v></c><c t="str"><v>B4</v></c></row><row r="7"><c t="str"><v>A7</v></c><c t="str"><v>B7</v></c></row><row><c t="str"><v>A8</v></c><c t="str"><v>B8</v></c></row></sheetData></worksheet>`)
f.checked = nil
cells := []string{"A3", "A4", "B4", "A7", "B7"}
rows, err := f.GetRows("Sheet1")
assert.Equal(t, [][]string{nil, nil, {"A3"}, {"A4", "B4"}, nil, nil, {"A7", "B7"}, {"A8", "B8"}}, rows)
assert.NoError(t, err)
for _, cell := range cells {
value, err := f.GetCellValue("Sheet1", cell)
assert.Equal(t, cell, value)
assert.NoError(t, err)
}
cols, err := f.GetCols("Sheet1")
assert.Equal(t, [][]string{{"", "", "A3", "A4", "", "", "A7", "A8"}, {"", "", "", "B4", "", "", "B7", "B8"}}, cols)
assert.NoError(t, err)
} | explode_data.jsonl/951 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 504
} | [
2830,
3393,
1949,
23885,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
633,
2779,
897,
2041,
435,
7035,
315,
279,
2802,
624,
1166,
1669,
1532,
1703,
741,
15618,
955,
808,
3674,
11,
330,
24310,
14,
18525,
20306,
2687,
3674,
16,
9028,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrincipalRoleAdmin(t *testing.T) {
msp1, err := setup("testdata/idemix/MSP1OU1Admin", "MSP1OU1Admin")
assert.NoError(t, err)
id1, err := getDefaultSigner(msp1)
assert.NoError(t, err)
principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_MEMBER, MspIdentifier: id1.GetMSPIdentifier()})
assert.NoError(t, err)
principal := &msp.MSPPrincipal{
PrincipalClassification: msp.MSPPrincipal_ROLE,
Principal: principalBytes}
// Admin should also satisfy member
err = id1.SatisfiesPrincipal(principal)
assert.NoError(t, err)
principalBytes, err = proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_ADMIN, MspIdentifier: id1.GetMSPIdentifier()})
assert.NoError(t, err)
principal = &msp.MSPPrincipal{
PrincipalClassification: msp.MSPPrincipal_ROLE,
Principal: principalBytes}
err = id1.SatisfiesPrincipal(principal)
assert.NoError(t, err)
} | explode_data.jsonl/46047 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
31771,
9030,
7210,
1155,
353,
8840,
836,
8,
341,
47691,
79,
16,
11,
1848,
1669,
6505,
445,
92425,
38146,
336,
941,
10270,
4592,
16,
11922,
16,
7210,
497,
330,
44,
4592,
16,
11922,
16,
7210,
1138,
6948,
35699,
1155,
11,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCloseConcurrentConns(t *testing.T) {
listener := Statsd{
Log: testutil.Logger{},
Protocol: "tcp",
ServiceAddress: "localhost:8125",
AllowedPendingMessages: 10000,
MaxTCPConnections: 2,
}
acc := &testutil.Accumulator{}
require.NoError(t, listener.Start(acc))
time.Sleep(time.Millisecond * 250)
_, err := net.Dial("tcp", "127.0.0.1:8125")
assert.NoError(t, err)
_, err = net.Dial("tcp", "127.0.0.1:8125")
assert.NoError(t, err)
listener.Stop()
} | explode_data.jsonl/14361 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
7925,
1109,
3231,
1109,
4412,
1155,
353,
8840,
836,
8,
341,
14440,
798,
1669,
29927,
67,
515,
197,
24201,
25,
503,
1273,
1314,
12750,
38837,
197,
197,
20689,
25,
2290,
330,
27161,
756,
197,
91619,
4286,
25,
260,
330,
8301,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue414(t *testing.T) {
skipOn(t, "broken", "linux", "386", "pie") // test occasionally hangs on linux/386/pie
// Stepping until the program exits
protest.AllowRecording(t)
withTestProcess("math", t, func(p *proc.Target, fixture protest.Fixture) {
setFileBreakpoint(p, t, fixture.Source, 9)
assertNoError(p.Continue(), t, "Continue()")
for {
pc := currentPC(p, t)
f, ln := currentLineNumber(p, t)
t.Logf("at %s:%d %#x\n", f, ln, pc)
var err error
// Stepping through the runtime is not generally safe so after we are out
// of main.main just use Next.
// See: https://github.com/go-delve/delve/pull/2082
if f == fixture.Source {
err = p.Step()
} else {
err = p.Next()
}
if err != nil {
if _, exited := err.(proc.ErrProcessExited); exited {
break
}
}
assertNoError(err, t, "Step()")
}
})
} | explode_data.jsonl/56247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 367
} | [
2830,
3393,
42006,
19,
16,
19,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
1925,
1155,
11,
330,
48909,
497,
330,
14210,
497,
330,
18,
23,
21,
497,
330,
20283,
899,
442,
1273,
22930,
58341,
389,
36245,
14,
18,
23,
21,
4322,
645,
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... | 5 |
func TestJobRestrictedManager(t *testing.T) {
c := NewCtx(t)
defer c.Close()
build := testBuild(1)
build.Manager = "restricted-manager"
c.client2.UploadBuild(build)
crash := testCrash(build, 1)
crash.ReproSyz = []byte("repro syz")
c.client2.ReportCrash(crash)
c.expectOK(c.GET("/email_poll"))
c.expectEQ(len(c.emailSink), 1)
sender := (<-c.emailSink).Sender
// Testing on a wrong repo must fail and no test jobs passed to manager.
c.incomingEmail(sender, "#syz test: git://mygit.com/git.git master\n", EmailOptMessageID(1))
c.expectEQ(strings.Contains((<-c.emailSink).Body, "you should test only on restricted.git"), true)
pollResp, _ := c.client2.JobPoll([]string{build.Manager})
c.expectEQ(pollResp.ID, "")
// Testing on the right repo must succeed.
c.incomingEmail(sender, "#syz test: git://restricted.git/restricted.git master\n", EmailOptMessageID(2))
pollResp, _ = c.client2.JobPoll([]string{build.Manager})
c.expectEQ(pollResp.ID != "", true)
c.expectEQ(pollResp.Manager, build.Manager)
c.expectEQ(pollResp.KernelRepo, "git://restricted.git/restricted.git")
} | explode_data.jsonl/54016 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 422
} | [
2830,
3393,
12245,
86405,
2043,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
23684,
1155,
340,
16867,
272,
10421,
2822,
69371,
1669,
1273,
11066,
7,
16,
340,
69371,
58298,
284,
330,
50797,
44896,
698,
1444,
6581,
17,
86597,
11066,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_checkFlags(t *testing.T) {
type args struct {
provider string
}
tests := []struct {
name string
args args
want int
}{
// TODO: Add test cases.
{
name: "exist",
args: args{
provider: "alibabacloud",
},
want: 0,
},
{
name: "notExist",
args: args{
provider: "alibabaclou",
},
want: -1,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := checkFlags(tt.args.provider); got != tt.want {
t.Errorf("checkFlags() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/53710 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
7200,
9195,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
197,
19979,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFileOpsCollection_GetFileOpsAtIndex_02(t *testing.T) {
sf := make([]string, 5, 10)
sf[0] = "../filesfortest/levelfilesfortest/level_0_0_test.txt"
sf[1] = "../filesfortest/levelfilesfortest/level_0_1_test.txt"
sf[2] = "../filesfortest/levelfilesfortest/level_0_2_test.txt"
sf[3] = "../filesfortest/levelfilesfortest/level_0_3_test.txt"
sf[4] = "../filesfortest/levelfilesfortest/level_0_4_test.txt"
df := make([]string, 5, 10)
df[0] = "../dirmgrtests/level_0_0_test.txt"
df[1] = "../dirmgrtests/level_0_1_test.txt"
df[2] = "../dirmgrtests/level_0_2_test.txt"
df[3] = "../dirmgrtests/level_0_3_test.txt"
df[4] = "../dirmgrtests/level_0_4_test.txt"
fOpsCol := FileOpsCollection{}.New()
for i := 0; i < 5; i++ {
err := fOpsCol.AddByPathFileNameExtStrs(sf[i], df[i])
if err != nil {
t.Errorf("Error returned by fOpsCol.AddByPathFileNameExtStrs(sf[i], df[i]). "+
"i='%v'\n" +
"sf[i]='%v'\n" +
"df[i]='%v'\n" +
"Error='%v'\n", i, sf[i], df[i], err.Error())
return
}
}
_, err := fOpsCol.GetFileOpsAtIndex(99)
if err == nil {
t.Error("Expected an error return from fOpsCol.GetFileOpsAtIndex(99)\n" +
"because the index, '99', is INVALID!\n" +
"However, NO ERROR WAS RETURNED!!!\n")
}
_, err = fOpsCol.GetFileOpsAtIndex(-1)
if err == nil {
t.Error("Expected an error return from fOpsCol.GetFileOpsAtIndex(-1)\n" +
"because the index, '-1', is INVALID!\n" +
"However, NO ERROR WAS RETURNED!!!\n")
}
} | explode_data.jsonl/76454 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 721
} | [
2830,
3393,
1703,
38904,
6482,
13614,
1703,
38904,
22556,
62,
15,
17,
1155,
353,
8840,
836,
8,
1476,
220,
13124,
1669,
1281,
10556,
917,
11,
220,
20,
11,
220,
16,
15,
692,
220,
13124,
58,
15,
60,
284,
7005,
7198,
3969,
477,
14,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCopyNil(t *testing.T) {
var s string
awsutil.Copy(&s, nil)
if v1, v2 := "", s; v1 != v2 {
t.Errorf("expected values to be equivalent but received %v and %v", v1, v2)
}
} | explode_data.jsonl/35703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
12106,
19064,
1155,
353,
8840,
836,
8,
341,
2405,
274,
914,
198,
197,
8635,
1314,
31770,
2099,
82,
11,
2092,
340,
743,
348,
16,
11,
348,
17,
1669,
7342,
274,
26,
348,
16,
961,
348,
17,
341,
197,
3244,
13080,
445,
7325,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestMetricsHandlerWithEnablingTagOnRequestMetrics(t *testing.T) {
defer reset()
baseHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
handler, err := NewRequestMetricsHandler(baseHandler, "ns", "svc", "cfg", "rev", "pod")
if err != nil {
t.Fatal("Failed to create handler:", err)
}
resp := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, targetURI, bytes.NewBufferString("test"))
req.Header.Set(netheader.RouteTagKey, "test-tag")
handler.ServeHTTP(resp, req)
wantTags := map[string]string{
metrics.LabelPodName: "pod",
metrics.LabelContainerName: "queue-proxy",
metrics.LabelResponseCode: "200",
metrics.LabelResponseCodeClass: "2xx",
metrics.LabelRouteTag: "test-tag",
}
wantResource := &resource.Resource{
Type: "knative_revision",
Labels: map[string]string{
metrics.LabelNamespaceName: "ns",
metrics.LabelRevisionName: "rev",
metrics.LabelServiceName: "svc",
metrics.LabelConfigurationName: "cfg",
},
}
metricstest.AssertMetric(t, metricstest.IntMetric("request_count", 1, wantTags).WithResource(wantResource))
// Testing for default route
reset()
handler, _ = NewRequestMetricsHandler(baseHandler, "ns", "svc", "cfg", "rev", "pod")
req.Header.Del(netheader.RouteTagKey)
req.Header.Set(netheader.DefaultRouteKey, "true")
handler.ServeHTTP(resp, req)
wantTags["route_tag"] = defaultTagName
metricstest.AssertMetric(t, metricstest.IntMetric("request_count", 1, wantTags).WithResource(wantResource))
reset()
handler, _ = NewRequestMetricsHandler(baseHandler, "ns", "svc", "cfg", "rev", "pod")
req.Header.Set(netheader.RouteTagKey, "test-tag")
req.Header.Set(netheader.DefaultRouteKey, "true")
handler.ServeHTTP(resp, req)
wantTags["route_tag"] = undefinedTagName
metricstest.AssertMetric(t, metricstest.IntMetric("request_count", 1, wantTags).WithResource(wantResource))
reset()
handler, _ = NewRequestMetricsHandler(baseHandler, "ns", "svc", "cfg", "rev", "pod")
req.Header.Set(netheader.RouteTagKey, "test-tag")
req.Header.Set(netheader.DefaultRouteKey, "false")
handler.ServeHTTP(resp, req)
wantTags["route_tag"] = "test-tag"
metricstest.AssertMetric(t, metricstest.IntMetric("request_count", 1, wantTags).WithResource(wantResource))
} | explode_data.jsonl/63523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 860
} | [
2830,
3393,
1900,
27328,
3050,
2354,
1702,
18768,
5668,
1925,
1900,
27328,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
741,
24195,
3050,
1669,
1758,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
35248,
53326,
11,
1848,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMultipleSlopes(t *testing.T) {
tm := ParseTreeMap(testData1)
treeCounts := []int{}
treeCounts = append(treeCounts, tm.CountTrees(1, 1))
treeCounts = append(treeCounts, tm.CountTrees(3, 1))
treeCounts = append(treeCounts, tm.CountTrees(5, 1))
treeCounts = append(treeCounts, tm.CountTrees(7, 1))
treeCounts = append(treeCounts, tm.CountTrees(1, 2))
total := 1
for _, t := range treeCounts {
total = total * t
}
fmt.Printf("trees: %v\n", treeCounts)
require.Equal(t, 336, total)
} | explode_data.jsonl/8953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
32089,
50,
385,
20352,
1155,
353,
8840,
836,
8,
341,
3244,
76,
1669,
14775,
6533,
2227,
8623,
1043,
16,
340,
51968,
63731,
1669,
3056,
396,
16094,
51968,
63731,
284,
8737,
21298,
63731,
11,
17333,
6134,
79071,
7,
16,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReconcileWithTimeout(t *testing.T) {
// TestReconcileWithTimeout runs "Reconcile" on a PipelineRun that has timed out.
// It verifies that reconcile is successful, the pipeline status updated and events generated.
ps := []*v1beta1.Pipeline{simpleHelloWorldPipeline}
prs := []*v1beta1.PipelineRun{parse.MustParsePipelineRun(t, `
metadata:
name: test-pipeline-run-with-timeout
namespace: foo
spec:
pipelineRef:
name: test-pipeline
serviceAccountName: test-sa
timeout: 12h0m0s
status:
startTime: "2021-12-31T00:00:00Z"
`)}
ts := []*v1beta1.Task{simpleHelloWorldTask}
d := test.Data{
PipelineRuns: prs,
Pipelines: ps,
Tasks: ts,
}
prt := newPipelineRunTest(d, t)
defer prt.Cancel()
wantEvents := []string{
"Warning Failed PipelineRun \"test-pipeline-run-with-timeout\" failed to finish within \"12h0m0s\"",
}
reconciledRun, clients := prt.reconcileRun("foo", "test-pipeline-run-with-timeout", wantEvents, false)
if reconciledRun.Status.CompletionTime == nil {
t.Errorf("Expected a CompletionTime on invalid PipelineRun but was nil")
}
// The PipelineRun should be timed out.
if reconciledRun.Status.GetCondition(apis.ConditionSucceeded).Reason != "PipelineRunTimeout" {
t.Errorf("Expected PipelineRun to be timed out, but condition reason is %s", reconciledRun.Status.GetCondition(apis.ConditionSucceeded))
}
actions := clients.Pipeline.Actions()
if len(actions) < 2 {
t.Fatalf("Expected client to have at least two action implementation but it has %d", len(actions))
}
// Check that the expected TaskRun was created
actual := getTaskRunCreations(t, actions)[0]
// The TaskRun timeout should be less than or equal to the PipelineRun timeout.
if actual.Spec.Timeout.Duration > prs[0].Spec.Timeout.Duration {
t.Errorf("TaskRun timeout %s should be less than or equal to PipelineRun timeout %s", actual.Spec.Timeout.Duration.String(), prs[0].Spec.Timeout.Duration.String())
}
} | explode_data.jsonl/27295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 681
} | [
2830,
3393,
693,
40446,
457,
2354,
7636,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
693,
40446,
457,
2354,
7636,
8473,
330,
693,
40446,
457,
1,
389,
264,
40907,
6727,
429,
702,
25182,
700,
624,
197,
322,
1084,
87856,
429,
63408,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStopConsuming_Consumer(t *testing.T) {
connection, err := OpenConnection("consume", "tcp", "localhost:6379", 1, nil)
assert.NoError(t, err)
queue, err := connection.OpenQueue("consume-q")
assert.NoError(t, err)
_, err = queue.PurgeReady()
assert.NoError(t, err)
deliveryCount := int64(30)
for i := int64(0); i < deliveryCount; i++ {
err := queue.Publish("d" + strconv.FormatInt(i, 10))
assert.NoError(t, err)
}
assert.NoError(t, queue.StartConsuming(20, time.Millisecond))
var consumers []*TestConsumer
for i := 0; i < 10; i++ {
consumer := NewTestConsumer("c" + strconv.Itoa(i))
consumers = append(consumers, consumer)
_, err = queue.AddConsumer("consume", consumer)
assert.NoError(t, err)
}
finishedChan := queue.StopConsuming()
require.NotNil(t, finishedChan)
<-finishedChan
var consumedCount int64
for i := 0; i < 10; i++ {
consumedCount += int64(len(consumers[i].LastDeliveries))
}
// make sure all deliveries are either ready, unacked or consumed (acked)
readyCount, err := queue.readyCount()
assert.NoError(t, err)
unackedCount, err := queue.unackedCount()
assert.NoError(t, err)
assert.Equal(t, readyCount+unackedCount+consumedCount, deliveryCount, "counts %d+%d+%d = %d", consumedCount, readyCount, unackedCount, deliveryCount)
assert.NoError(t, connection.stopHeartbeat())
} | explode_data.jsonl/44670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 489
} | [
2830,
3393,
10674,
41966,
287,
15100,
11761,
1155,
353,
8840,
836,
8,
341,
54590,
11,
1848,
1669,
5264,
4526,
445,
84494,
497,
330,
27161,
497,
330,
8301,
25,
21,
18,
22,
24,
497,
220,
16,
11,
2092,
340,
6948,
35699,
1155,
11,
1848,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestXLSXReadMulti(t *testing.T) {
f, err := reader.OpenXLSXSheet("./_test/test.xlsx", 0)
if err != nil {
t.Errorf("unable to open xlsx file: %#v", err.Error())
}
for i := 0; i < f.Len(); i++ {
strs, err := reader.ReadMulti(f, 0, 1)(i)
if err != nil {
t.Errorf("unable to ReadMulti on line %d: %#v",
i, err.Error())
}
res := strings.Join(strs, ", ")
exp := testXLSXdata[i][0] + ", " + testXLSXdata[i][1]
if res != exp {
t.Errorf("row %d exptects %#v, got %#v",
exp, res)
}
t.Logf("%#v", res)
}
} | explode_data.jsonl/77502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
55,
7268,
55,
4418,
20358,
1155,
353,
8840,
836,
8,
1476,
1166,
11,
1848,
1669,
6604,
12953,
55,
7268,
55,
10541,
13988,
62,
1944,
12697,
46838,
497,
220,
15,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
45928,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconsileServiceInstanceDeleteWithParameters(t *testing.T) {
cases := []struct {
name string
externalProperties *v1beta1.ServiceInstancePropertiesState
deprovisionStatus v1beta1.ServiceInstanceDeprovisionStatus
serviceBinding *v1beta1.ServiceBinding
generation int64
reconciledGeneration int64
}{
{
name: "With a failed to provision instance and without making a provision request",
externalProperties: &v1beta1.ServiceInstancePropertiesState{},
deprovisionStatus: v1beta1.ServiceInstanceDeprovisionStatusNotRequired,
serviceBinding: nil,
generation: 1,
reconciledGeneration: 0,
},
{
name: "With a failed to provision instance, with inactive binding, and without making a provision request",
externalProperties: &v1beta1.ServiceInstancePropertiesState{},
deprovisionStatus: v1beta1.ServiceInstanceDeprovisionStatusNotRequired,
serviceBinding: getTestServiceInactiveBinding(),
generation: 1,
reconciledGeneration: 0,
},
{
name: "With a deprovisioned instance and without making a deprovision request",
externalProperties: nil,
deprovisionStatus: v1beta1.ServiceInstanceDeprovisionStatusSucceeded,
serviceBinding: nil,
generation: 2,
reconciledGeneration: 1,
},
{
name: "With a deprovisioned instance, with inactive binding, and without making a deprovision request",
externalProperties: nil,
deprovisionStatus: v1beta1.ServiceInstanceDeprovisionStatusSucceeded,
serviceBinding: getTestServiceInactiveBinding(),
generation: 2,
reconciledGeneration: 1,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
fakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, noFakeActions())
sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())
sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())
if tc.serviceBinding != nil {
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(tc.serviceBinding)
}
instance := getTestServiceInstanceWithFailedStatus()
instance.ObjectMeta.DeletionTimestamp = &metav1.Time{}
instance.ObjectMeta.Finalizers = []string{v1beta1.FinalizerServiceCatalog}
instance.Status.ExternalProperties = tc.externalProperties
instance.Status.DeprovisionStatus = tc.deprovisionStatus
instance.Generation = tc.generation
instance.Status.ReconciledGeneration = tc.reconciledGeneration
instance.Status.ObservedGeneration = 1
instance.Status.ProvisionStatus = v1beta1.ServiceInstanceProvisionStatusNotProvisioned
fakeCatalogClient.AddReactor("get", "serviceinstances", func(action clientgotesting.Action) (bool, runtime.Object, error) {
return true, instance, nil
})
err := reconcileServiceInstance(t, testController, instance)
if err != nil {
t.Fatalf("Unexpected error from reconcileServiceInstance: %v", err)
}
brokerActions := fakeClusterServiceBrokerClient.Actions()
assertNumberOfBrokerActions(t, brokerActions, 0)
// Verify no core kube actions occurred
kubeActions := fakeKubeClient.Actions()
assertNumberOfActions(t, kubeActions, 0)
actions := fakeCatalogClient.Actions()
assertNumberOfActions(t, actions, 1)
updatedServiceInstance := assertUpdateStatus(t, actions[0], instance)
assertEmptyFinalizers(t, updatedServiceInstance)
events := getRecordedEvents(testController)
assertNumEvents(t, events, 0)
})
}
} | explode_data.jsonl/58152 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1390
} | [
2830,
3393,
693,
6254,
457,
1860,
2523,
6435,
2354,
9706,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
197,
20921,
7903,
256,
353,
85,
16,
19127,
16,
13860,
2523,
7903,
1397,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestControllerAddGameServerHealthCheck(t *testing.T) {
c, _ := newFakeController()
fixture := &v1alpha1.GameServer{ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"},
Spec: newSingleContainerSpec(), Status: v1alpha1.GameServerStatus{State: v1alpha1.Creating}}
fixture.ApplyDefaults()
assert.False(t, fixture.Spec.Health.Disabled)
pod, err := fixture.Pod()
assert.Nil(t, err, "Error: %v", err)
c.addGameServerHealthCheck(fixture, pod)
assert.Len(t, pod.Spec.Containers, 1)
probe := pod.Spec.Containers[0].LivenessProbe
assert.NotNil(t, probe)
assert.Equal(t, "/gshealthz", probe.HTTPGet.Path)
assert.Equal(t, intstr.IntOrString{IntVal: 8080}, probe.HTTPGet.Port)
assert.Equal(t, fixture.Spec.Health.FailureThreshold, probe.FailureThreshold)
assert.Equal(t, fixture.Spec.Health.InitialDelaySeconds, probe.InitialDelaySeconds)
assert.Equal(t, fixture.Spec.Health.PeriodSeconds, probe.PeriodSeconds)
} | explode_data.jsonl/25436 | {
"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,
2051,
2212,
4868,
5475,
14542,
3973,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
501,
52317,
2051,
741,
1166,
12735,
1669,
609,
85,
16,
7141,
16,
20940,
5475,
90,
1190,
12175,
25,
77520,
16,
80222,
63121,
25,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestScopesAnyMatcher(t *testing.T) {
for _, v := range []struct {
name string
scopesKey string
claims map[string]interface{}
requiredScopes []string
expected bool
}{
{
name: "any_simple_success",
scopesKey: "scope",
claims: map[string]interface{}{"scope": "a b"},
requiredScopes: []string{"a", "b"},
expected: true,
},
{
name: "any_simple_fail",
scopesKey: "scope",
claims: map[string]interface{}{"scope": "a b"},
requiredScopes: []string{"c"},
expected: false,
},
{
name: "any_missingone_success",
scopesKey: "scope",
claims: map[string]interface{}{"scope": "a"},
requiredScopes: []string{"a", "b"},
expected: true,
},
{
name: "any_one_simple_success",
scopesKey: "scope",
claims: map[string]interface{}{"scope": "a b"},
requiredScopes: []string{"b"},
expected: true,
},
{
name: "any_no_req_scopes_success",
scopesKey: "scope",
claims: map[string]interface{}{"scope": "a b"},
requiredScopes: []string{},
expected: true,
},
{
name: "any_struct_success",
scopesKey: "data.scope",
claims: map[string]interface{}{"data": map[string]interface{}{"scope": "a"}},
requiredScopes: []string{"a", "b"},
expected: true,
},
{
name: "any_deep_struct_success",
scopesKey: "data.data.data.data.data.data.data.scope",
claims: map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"data": map[string]interface{}{
"scope": "a",
},
},
},
},
},
},
},
},
requiredScopes: []string{"a", "b"},
expected: true,
},
} {
t.Run(v.name, func(t *testing.T) {
if res := ScopesAnyMatcher(v.scopesKey, v.claims, v.requiredScopes); res != v.expected {
t.Errorf("'%s' have %v, want %v", v.name, res, v.expected)
}
})
}
} | explode_data.jsonl/67490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1155
} | [
2830,
3393,
3326,
18523,
8610,
37554,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
348,
1669,
2088,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
29928,
18523,
1592,
414,
914,
198,
197,
197,
48561,
260,
2415,
14032,
31344,
16094,
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 TestSmallBatchSize(t *testing.T) {
viper.Set("ledger.state.couchDBConfig.maxBatchUpdateSize", 2)
env := NewTestVDBEnv(t)
env.Cleanup("testsmallbatchsize_")
env.Cleanup("testsmallbatchsize_ns1")
defer env.Cleanup("testsmallbatchsize_")
defer env.Cleanup("testsmallbatchsize_ns1")
defer viper.Set("ledger.state.couchDBConfig.maxBatchUpdateSize", 1000)
commontests.TestSmallBatchSize(t, env.DBProvider)
} | explode_data.jsonl/597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
25307,
21074,
1695,
1155,
353,
8840,
836,
8,
341,
5195,
12858,
4202,
445,
50704,
3467,
520,
3026,
3506,
2648,
6678,
21074,
4289,
1695,
497,
220,
17,
340,
57538,
1669,
1532,
2271,
53,
3506,
14359,
1155,
340,
57538,
727,
60639... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_NamespacesTopic_WhenPropertiesConverted_RoundTripsWithoutLoss(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip from NamespacesTopic to NamespacesTopic via AssignPropertiesToNamespacesTopic & AssignPropertiesFromNamespacesTopic returns original",
prop.ForAll(RunPropertyAssignmentTestForNamespacesTopic, NamespacesTopicGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(false, 240, os.Stdout))
} | explode_data.jsonl/36547 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
1604,
971,
27338,
26406,
62,
4498,
7903,
61941,
2568,
795,
21884,
1690,
26040,
39838,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
220,
16,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExpiredKeys_RemoveKeysExpiredFromDatabase(t *testing.T) {
t.Run("Should return empty key because return unexpected error on find keys", func(t *testing.T) {
conn, err := gorm.Open("sqlite3", ":memory:")
assert.NoError(t, err)
mockWrite := &relational.MockWrite{}
mockRead := &relational.MockRead{}
mockRead.On("Find").Return(response.NewResponse(0, errors.New("some error"), nil))
mockRead.On("SetFilter").Return(conn)
mockRead.On("GetConnection").Return(conn)
c := NewExpiredKeys(mockRead, mockWrite)
c.RemoveKeysExpiredFromDatabase()
})
t.Run("Should return empty key because return not found records", func(t *testing.T) {
conn, err := gorm.Open("sqlite3", ":memory:")
assert.NoError(t, err)
mockWrite := &relational.MockWrite{}
mockRead := &relational.MockRead{}
mockRead.On("Find").Return(response.NewResponse(0, errorsEnum.ErrNotFoundRecords, nil))
mockRead.On("SetFilter").Return(conn)
mockRead.On("GetConnection").Return(conn)
c := NewExpiredKeys(mockRead, mockWrite)
c.RemoveKeysExpiredFromDatabase()
})
t.Run("Should return keys but return errors on delete from database", func(t *testing.T) {
conn, err := gorm.Open("sqlite3", ":memory:")
assert.NoError(t, err)
mockWrite := &relational.MockWrite{}
mockWrite.On("DeleteByQuery").Return(response.NewResponse(0, errors.New("test"), nil))
mockWrite.On("GetConnection").Return(conn)
mockRead := &relational.MockRead{}
mockRead.On("Find").Return(response.NewResponse(1, nil, &[]cache.Cache{{Value: []byte("test"), Key: "key"}}))
mockRead.On("SetFilter").Return(conn)
mockRead.On("GetConnection").Return(conn)
c := NewExpiredKeys(mockRead, mockWrite)
c.RemoveKeysExpiredFromDatabase()
})
} | explode_data.jsonl/42405 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 637
} | [
2830,
3393,
54349,
8850,
66843,
8850,
54349,
3830,
5988,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
14996,
470,
4287,
1376,
1576,
470,
16500,
1465,
389,
1477,
6894,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
32917,
11,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStreamWriter6(t *testing.T) {
runBadgerTest(t, nil, func(t *testing.T, db *DB) {
fmt.Println(db.opt.Dir)
list := &pb.KVList{}
str := []string{"a", "a", "b", "b", "c", "c"}
ver := 1
for i := range str {
kv := &pb.KV{
Key: bytes.Repeat([]byte(str[i]), int(db.opt.MaxTableSize)),
Value: []byte("val"),
Version: uint64(ver),
}
list.Kv = append(list.Kv, kv)
ver = (ver + 1) % 2
}
// list has 3 pairs for equal keys. Since each Key has size equal to MaxTableSize
// we would have 6 tables, if keys are not equal. Here we should have 3 tables.
sw := db.NewStreamWriter()
require.NoError(t, sw.Prepare(), "sw.Prepare() failed")
require.NoError(t, sw.Write(list), "sw.Write() failed")
require.NoError(t, sw.Flush(), "sw.Flush() failed")
tables := db.Tables(true)
require.Equal(t, 4, len(tables), "Count of tables not matching")
for _, tab := range tables {
if tab.Level > 0 {
require.Equal(t, 2, int(tab.KeyCount),
fmt.Sprintf("failed for level: %d", tab.Level))
} else {
require.Equal(t, 1, int(tab.KeyCount)) // level 0 table will have head key
}
}
require.NoError(t, db.Close())
_, err := Open(db.opt)
require.NoError(t, err)
})
} | explode_data.jsonl/17984 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
93031,
21,
1155,
353,
8840,
836,
8,
341,
56742,
17082,
1389,
2271,
1155,
11,
2092,
11,
2915,
1155,
353,
8840,
836,
11,
2927,
353,
3506,
8,
341,
197,
11009,
12419,
9791,
28102,
83757,
340,
197,
14440,
1669,
609,
16650,
1135... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddAssetAnnotations(t *testing.T) {
assert := assert.New(t)
expectedAnnotations := map[string]string{
vcAnnotations.KernelPath: "/abc/rgb/kernel",
vcAnnotations.ImagePath: "/abc/rgb/image",
vcAnnotations.InitrdPath: "/abc/rgb/initrd",
vcAnnotations.KernelHash: "3l2353we871g",
vcAnnotations.ImageHash: "52ss2550983",
vcAnnotations.AssetHashType: "sha",
}
config := vc.SandboxConfig{
Annotations: make(map[string]string),
}
ocispec := specs.Spec{
Annotations: expectedAnnotations,
}
addAnnotations(ocispec, &config)
assert.Exactly(expectedAnnotations, config.Annotations)
} | explode_data.jsonl/44053 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
2212,
16604,
21418,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
42400,
21418,
1669,
2415,
14032,
30953,
515,
197,
5195,
66,
21418,
11352,
5454,
1820,
25,
262,
3521,
13683,
14,
16509,
58343,
756,
197,
519... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDPAReconciler_updateRegistryRouteCM(t *testing.T) {
tests := []struct {
name string
registryRouteCM *corev1.ConfigMap
bsl *velerov1.BackupStorageLocation
dpa *oadpv1alpha1.DataProtectionApplication
wantErr bool
}{
{
name: "Given Velero CR and bsl instance, appropriate registry cm is updated",
wantErr: false,
bsl: &velerov1.BackupStorageLocation{
ObjectMeta: metav1.ObjectMeta{
Name: "test-bsl",
Namespace: "test-ns",
},
Spec: velerov1.BackupStorageLocationSpec{
Provider: "test-provider",
},
},
dpa: &oadpv1alpha1.DataProtectionApplication{
ObjectMeta: metav1.ObjectMeta{
Name: "Velero-test-CR",
Namespace: "test-ns",
},
},
registryRouteCM: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "oadp-registry-config",
Namespace: "test-ns",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fakeClient, err := getFakeClientFromObjects()
if err != nil {
t.Errorf("error in creating fake client, likely programmer error")
}
r := &DPAReconciler{
Client: fakeClient,
Scheme: fakeClient.Scheme(),
Log: logr.Discard(),
Context: newContextForTest(tt.name),
NamespacedName: types.NamespacedName{
Namespace: tt.dpa.Namespace,
Name: tt.dpa.Name,
},
EventRecorder: record.NewFakeRecorder(10),
}
wantRegitryRouteCM := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "oadp-registry-config",
Namespace: "test-ns",
OwnerReferences: []metav1.OwnerReference{{
APIVersion: oadpv1alpha1.SchemeBuilder.GroupVersion.String(),
Kind: "DataProtectionApplication",
Name: tt.dpa.Name,
UID: tt.dpa.UID,
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
}},
},
Data: map[string]string{
"test-bsl": "oadp-" + "test-bsl" + "-" + "test-provider" + "-registry-route",
},
}
if err := r.updateRegistryConfigMap(tt.registryRouteCM, tt.bsl, tt.dpa); (err != nil) != tt.wantErr {
t.Errorf("updateRegistryConfigMap() error = %v, wantErr %v", err, tt.wantErr)
}
if !reflect.DeepEqual(tt.registryRouteCM, wantRegitryRouteCM) {
t.Errorf("expected registry CM to be %#v, got %#v", tt.registryRouteCM, wantRegitryRouteCM)
}
})
}
} | explode_data.jsonl/45548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1198
} | [
2830,
3393,
35,
8041,
693,
40446,
5769,
8882,
15603,
4899,
9985,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
197,
29172,
4899,
9985,
353,
98645,
16,
10753,
2227,
198,
197,
93801,
75,
179... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepare(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(id TEXT)")
tk.MustExec(`INSERT INTO t VALUES ("id");`)
id, ps, _, err := tk.Session().PrepareStmt("select id+? from t")
ctx := context.Background()
require.NoError(t, err)
require.Equal(t, uint32(1), id)
require.Equal(t, 1, ps)
tk.MustExec(`set @a=1`)
rs, err := tk.Session().ExecutePreparedStmt(ctx, id, []types.Datum{types.NewDatum("1")})
require.NoError(t, err)
require.NoError(t, rs.Close())
err = tk.Session().DropPreparedStmt(id)
require.NoError(t, err)
tk.MustExec("prepare stmt from 'select 1+?'")
tk.MustExec("set @v1=100")
tk.MustQuery("execute stmt using @v1").Check(testkit.Rows("101"))
tk.MustExec("set @v2=200")
tk.MustQuery("execute stmt using @v2").Check(testkit.Rows("201"))
tk.MustExec("set @v3=300")
tk.MustQuery("execute stmt using @v3").Check(testkit.Rows("301"))
tk.MustExec("deallocate prepare stmt")
// Execute prepared statements for more than one time.
tk.MustExec("create table multiexec (a int, b int)")
tk.MustExec("insert multiexec values (1, 1), (2, 2)")
id, _, _, err = tk.Session().PrepareStmt("select a from multiexec where b = ? order by b")
require.NoError(t, err)
rs, err = tk.Session().ExecutePreparedStmt(ctx, id, []types.Datum{types.NewDatum(1)})
require.NoError(t, err)
require.NoError(t, rs.Close())
rs, err = tk.Session().ExecutePreparedStmt(ctx, id, []types.Datum{types.NewDatum(2)})
require.NoError(t, err)
require.NoError(t, rs.Close())
} | explode_data.jsonl/5774 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 654
} | [
2830,
3393,
50590,
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,
11,
3553,
340,
3244,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEmptyNodeJS(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("empty", "nodejs"),
Dependencies: []string{"@pulumi/pulumi"},
Quick: true,
})
} | explode_data.jsonl/76337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
3522,
1955,
12545,
1155,
353,
8840,
836,
8,
341,
2084,
17376,
80254,
2271,
1155,
11,
609,
60168,
80254,
2271,
3798,
515,
197,
197,
6184,
25,
688,
26054,
22363,
445,
3194,
497,
330,
3509,
2519,
4461,
197,
197,
48303,
25,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidContainerNames(t *testing.T) {
invalidNames := []string{"-rm", "&sdfsfd", "safd%sd"}
validNames := []string{"word-word", "word_word", "1weoid"}
for _, name := range invalidNames {
if validContainerNamePattern.MatchString(name) {
t.Fatalf("%q is not a valid container name and was returned as valid.", name)
}
}
for _, name := range validNames {
if !validContainerNamePattern.MatchString(name) {
t.Fatalf("%q is a valid container name and was returned as invalid.", name)
}
}
} | explode_data.jsonl/21112 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
4088,
4502,
7980,
1155,
353,
8840,
836,
8,
341,
197,
11808,
7980,
1669,
3056,
917,
4913,
12,
8719,
497,
13399,
82,
34378,
6902,
497,
330,
82,
92139,
12952,
67,
16707,
56322,
7980,
1669,
3056,
917,
4913,
1158,
37328,
497,
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... | 5 |
func TestCannotParseArgon2idHash(t *testing.T) {
ok, err := CheckPassword("password", "$argon2id$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM")
assert.EqualError(t, err, "Hash key is not the last parameter, the hash is likely malformed ($argon2id$o/vzA4myCqZZ36bUGsDY//8mKUYNZZaR0t4MFFSs+iM)")
assert.False(t, ok)
} | explode_data.jsonl/40188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
17444,
14463,
2735,
263,
17,
307,
6370,
1155,
353,
8840,
836,
8,
341,
59268,
11,
1848,
1669,
4248,
4876,
445,
3833,
497,
5201,
70821,
17,
307,
75475,
5457,
89,
32,
19,
2408,
34,
80,
33536,
18,
21,
65,
2941,
82,
69916,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOCILayoutPath(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatalf("could not create temp dir: %s", err)
}
defer os.RemoveAll(tmpDir)
image, err := random.Image(1024, 4)
if err != nil {
t.Fatalf("could not create image: %s", err)
}
digest, err := image.Digest()
if err != nil {
t.Fatalf("could not get image digest: %s", err)
}
want, err := image.Manifest()
if err != nil {
t.Fatalf("could not get image manifest: %s", err)
}
opts := config.KanikoOptions{
NoPush: true,
OCILayoutPath: tmpDir,
}
if err := DoPush(image, &opts); err != nil {
t.Fatalf("could not push image: %s", err)
}
layoutIndex, err := layout.ImageIndexFromPath(tmpDir)
if err != nil {
t.Fatalf("could not get index from layout: %s", err)
}
testutil.CheckError(t, false, validate.Index(layoutIndex))
layoutImage, err := layoutIndex.Image(digest)
if err != nil {
t.Fatalf("could not get image from layout: %s", err)
}
got, err := layoutImage.Manifest()
testutil.CheckErrorAndDeepEqual(t, false, err, want, got)
} | explode_data.jsonl/14802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
7612,
1715,
1407,
1820,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
28077,
537,
1855,
2730,
5419,
25,
1018,
82,
497,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestContext2Plan_computedDataResource(t *testing.T) {
m := testModule(t, "plan-computed-data-resource")
p := testProvider("aws")
p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
"aws_instance": {
Attributes: map[string]*configschema.Attribute{
"num": {Type: cty.String, Optional: true},
"compute": {Type: cty.String, Optional: true},
"foo": {Type: cty.String, Computed: true},
},
},
},
DataSources: map[string]*configschema.Block{
"aws_vpc": {
Attributes: map[string]*configschema.Attribute{
"foo": {Type: cty.String, Optional: true},
},
},
},
}
p.DiffFn = testDiffFn
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
})
plan, diags := ctx.Plan()
if diags.HasErrors() {
t.Fatalf("unexpected errors: %s", diags.Err())
}
schema := p.GetSchemaReturn.DataSources["aws_vpc"]
ty := schema.ImpliedType()
if rc := plan.Changes.ResourceInstance(addrs.Resource{Mode: addrs.ManagedResourceMode, Type: "aws_instance", Name: "foo"}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance)); rc == nil {
t.Fatalf("missing diff for aws_instance.foo")
}
rcs := plan.Changes.ResourceInstance(addrs.Resource{
Mode: addrs.DataResourceMode,
Type: "aws_vpc",
Name: "bar",
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance))
if rcs == nil {
t.Fatalf("missing diff for data.aws_vpc.bar")
}
rc, err := rcs.Decode(ty)
if err != nil {
t.Fatal(err)
}
checkVals(t,
cty.ObjectVal(map[string]cty.Value{
"foo": cty.UnknownVal(cty.String),
}),
rc.After,
)
} | explode_data.jsonl/28668 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 721
} | [
2830,
3393,
1972,
17,
20485,
2965,
19292,
1043,
4783,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
11476,
19292,
13945,
74790,
1138,
3223,
1669,
1273,
5179,
445,
8635,
1138,
3223,
2234,
8632,
5598,
284,
60... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeBase32Secret(t *testing.T) {
for _, c := range []struct {
name string
input string
want string
}{
{
name: "empty input",
input: "",
want: "",
},
{
name: "test padding #1",
input: "GE",
want: "1",
},
{
name: "test padding #2",
input: "GE=====",
want: "1",
},
{
name: "test lowercase",
input: "ge=====",
want: "1",
},
} {
c := c
t.Run(c.name, func(t *testing.T) {
if got := DecodeBase32Secret(c.input); got != c.want {
t.Errorf("wrong decoded value for %s input, want: %s != got: %s", c.input, c.want, got)
}
})
}
} | explode_data.jsonl/31147 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
32564,
3978,
18,
17,
19773,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
22427,
914,
198,
197,
50780,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
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 TestReconcileSecurityGroupNewServiceAddsPort(t *testing.T) {
az := getTestCloud()
getTestSecurityGroup(az)
svc1 := getTestService("servicea", v1.ProtocolTCP, 80)
clusterResources := getClusterResources(az, 1, 1)
lb, _ := az.reconcileLoadBalancer(testClusterName, &svc1, clusterResources.nodes, true)
lbStatus, _ := az.getServiceLoadBalancerStatus(&svc1, lb)
sg, err := az.reconcileSecurityGroup(testClusterName, &svc1, &lbStatus.Ingress[0].IP, true /* wantLb */)
if err != nil {
t.Errorf("Unexpected error: %q", err)
}
validateSecurityGroup(t, sg, svc1)
} | explode_data.jsonl/50399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
693,
40446,
457,
15352,
2808,
3564,
1860,
72111,
7084,
1155,
353,
8840,
836,
8,
341,
197,
1370,
1669,
633,
2271,
16055,
741,
10366,
2271,
15352,
2808,
7,
1370,
340,
1903,
7362,
16,
1669,
633,
2271,
1860,
445,
7936,
64,
497... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFutureExpirationRender(t *testing.T) {
t.Parallel()
sources := []source.ByteSource{
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("---\ntitle: doc1\nexpirydate: \"2400-05-29\"\n---\n# doc1\n*some content*")},
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc2\nexpirydate: \"2000-05-29\"\n---\n# doc2\n*some content*")},
}
siteSetup := func(t *testing.T) *Site {
cfg, fs := newTestCfg()
cfg.Set("baseURL", "http://auth/bub")
for _, src := range sources {
writeSource(t, fs, filepath.Join("content", src.Name), string(src.Content))
}
return buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
}
s := siteSetup(t)
if len(s.AllPages) != 1 {
if len(s.RegularPages) > 1 {
t.Fatal("Expired content published unexpectedly")
}
if len(s.RegularPages) < 1 {
t.Fatal("Valid content expired unexpectedly")
}
}
if s.AllPages[0].Title == "doc2" {
t.Fatal("Expired content published unexpectedly")
}
} | explode_data.jsonl/40665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 408
} | [
2830,
3393,
24206,
66301,
6750,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
2360,
1669,
3056,
2427,
32119,
3608,
515,
197,
197,
63121,
25,
26054,
11439,
88004,
445,
9687,
39510,
18,
21324,
3975,
8883,
25,
3056,
3782,
740... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDivide3Members(t *testing.T) {
ctx := wasmsolo.NewSoloContext(t, dividend.ScName, dividend.OnLoad)
member1 := ctx.NewSoloAgent()
dividendMember(ctx, member1, 25)
require.NoError(t, ctx.Err)
member2 := ctx.NewSoloAgent()
dividendMember(ctx, member2, 50)
require.NoError(t, ctx.Err)
member3 := ctx.NewSoloAgent()
dividendMember(ctx, member3, 75)
require.NoError(t, ctx.Err)
require.EqualValues(t, 3, ctx.Balance(ctx.Account()))
dividendDivide(ctx, 97)
require.NoError(t, ctx.Err)
// 97 from divide() + 3 from the member() calls
require.EqualValues(t, solo.Saldo+16, member1.Balance())
require.EqualValues(t, solo.Saldo+33, member2.Balance())
require.EqualValues(t, solo.Saldo+50, member3.Balance())
// 1 remaining due to fractions
require.EqualValues(t, 1, ctx.Balance(ctx.Account()))
dividendDivide(ctx, 100)
require.NoError(t, ctx.Err)
// 100 from divide() + 1 remaining
require.EqualValues(t, solo.Saldo+16+16, member1.Balance())
require.EqualValues(t, solo.Saldo+33+33, member2.Balance())
require.EqualValues(t, solo.Saldo+50+50, member3.Balance())
// now we have 2 remaining due to fractions
require.EqualValues(t, 2, ctx.Balance(ctx.Account()))
dividendDivide(ctx, 100)
require.NoError(t, ctx.Err)
// 100 from divide() + 2 remaining
require.EqualValues(t, solo.Saldo+16+16+17, member1.Balance())
require.EqualValues(t, solo.Saldo+33+33+34, member2.Balance())
require.EqualValues(t, solo.Saldo+50+50+51, member3.Balance())
// managed to give every one an exact integer amount, so no remainder
require.EqualValues(t, 0, ctx.Balance(ctx.Account()))
} | explode_data.jsonl/31346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 621
} | [
2830,
3393,
12509,
577,
18,
24371,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
572,
1011,
10011,
7121,
89299,
1972,
1155,
11,
45880,
18326,
675,
11,
45880,
8071,
5879,
692,
2109,
1377,
16,
1669,
5635,
7121,
89299,
16810,
741,
63278,
6885... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJSONFieldTypes(t *testing.T) {
lgr, _ := logr.New()
filter := &logr.StdFilter{Lvl: logr.Error, Stacktrace: logr.Error}
formatter := &formatters.JSON{
DisableTimestamp: true,
DisableStacktrace: true,
}
t.Run("basic types", func(t *testing.T) {
buf := &test.Buffer{}
target := targets.NewWriterTarget(buf)
err := lgr.AddTarget(target, "basicTest", filter, formatter, 1000)
if err != nil {
t.Error(err)
}
logger := lgr.NewLogger()
logger.Error("Basic types test",
logr.String("f1", "one"),
logr.Int("f2", 77),
logr.Bool("f3", true),
logr.Float64("f4", 3.14),
logr.Err(errors.New("test error")),
)
err = lgr.Flush()
require.NoError(t, err)
want := NL(`{"level":"error","msg":"Basic types test","f1":"one","f2":77,"f3":true,"f4":3.14,"error":"test error"}`)
if strings.Compare(want, buf.String()) != 0 {
t.Errorf("JSON does not match: expected %s got %s", want, buf.String())
}
})
t.Run("time types", func(t *testing.T) {
buf := &test.Buffer{}
target := targets.NewWriterTarget(buf)
err := lgr.AddTarget(target, "timeTest", filter, formatter, 1000)
if err != nil {
t.Error(err)
}
logger := lgr.NewLogger()
now, _ := time.Parse(logr.DefTimestampFormat, "2021-05-16 22:23:10.989 -04:00")
millis := int64(1621218819966) // May 16, 2021 22:33:39.966
dur := (time.Hour * 1) + (time.Minute * 34) + (time.Second * 17) + (time.Millisecond * 230)
logger.Error("Time types test",
logr.Time("f1", now),
logr.Millis("f2", millis),
logr.Duration("f3", dur),
)
err = lgr.Flush()
require.NoError(t, err)
want := NL(`{"level":"error","msg":"Time types test","f1":"2021-05-16 22:23:10.989 -04:00","f2":"May 17 02:33:39.966","f3":"1h34m17.23s"}`)
if strings.Compare(want, buf.String()) != 0 {
t.Errorf("JSON does not match: expected %s got %s", want, buf.String())
}
})
t.Run("struct types", func(t *testing.T) {
buf := &test.Buffer{}
target := targets.NewWriterTarget(buf)
err := lgr.AddTarget(target, "structTest", filter, formatter, 1000)
if err != nil {
t.Error(err)
}
logger := lgr.NewLogger()
user := User{Name: "wiggin", Age: 13, Props: &Props{Key: "foo", Blap: 77}}
logger.Error("Struct types test",
logr.Any("f1", user),
logr.Any("f2", &user),
)
err = lgr.Flush()
require.NoError(t, err)
want := NL(`{"level":"error","msg":"Struct types test","f1":{"Name":"wiggin","Age":13,"Props":{"Key":"foo","Blap":77}},"f2":{"Name":"wiggin","Age":13,"Props":{"Key":"foo","Blap":77}}}`)
if strings.Compare(want, buf.String()) != 0 {
t.Errorf("JSON does not match: expected %s got %s", want, buf.String())
}
})
t.Run("array type", func(t *testing.T) {
buf := &test.Buffer{}
target := targets.NewWriterTarget(buf)
err := lgr.AddTarget(target, "arrayTest", filter, formatter, 1000)
if err != nil {
t.Error(err)
}
logger := lgr.NewLogger()
f1 := []int{2, 4, 6, 8}
f2 := []*User{
{Name: "wiggin", Age: 13, Props: &Props{Key: "foo", Blap: 77}},
{Name: "Jude", Age: 44, Props: &Props{Key: "foo", Blap: 78}},
}
logger.Error("Array test",
logr.Array("f1", f1),
logr.Array("f2", f2),
)
err = lgr.Flush()
require.NoError(t, err)
want := NL(`{"level":"error","msg":"Array test","f1":[2,4,6,8],"f2":[{"Name":"wiggin","Age":13,"Props":{"Key":"foo","Blap":77}},{"Name":"Jude","Age":44,"Props":{"Key":"foo","Blap":78}}]}`)
if strings.Compare(want, buf.String()) != 0 {
t.Errorf("JSON does not match: expected %s got %s", want, buf.String())
}
})
t.Run("map type", func(t *testing.T) {
buf := &test.Buffer{}
target := targets.NewWriterTarget(buf)
err := lgr.AddTarget(target, "mapTest", filter, formatter, 1000)
if err != nil {
t.Error(err)
}
logger := lgr.NewLogger()
f1 := map[string]int{"two": 2, "four": 4, "six": 6, "eight": 8}
f2 := map[string]*User{
"one": {Name: "wiggin", Age: 13, Props: &Props{Key: "foo", Blap: 77}},
"two": {Name: "Jude", Age: 44, Props: &Props{Key: "foo", Blap: 78}},
}
logger.Error("Array test",
logr.Map("f1", f1),
logr.Map("f2", f2),
)
err = lgr.Flush()
require.NoError(t, err)
want := NL(`{"level":"error","msg":"Array test","f1":{"eight":8,"four":4,"six":6,"two":2},"f2":{"one":{"Name":"wiggin","Age":13,"Props":{"Key":"foo","Blap":77}},"two":{"Name":"Jude","Age":44,"Props":{"Key":"foo","Blap":78}}}}`)
if strings.Compare(want, buf.String()) != 0 {
t.Errorf("JSON does not match: expected %s got %s", want, buf.String())
}
})
err := lgr.Shutdown()
require.NoError(t, err)
} | explode_data.jsonl/3407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1996
} | [
2830,
3393,
5370,
1877,
4173,
1155,
353,
8840,
836,
8,
341,
8810,
901,
11,
716,
1669,
1487,
81,
7121,
741,
50108,
1669,
609,
839,
81,
36086,
5632,
90,
43,
14536,
25,
1487,
81,
6141,
11,
14284,
15067,
25,
1487,
81,
6141,
532,
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 TestServerRequestNumAndTime(t *testing.T) {
n := uint64(0)
var connT time.Time
s := &Server{
Handler: func(ctx *RequestCtx) {
n++
if ctx.ConnRequestNum() != n {
t.Fatalf("unexpected request number: %d. Expecting %d", ctx.ConnRequestNum(), n)
}
if connT.IsZero() {
connT = ctx.ConnTime()
}
if ctx.ConnTime() != connT {
t.Fatalf("unexpected serve conn time: %s. Expecting %s", ctx.ConnTime(), connT)
}
},
}
rw := &readWriter{}
rw.r.WriteString("GET /foo1 HTTP/1.1\r\nHost: google.com\r\n\r\n")
rw.r.WriteString("GET /bar HTTP/1.1\r\nHost: google.com\r\n\r\n")
rw.r.WriteString("GET /baz HTTP/1.1\r\nHost: google.com\r\n\r\n")
ch := make(chan error)
go func() {
ch <- s.ServeConn(rw)
}()
select {
case err := <-ch:
if err != nil {
t.Fatalf("Unexpected error from serveConn: %s", err)
}
case <-time.After(100 * time.Millisecond):
t.Fatalf("timeout")
}
if n != 3 {
t.Fatalf("unexpected number of requests served: %d. Expecting %d", n, 3)
}
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, 200, string(defaultContentType), "")
} | explode_data.jsonl/73307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 497
} | [
2830,
3393,
5475,
1900,
4651,
3036,
1462,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
2622,
21,
19,
7,
15,
340,
2405,
4534,
51,
882,
16299,
198,
1903,
1669,
609,
5475,
515,
197,
197,
3050,
25,
2915,
7502,
353,
1900,
23684,
8,
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... | 4 |
func TestDeploy(t *testing.T) {
path := "github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd"
testDeploy(t, "example02", "0", path, false, false, true, "", nil, nil, nil)
testDeploy(t, "example02", "1.0", path, false, false, true, "", nil, nil, nil)
testDeploy(t, "example02", "1.0", path, false, false, false, "cannot get package for chaincode (example02:1.0)", nil, nil, nil)
testDeploy(t, "example02", "0", path, true, false, true, EmptyChaincodeNameErr("").Error(), nil, nil, nil)
testDeploy(t, "example02", "0", path, false, true, true, EmptyVersionErr("example02").Error(), nil, nil, nil)
testDeploy(t, "example02.go", "0", path, false, false, true, InvalidChaincodeNameErr("example02.go").Error(), nil, nil, nil)
testDeploy(t, "example02", "1{}0", path, false, false, true, InvalidVersionErr("1{}0").Error(), nil, nil, nil)
testDeploy(t, "example02", "0", path, true, true, true, EmptyChaincodeNameErr("").Error(), nil, nil, nil)
scc := New(NewMockProvider(), mockAclProvider)
scc.support = &lscc.MockSupport{}
stub := shim.NewMockStub("lscc", scc)
res := stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
res = stub.MockInvokeWithSignedProposal("1", [][]byte{[]byte("deploy")}, nil)
assert.NotEqual(t, int32(shim.OK), res.Status)
assert.Equal(t, "invalid number of arguments to lscc: 1", res.Message)
res = stub.MockInvokeWithSignedProposal("1", [][]byte{[]byte("deploy"), []byte(""), []byte("")}, nil)
assert.NotEqual(t, int32(shim.OK), res.Status)
assert.Equal(t, "invalid channel name: ", res.Message)
res = stub.MockInvokeWithSignedProposal("1", [][]byte{[]byte("deploy"), []byte("chain"), []byte("barf")}, nil)
assert.NotEqual(t, int32(shim.OK), res.Status)
assert.Equal(t, "unexpected EOF", res.Message)
testDeploy(t, "example02", "1.0", path, false, false, true, "", scc, stub, nil)
testDeploy(t, "example02", "1.0", path, false, false, true, "chaincode with name 'example02' already exists", scc, stub, nil)
scc = New(NewMockProvider(), mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
scc.support.(*lscc.MockSupport).GetInstantiationPolicyErr = errors.New("barf")
testDeploy(t, "example02", "1.0", path, false, false, true, "barf", scc, stub, nil)
scc = New(NewMockProvider(), mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
scc.support.(*lscc.MockSupport).CheckInstantiationPolicyErr = errors.New("barf")
testDeploy(t, "example02", "1.0", path, false, false, true, "barf", scc, stub, nil)
scc = New(NewMockProvider(), mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
// As the PrivateChannelData is disabled, the following error message is expected due to the presence of
// collectionConfigBytes in the stub.args
errMessage := InvalidArgsLenErr(7).Error()
testDeploy(t, "example02", "1.0", path, false, false, true, InvalidArgsLenErr(7).Error(), scc, stub, []byte("collections"))
// Enable PrivateChannelData
mocksccProvider := (&mscc.MocksccProviderFactory{
ApplicationConfigBool: true,
ApplicationConfigRv: &config.MockApplication{
CapabilitiesRv: &config.MockApplicationCapabilities{
PrivateChannelDataRv: true,
},
},
}).NewSystemChaincodeProvider().(*mscc.MocksccProviderImpl)
scc = New(mocksccProvider, mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
// As the PrivateChannelData is enabled and collectionConfigBytes is invalid, the following error
// message is expected.
errMessage = "invalid collection configuration supplied for chaincode example02:1.0"
testDeploy(t, "example02", "1.0", path, false, false, true, errMessage, scc, stub, []byte("invalid collection"))
// Should contain an entry for the chaincodeData only
assert.Equal(t, 1, len(stub.State))
_, ok := stub.State["example02"]
assert.Equal(t, true, ok)
collName1 := "mycollection1"
policyEnvelope := cauthdsl.SignedByAnyMember([]string{"SampleOrg"})
var requiredPeerCount, maximumPeerCount int32
requiredPeerCount = 1
maximumPeerCount = 2
coll1 := createCollectionConfig(collName1, policyEnvelope, requiredPeerCount, maximumPeerCount)
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{coll1}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
scc = New(mocksccProvider, mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
// As the PrivateChannelData is enabled and collectionConfigBytes is valid, no error is expected
testDeploy(t, "example02", "1.0", path, false, false, true, "", scc, stub, ccpBytes)
// Should contain two entries: one for the chaincodeData and another for the collectionConfigBytes
assert.Equal(t, 2, len(stub.State))
_, ok = stub.State["example02"]
assert.Equal(t, true, ok)
actualccpBytes, ok := stub.State["example02~collection"]
assert.Equal(t, true, ok)
assert.Equal(t, ccpBytes, actualccpBytes)
scc = New(mocksccProvider, mockAclProvider)
scc.support = &lscc.MockSupport{}
stub = shim.NewMockStub("lscc", scc)
res = stub.MockInit("1", nil)
assert.Equal(t, int32(shim.OK), res.Status, res.Message)
// As the PrivateChannelData is enabled and collectionConfigBytes is nil, no error is expected
testDeploy(t, "example02", "1.0", path, false, false, true, "", scc, stub, []byte("nil"))
// Should contain an entry for the chaincodeData only. As the collectionConfigBytes is nil, it
// is ignored
assert.Equal(t, 1, len(stub.State))
_, ok = stub.State["example02"]
assert.Equal(t, true, ok)
} | explode_data.jsonl/46556 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2246
} | [
2830,
3393,
69464,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
330,
5204,
905,
7530,
39252,
50704,
6663,
28897,
67020,
14,
8819,
1851,
25525,
65182,
15,
17,
83033,
1837,
18185,
69464,
1155,
11,
330,
8687,
15,
17,
497,
330,
15,
497,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPublish(t *testing.T) {
var gotname string
var gotv expvar.Var
clear()
Register(func(name string, v expvar.Var) {
gotname = name
gotv = v.(*Mystr)
})
v := Mystr("abcd")
Publish("Mystr", &v)
if gotname != "Mystr" {
t.Errorf("want Mystr, got %s", gotname)
}
if gotv != &v {
t.Errorf("want %#v, got %#v", &v, gotv)
}
} | explode_data.jsonl/43069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
50145,
1155,
353,
8840,
836,
8,
341,
2405,
2684,
606,
914,
198,
2405,
2684,
85,
1343,
947,
87968,
198,
40408,
741,
79096,
18552,
3153,
914,
11,
348,
1343,
947,
87968,
8,
341,
197,
3174,
354,
606,
284,
829,
198,
197,
3174... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSnmpInit_noName_noOid(t *testing.T) {
s := &Snmp{
Tables: []Table{
{Fields: []Field{
{Oid: ".1.1.1.4", Name: "four", IsTag: true},
{Oid: ".1.1.1.5", Name: "five"},
{Oid: ".1.1.1.6"},
}},
},
}
err := s.Init()
require.Error(t, err)
} | explode_data.jsonl/50783 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
20720,
1307,
3803,
6536,
675,
6536,
46,
307,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
609,
20720,
1307,
515,
197,
197,
21670,
25,
3056,
2556,
515,
298,
197,
90,
8941,
25,
3056,
1877,
515,
571,
197,
90,
46,
307,
25,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecompressStreamXz(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Xz not present in msys2")
}
testDecompressStream(t, "xz", "xz -f")
} | explode_data.jsonl/79222 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
4900,
316,
1873,
3027,
55,
89,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
445,
55,
89,
537,
3042,
304,
296,
7791,
17,
1138,
197,
532,
18185,
4900,
316,
1873,
3027,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatter_PrintLog(t *testing.T) {
g := NewWithT(t)
firstMsg := diag.NewMessage(
diag.NewMessageType(diag.Error, "B1", "Explosion accident: %v"),
diag.MockResource("SoapBubble"),
"the bubble is too big",
)
secondMsg := diag.NewMessage(
diag.NewMessageType(diag.Warning, "C1", "Collapse danger: %v"),
diag.MockResource("GrandCastle"),
"the castle is too old",
)
msgs := diag.Messages{firstMsg, secondMsg}
output, _ := Print(msgs, LogFormat, false)
g.Expect(output).To(Equal(
"Error [B1] (SoapBubble) Explosion accident: the bubble is too big\n" +
"Warning [C1] (GrandCastle) Collapse danger: the castle is too old",
))
} | explode_data.jsonl/54029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
14183,
45788,
2201,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
2354,
51,
1155,
692,
42190,
6611,
1669,
39717,
7121,
2052,
1006,
197,
2698,
72,
351,
7121,
82107,
55493,
351,
6141,
11,
330,
33,
16,
497,
330,
8033,
40455... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_GetAdvisories(t *testing.T) {
type args struct {
source string
pkgName string
}
tests := []struct {
name string
args args
fixtures []string
want []types.Advisory
wantErr string
}{
{
name: "os package advisories",
args: args{
source: "Red Hat Enterprise Linux 8",
pkgName: "bind",
},
fixtures: []string{"testdata/fixtures/ospkg.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2018-5745",
FixedVersion: "32:9.11.4-26.P2.el8",
},
{
VulnerabilityID: "CVE-2020-8617",
FixedVersion: "32:9.11.13-5.el8_2",
},
},
},
{
name: "library advisories",
args: args{
source: "GitHub Security Advisory Composer",
pkgName: "symfony/symfony",
},
fixtures: []string{"testdata/fixtures/single-bucket.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2019-10909",
PatchedVersions: []string{"4.2.7", "3.4.26"},
VulnerableVersions: []string{">= 4.2.0, < 4.2.7", ">= 3.0.0, < 3.4.26"},
},
{
VulnerabilityID: "CVE-2019-18889",
PatchedVersions: []string{"4.3.8", "3.4.35"},
VulnerableVersions: []string{">= 4.3.0, < 4.3.8", ">= 3.1.0, < 3.4.35"},
},
},
},
{
name: "prefix scan",
args: args{
source: "composer::",
pkgName: "symfony/symfony",
},
fixtures: []string{"testdata/fixtures/multiple-buckets.yaml"},
want: []types.Advisory{
{
VulnerabilityID: "CVE-2019-10909",
PatchedVersions: []string{"4.2.7"},
VulnerableVersions: []string{">= 4.2.0, < 4.2.7"},
},
{
VulnerabilityID: "CVE-2020-5275",
VulnerableVersions: []string{">= 4.4.0, < 4.4.7"},
},
},
},
{
name: "non-existent bucket",
args: args{
source: "non-existent",
pkgName: "symfony/symfony",
},
fixtures: []string{"testdata/fixtures/single-bucket.yaml"},
},
{
name: "non-existent package",
args: args{
source: "GitHub Security Advisory Composer",
pkgName: "non-existent",
},
fixtures: []string{"testdata/fixtures/single-bucket.yaml"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Initialize DB
dbtest.InitDB(t, tt.fixtures)
defer db.Close()
dbc := db.Config{}
got, err := dbc.GetAdvisories(tt.args.source, tt.args.pkgName)
switch {
case tt.wantErr != "":
require.NotNil(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
default:
assert.NoError(t, err)
}
// Compare
assert.ElementsMatch(t, tt.want, got)
})
}
} | explode_data.jsonl/72885 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1277
} | [
2830,
3393,
2648,
13614,
2589,
2682,
2433,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
47418,
220,
914,
198,
197,
3223,
7351,
675,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
31215,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterfaces(t *testing.T) {
_ = (buf.Reader)(new(Reader))
_ = (buf.TimeoutReader)(new(Reader))
_ = (common.Interruptible)(new(Reader))
_ = (common.Interruptible)(new(Writer))
_ = (common.Closable)(new(Writer))
} | explode_data.jsonl/988 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
41066,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
320,
5909,
47431,
2376,
931,
7,
5062,
1171,
197,
62,
284,
320,
5909,
63977,
5062,
2376,
931,
7,
5062,
4390,
197,
62,
284,
320,
5464,
7371,
10579,
1238,
2376,
931,
7,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExceptionsWithInvalidSql(t *testing.T) {
var columns []string
if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
t.Errorf("Should got error with invalid SQL")
}
if DB.Model(&User{}).Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
t.Errorf("Should got error with invalid SQL")
}
if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Find(&User{}).Error == nil {
t.Errorf("Should got error with invalid SQL")
}
var count1, count2 int64
DB.Model(&User{}).Count(&count1)
if count1 <= 0 {
t.Errorf("Should find some users")
}
if DB.Where("name = ?", "jinzhu; delete * from users").First(&User{}).Error == nil {
t.Errorf("Should got error with invalid SQL")
}
DB.Model(&User{}).Count(&count2)
if count1 != count2 {
t.Errorf("No user should not be deleted by invalid SQL")
}
} | explode_data.jsonl/28035 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
1354,
16056,
7928,
8269,
1155,
353,
8840,
836,
8,
341,
2405,
8147,
3056,
917,
198,
743,
5952,
17067,
445,
82,
5356,
67,
3938,
32646,
284,
42313,
330,
13446,
36328,
5305,
1827,
2120,
1942,
445,
32646,
497,
609,
16369,
568,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJvKind(t *testing.T) {
table := []struct {
testName string
*jq.Jv
jq.JvKind
stringKind string
}{
{"Null", jq.JvNull(), jq.JvKindNull, "null"},
{"FromString", jq.JvFromString("a"), jq.JvKindString, "string"},
}
for _, tt := range table {
t.Run(tt.testName, func(t *testing.T) {
defer tt.Free()
if tt.Kind() != tt.JvKind {
t.Errorf("JvKind() got: %v, want: %v", tt.Kind(), tt.JvKind)
}
if tt.Kind().String() != tt.stringKind {
t.Errorf("JvKind().String() got: %s, want: %s", tt.Kind().String(), tt.stringKind)
}
})
}
} | explode_data.jsonl/38753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
41,
85,
10629,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
3056,
1235,
341,
197,
18185,
675,
914,
198,
197,
197,
9,
43915,
3503,
85,
198,
197,
12428,
80,
3503,
85,
10629,
198,
197,
11357,
10629,
914,
198,
197,
59403,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestInterceptorBatchGetTemporaryTableKeys(t *testing.T) {
localTempTableData := []*kv.Entry{
{Key: encodeTableKey(5), Value: []byte("v5")},
{Key: encodeTableKey(5, 0), Value: []byte("v50")},
{Key: encodeTableKey(5, 1), Value: []byte("v51")},
{Key: encodeTableKey(5, 0, 1), Value: []byte("v501")},
{Key: encodeTableKey(5, 2), Value: []byte("")},
{Key: encodeTableKey(5, 3), Value: nil},
{Key: encodeTableKey(8), Value: []byte("v8")},
{Key: encodeTableKey(8, 0), Value: []byte("v80")},
{Key: encodeTableKey(8, 1), Value: []byte("v81")},
{Key: encodeTableKey(8, 0, 1), Value: []byte("v801")},
{Key: encodeTableKey(8, 2), Value: []byte("")},
{Key: encodeTableKey(8, 3), Value: nil},
}
is := newMockedInfoSchema(t).
AddTable(model.TempTableNone, 1, 4).
AddTable(model.TempTableGlobal, 3, 6).
AddTable(model.TempTableLocal, 5, 8)
retriever := newMockedRetriever(t).SetAllowedMethod("Get").SetData(localTempTableData)
interceptor := NewTemporaryTableSnapshotInterceptor(is, retriever)
emptyRetrieverInterceptor := NewTemporaryTableSnapshotInterceptor(is, nil)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
cases := []struct {
keys []kv.Key
snapKeys []kv.Key
nilSession bool
result map[string][]byte
}{
{
keys: nil,
snapKeys: nil,
result: nil,
},
{
keys: []kv.Key{
encodeTableKey(3),
encodeTableKey(3, 1),
encodeTableKey(6),
},
snapKeys: nil,
result: nil,
},
{
keys: []kv.Key{
encodeTableKey(3),
encodeTableKey(5, 'n'),
},
snapKeys: nil,
result: nil,
},
{
keys: []kv.Key{
encodeTableKey(5, 'n'),
},
snapKeys: nil,
result: nil,
},
{
keys: []kv.Key{
encodeTableKey(0),
encodeTableKey(1),
encodeTableKey(2),
encodeTableKey(math.MaxInt64),
tablecodec.TablePrefix(),
kv.Key("s"),
kv.Key("v"),
},
snapKeys: []kv.Key{
encodeTableKey(0),
encodeTableKey(1),
encodeTableKey(2),
encodeTableKey(math.MaxInt64),
tablecodec.TablePrefix(),
kv.Key("s"),
kv.Key("v"),
},
result: nil,
},
{
keys: []kv.Key{
encodeTableKey(5),
encodeTableKey(5, 2),
encodeTableKey(5, 'n'),
encodeTableKey(8, 1),
},
snapKeys: nil,
result: map[string][]byte{
string(encodeTableKey(5)): []byte("v5"),
string(encodeTableKey(8, 1)): []byte("v81"),
},
},
{
keys: []kv.Key{
encodeTableKey(5),
encodeTableKey(1),
encodeTableKey(5, 'n'),
encodeTableKey(8, 1),
},
snapKeys: []kv.Key{encodeTableKey(1)},
result: map[string][]byte{
string(encodeTableKey(5)): []byte("v5"),
string(encodeTableKey(8, 1)): []byte("v81"),
},
},
{
keys: []kv.Key{
tablecodec.TablePrefix(),
encodeTableKey(5),
encodeTableKey(1),
encodeTableKey(5, 2),
encodeTableKey(5, 'n'),
encodeTableKey(8, 1),
},
snapKeys: []kv.Key{tablecodec.TablePrefix(), encodeTableKey(1)},
result: map[string][]byte{
string(encodeTableKey(5)): []byte("v5"),
string(encodeTableKey(8, 1)): []byte("v81"),
},
},
{
keys: []kv.Key{
tablecodec.TablePrefix(),
encodeTableKey(5),
encodeTableKey(1),
encodeTableKey(5, 2),
encodeTableKey(5, 'n'),
encodeTableKey(8, 1),
},
snapKeys: []kv.Key{tablecodec.TablePrefix(), encodeTableKey(1)},
nilSession: true,
result: nil,
},
}
for i, c := range cases {
inter := interceptor
if c.nilSession {
inter = emptyRetrieverInterceptor
}
snapKeys, result, err := inter.batchGetTemporaryTableKeys(ctx, c.keys)
require.NoError(t, err, i)
if c.snapKeys == nil {
require.Nil(t, snapKeys, i)
} else {
require.Equal(t, c.snapKeys, snapKeys, i)
}
if c.result == nil {
require.Nil(t, result, i)
} else {
require.Equal(t, c.result, result, i)
}
if c.nilSession {
require.Equal(t, 0, len(retriever.GetInvokes()))
}
for j, invoke := range retriever.GetInvokes() {
require.Equal(t, "Get", invoke.Method, "%d, %d", i, j)
require.Equal(t, ctx, invoke.Args[0], "%d, %d", i, j)
}
retriever.ResetInvokes()
}
// test for error occurs
injectedErr := errors.New("err")
retriever.InjectMethodError("Get", injectedErr)
snapKeys, result, err := interceptor.batchGetTemporaryTableKeys(ctx, []kv.Key{
tablecodec.TablePrefix(),
encodeTableKey(5),
encodeTableKey(1),
encodeTableKey(5, 'n'),
encodeTableKey(8, 1),
})
require.Nil(t, snapKeys)
require.Nil(t, result)
require.Equal(t, injectedErr, err)
retriever.ResetInvokes()
} | explode_data.jsonl/13203 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2165
} | [
2830,
3393,
32786,
21074,
1949,
59362,
2556,
8850,
1155,
353,
8840,
836,
8,
341,
8854,
12151,
2556,
1043,
1669,
29838,
43408,
22330,
515,
197,
197,
90,
1592,
25,
16164,
2556,
1592,
7,
20,
701,
5162,
25,
3056,
3782,
445,
85,
20,
79583,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetHistoricCandlesExtended(t *testing.T) {
t.Parallel()
currencyPair, err := currency.NewPairFromString("BTC/USD")
if err != nil {
t.Fatal(err)
}
start := time.Date(2019, 11, 12, 0, 0, 0, 0, time.UTC)
end := start.AddDate(0, 0, 2)
_, err = f.GetHistoricCandlesExtended(context.Background(),
currencyPair, asset.Spot, start, end, kline.OneDay)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/15233 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
1949,
48983,
292,
34,
20125,
53190,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1444,
5088,
12443,
11,
1848,
1669,
11413,
7121,
12443,
44491,
445,
59118,
14,
26749,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.