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 TestRefractiveComputations(t *testing.T) {
A := primitives.NewGlassSphere(algebra.ScalingMatrix(2, 2, 2), 1.5)
B := primitives.NewGlassSphere(algebra.TranslationMatrix(0, 0, -0.25), 2.0)
C := primitives.NewGlassSphere(algebra.TranslationMatrix(0, 0, 0.25), 2.5)
r := algebra.NewRay(0, 0, -4, 0, 0, 1)
xs := primitives.NewIntersections()
i1 := primitives.NewIntersection(A, 2)
i2 := primitives.NewIntersection(B, 2.75)
i3 := primitives.NewIntersection(C, 3.25)
i4 := primitives.NewIntersection(B, 4.75)
i5 := primitives.NewIntersection(C, 5.25)
i6 := primitives.NewIntersection(A, 6)
xs.GetHits().PushAll(i1, i2, i3, i4, i5, i6)
comps := PrepareComputations(i1, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 1.0, 1.5)
comps = PrepareComputations(i2, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 1.5, 2.0)
comps = PrepareComputations(i3, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 2.0, 2.5)
comps = PrepareComputations(i4, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 2.5, 2.5)
comps = PrepareComputations(i5, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 2.5, 1.5)
comps = PrepareComputations(i6, r, xs)
testRefractiveIndexes(t, comps.N1, comps.N2, 1.5, 1.0)
} | explode_data.jsonl/27654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 559
} | [
2830,
3393,
693,
1626,
3028,
58022,
804,
1155,
353,
8840,
836,
8,
341,
22985,
1669,
71194,
7121,
84003,
42959,
17643,
26083,
808,
81552,
6689,
7,
17,
11,
220,
17,
11,
220,
17,
701,
220,
16,
13,
20,
340,
12791,
1669,
71194,
7121,
840... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadStats(t *testing.T) {
rootDir, err := ioutil.TempDir("", "test")
if err != nil {
t.Fatalf("creating temp dir %v", err)
}
defer os.RemoveAll(rootDir) // clean up
procDir := filepath.Join(rootDir, "proc")
if err := os.Mkdir(procDir, 0755); err != nil {
t.Fatalf("Mkdir(%s) failed: %v", procDir, err)
}
if err := ioutil.WriteFile(filepath.Join(procDir, "interrupts"), []byte(fakeInterrupts), 0644); err != nil {
t.Fatalf("WriteFile failed: %v", err)
}
ih := irqs.New(nullLog, procDir)
counters, err := ih.ReadStats()
if err != nil {
t.Errorf("ReadStats(%s) failed: %v", procDir, err)
}
var irqTestCases = []struct {
cpuIdx int
irqName string
value uint64
}{
// some random non-zero values from the fakeInterrupts below.
// any non-zero value is fine, no special meaning.
{0, "131", 3949116},
{0, "LOC", 14926901},
{1, "139", 21},
{1, "LOC", 16283403},
{2, "125", 12356620},
{2, "LOC", 14699417},
{3, "12", 713},
{3, "LOC", 15519974},
// now some zero values. Same criteria as above.
{0, "120", 0},
{1, "120", 0},
{2, "120", 0},
{3, "120", 0},
}
for _, tt := range irqTestCases {
t.Run(fmt.Sprintf("cpu %d irq %q", tt.cpuIdx, tt.irqName), func(t *testing.T) {
v := counters[tt.cpuIdx][tt.irqName]
if v != tt.value {
t.Errorf("Counters mismatch got %v expected %v", v, tt.value)
}
})
}
} | explode_data.jsonl/66198 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 627
} | [
2830,
3393,
4418,
16635,
1155,
353,
8840,
836,
8,
341,
33698,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
1944,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
44902,
2730,
5419,
1018,
85,
497,
1848,
340,
197,
532,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPodInvalidResponseType(t *testing.T) {
t.Parallel()
ms, ctrl, pod, executor := setup(t)
defer ctrl.Finish()
// Expectations
ms.EXPECT().GetPodFlag(pod, events.PodCreatePodResponse).Return(42, nil)
// Run code under test
out, err := executor(events.PodCreatePodResponse)
// Assert
assert.Error(t, err)
assert.False(t, IsExpected(err))
assert.Nil(t, out)
} | explode_data.jsonl/35142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
23527,
7928,
53388,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
47691,
11,
23743,
11,
7509,
11,
31558,
1669,
6505,
1155,
340,
16867,
23743,
991,
18176,
2822,
197,
322,
32085,
804,
198,
47691,
22402,
7285,
1005,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAgent_NodeMaintenance_Disable(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
// Force the node into maintenance mode
a.EnableNodeMaintenance("", "")
// Leave maintenance mode
req, _ := http.NewRequest("PUT", "/v1/agent/self/maintenance?enable=false", nil)
resp := httptest.NewRecorder()
if _, err := a.srv.AgentNodeMaintenance(resp, req); err != nil {
t.Fatalf("err: %s", err)
}
if resp.Code != 200 {
t.Fatalf("expected 200, got %d", resp.Code)
}
// Ensure the maintenance check was removed
if _, ok := a.State.Checks()[structs.NodeMaint]; ok {
t.Fatalf("should have removed maintenance check")
}
} | explode_data.jsonl/33644 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
16810,
41340,
92735,
45525,
480,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
14676,
16867,
264,
10849,
18452,
2822,
197,
322,
11732,
279,
2436,
1119,
13404,
3856,
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... | 4 |
func TestDefaultAllowPrivilegeEscalationForPodSecurityPolicy(t *testing.T) {
psp := &extensionsv1beta1.PodSecurityPolicy{}
output := roundTrip(t, runtime.Object(psp))
psp2 := output.(*extensionsv1beta1.PodSecurityPolicy)
if psp2.Spec.AllowPrivilegeEscalation == nil || *psp2.Spec.AllowPrivilegeEscalation != true {
t.Errorf("Expected default to true, got: %#v", psp2.Spec.AllowPrivilegeEscalation)
}
} | explode_data.jsonl/53703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
3675,
18605,
32124,
42769,
36121,
278,
367,
2461,
23527,
15352,
13825,
1155,
353,
8840,
836,
8,
341,
35009,
79,
1669,
609,
27609,
85,
16,
19127,
16,
88823,
15352,
13825,
16094,
21170,
1669,
4778,
56352,
1155,
11,
15592,
8348,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransactionRollbackReal(t *testing.T) {
// Insert by specifying values
s := createRealSessionWithFixtures(t, nil)
defer testCloser(t, s)
tx, err := s.BeginTx(context.TODO(), nil)
assert.NoError(t, err)
var person dmlPerson
_, err = tx.WithQueryBuilder(NewSelect("*").From("dml_people").Where(Column("email").PlaceHolder())).Load(context.TODO(), &person, "SirGeorge@GoIsland.com")
assert.NoError(t, err)
assert.Exactly(t, "Sir George", person.Name)
err = tx.Rollback()
assert.NoError(t, err)
} | explode_data.jsonl/11093 | {
"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,
8070,
32355,
1419,
12768,
1155,
353,
8840,
836,
8,
341,
197,
322,
17101,
553,
37838,
2750,
198,
1903,
1669,
1855,
12768,
5283,
2354,
25958,
18513,
1155,
11,
2092,
340,
16867,
1273,
51236,
799,
1155,
11,
274,
692,
46237,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBasePathStripping(t *testing.T) {
envSpec := createAuthEnvSpec()
specExt, err := config.NewEnvironmentSpecExt(&envSpec)
if err != nil {
t.Fatalf("%v", err)
}
environmentSpecsByID := map[string]*config.EnvironmentSpecExt{
specExt.ID: specExt,
}
testAuthMan := &testAuthMan{}
testAuthMan.sendAuth(&auth.Context{
APIProducts: []string{"product1"},
}, nil)
testQuotaMan := &testQuotaMan{}
testAnalyticsMan := &testAnalyticsMan{}
privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
t.Fatal(err)
}
jwtClaims := map[string]interface{}{
"iss": "issuer",
"aud": []string{"aud1", "aud2"},
}
jwtString, err := testutil.GenerateJWT(privateKey, jwtClaims)
if err != nil {
t.Fatalf("generateJWT() failed: %v", err)
}
headers := map[string]string{
"jwt": jwtString,
}
uri := "/v1/petstore?x-api-key=foo"
contextExtensions := map[string]string{
envSpecContextKey: specExt.ID,
}
tests := []struct {
desc string
opConfigType string
path string
}{
{
desc: "base path stripped for proxy mode",
opConfigType: "proxy",
path: "/petstore",
},
{
desc: "base path stripped by default",
path: "/petstore",
},
{
desc: "base path stripped for remoteservice mode",
opConfigType: "remoteservice",
path: "/petstore",
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
testProductMan := &testProductMan{
api: "api",
resolve: true,
products: product.ProductsNameMap{
"product1": &product.APIProduct{
DisplayName: "product1",
},
},
path: test.path,
}
server := AuthorizationServer{
handler: &Handler{
authMan: testAuthMan,
productMan: testProductMan,
quotaMan: testQuotaMan,
analyticsMan: testAnalyticsMan,
envSpecsByID: environmentSpecsByID,
operationConfigType: test.opConfigType,
ready: util.NewAtomicBool(true),
},
}
req := testutil.NewEnvoyRequest("GET", uri, headers, nil)
req.Attributes.ContextExtensions = contextExtensions
resp, err := server.Check(context.Background(), req)
if err != nil {
t.Errorf("should not get error. got: %s", err)
}
if resp.Status.Code != int32(rpc.OK) {
t.Errorf("expected status code OK, got %d", resp.Status.Code)
}
})
}
} | explode_data.jsonl/73191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1071
} | [
2830,
3393,
3978,
1820,
2580,
5654,
1155,
353,
8840,
836,
8,
341,
57538,
8327,
1669,
1855,
5087,
14359,
8327,
741,
98100,
6756,
11,
1848,
1669,
2193,
7121,
12723,
8327,
6756,
2099,
3160,
8327,
340,
743,
1848,
961,
2092,
341,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNoneDeleteRecord(t *testing.T) {
noneReset()
err := cache.DeleteRecord("nanopack.io")
if err != nil {
t.Errorf("Failed to delete record from none cacher - %v", err)
}
} | explode_data.jsonl/60815 | {
"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,
4064,
6435,
6471,
1155,
353,
8840,
836,
8,
341,
197,
6697,
14828,
741,
9859,
1669,
6500,
18872,
6471,
445,
18759,
453,
473,
4245,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
9408,
311,
3698,
3255,
504,
6857,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestSketchBookPSDFail(t *testing.T) {
// https://github.com/oov/psd/issues/3
Debug = &testLogger{t}
testOne(testImage{
Name: "PSD(Autodesk SketchBook)",
PSD: "sketchbook.psd",
}, t)
} | explode_data.jsonl/50816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
75288,
7134,
5012,
5262,
604,
1155,
353,
8840,
836,
8,
341,
197,
322,
3703,
1110,
5204,
905,
20271,
859,
14,
1690,
67,
38745,
14,
18,
198,
34424,
284,
609,
1944,
7395,
90,
83,
532,
18185,
3966,
8623,
1906,
515,
197,
2129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseMovingVariableDeclarationWithTypeAnnotation(t *testing.T) {
t.Parallel()
result, errs := ParseProgram(`
let x: @R <- y
`)
require.Empty(t, errs)
utils.AssertEqualWithDiff(t,
[]ast.Declaration{
&ast.VariableDeclaration{
IsConstant: true,
Identifier: ast.Identifier{
Identifier: "x",
Pos: ast.Position{Offset: 13, Line: 2, Column: 12},
},
TypeAnnotation: &ast.TypeAnnotation{
IsResource: true,
Type: &ast.NominalType{
Identifier: ast.Identifier{
Identifier: "R",
Pos: ast.Position{Offset: 17, Line: 2, Column: 16},
},
},
StartPos: ast.Position{Offset: 16, Line: 2, Column: 15},
},
Value: &ast.IdentifierExpression{
Identifier: ast.Identifier{
Identifier: "y",
Pos: ast.Position{Offset: 22, Line: 2, Column: 21},
},
},
Transfer: &ast.Transfer{
Operation: ast.TransferOperationMove,
Pos: ast.Position{Offset: 19, Line: 2, Column: 18},
},
StartPos: ast.Position{Offset: 9, Line: 2, Column: 8},
},
},
result.Declarations(),
)
} | explode_data.jsonl/35994 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 521
} | [
2830,
3393,
14463,
39732,
7827,
24489,
73716,
19711,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
9559,
11,
70817,
1669,
14775,
10690,
61528,
286,
1077,
856,
25,
569,
49,
9119,
379,
198,
197,
24183,
17957,
11180,
1155,
11,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHeadDeleteSimple(t *testing.T) {
buildSmpls := func(s []int64) []sample {
ss := make([]sample, 0, len(s))
for _, t := range s {
ss = append(ss, sample{t: t, v: float64(t)})
}
return ss
}
smplsAll := buildSmpls([]int64{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
lblDefault := labels.Label{"a", "b"}
cases := []struct {
dranges Intervals
smplsExp []sample
}{
{
dranges: Intervals{{0, 3}},
smplsExp: buildSmpls([]int64{4, 5, 6, 7, 8, 9}),
},
{
dranges: Intervals{{1, 3}},
smplsExp: buildSmpls([]int64{0, 4, 5, 6, 7, 8, 9}),
},
{
dranges: Intervals{{1, 3}, {4, 7}},
smplsExp: buildSmpls([]int64{0, 8, 9}),
},
{
dranges: Intervals{{1, 3}, {4, 700}},
smplsExp: buildSmpls([]int64{0}),
},
{ // This case is to ensure that labels and symbols are deleted.
dranges: Intervals{{0, 9}},
smplsExp: buildSmpls([]int64{}),
},
}
Outer:
for _, c := range cases {
dir, err := ioutil.TempDir("", "test_wal_reload")
testutil.Ok(t, err)
defer func() {
testutil.Ok(t, os.RemoveAll(dir))
}()
w, err := wal.New(nil, nil, path.Join(dir, "wal"))
testutil.Ok(t, err)
defer w.Close()
head, err := NewHead(nil, nil, w, 1000)
testutil.Ok(t, err)
defer head.Close()
app := head.Appender()
for _, smpl := range smplsAll {
_, err = app.Add(labels.Labels{lblDefault}, smpl.t, smpl.v)
testutil.Ok(t, err)
}
testutil.Ok(t, app.Commit())
// Delete the ranges.
for _, r := range c.dranges {
testutil.Ok(t, head.Delete(r.Mint, r.Maxt, labels.NewEqualMatcher(lblDefault.Name, lblDefault.Value)))
}
// Compare the samples for both heads - before and after the reload.
reloadedW, err := wal.New(nil, nil, w.Dir()) // Use a new wal to ensure deleted samples are gone even after a reload.
testutil.Ok(t, err)
defer reloadedW.Close()
reloadedHead, err := NewHead(nil, nil, reloadedW, 1000)
testutil.Ok(t, err)
defer reloadedHead.Close()
testutil.Ok(t, reloadedHead.Init(0))
for _, h := range []*Head{head, reloadedHead} {
indexr, err := h.Index()
testutil.Ok(t, err)
// Use an emptyTombstoneReader explicitly to get all the samples.
css, err := LookupChunkSeries(indexr, emptyTombstoneReader, labels.NewEqualMatcher(lblDefault.Name, lblDefault.Value))
testutil.Ok(t, err)
// Getting the actual samples.
actSamples := make([]sample, 0)
for css.Next() {
lblsAct, chkMetas, intv := css.At()
testutil.Equals(t, labels.Labels{lblDefault}, lblsAct)
testutil.Equals(t, 0, len(intv))
chunkr, err := h.Chunks()
testutil.Ok(t, err)
for _, meta := range chkMetas {
chk, err := chunkr.Chunk(meta.Ref)
testutil.Ok(t, err)
ii := chk.Iterator()
for ii.Next() {
t, v := ii.At()
actSamples = append(actSamples, sample{t: t, v: v})
}
}
}
testutil.Ok(t, css.Err())
testutil.Equals(t, c.smplsExp, actSamples)
}
// Compare the query results for both heads - before and after the reload.
expSeriesSet := newMockSeriesSet([]Series{
newSeries(map[string]string{lblDefault.Name: lblDefault.Value}, func() []tsdbutil.Sample {
ss := make([]tsdbutil.Sample, 0, len(c.smplsExp))
for _, s := range c.smplsExp {
ss = append(ss, s)
}
return ss
}(),
),
})
for _, h := range []*Head{head, reloadedHead} {
q, err := NewBlockQuerier(h, h.MinTime(), h.MaxTime())
testutil.Ok(t, err)
actSeriesSet, err := q.Select(labels.NewEqualMatcher(lblDefault.Name, lblDefault.Value))
testutil.Ok(t, err)
lns, err := q.LabelNames()
testutil.Ok(t, err)
lvs, err := q.LabelValues(lblDefault.Name)
testutil.Ok(t, err)
// When all samples are deleted we expect that no labels should exist either.
if len(c.smplsExp) == 0 {
testutil.Equals(t, 0, len(lns))
testutil.Equals(t, 0, len(lvs))
testutil.Assert(t, actSeriesSet.Next() == false, "")
testutil.Ok(t, h.Close())
continue
} else {
testutil.Equals(t, 1, len(lns))
testutil.Equals(t, 1, len(lvs))
testutil.Equals(t, lblDefault.Name, lns[0])
testutil.Equals(t, lblDefault.Value, lvs[0])
}
for {
eok, rok := expSeriesSet.Next(), actSeriesSet.Next()
testutil.Equals(t, eok, rok)
if !eok {
testutil.Ok(t, h.Close())
continue Outer
}
expSeries := expSeriesSet.At()
actSeries := actSeriesSet.At()
testutil.Equals(t, expSeries.Labels(), actSeries.Labels())
smplExp, errExp := expandSeriesIterator(expSeries.Iterator())
smplRes, errRes := expandSeriesIterator(actSeries.Iterator())
testutil.Equals(t, errExp, errRes)
testutil.Equals(t, smplExp, smplRes)
}
}
}
} | explode_data.jsonl/38162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2134
} | [
2830,
3393,
12346,
6435,
16374,
1155,
353,
8840,
836,
8,
341,
69371,
10673,
56986,
1669,
2915,
1141,
3056,
396,
21,
19,
8,
3056,
13611,
341,
197,
34472,
1669,
1281,
10556,
13611,
11,
220,
15,
11,
2422,
1141,
1171,
197,
2023,
8358,
259... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRaceConditions(t *testing.T) {
nClients := 10
// Generate random conns
genConns := func(n uint32) []ConnectionStats {
conns := make([]ConnectionStats, 0, n)
for i := uint32(0); i < n; i++ {
conns = append(conns, ConnectionStats{
Pid: 1 + i,
Type: TCP,
Family: AFINET,
Source: util.AddressFromString("127.0.0.1"),
Dest: util.AddressFromString("127.0.0.1"),
SPort: uint16(rand.Int()),
DPort: uint16(rand.Int()),
MonotonicSentBytes: uint64(rand.Int()),
MonotonicRecvBytes: uint64(rand.Int()),
MonotonicRetransmits: uint32(rand.Int()),
})
}
return conns
}
state := NewDefaultNetworkState()
nConns := uint32(100)
var wg sync.WaitGroup
wg.Add(nClients)
// Spawn multiple clients to get multiple times
for i := 1; i <= nClients; i++ {
go func(c string) {
defer wg.Done()
defer state.RemoveClient(c)
timer := time.NewTimer(1 * time.Second)
for {
select {
case <-timer.C:
return
default:
state.Connections(c, latestEpochTime(), genConns(nConns))
}
}
}(fmt.Sprintf("%d", i))
}
wg.Wait()
} | explode_data.jsonl/22148 | {
"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,
55991,
35435,
1155,
353,
8840,
836,
8,
341,
9038,
47174,
1669,
220,
16,
15,
271,
197,
322,
19813,
4194,
390,
4412,
198,
82281,
1109,
4412,
1669,
2915,
1445,
2622,
18,
17,
8,
3056,
4526,
16635,
341,
197,
37203,
4412,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewConfigs(t *testing.T) {
conf := NewTestConfig()
if conf == nil {
t.Fatal("Expected Config interface, got <nil>")
}
conf = NewLiquidTestConfig()
if conf == nil {
t.Fatal("Expected Config interface, got <nil>")
}
} | explode_data.jsonl/60546 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
3564,
84905,
1155,
353,
8840,
836,
8,
341,
67850,
1669,
1532,
2271,
2648,
741,
743,
2335,
621,
2092,
341,
197,
3244,
26133,
445,
18896,
5532,
3749,
11,
2684,
366,
8385,
42363,
197,
630,
67850,
284,
1532,
96640,
2271,
2648,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestObserve_Pagination(t *testing.T) {
session := createSession(t)
defer session.Close()
if err := createTable(session, `CREATE TABLE gocql_test.observe2 (id int, PRIMARY KEY (id))`); err != nil {
t.Fatal("create:", err)
}
var observedRows int
resetObserved := func() {
observedRows = -1
}
observer := funcQueryObserver(func(ctx context.Context, o ObservedQuery) {
observedRows = o.Rows
})
// insert 100 entries, relevant for pagination
for i := 0; i < 50; i++ {
if err := session.Query(`INSERT INTO observe2 (id) VALUES (?)`, i).Exec(); err != nil {
t.Fatal("insert:", err)
}
}
resetObserved()
// read the 100 entries in paginated entries of size 10. Expecting 5 observations, each with 10 rows
scanner := session.Query(`SELECT id FROM observe2 LIMIT 100`).
Observer(observer).
PageSize(10).
Iter().Scanner()
for i := 0; i < 50; i++ {
if !scanner.Next() {
t.Fatalf("next: should still be true: %d: %v", i, scanner.Err())
}
if i%10 == 0 {
if observedRows != 10 {
t.Fatalf("next: expecting a paginated query with 10 entries, got: %d (%d)", observedRows, i)
}
} else if observedRows != -1 {
t.Fatalf("next: not expecting paginated query (-1 entries), got: %d", observedRows)
}
resetObserved()
}
if scanner.Next() {
t.Fatal("next: no more entries where expected")
}
} | explode_data.jsonl/11134 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 513
} | [
2830,
3393,
4121,
13267,
1088,
10353,
1155,
353,
8840,
836,
8,
341,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
743,
1848,
1669,
1855,
2556,
16264,
11,
1565,
22599,
14363,
342,
509,
1470,
4452,
53093,
17,
320,
307,
526... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBindUnmarshalTextPtr(t *testing.T) {
e := New()
req := httptest.NewRequest(GET, "/?ts=2016-12-06T19:09:05Z", nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
result := struct {
Tptr *time.Time `query:"ts"`
}{}
err := c.Bind(&result)
if assert.NoError(t, err) {
assert.Equal(t, time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC), *result.Tptr)
}
} | explode_data.jsonl/72323 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
9950,
1806,
27121,
1178,
5348,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1532,
741,
24395,
1669,
54320,
70334,
75274,
62918,
11,
3521,
30,
2576,
28,
17,
15,
16,
21,
12,
16,
17,
12,
15,
21,
51,
16,
24,
25,
15,
24,
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... | 2 |
func TestParsedTypes(t *testing.T) {
const (
firstReqType = 0
knownType = 1
unknownType = 3
secondReqType = 4
)
tests := []parsedTypeTest{
{
name: "known optional and unknown optional",
encode: []tlv.Type{knownType, unknownType},
decode: []tlv.Type{knownType},
},
{
name: "unknown required and known optional",
encode: []tlv.Type{firstReqType, knownType},
decode: []tlv.Type{knownType},
expErr: tlv.ErrUnknownRequiredType(firstReqType),
},
{
name: "unknown required and unknown optional",
encode: []tlv.Type{unknownType, secondReqType},
expErr: tlv.ErrUnknownRequiredType(secondReqType),
},
{
name: "unknown required and known required",
encode: []tlv.Type{firstReqType, secondReqType},
decode: []tlv.Type{secondReqType},
expErr: tlv.ErrUnknownRequiredType(firstReqType),
},
{
name: "two unknown required",
encode: []tlv.Type{firstReqType, secondReqType},
expErr: tlv.ErrUnknownRequiredType(firstReqType),
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
testParsedTypes(t, test)
})
}
} | explode_data.jsonl/30591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 491
} | [
2830,
3393,
82959,
4173,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
42190,
27234,
929,
220,
284,
220,
15,
198,
197,
197,
5278,
929,
257,
284,
220,
16,
198,
197,
197,
16088,
929,
256,
284,
220,
18,
198,
197,
197,
5569,
27234,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReplyf(t *testing.T) {
message := mockMessage()
go message.Replyf("the answer is %d", 42)
reply := <-message.Replies
if reply.Data != "the answer is 42" {
t.Fail()
}
} | explode_data.jsonl/25060 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
20841,
69,
1155,
353,
8840,
836,
8,
341,
24753,
1669,
7860,
2052,
741,
30680,
1943,
2817,
2541,
69,
445,
1782,
4226,
374,
1018,
67,
497,
220,
19,
17,
340,
86149,
1669,
9119,
1994,
2817,
7202,
198,
743,
9851,
3336,
961,
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
] | 2 |
func TestEncodeJSON(t *testing.T) {
marshaled, err := allcoin.Marshal()
if err != nil {
t.Fatal(err)
}
jsonEncoded, err := allcoin.EncodeJSON()
if err != nil {
t.Fatal(err)
}
if jsonEncoded != string(marshaled) {
t.Fatalf("Should have the same value: EncodeJSON: %s, Marshaled and casted to string: %s\n", jsonEncoded, string(marshaled))
}
} | explode_data.jsonl/74138 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
32535,
5370,
1155,
353,
8840,
836,
8,
341,
2109,
277,
75303,
11,
1848,
1669,
678,
7160,
37271,
2822,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
30847,
46795,
11,
1848,
1669,
678,
7160,
50217,
5370,
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 Test_rotate(t *testing.T) {
type args struct {
nums []int
k int
expect []int
}
tests := []struct {
name string
args args
}{
{"case 1", args{[]int{1, 2, 3, 4, 5, 6, 7}, 3, []int{5, 6, 7, 1, 2, 3, 4}}},
{"case 2", args{[]int{-1, -100, 3, 99}, 2, []int{3, 99, -1, -100}}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
expect := tt.args.expect
rotate(tt.args.nums, tt.args.k)
if !TestSliceEqual(tt.args.nums, expect) {
t.Errorf("not equal: want:%v, got:%v", expect, tt.args.nums)
}
})
}
} | explode_data.jsonl/40366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
60834,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
22431,
82,
256,
3056,
396,
198,
197,
16463,
414,
526,
198,
197,
24952,
3056,
396,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSetSetOperation(t *testing.T) {
var s *MapSetDef[int, bool]
var s2 *MapSetDef[int, bool]
var s3 *MapSetDef[int, bool]
var tempString string
s = SetFrom[int, bool](11, 2, 3, 4, 5)
s2 = SetFrom[int, bool](9, 2, 5, 6)
s3 = SetFrom[int, bool](2, 5)
assert.Equal(t, true, s.ContainsKey(4))
assert.Equal(t, false, s.ContainsKey(6))
assert.Equal(t, true, s.IsSupersetByKey(s3))
assert.Equal(t, true, s2.IsSupersetByKey(s3))
assert.Equal(t, true, s3.IsSubsetByKey(s))
assert.Equal(t, true, s3.IsSubsetByKey(s2))
assert.Equal(t, false, s.IsSupersetByKey(s2))
tempString = ""
for _, v := range SortOrderedAscending(s.Clone().Intersection(s2).Keys()...) {
tempString += Maybe.Just(v).ToMaybe().ToString() + "/"
}
assert.Equal(t, "2/5/", tempString)
assert.Equal(t, 2, s.Intersection(s2).Size())
tempString = ""
for _, v := range SortOrderedAscending(s.Union(s2).Keys()...) {
tempString += Maybe.Just(v).ToMaybe().ToString() + "/"
}
assert.Equal(t, "2/3/4/5/6/9/11/", tempString)
assert.Equal(t, 7, s.Union(s2).Size())
tempString = ""
for _, v := range SortOrderedAscending(s.Minus(s2).Keys()...) {
tempString += Maybe.Just(v).ToMaybe().ToString() + "/"
}
assert.Equal(t, "3/4/11/", tempString)
tempString = ""
for _, v := range SortOrderedAscending(s2.Minus(s).Keys()...) {
tempString += Maybe.Just(v).ToMaybe().ToString() + "/"
}
assert.Equal(t, "6/9/", tempString)
} | explode_data.jsonl/22962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 627
} | [
2830,
3393,
1649,
1649,
8432,
1155,
353,
8840,
836,
8,
341,
2405,
274,
353,
2227,
1649,
2620,
18640,
11,
1807,
921,
2405,
274,
17,
353,
2227,
1649,
2620,
18640,
11,
1807,
921,
2405,
274,
18,
353,
2227,
1649,
2620,
18640,
11,
1807,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestSkipCreateTable(t *testing.T) {
db := newDB()
store := NewOptions(db, Options{SkipCreateTable: true}, []byte("secret"))
if db.HasTable(&gormSession{tableName: store.opts.TableName}) {
t.Error("Expected no table created")
}
} | explode_data.jsonl/71336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
35134,
4021,
2556,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
501,
3506,
741,
57279,
1669,
1532,
3798,
9791,
11,
14566,
90,
35134,
4021,
2556,
25,
830,
2137,
3056,
3782,
445,
20474,
28075,
743,
2927,
16152,
2556,
2099,
73281... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAlphaVolumePVCDataSource(t *testing.T) {
testCases := []struct {
testName string
claimSpec core.PersistentVolumeClaimSpec
expectedFail bool
}{
{
testName: "test create from valid snapshot source",
claimSpec: *testDataSourceInSpec("test_snapshot", "VolumeSnapshot", "snapshot.storage.k8s.io"),
},
{
testName: "test create from valid pvc source",
claimSpec: *testDataSourceInSpec("test_pvc", "PersistentVolumeClaim", ""),
},
{
testName: "test missing name in snapshot datasource should fail",
claimSpec: *testDataSourceInSpec("", "VolumeSnapshot", "snapshot.storage.k8s.io"),
expectedFail: true,
},
{
testName: "test specifying pvc with snapshot api group should fail",
claimSpec: *testDataSourceInSpec("test_snapshot", "PersistentVolumeClaim", "snapshot.storage.k8s.io"),
expectedFail: true,
},
{
testName: "test invalid group name in snapshot datasource should fail",
claimSpec: *testDataSourceInSpec("test_snapshot", "VolumeSnapshot", "storage.k8s.io"),
expectedFail: true,
},
}
for _, tc := range testCases {
if tc.expectedFail {
if errs := ValidatePersistentVolumeClaimSpec(&tc.claimSpec, field.NewPath("spec")); len(errs) == 0 {
t.Errorf("expected failure: %v", errs)
}
} else {
if errs := ValidatePersistentVolumeClaimSpec(&tc.claimSpec, field.NewPath("spec")); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
}
} | explode_data.jsonl/25700 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 562
} | [
2830,
3393,
19384,
18902,
47,
11287,
17173,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
18185,
675,
257,
914,
198,
197,
197,
7859,
8327,
262,
6200,
61655,
18902,
45544,
8327,
198,
197,
42400,
19524,
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... | 5 |
func TestGarbageCollectImageNotOldEnough(t *testing.T) {
policy := ImageGCPolicy{
HighThresholdPercent: 90,
LowThresholdPercent: 80,
MinAge: time.Minute * 1,
}
fakeRuntime := &containertest.FakeRuntime{}
mockStatsProvider := new(statstest.StatsProvider)
manager := &realImageGCManager{
runtime: fakeRuntime,
policy: policy,
imageRecords: make(map[string]*imageRecord),
statsProvider: mockStatsProvider,
recorder: &record.FakeRecorder{},
}
fakeRuntime.ImageList = []container.Image{
makeImage(0, 1024),
makeImage(1, 2048),
}
// 1 image is in use, and another one is not old enough
fakeRuntime.AllPodList = []*containertest.FakePod{
{Pod: &container.Pod{
Containers: []*container.Container{
makeContainer(1),
},
}},
}
fakeClock := clock.NewFakeClock(time.Now())
t.Log(fakeClock.Now())
require.NoError(t, manager.detectImages(fakeClock.Now()))
require.Equal(t, manager.imageRecordsLen(), 2)
// no space freed since one image is in used, and another one is not old enough
spaceFreed, err := manager.freeSpace(1024, fakeClock.Now())
assert := assert.New(t)
require.NoError(t, err)
assert.EqualValues(0, spaceFreed)
assert.Len(fakeRuntime.ImageList, 2)
// move clock by minAge duration, then 1 image will be garbage collected
fakeClock.Step(policy.MinAge)
spaceFreed, err = manager.freeSpace(1024, fakeClock.Now())
require.NoError(t, err)
assert.EqualValues(1024, spaceFreed)
assert.Len(fakeRuntime.ImageList, 1)
} | explode_data.jsonl/48116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 558
} | [
2830,
3393,
43930,
20652,
47504,
1906,
2623,
18284,
95801,
1155,
353,
8840,
836,
8,
341,
3223,
8018,
1669,
4654,
38,
7123,
8018,
515,
197,
197,
11976,
37841,
32010,
25,
220,
24,
15,
345,
197,
15070,
363,
37841,
32010,
25,
220,
220,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJWTFetch_BadResponse(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"scope": "user", "token_type": "bearer"}`))
}))
defer ts.Close()
conf := &Config{
Email: "aaa@xxx.com",
PrivateKey: dummyPrivateKey,
TokenURL: ts.URL,
}
tok, err := conf.TokenSource(oauth2.NoContext).Token()
if err != nil {
t.Fatal(err)
}
if tok == nil {
t.Fatalf("token is nil")
}
if tok.Valid() {
t.Errorf("token is valid. want invalid.")
}
if tok.AccessToken != "" {
t.Errorf("Unexpected non-empty access token %q.", tok.AccessToken)
}
if want := "bearer"; tok.TokenType != want {
t.Errorf("TokenType = %q; want %q", tok.TokenType, want)
}
scope := tok.Extra("scope")
if want := "user"; scope != want {
t.Errorf("token scope = %q; want %q", scope, want)
}
} | explode_data.jsonl/45786 | {
"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,
41,
54,
10808,
2995,
1668,
329,
2582,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
15753,
1005,
1649,
445,
2762,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAndroidTest_FixTestConfig(t *testing.T) {
ctx, _ := testJava(t, `
android_app {
name: "foo",
srcs: ["a.java"],
package_name: "com.android.foo",
sdk_version: "current",
}
android_test {
name: "foo_test",
srcs: ["b.java"],
instrumentation_for: "foo",
}
android_test {
name: "bar_test",
srcs: ["b.java"],
package_name: "com.android.bar.test",
instrumentation_for: "foo",
}
override_android_test {
name: "baz_test",
base: "foo_test",
package_name: "com.android.baz.test",
}
`)
testCases := []struct {
moduleName string
variantName string
expectedFlags []string
}{
{
moduleName: "foo_test",
variantName: "android_common",
},
{
moduleName: "bar_test",
variantName: "android_common",
expectedFlags: []string{
"--manifest out/soong/.intermediates/bar_test/android_common/manifest_fixer/AndroidManifest.xml",
"--package-name com.android.bar.test",
},
},
{
moduleName: "foo_test",
variantName: "android_common_baz_test",
expectedFlags: []string{
"--manifest out/soong/.intermediates/foo_test/android_common_baz_test/manifest_fixer/AndroidManifest.xml",
"--package-name com.android.baz.test",
"--test-file-name baz_test.apk",
},
},
}
for _, test := range testCases {
variant := ctx.ModuleForTests(test.moduleName, test.variantName)
params := variant.MaybeOutput("test_config_fixer/AndroidTest.xml")
if len(test.expectedFlags) > 0 {
if params.Rule == nil {
t.Errorf("test_config_fixer was expected to run, but didn't")
} else {
for _, flag := range test.expectedFlags {
if !strings.Contains(params.RuleParams.Command, flag) {
t.Errorf("Flag %q was not found in command: %q", flag, params.RuleParams.Command)
}
}
}
} else {
if params.Rule != nil {
t.Errorf("test_config_fixer was not expected to run, but did: %q", params.RuleParams.Command)
}
}
}
} | explode_data.jsonl/58500 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 848
} | [
2830,
3393,
21831,
2271,
1400,
941,
2271,
2648,
1155,
353,
8840,
836,
8,
341,
20985,
11,
716,
1669,
1273,
15041,
1155,
11,
22074,
197,
197,
5954,
8191,
341,
298,
11609,
25,
330,
7975,
756,
298,
41144,
82,
25,
4383,
64,
10848,
8097,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFunctionalStyleStylings(t *testing.T) {
// lambda
Test(t,
That("print (styled abc [s]{ put $s })").Prints("abc"),
That("print (styled abc [s]{ styled-segment $s &bold=$true &italic=$false })").Prints("\033[1mabc\033[m"),
That("print (styled abc italic [s]{ styled-segment $s &bold=$true &italic=$false })").Prints("\033[1mabc\033[m"),
)
// fn
Test(t,
That("fn f [s]{ put $s }; print (styled abc $f~)").Prints("abc"),
That("fn f [s]{ styled-segment $s &bold=$true &italic=$false }; print (styled abc $f~)").Prints("\033[1mabc\033[m"),
That("fn f [s]{ styled-segment $s &bold=$true &italic=$false }; print (styled abc italic $f~)").Prints("\033[1mabc\033[m"),
)
// var
Test(t,
That("f = [s]{ put $s }; print (styled abc $f)").Prints("abc"),
That("f = [s]{ styled-segment $s &bold=$true &italic=$false }; print (styled abc $f)").Prints("\033[1mabc\033[m"),
That("f = [s]{ styled-segment $s &bold=$true &italic=$false }; print (styled abc italic $f)").Prints("\033[1mabc\033[m"),
)
} | explode_data.jsonl/6986 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
71271,
2323,
623,
3923,
819,
1155,
353,
8840,
836,
8,
341,
197,
322,
12459,
198,
73866,
1155,
345,
197,
197,
4792,
445,
1350,
320,
22849,
39022,
508,
82,
15370,
2182,
400,
82,
6413,
1827,
8994,
82,
445,
13683,
4461,
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 TestSendMultiple(t *testing.T) {
s, port := tcpudp.NewUDPServer(&defaultConf, true)
defer s.Stop()
m := createTimelineManager(port, true, false, defaultTransportSize, time.Second, nil)
defer m.Shutdown()
numbers := []*jsonserializer.NumberPoint{newNumberPoint(1), newNumberPoint(2), newNumberPoint(3)}
for _, n := range numbers {
err := m.SendJSON(numberPoint, toGenericParametersN(n)...)
assert.NoError(t, err, "no error expected when sending number")
}
for i := 0; i < len(numbers); i++ {
message := <-s.MessageChannel()
testReceivedData(t, &message, numbers[i], true)
}
} | explode_data.jsonl/68114 | {
"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,
11505,
32089,
1155,
353,
8840,
836,
8,
1476,
1903,
11,
2635,
1669,
28051,
31101,
7121,
4656,
5012,
2836,
2099,
2258,
15578,
11,
830,
340,
16867,
274,
30213,
2822,
2109,
1669,
1855,
59641,
2043,
21230,
11,
830,
11,
895,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestServiceCreateWithMultipleNames(t *testing.T) {
_, _, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "foo1", "--image", "gcr.io/foo/bar:baz", "--no-wait"}, false)
assert.Assert(t, util.ContainsAll(err.Error(), "'service create' requires the service name given as single argument"))
} | explode_data.jsonl/42440 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
1860,
4021,
2354,
32089,
7980,
1155,
353,
8840,
836,
8,
341,
197,
6878,
8358,
8358,
1848,
1669,
12418,
1860,
4021,
10556,
917,
515,
197,
197,
1,
7936,
497,
330,
3182,
497,
330,
7975,
497,
330,
7975,
16,
497,
14482,
1805,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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) {
acfg, _ := utils.AWSSession(utils.AWSConfig(true))
badcfg, _ := session.NewSession(aws.NewConfig())
type args struct {
awsConfig client.ConfigProvider
opts Opts
}
tests := []struct {
name string
args args
wantErr bool
}{
{"invalid aws config", args{badcfg, Opts{}}, true},
{"invalid tls config", args{acfg, Opts{
TLSOpts: TLSOpts{
CertFile: "../../dev/certs/asdf.crt",
},
}}, true},
{"valid no tls", args{acfg, Opts{}}, false},
{"valid tls config", args{acfg, Opts{
TLSOpts: TLSOpts{
CertFile: "../../dev/certs/127.0.0.1.crt",
KeyFile: "../../dev/certs/127.0.0.1.key",
},
}}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var l = zaptest.NewLogger(t).Sugar()
_, err := New(tt.args.awsConfig, l, tt.args.opts)
if (err != nil) != tt.wantErr {
t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
} | explode_data.jsonl/22349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
3564,
1155,
353,
8840,
836,
8,
341,
81200,
4817,
11,
716,
1669,
12439,
875,
54,
1220,
1338,
64166,
91670,
2648,
3715,
1171,
2233,
329,
14072,
11,
716,
1669,
3797,
7121,
5283,
7,
8635,
7121,
2648,
2398,
13158,
2827,
2036,
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... | 2 |
func TestGetAppDetailsWithAppParameterFile(t *testing.T) {
t.Run("No app name set and app specific file exists", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "multi", func(t *testing.T, path string) {
details, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
})
require.NoError(t, err)
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
})
})
t.Run("No app specific override", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "single-global", func(t *testing.T, path string) {
details, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
AppName: "testapp",
})
require.NoError(t, err)
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.2"}, details.Kustomize.Images)
})
})
t.Run("Only app specific override", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "single-app-only", func(t *testing.T, path string) {
details, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
AppName: "testapp",
})
require.NoError(t, err)
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
})
})
t.Run("App specific override", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "multi", func(t *testing.T, path string) {
details, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
AppName: "testapp",
})
require.NoError(t, err)
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
})
})
t.Run("App specific overrides containing non-mergeable field", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "multi", func(t *testing.T, path string) {
details, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
AppName: "unmergeable",
})
require.NoError(t, err)
assert.EqualValues(t, []string{"gcr.io/heptio-images/ks-guestbook-demo:0.3"}, details.Kustomize.Images)
})
})
t.Run("Broken app-specific overrides", func(t *testing.T) {
service := newService(".")
runWithTempTestdata(t, "multi", func(t *testing.T, path string) {
_, err := service.GetAppDetails(context.Background(), &apiclient.RepoServerAppDetailsQuery{
Repo: &argoappv1.Repository{},
Source: &argoappv1.ApplicationSource{
Path: path,
},
AppName: "broken",
})
assert.Error(t, err)
})
})
} | explode_data.jsonl/5697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1300
} | [
2830,
3393,
1949,
2164,
7799,
2354,
2164,
4971,
1703,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2753,
906,
829,
738,
323,
906,
3151,
1034,
6724,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
52934,
1669,
501,
1860,
5680,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCopyFileWithTarInvalidSrc(t *testing.T) {
tempFolder, err := os.MkdirTemp("", "docker-archive-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempFolder)
destFolder := filepath.Join(tempFolder, "dest")
err = os.MkdirAll(destFolder, 0740)
if err != nil {
t.Fatal(err)
}
invalidFile := filepath.Join(tempFolder, "doesnotexists")
err = defaultCopyFileWithTar(invalidFile, destFolder)
if err == nil {
t.Fatalf("archiver.CopyWithTar with invalid src path should throw an error.")
}
} | explode_data.jsonl/79245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
12106,
1703,
2354,
62733,
7928,
20360,
1155,
353,
8840,
836,
8,
341,
16280,
13682,
11,
1848,
1669,
2643,
1321,
12438,
12151,
19814,
330,
28648,
95100,
16839,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
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... | 4 |
func TestReviewHandler_GetReviewsForProduct(t *testing.T) {
productId := uint64(4)
sess := models.Session{
Value: "fdsfdsfdsf",
UserData: models.UserId{
Id: 3,
},
}
paginatorReview := models.PaginatorReviews{
PageNum: 2,
Count: 4,
SortReviewsOptions: models.SortReviewsOptions{
SortKey: "date",
SortDirection: "ASC",
},
}
reviews := models.RangeReviews{
ListPreviews: nil,
MaxCountPages: 5,
}
t.Run("GetReviewsForProduct_success", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
reviewUCase := mock.NewMockUseCase(ctrl)
reviewUCase.
EXPECT().
GetReviewsByProductId(productId, &paginatorReview).
Return(&reviews, nil)
reviewHandler := NewHandler(reviewUCase)
paginatorBytes, _ := json.Marshal(paginatorReview)
ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New())
cctx := context.WithValue(ctx, models.SessionContextKey, &sess)
req, _ := http.NewRequestWithContext(cctx, "POST", "/api/v1/review/product/{id:[0-9]+}",
bytes.NewBuffer(paginatorBytes))
vars := map[string]string{
"id": fmt.Sprintf("%d", productId),
}
req = mux.SetURLVars(req, vars)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(reviewHandler.GetReviewsForProduct)
handler.ServeHTTP(rr, req)
assert.Equal(t, rr.Code, http.StatusOK, "incorrect http code")
})
t.Run("GetReviewsForProduct_bad_body", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
reviewUCase := mock.NewMockUseCase(ctrl)
reviewHandler := NewHandler(reviewUCase)
ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New())
cctx := context.WithValue(ctx, models.SessionContextKey, &sess)
req, _ := http.NewRequestWithContext(cctx, "POST", "/api/v1/review/product/{id:[0-9]+}",
bytes.NewBuffer(nil))
vars := map[string]string{
"id": fmt.Sprintf("%d", productId),
}
req = mux.SetURLVars(req, vars)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(reviewHandler.GetReviewsForProduct)
handler.ServeHTTP(rr, req)
assert.Equal(t, rr.Code, http.StatusBadRequest, "incorrect http code")
})
t.Run("GetReviewsForProduct_not_found_reviews", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
reviewUCase := mock.NewMockUseCase(ctrl)
reviewUCase.
EXPECT().
GetReviewsByProductId(productId, &paginatorReview).
Return(&reviews, errors.ErrInternalError)
reviewHandler := NewHandler(reviewUCase)
paginatorBytes, _ := json.Marshal(paginatorReview)
ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New())
cctx := context.WithValue(ctx, models.SessionContextKey, &sess)
req, _ := http.NewRequestWithContext(cctx, "POST", "/api/v1/review/product/{id:[0-9]+}",
bytes.NewBuffer(paginatorBytes))
vars := map[string]string{
"id": fmt.Sprintf("%d", productId),
}
req = mux.SetURLVars(req, vars)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(reviewHandler.GetReviewsForProduct)
handler.ServeHTTP(rr, req)
assert.Equal(t, rr.Code, http.StatusInternalServerError, "incorrect http code")
})
t.Run("GetReviewsForProduct_bad_id", func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
reviewUCase := mock.NewMockUseCase(ctrl)
reviewHandler := NewHandler(reviewUCase)
paginatorBytes, _ := json.Marshal(paginatorReview)
ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New())
cctx := context.WithValue(ctx, models.SessionContextKey, &sess)
req, _ := http.NewRequestWithContext(cctx, "POST", "/api/v1/review/product/{id:[0-9]+}",
bytes.NewBuffer(paginatorBytes))
vars := map[string]string{
"id": "-10",
}
req = mux.SetURLVars(req, vars)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(reviewHandler.GetReviewsForProduct)
handler.ServeHTTP(rr, req)
assert.Equal(t, rr.Code, http.StatusBadRequest, "incorrect http code")
})
} | explode_data.jsonl/71563 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1578
} | [
2830,
3393,
19432,
3050,
13614,
45206,
2461,
4816,
1155,
353,
8840,
836,
8,
341,
197,
46166,
1669,
2622,
21,
19,
7,
19,
340,
1903,
433,
1669,
4119,
20674,
515,
197,
47399,
25,
330,
64834,
64834,
64834,
69,
756,
197,
31672,
1043,
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 TestAddToArchiveWithClosedWriter(t *testing.T) {
dir, err := ioutil.TempDir("", "tarwriter_test")
if err != nil {
assert.FailNow(t, "Cannot create temp dir", err.Error())
}
tempFilePath := filepath.Join(dir, "test_file.tar")
defer os.RemoveAll(dir)
w := tarfile.NewWriter(tempFilePath)
// Note that we have not opened the writer
err = w.AddToArchive(pathToTestFile("cleanup_result.json"), "file1.json")
if err == nil {
assert.FailNow(t, "Should have gotten a tar write error")
}
assert.True(t, strings.HasPrefix(err.Error(), "Underlying TarWriter is nil"))
// Open and close the writer, so the file exists.
w.Open()
w.Close()
if _, err := os.Stat(w.PathToTarFile); os.IsNotExist(err) {
assert.Fail(t, "Tar file does not exist at %s", w.PathToTarFile)
}
err = w.AddToArchive(pathToTestFile("cleanup_result.json"), "file1.json")
if err == nil {
assert.FailNow(t, "Should have gotten a tar write error")
}
assert.True(t, strings.Contains(err.Error(), "tar: write after close"), err.Error())
} | explode_data.jsonl/75876 | {
"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,
2212,
1249,
42502,
2354,
26884,
6492,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
26737,
18189,
4452,
1138,
743,
1848,
961,
2092,
341,
197,
6948,
57243,
7039,
1155,
11,
330,
17444,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_DescribeRegionsWithRPCrequestWithescape(t *testing.T) {
client, err := ecs.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
request := ecs.CreateDescribeRegionsRequest()
request.Scheme = "HTTP"
ts := mockServer(400, `{"Code": "\t"}`)
defer ts.Close()
domain := strings.Replace(ts.URL, "http://", "", 1)
request.Domain = domain
response, err := client.DescribeRegions(request)
assert.NotNil(t, err)
assert.Equal(t, 400, response.GetHttpStatus())
assert.Equal(t, "{\"Code\": \"\\t\"}", response.GetHttpContentString())
} | explode_data.jsonl/56879 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
98054,
3114,
79284,
2354,
29528,
2035,
2354,
12998,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
78422,
7121,
2959,
2354,
6054,
1592,
9638,
64883,
445,
77431,
3450,
3975,
2643,
64883,
445,
55749,
6600,
3450,
3975,
2643... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHashKeyValueRepoOverwrite(t *testing.T) {
repo := NewHashKeyValueRepo(&mockRepo{})
item := "a"
_, err := repo.Overwrite(item)
checkError(err, t)
if !repo.Contains(item) {
t.Errorf("Could not find %v", item)
}
} | explode_data.jsonl/79719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
6370,
72082,
25243,
1918,
4934,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
1669,
1532,
6370,
72082,
25243,
2099,
16712,
25243,
6257,
692,
22339,
1669,
330,
64,
698,
197,
6878,
1848,
1669,
15867,
13,
1918,
4934,
5393,
340,
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... | 2 |
func TestLogsExporter_WithShutdown(t *testing.T) {
shutdownCalled := false
shutdown := func(context.Context) error { shutdownCalled = true; return nil }
le, err := NewLogsExporter(&fakeLogsExporterConfig, componenttest.NewNopExporterCreateSettings(), newPushLogsData(nil), WithShutdown(shutdown))
assert.NotNil(t, le)
assert.NoError(t, err)
assert.Nil(t, le.Shutdown(context.Background()))
assert.True(t, shutdownCalled)
} | explode_data.jsonl/59612 | {
"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,
51053,
88025,
62,
2354,
62004,
1155,
353,
8840,
836,
8,
341,
36196,
18452,
20960,
1669,
895,
198,
36196,
18452,
1669,
2915,
5378,
9328,
8,
1465,
314,
23766,
20960,
284,
830,
26,
470,
2092,
555,
197,
273,
11,
1848,
1669,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAbilityToValidateNils(t *testing.T) {
type TestStruct struct {
Test *string `validate:"nil"`
}
ts := TestStruct{}
val := New()
fn := func(fl FieldLevel) bool {
return fl.Field().Kind() == reflect.Ptr && fl.Field().IsNil()
}
err := val.RegisterValidation("nil", fn, true)
Equal(t, err, nil)
errs := val.Struct(ts)
Equal(t, errs, nil)
str := "string"
ts.Test = &str
errs = val.Struct(ts)
NotEqual(t, errs, nil)
} | explode_data.jsonl/77372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
33903,
1249,
17926,
45,
8669,
1155,
353,
8840,
836,
8,
1476,
13158,
3393,
9422,
2036,
341,
197,
73866,
353,
917,
1565,
7067,
2974,
8385,
8805,
197,
630,
57441,
1669,
3393,
9422,
16094,
19302,
1669,
1532,
741,
40095,
1669,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNoNullTerminator(t *testing.T) {
v := "\x02\x01\x06\x00" +
"\xc8\x37\xbe\x73\x00\x00\x80\x00\x00\x00\x00\x00\xc0\xa8\x2b\x92" +
"\xc0\xa8\x2b\x01\x00\x00\x00\x00\x00\x0f\x60\x0a\x23\x93\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +
"\x00\x00\x00\x00\x00\x00\x00\x00\x63\x82\x53\x63\x35\x01\x02\x36" +
"\x04\xc0\xa8\x2b\x01\x33\x04\x00\x00\x0e\x10\x3a\x04\x00\x00\x07" +
"\x08\x3b\x04\x00\x00\x0c\x4e\x01\x04\xff\xff\xff\x00\x1c\x04\xc0" +
"\xa8\x2b\xff\x03\x04\xc0\xa8\x2b\x01\x06\x04\xc0\xa8\x2b\x01\x2b" +
"\x0f\x41\x4e\x44\x52\x4f\x49\x44\x5f\x4d\x45\x54\x45\x52\x45\x44" +
"\xff"
h := hdr(v)
if !h.isValid() {
t.Error("failed to decode header")
}
if got, want := h.op(), opReply; got != want {
t.Errorf("h.op()=%s, want=%s", got, want)
}
if _, err := h.options(); err != nil {
t.Errorf("bad options: %s", err)
}
} | explode_data.jsonl/20583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1197
} | [
2830,
3393,
2753,
3280,
21209,
1065,
850,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
2917,
87,
15,
17,
3462,
15,
16,
3462,
15,
21,
3462,
15,
15,
1,
3610,
197,
197,
11934,
8148,
23,
3462,
18,
22,
3462,
1371,
3462,
22,
18,
3462,
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... | 4 |
func Test_ConsumerMessage(t *testing.T) {
addr := []string{"10.4.7.71:9092"}
client, err := NewKafkaConsumer(addr)
if err != nil {
t.Error(err.Error())
}
client.ConsumerMessage("test")
} | explode_data.jsonl/48907 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
15100,
11761,
2052,
1155,
353,
8840,
836,
8,
341,
53183,
1669,
3056,
917,
4913,
16,
15,
13,
19,
13,
22,
13,
22,
16,
25,
24,
15,
24,
17,
16707,
25291,
11,
1848,
1669,
1532,
42,
21883,
29968,
24497,
340,
743,
1848,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergeVolumes(t *testing.T) {
tests := map[string]struct {
orig []api.Volume
mod []api.Volume
result []api.Volume
shouldFail bool
}{
"empty original": {
mod: []api.Volume{
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
result: []api.Volume{
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
shouldFail: false,
},
"good merge": {
orig: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
mod: []api.Volume{
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
result: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
shouldFail: false,
},
"conflict": {
orig: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
mod: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{HostPath: &api.HostPathVolumeSource{Path: "/etc/apparmor.d"}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
shouldFail: true,
},
"one is exact same": {
orig: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
mod: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
result: []api.Volume{
{Name: "vol3", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol4", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
{Name: "vol2", VolumeSource: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}},
},
shouldFail: false,
},
}
for name, test := range tests {
result, err := mergeVolumes(
test.orig,
[]*settings.PodPreset{{Spec: settings.PodPresetSpec{Volumes: test.mod}}},
)
if test.shouldFail && err == nil {
t.Fatalf("expected test %q to fail but got nil", name)
}
if !test.shouldFail && err != nil {
t.Fatalf("test %q failed: %v", name, err)
}
if !reflect.DeepEqual(test.result, result) {
t.Fatalf("results were not equal for test %q: got %#v; expected: %#v", name, result, test.result)
}
}
} | explode_data.jsonl/20881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1291
} | [
2830,
3393,
52096,
96325,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
4670,
981,
3056,
2068,
79106,
198,
197,
42228,
286,
3056,
2068,
79106,
198,
197,
9559,
257,
3056,
2068,
79106,
198,
197,
197,
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... | 7 |
func TestUserList_Err(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
users := mock.NewMockUserStore(controller)
users.EXPECT().List(gomock.Any()).Return(nil, sql.ErrNoRows)
w := httptest.NewRecorder()
r := httptest.NewRequest("GET", "/", nil)
HandleList(users)(w, r)
if got, want := w.Code, 500; want != got {
t.Errorf("Want response code %d, got %d", want, got)
}
// got, want := new(render.Error), &render.Error{Message: "sql: no rows in result set"}
// json.NewDecoder(w.Body).Decode(got)
// if diff := cmp.Diff(got, want); len(diff) > 0 {
// t.Errorf(diff)
// }
} | explode_data.jsonl/69910 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
1474,
852,
93623,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
6461,
991,
18176,
2822,
90896,
1669,
7860,
7121,
11571,
1474,
6093,
40845,
340,
90896,
22402,
7285,
1005,
852,
3268,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapIterate(t *testing.T) {
hash, err := NewMap(&MapSpec{
Type: Hash,
KeySize: 5,
ValueSize: 4,
MaxEntries: 2,
})
if err != nil {
t.Fatal(err)
}
defer hash.Close()
if err := hash.Put("hello", uint32(21)); err != nil {
t.Fatal(err)
}
if err := hash.Put("world", uint32(42)); err != nil {
t.Fatal(err)
}
var key string
var value uint32
var keys []string
entries := hash.Iterate()
for entries.Next(&key, &value) {
keys = append(keys, key)
}
if err := entries.Err(); err != nil {
t.Fatal(err)
}
sort.Strings(keys)
if n := len(keys); n != 2 {
t.Fatal("Expected to get 2 keys, have", n)
}
if keys[0] != "hello" {
t.Error("Expected index 0 to be hello, got", keys[0])
}
if keys[1] != "world" {
t.Error("Expected index 1 to be hello, got", keys[1])
}
} | explode_data.jsonl/21666 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 363
} | [
2830,
3393,
2227,
8537,
349,
1155,
353,
8840,
836,
8,
341,
50333,
11,
1848,
1669,
1532,
2227,
2099,
2227,
8327,
515,
197,
27725,
25,
981,
6531,
345,
197,
55242,
1695,
25,
262,
220,
20,
345,
197,
47399,
1695,
25,
220,
220,
19,
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... | 9 |
func TestReadP256(t *testing.T) {
v := New()
const (
k1 = "did:key:zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv"
k1KID = "did:key:zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv#zDnaerx9CtbPJ1q36T5Ln5wYt3MQYeGRG5ehnPAmxcf5mDZpv" //nolint:lll
k1X = "igrFmi0whuihKnj9R3Om1SoMph72wUGeFaBbzG2vzns"
k1Y = "efsX5b10x8yjyrj4ny3pGfLcY7Xby1KzgqOdqnsrJIM"
k2 = "did:key:zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169"
k2KID = "did:key:zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169#zDnaerDaTF5BXEavCrfRZEk316dpbLsfPDZ3WJ5hRTPFU2169" //nolint:lll
k2X = "fyNYMN0976ci7xqiSdag3buk-ZCwgXU4kz9XNkBlNUI"
k2Y = "hW2ojTNfH7Jbi8--CJUo3OCbH3y5n91g-IMA9MLMbTU"
)
t.Run("key 1", func(t *testing.T) {
docResolution, err := v.Read(k1)
require.NoError(t, err)
require.NotNil(t, docResolution.DIDDocument)
assertJSONWebKeyDoc(t, docResolution.DIDDocument, k1, k1KID, elliptic.P256(),
readBigInt(t, k1X), readBigInt(t, k1Y))
})
t.Run("key 2", func(t *testing.T) {
docResolution, err := v.Read(k2)
require.NoError(t, err)
require.NotNil(t, docResolution.DIDDocument)
assertJSONWebKeyDoc(t, docResolution.DIDDocument, k2, k2KID, elliptic.P256(),
readBigInt(t, k2X), readBigInt(t, k2Y))
})
} | explode_data.jsonl/16606 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 742
} | [
2830,
3393,
4418,
47,
17,
20,
21,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
1532,
2822,
4777,
2399,
197,
16463,
16,
262,
284,
330,
22920,
64849,
25,
89,
35,
3376,
261,
87,
24,
34,
18387,
94235,
16,
80,
18,
21,
51,
20,
40101,
20,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClusterValidateConfigurationChange(t *testing.T) {
cl := newCluster("")
cl.SetStore(store.New())
for i := 1; i <= 4; i++ {
attr := RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", i)}}
cl.AddMember(&Member{ID: types.ID(i), RaftAttributes: attr})
}
cl.RemoveMember(4)
attr := RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 1)}}
ctx, err := json.Marshal(&Member{ID: types.ID(5), RaftAttributes: attr})
if err != nil {
t.Fatal(err)
}
attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 5)}}
ctx5, err := json.Marshal(&Member{ID: types.ID(5), RaftAttributes: attr})
if err != nil {
t.Fatal(err)
}
attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 3)}}
ctx2to3, err := json.Marshal(&Member{ID: types.ID(2), RaftAttributes: attr})
if err != nil {
t.Fatal(err)
}
attr = RaftAttributes{PeerURLs: []string{fmt.Sprintf("http://127.0.0.1:%d", 5)}}
ctx2to5, err := json.Marshal(&Member{ID: types.ID(2), RaftAttributes: attr})
if err != nil {
t.Fatal(err)
}
tests := []struct {
cc raftpb.ConfChange
werr error
}{
{
raftpb.ConfChange{
Type: raftpb.ConfChangeRemoveNode,
NodeID: 3,
},
nil,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeAddNode,
NodeID: 4,
},
ErrIDRemoved,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeRemoveNode,
NodeID: 4,
},
ErrIDRemoved,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeAddNode,
NodeID: 1,
},
ErrIDExists,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeAddNode,
NodeID: 5,
Context: ctx,
},
ErrPeerURLexists,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeRemoveNode,
NodeID: 5,
},
ErrIDNotFound,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeAddNode,
NodeID: 5,
Context: ctx5,
},
nil,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeUpdateNode,
NodeID: 5,
Context: ctx,
},
ErrIDNotFound,
},
// try to change the peer url of 2 to the peer url of 3
{
raftpb.ConfChange{
Type: raftpb.ConfChangeUpdateNode,
NodeID: 2,
Context: ctx2to3,
},
ErrPeerURLexists,
},
{
raftpb.ConfChange{
Type: raftpb.ConfChangeUpdateNode,
NodeID: 2,
Context: ctx2to5,
},
nil,
},
}
for i, tt := range tests {
err := cl.ValidateConfigurationChange(tt.cc)
if err != tt.werr {
t.Errorf("#%d: validateConfigurationChange error = %v, want %v", i, err, tt.werr)
}
}
} | explode_data.jsonl/52336 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1265
} | [
2830,
3393,
28678,
17926,
7688,
4072,
1155,
353,
8840,
836,
8,
341,
39407,
1669,
501,
28678,
31764,
39407,
4202,
6093,
31200,
7121,
2398,
2023,
600,
1669,
220,
16,
26,
600,
2651,
220,
19,
26,
600,
1027,
341,
197,
60943,
1669,
18482,
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... | 8 |
func TestIsConnTimeoutForWrappedConnTimeouts(t *testing.T) {
tcpAddr := GetFreeLocalhostAddrPort()
dialer := DialTCPFn(tcpAddr, time.Millisecond, ed25519.GenPrivKey())
_, err := dialer()
assert.Error(t, err)
err = fmt.Errorf("%v: %w", err, ErrConnectionTimeout)
assert.True(t, IsConnTimeout(err))
} | explode_data.jsonl/67896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
3872,
9701,
7636,
2461,
67795,
9701,
7636,
82,
1155,
353,
8840,
836,
8,
341,
3244,
4672,
13986,
1669,
2126,
10940,
7319,
3790,
13986,
7084,
741,
2698,
530,
261,
1669,
66155,
49896,
24911,
98203,
13986,
11,
882,
71482,
11,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetStakeRewards(t *testing.T) {
// SSGen example with >0 subsidy
amounts := []int64{
21000000,
11000000,
10000000,
}
amountTicket := int64(42000000)
subsidy := int64(400000)
outAmts := stake.CalculateRewards(amounts, amountTicket, subsidy)
// SSRtx example with 0 subsidy
expectedAmts := []int64{
21200000,
11104761,
10095238,
}
if !reflect.DeepEqual(expectedAmts, outAmts) {
t.Errorf("TestGetStakeRewards error, wanted %v, "+
"but got %v", expectedAmts, outAmts)
}
} | explode_data.jsonl/70517 | {
"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,
1949,
623,
726,
58465,
2347,
1155,
353,
8840,
836,
8,
341,
197,
322,
328,
7783,
268,
3110,
448,
861,
15,
67647,
198,
197,
6045,
82,
1669,
3056,
396,
21,
19,
515,
197,
197,
17,
16,
15,
15,
15,
15,
15,
15,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetEthereumBalance(t *testing.T) {
address := "0xb794f5ea0ba39494ce839613fffba74279579268"
nonsenseAddress := "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
response, err := GetEthereumBalance(address)
if err != nil {
t.Errorf("Test Failed - Portfolio GetEthereumBalance() Error: %s", err)
}
if response.Address != "0xb794f5ea0ba39494ce839613fffba74279579268" {
t.Error("Test Failed - Portfolio GetEthereumBalance() address invalid")
}
response, err = GetEthereumBalance(nonsenseAddress)
if response.Error.Message != "" || err == nil {
t.Errorf("Test Failed - Portfolio GetEthereumBalance() Error: %s",
response.Error.Message)
}
} | explode_data.jsonl/33730 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
1949,
36,
18532,
372,
21190,
1155,
353,
8840,
836,
8,
341,
63202,
1669,
330,
15,
7929,
22,
24,
19,
69,
20,
12508,
15,
4645,
18,
24,
19,
24,
19,
346,
23,
18,
24,
21,
16,
18,
14092,
4645,
22,
19,
17,
22,
24,
20,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestIssue11503(t *testing.T) {
testReadMessageError(t, "8c040402000aa430aa8228b9248b01fc899a91197130303030")
} | explode_data.jsonl/2292 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 50
} | [
2830,
3393,
42006,
16,
16,
20,
15,
18,
1155,
353,
8840,
836,
8,
341,
18185,
4418,
2052,
1454,
1155,
11,
330,
23,
66,
15,
19,
15,
19,
15,
17,
15,
15,
15,
5305,
19,
18,
15,
5305,
23,
17,
17,
23,
65,
24,
17,
19,
23,
65,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestImport(t *testing.T) {
gopClTest(t, `import "fmt"
func main() {
fmt.println "Hi"
}`, `package main
import fmt "fmt"
func main() {
fmt.Println("Hi")
}
`)
} | explode_data.jsonl/73667 | {
"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,
11511,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
1565,
474,
330,
12501,
1837,
2830,
1887,
368,
341,
11009,
2913,
330,
13048,
698,
28350,
1565,
1722,
1887,
271,
474,
8879,
330,
12501,
1837,
2830,
1887,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAutocommit(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t;")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("create table t (id BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL)")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("insert t values ()")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("begin")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("insert t values ()")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("drop table if exists t")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("create table t (id BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL)")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
tk.MustExec("set autocommit=0")
require.Equal(t, 0, int(tk.Session().Status()&mysql.ServerStatusAutocommit))
tk.MustExec("insert t values ()")
require.Equal(t, 0, int(tk.Session().Status()&mysql.ServerStatusAutocommit))
tk.MustExec("commit")
require.Equal(t, 0, int(tk.Session().Status()&mysql.ServerStatusAutocommit))
tk.MustExec("drop table if exists t")
require.Equal(t, 0, int(tk.Session().Status()&mysql.ServerStatusAutocommit))
tk.MustExec("set autocommit='On'")
require.Greater(t, int(tk.Session().Status()&mysql.ServerStatusAutocommit), 0)
// When autocommit is 0, transaction start ts should be the first *valid*
// statement, rather than *any* statement.
tk.MustExec("create table t (id int)")
tk.MustExec("set @@autocommit = 0")
tk.MustExec("rollback")
tk.MustExec("set @@autocommit = 0")
tk1 := testkit.NewTestKit(t, store)
tk1.MustExec("use test")
tk1.MustExec("insert into t select 1")
tk.MustQuery("select * from t").Check(testkit.Rows("1"))
// TODO: MySQL compatibility for setting global variable.
// tk.MustExec("begin")
// tk.MustExec("insert into t values (42)")
// tk.MustExec("set @@global.autocommit = 1")
// tk.MustExec("rollback")
// tk.MustQuery("select count(*) from t where id = 42").Check(testkit.Rows("0"))
// Even the transaction is rollbacked, the set statement succeed.
// tk.MustQuery("select @@global.autocommit").Rows("1")
} | explode_data.jsonl/5802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 903
} | [
2830,
3393,
19602,
11986,
1763,
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,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPeers(t *testing.T) {
// single node
single := &node{
id: testNodeId,
address: testNodeAddress,
peers: make(map[string]*node),
network: newNetwork(Name(testNodeNetName)),
}
// get node peers
peers := single.Peers()
// there should be no peers
peerCount := 0
if len(peers) != peerCount {
t.Errorf("Expected to find %d nodes, found: %d", peerCount, len(peers))
}
// complicated node graph
node := testSetup()
// list of ids of nodes of MaxDepth
peerIds := make(map[string]bool)
// add peer Ids
for _, id := range testNodePeerIds {
peerIds[id] = true
}
// add peers of peers to peerIds
for _, id := range testPeerOfPeerIds {
peerIds[id] = true
}
// get node peers
peers = node.Peers()
// we will collect all returned Peer Ids into this map
resPeerIds := make(map[string]bool)
for _, peer := range peers {
resPeerIds[peer.Id()] = true
resPeerIds = collectPeerIds(peer, resPeerIds)
}
// if correct, we must collect all peerIds
if len(resPeerIds) != len(peerIds) {
t.Errorf("Expected to find %d peers, found: %d", len(peerIds), len(resPeerIds))
}
for id := range resPeerIds {
if _, ok := peerIds[id]; !ok {
t.Errorf("Expected to find %s peer", id)
}
}
} | explode_data.jsonl/23545 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 498
} | [
2830,
3393,
10197,
388,
1155,
353,
8840,
836,
8,
341,
197,
322,
3175,
2436,
198,
1903,
2173,
1669,
609,
3509,
515,
197,
15710,
25,
414,
1273,
79206,
345,
197,
63202,
25,
1273,
1955,
4286,
345,
197,
197,
375,
388,
25,
256,
1281,
9147... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache(t *testing.T) {
mux := http.NewServeMux()
var n uint32
mux.Handle("/", http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
atomic.AddUint32(&n, 1)
res.Write([]byte(expectedBodyStr))
}))
cachedMux := httpcache.Cache(mux, cacheDuration)
e := httptest.New(t, httptest.Handler(cachedMux))
if err := runTest(e, &n, expectedBodyStr, ""); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/16263 | {
"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,
8233,
1155,
353,
8840,
836,
8,
341,
2109,
2200,
1669,
1758,
7121,
60421,
44,
2200,
741,
2405,
308,
2622,
18,
17,
198,
2109,
2200,
31421,
35460,
1758,
89164,
18552,
4590,
1758,
37508,
11,
4232,
353,
1254,
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 TestBigFilterEvictsEverything(t *testing.T) {
// Create different sized filters.
b1, f1, _ := genRandFilter(1, t)
b2, f2, _ := genRandFilter(3, t)
b3, f3, s3 := genRandFilter(10, t)
cs := &ChainService{
FilterCache: lru.NewCache(s3),
}
// Insert the smaller filters.
assertEqual(t, cs.FilterCache.Len(), 0, "")
cs.putFilterToCache(b1, filterdb.RegularFilter, f1)
assertEqual(t, cs.FilterCache.Len(), 1, "")
cs.putFilterToCache(b2, filterdb.RegularFilter, f2)
assertEqual(t, cs.FilterCache.Len(), 2, "")
// Insert the big filter and check all previous filters are evicted.
cs.putFilterToCache(b3, filterdb.RegularFilter, f3)
assertEqual(t, cs.FilterCache.Len(), 1, "")
assertEqual(t, getFilter(cs, b3, t), f3, "")
} | explode_data.jsonl/18465 | {
"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,
15636,
5632,
34112,
29995,
34964,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
2155,
29287,
13406,
624,
2233,
16,
11,
282,
16,
11,
716,
1669,
4081,
56124,
5632,
7,
16,
11,
259,
340,
2233,
17,
11,
282,
17,
11,
716,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClientConectionRemoteaddrIsNil(t *testing.T) {
conn := NewClientConnection(nil, 0, nil, nil, nil)
err := conn.Connect()
if err == nil {
t.Errorf("connect should Failed")
return
}
} | explode_data.jsonl/50582 | {
"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,
2959,
34,
603,
407,
24703,
6214,
3872,
19064,
1155,
353,
8840,
836,
8,
341,
32917,
1669,
1532,
2959,
4526,
27907,
11,
220,
15,
11,
2092,
11,
2092,
11,
2092,
340,
9859,
1669,
4534,
43851,
741,
743,
1848,
621,
2092,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestExecute(t *testing.T) {
url := testserver.StartSocketHttpServer(t, requests)
testCases := []struct {
desc string
arguments *commandargs.Shell
expectedOutput string
}{
{
desc: "With a known username",
arguments: &commandargs.Shell{GitlabUsername: "alex-doe"},
expectedOutput: "Welcome to GitLab, @alex-doe!\n",
},
{
desc: "With a known key id",
arguments: &commandargs.Shell{GitlabKeyId: "1"},
expectedOutput: "Welcome to GitLab, @alex-doe!\n",
},
{
desc: "With an unknown key",
arguments: &commandargs.Shell{GitlabKeyId: "-1"},
expectedOutput: "Welcome to GitLab, Anonymous!\n",
},
{
desc: "With an unknown username",
arguments: &commandargs.Shell{GitlabUsername: "unknown"},
expectedOutput: "Welcome to GitLab, Anonymous!\n",
},
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
buffer := &bytes.Buffer{}
cmd := &Command{
Config: &config.Config{GitlabUrl: url},
Args: tc.arguments,
ReadWriter: &readwriter.ReadWriter{Out: buffer},
}
err := cmd.Execute(context.Background())
require.NoError(t, err)
require.Equal(t, tc.expectedOutput, buffer.String())
})
}
} | explode_data.jsonl/56000 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 569
} | [
2830,
3393,
17174,
1155,
353,
8840,
836,
8,
341,
19320,
1669,
1273,
4030,
12101,
10286,
2905,
5475,
1155,
11,
7388,
692,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
1843,
914,
198,
197,
197,
16370,
414,
353,
5631,
2116,
10849,
613,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLookupPTR(t *testing.T) {
testenv.MustHaveExternalNetwork(t)
for _, addr := range lookupTestIPs {
names, err := LookupAddr(addr)
if err != nil {
t.Errorf("failed %s: %s", addr, err)
}
if len(names) == 0 {
t.Errorf("no results")
}
expected, err := lookupPTR(addr)
if err != nil {
t.Logf("skipping failed lookup %s test: %s", addr, err)
}
sort.Strings(expected)
sort.Strings(names)
if !reflect.DeepEqual(expected, names) {
t.Errorf("different results %s:\texp:%v\tgot:%v", addr, toJson(expected), toJson(names))
}
}
} | explode_data.jsonl/5820 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
34247,
47605,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
50463,
12116,
25913,
12320,
1155,
692,
2023,
8358,
10789,
1669,
2088,
18615,
2271,
3298,
82,
341,
197,
93940,
11,
1848,
1669,
50311,
13986,
24497,
340,
197,
743,
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 TestArgs(t *testing.T) {
for _, tt := range argsTests {
if !reflect.DeepEqual(tt.actual, tt.expected) {
t.Fatalf("%s is %v, want %v", tt.title, tt.actual, tt.expected)
}
}
} | explode_data.jsonl/44285 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
4117,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
2827,
18200,
341,
197,
743,
753,
34913,
94750,
47152,
68120,
11,
17853,
56835,
8,
341,
298,
3244,
30762,
4430,
82,
374,
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
] | 3 |
func Test_GenericDriver_Create(t *testing.T) {
db, mock, err := sqlmock.New()
if err != nil {
t.Errorf("sqlmock.New().error != nil, wants nil")
}
defer db.Close()
dialect := MySQLDialect{}
mock.ExpectBegin()
mock.ExpectExec(escapeQuery(dialect.CreateTableSQL())).WillReturnResult(sqlmock.NewResult(0, 0))
mock.ExpectCommit()
d, _ := NewGenericDriver(db, dialect)
d.Create()
if err := mock.ExpectationsWereMet(); err != nil {
t.Errorf("there were unfulfilled expections: %s", err)
}
} | explode_data.jsonl/78090 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
29085,
11349,
34325,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
1848,
1669,
5704,
16712,
7121,
2822,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
3544,
16712,
7121,
1005,
841,
961,
2092,
11,
6801,
2092,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSet_SCard(t *testing.T) {
var testSetSCardKey = []byte("SCardKey")
testAddData(t, testSetSCardKey, []byte("ExistsValue1"))
testAddData(t, testSetSCardKey, []byte("ExistsValue2"))
tests := []struct {
name string
key []byte
want int64
}{
{
name: "SCardKey",
key: testSetSCardKey,
want: 2,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
txn, err := mockDB.Begin()
assert.NotNil(t, txn)
assert.NoError(t, err)
set, err := GetSet(txn, tt.key)
assert.NoError(t, err)
assert.NotNil(t, set)
got, err := set.SCard()
assert.NotNil(t, got)
assert.NoError(t, err)
if err = txn.Commit(context.TODO()); err != nil {
t.Errorf("SCard() txn.Commit error = %v", err)
return
}
assert.Equal(t, got, tt.want)
})
}
} | explode_data.jsonl/56404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 390
} | [
2830,
3393,
1649,
1098,
5770,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
1649,
3540,
567,
1592,
284,
3056,
3782,
445,
3540,
567,
1592,
1138,
18185,
2212,
1043,
1155,
11,
1273,
1649,
3540,
567,
1592,
11,
3056,
3782,
445,
15575,
1130,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCaller(t *testing.T) {
procs := runtime.GOMAXPROCS(-1)
c := make(chan bool, procs)
for p := 0; p < procs; p++ {
go func() {
for i := 0; i < 1000; i++ {
testCallerFoo(t)
}
c <- true
}()
defer func() {
<-c
}()
}
} | explode_data.jsonl/59624 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
58735,
1155,
353,
8840,
836,
8,
341,
197,
90087,
1669,
15592,
1224,
1898,
2954,
9117,
6412,
4080,
16,
340,
1444,
1669,
1281,
35190,
1807,
11,
462,
4837,
340,
2023,
281,
1669,
220,
15,
26,
281,
366,
462,
4837,
26,
281,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLogin_LoginHint_Hydra_Success(t *testing.T) {
s, cfg, _, h, _, err := setupHydraTest(true)
if err != nil {
t.Fatalf("setupHydraTest() failed: %v", err)
}
resp := sendLogin(s, cfg, h, "login_hint=idp:foo@bar.com", []string{"openid", "identities", "offline"})
if resp.StatusCode != http.StatusSeeOther {
t.Errorf("resp.StatusCode wants %d, got %d", http.StatusSeeOther, resp.StatusCode)
}
idpc := cfg.TrustedIssuers[s.defaultBroker]
l := resp.Header.Get("Location")
loc, err := url.Parse(l)
if err != nil {
t.Fatalf("url.Parse(%s) failed", l)
}
a, err := url.Parse(idpc.AuthUrl)
if err != nil {
t.Fatalf("url.Parse(%s) failed", idpc.AuthUrl)
}
if loc.Scheme != a.Scheme {
t.Errorf("Scheme wants %s got %s", a.Scheme, loc.Scheme)
}
if loc.Host != a.Host {
t.Errorf("Host wants %s got %s", a.Host, loc.Host)
}
if loc.Path != a.Path {
t.Errorf("Path wants %s got %s", a.Path, loc.Path)
}
q := loc.Query()
wantLoginHint := "idp:foo@bar.com"
if q.Get("login_hint") != wantLoginHint {
t.Errorf("login_hint = %s wants %s", q.Get("login_hint"), wantLoginHint)
}
} | explode_data.jsonl/18494 | {
"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,
6231,
79232,
26987,
2039,
88,
22248,
87161,
1155,
353,
8840,
836,
8,
341,
1903,
11,
13286,
11,
8358,
305,
11,
8358,
1848,
1669,
6505,
30816,
22248,
2271,
3715,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
15188,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateRuntimeConfigurationInvalidKernelParams(t *testing.T) {
assert := assert.New(t)
config := oci.RuntimeConfig{}
tomlConf := tomlConfig{}
savedFunc := GetKernelParamsFunc
defer func() {
GetKernelParamsFunc = savedFunc
}()
GetKernelParamsFunc = func(needSystemd, trace bool) []vc.Param {
return []vc.Param{
{
Key: "",
Value: "",
},
}
}
err := updateRuntimeConfig("", tomlConf, &config, false)
assert.EqualError(err, "Empty kernel parameter")
} | explode_data.jsonl/11750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 194
} | [
2830,
3393,
4289,
15123,
7688,
7928,
26343,
4870,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
25873,
1669,
93975,
16706,
2648,
31483,
3244,
316,
75,
15578,
1669,
311,
1014,
2648,
31483,
1903,
4141,
9626,
1669,
2126,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDirFileFileFromUserHomeDir(t *testing.T) {
hds := NewHomedirService()
content := []byte(`t`)
pathToFile := "./testfile"
_, err := hds.ReadFileFromUserHomeDir(pathToFile)
assert.Error(t, err)
err = hds.WriteFileToUserHomeDir(content, pathToFile)
assert.Nil(t, err)
strcontent, err := hds.ReadFileFromUserHomeDir(pathToFile)
assert.NotEmpty(t, strcontent)
assert.Nil(t, err)
os.RemoveAll(pathToFile)
} | explode_data.jsonl/35867 | {
"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,
6184,
1703,
1703,
3830,
1474,
7623,
6184,
1155,
353,
8840,
836,
8,
341,
9598,
5356,
1669,
1532,
39,
24139,
404,
1860,
741,
27751,
1669,
3056,
3782,
5809,
83,
24183,
26781,
41550,
1669,
5924,
1944,
1192,
698,
197,
6878,
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 |
func TestGetFederatedBundle(t *testing.T) {
test := setupServiceTest(t)
defer test.Cleanup()
for _, tt := range []struct {
name string
trustDomain string
err string
expectLogs []spiretest.LogEntry
outputMask *types.BundleMask
isAdmin bool
isAgent bool
isLocal bool
setBundle bool
}{
{
name: "Trust domain is empty",
isAdmin: true,
err: "rpc error: code = InvalidArgument desc = trust domain argument is not valid: trust domain is missing",
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: trust domain argument is not valid",
Data: logrus.Fields{
telemetry.TrustDomainID: "",
logrus.ErrorKey: "trust domain is missing",
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: "trust domain argument is not valid: trust domain is missing",
telemetry.TrustDomainID: "",
telemetry.Type: "audit",
},
},
},
},
{
name: "Trust domain is not a valid trust domain",
isAdmin: true,
trustDomain: "malformed id",
err: `rpc error: code = InvalidArgument desc = trust domain argument is not valid: trust domain characters are limited to lowercase letters, numbers, dots, dashes, and underscores`,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: trust domain argument is not valid",
Data: logrus.Fields{
telemetry.TrustDomainID: "malformed id",
logrus.ErrorKey: `trust domain characters are limited to lowercase letters, numbers, dots, dashes, and underscores`,
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: `trust domain argument is not valid: trust domain characters are limited to lowercase letters, numbers, dots, dashes, and underscores`,
telemetry.TrustDomainID: "malformed id",
telemetry.Type: "audit",
},
},
},
},
{
name: "The given trust domain is server's own trust domain",
isAdmin: true,
trustDomain: "example.org",
err: "rpc error: code = InvalidArgument desc = getting a federated bundle for the server's own trust domain is not allowed",
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Invalid argument: getting a federated bundle for the server's own trust domain is not allowed",
Data: logrus.Fields{
telemetry.TrustDomainID: serverTrustDomain.String(),
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "InvalidArgument",
telemetry.StatusMessage: "getting a federated bundle for the server's own trust domain is not allowed",
telemetry.TrustDomainID: "example.org",
telemetry.Type: "audit",
},
},
},
},
{
name: "Trust domain not found",
isAdmin: true,
trustDomain: "another-example.org",
err: `rpc error: code = NotFound desc = bundle not found`,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.ErrorLevel,
Message: "Bundle not found",
Data: logrus.Fields{
telemetry.TrustDomainID: federatedTrustDomain.String(),
},
},
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "error",
telemetry.StatusCode: "NotFound",
telemetry.StatusMessage: "bundle not found",
telemetry.TrustDomainID: "another-example.org",
telemetry.Type: "audit",
},
},
},
},
{
name: "Get federated bundle do not returns fields filtered by mask",
isAdmin: true,
trustDomain: "another-example.org",
setBundle: true,
outputMask: &types.BundleMask{
RefreshHint: false,
SequenceNumber: false,
X509Authorities: false,
JwtAuthorities: false,
},
expectLogs: []spiretest.LogEntry{
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "success",
telemetry.TrustDomainID: "another-example.org",
telemetry.Type: "audit",
},
},
},
},
{
name: "Get federated bundle succeeds for admin workloads",
isAdmin: true,
trustDomain: "another-example.org",
setBundle: true,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "success",
telemetry.TrustDomainID: "another-example.org",
telemetry.Type: "audit",
},
},
},
},
{
name: "Get federated bundle succeeds for local workloads",
isLocal: true,
trustDomain: "another-example.org",
setBundle: true,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "success",
telemetry.TrustDomainID: "another-example.org",
telemetry.Type: "audit",
},
},
},
},
{
name: "Get federated bundle succeeds for agent workload",
isAgent: true,
trustDomain: "another-example.org",
setBundle: true,
expectLogs: []spiretest.LogEntry{
{
Level: logrus.InfoLevel,
Message: "API accessed",
Data: logrus.Fields{
telemetry.Status: "success",
telemetry.TrustDomainID: "another-example.org",
telemetry.Type: "audit",
},
},
},
},
} {
tt := tt
t.Run(tt.name, func(t *testing.T) {
test.logHook.Reset()
test.isAdmin = tt.isAdmin
test.isAgent = tt.isAgent
test.isLocal = tt.isLocal
bundle := makeValidCommonBundle(t, federatedTrustDomain)
if tt.setBundle {
test.setBundle(t, bundle)
}
b, err := test.client.GetFederatedBundle(context.Background(), &bundlev1.GetFederatedBundleRequest{
TrustDomain: tt.trustDomain,
OutputMask: tt.outputMask,
})
spiretest.AssertLogs(t, test.logHook.AllEntries(), tt.expectLogs)
if tt.err != "" {
require.Nil(t, b)
require.Error(t, err)
require.EqualError(t, err, tt.err)
return
}
require.NoError(t, err)
require.NotNil(t, b)
assertCommonBundleWithMask(t, bundle, b, tt.outputMask)
})
}
} | explode_data.jsonl/45885 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3050
} | [
2830,
3393,
1949,
37,
7294,
657,
8409,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
6505,
1860,
2271,
1155,
340,
16867,
1273,
727,
60639,
2822,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
25583,
590,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnv(t *testing.T) {
env, err := NewEnv("KeysTest", build)
require.NoError(t, err)
defer func() {
removeErr := os.RemoveAll(env.AppDir())
require.NoError(t, removeErr)
}()
require.Equal(t, "KeysTest", env.AppName())
require.Equal(t, 9999, env.Port())
env.SetInt("port", 3001)
env.Set("server", "https://server.url")
env.SetBool("disableSymlinkCheck", true)
err = env.Save()
require.NoError(t, err)
env2, err := NewEnv("KeysTest", build)
require.NoError(t, err)
require.Equal(t, 3001, env2.Port())
require.Equal(t, "https://server.url", env2.Server())
require.True(t, env2.GetBool("disableSymlinkCheck"))
} | explode_data.jsonl/45053 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
14359,
1155,
353,
8840,
836,
8,
341,
57538,
11,
1848,
1669,
1532,
14359,
445,
8850,
2271,
497,
1936,
340,
17957,
35699,
1155,
11,
1848,
340,
16867,
2915,
368,
341,
197,
47233,
7747,
1669,
2643,
84427,
16978,
5105,
6184,
2398... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostStoreDelete1Level(t *testing.T) {
Setup()
o1 := &model.Post{}
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "zz" + model.NewId() + "b"
o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
o2.UserId = model.NewId()
o2.Message = "zz" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
if r2 := <-store.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
t.Fatal("Deleted id should have failed")
}
if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
t.Fatal("Deleted id should have failed")
}
} | explode_data.jsonl/55943 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
4133,
6093,
6435,
16,
4449,
1155,
353,
8840,
836,
8,
341,
197,
21821,
2822,
22229,
16,
1669,
609,
2528,
23442,
16094,
22229,
16,
38716,
764,
284,
1614,
7121,
764,
741,
22229,
16,
37478,
284,
1614,
7121,
764,
741,
22229,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestJWXRace(t *testing.T) {
e := echo.New()
handler := func(c echo.Context) error {
return c.String(http.StatusOK, "test")
}
initialToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
raceToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlJhY2UgQ29uZGl0aW9uIiwiYWRtaW4iOmZhbHNlfQ.Xzkx9mcgGqYMTkuxSCbJ67lsDyk5J2aB7hu65cEE-Ss"
validKey := []byte("secret")
key, err := jwk.New(validKey)
if !assert.NoError(t, err, `jwk.New should succeed`) {
return
}
h := jwx.WithConfig(jwx.Config{
Key: key,
})(handler)
makeReq := func(token string) echo.Context {
req := httptest.NewRequest(http.MethodGet, "/", nil)
res := httptest.NewRecorder()
req.Header.Set(echo.HeaderAuthorization, jwx.DefaultConfig.AuthScheme+" "+token)
c := e.NewContext(req, res)
if !assert.NoError(t, h(c)) {
panic("error")
}
return c
}
c := makeReq(initialToken)
user := c.Get("user").(jwt.Token)
{
v, ok := user.Get("name")
if !assert.True(t, ok, "'name' field should exist") {
return
}
if !assert.Equal(t, v, "John Doe", "'name' field should match") {
return
}
}
makeReq(raceToken)
user = c.Get("user").(jwt.Token)
// Initial context should still be "John Doe", not "Race Condition"
{
v, ok := user.Get("name")
if !assert.True(t, ok, "'name' field should exist") {
return
}
if !assert.Equal(t, v, "John Doe", "'name' field should match") {
return
}
}
{
v, ok := user.Get("admin")
if !assert.True(t, ok, "'adming' field should exist") {
return
}
if !assert.Equal(t, v, true, "'admin' field should match") {
return
}
}
} | explode_data.jsonl/55413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 842
} | [
2830,
3393,
41,
54,
52821,
578,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1687,
7121,
741,
53326,
1669,
2915,
1337,
1687,
9328,
8,
1465,
341,
197,
853,
272,
6431,
19886,
52989,
11,
330,
1944,
1138,
197,
532,
85270,
3323,
1669,
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 TestVarsInitialized(t *testing.T) {
// Test that global initialization was successful
for i, k := range []tag.Key{Host, StatusCode, Path, Method} {
if k.Name() == "" {
t.Errorf("key not initialized: %d", i)
}
}
for i, m := range []stats.Measure{ClientRequestCount, ClientResponseBytes, ClientRequestBytes, ClientLatency} {
if m == nil {
t.Errorf("measure not initialized: %d", i)
}
}
for i, v := range DefaultViews {
if v == nil {
t.Errorf("view not initialized: %d", i)
}
}
} | explode_data.jsonl/54618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 192
} | [
2830,
3393,
28305,
22495,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
429,
3644,
17465,
572,
6849,
198,
2023,
600,
11,
595,
1669,
2088,
3056,
4578,
9610,
90,
9296,
11,
53403,
11,
7933,
11,
6730,
92,
341,
197,
743,
595,
2967,
368,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestGenerateSigningKeyPairED25519(t *testing.T) {
curve := CurveEd25519
publicKey, privateKey := GenerateKeyFilesForTest(t, curve)
assert.Equal(t, len(publicKey), PublicKeyED25519Len, "public key length not correct")
assert.Equal(t, len(privateKey), PrivateKeyED25519Len, "private key length not correct")
} | explode_data.jsonl/4725 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
31115,
93358,
1592,
12443,
1479,
17,
20,
20,
16,
24,
1155,
353,
8840,
836,
8,
1476,
33209,
586,
1669,
53677,
2715,
17,
20,
20,
16,
24,
198,
1219,
1592,
11,
70565,
1669,
19813,
1592,
10809,
2461,
2271,
1155,
11,
15655,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPresubmitsForBatch(t *testing.T) {
testCases := []struct {
name string
prs []PullRequest
changedFiles *changedFilesAgent
jobs []config.Presubmit
prowYAMLGetter config.ProwYAMLGetter
expected []config.Presubmit
}{
{
name: "All jobs get picked",
prs: []PullRequest{getPR("org", "repo", 1)},
jobs: []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
}},
expected: []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
}},
},
{
name: "Jobs with branchconfig get picked",
prs: []PullRequest{getPR("org", "repo", 1)},
jobs: []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
Brancher: config.Brancher{Branches: []string{defaultBranch}},
}},
expected: []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
Brancher: config.Brancher{Branches: []string{defaultBranch}},
}},
},
{
name: "Optional jobs are excluded",
prs: []PullRequest{getPR("org", "repo", 1)},
jobs: []config.Presubmit{
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
},
{
Reporter: config.Reporter{Context: "bar"},
},
},
expected: []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
}},
},
{
name: "Jobs that are required by any of the PRs get included",
prs: []PullRequest{
getPR("org", "repo", 2),
getPR("org", "repo", 1, func(pr *PullRequest) {
pr.HeadRefOID = githubql.String("sha")
}),
},
jobs: []config.Presubmit{{
RegexpChangeMatcher: config.RegexpChangeMatcher{
RunIfChanged: "/very-important",
},
Reporter: config.Reporter{Context: "foo"},
}},
changedFiles: &changedFilesAgent{
changeCache: map[changeCacheKey][]string{
{org: "org", repo: "repo", number: 1, sha: "sha"}: {"/very-important"},
{org: "org", repo: "repo", number: 2}: {},
},
nextChangeCache: map[changeCacheKey][]string{},
},
expected: []config.Presubmit{{
RegexpChangeMatcher: config.RegexpChangeMatcher{
RunIfChanged: "/very-important",
},
Reporter: config.Reporter{Context: "foo"},
}},
},
{
name: "Inrepoconfig jobs get included if headref matches",
prs: []PullRequest{
getPR("org", "repo", 2),
getPR("org", "repo", 1, func(pr *PullRequest) {
pr.HeadRefOID = githubql.String("sha")
}),
},
jobs: []config.Presubmit{
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
},
},
prowYAMLGetter: prowYAMLGetterForHeadRefs([]string{"sha", ""}, []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "bar"},
}}),
expected: []config.Presubmit{
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
},
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "bar"},
},
},
},
{
name: "Inrepoconfig jobs do not get included if headref doesnt match",
prs: []PullRequest{
getPR("org", "repo", 2),
getPR("org", "repo", 1, func(pr *PullRequest) {
pr.HeadRefOID = githubql.String("sha")
}),
},
jobs: []config.Presubmit{
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
},
},
prowYAMLGetter: prowYAMLGetterForHeadRefs([]string{"other-sha", ""}, []config.Presubmit{{
AlwaysRun: true,
Reporter: config.Reporter{Context: "bar"},
}}),
expected: []config.Presubmit{
{
AlwaysRun: true,
Reporter: config.Reporter{Context: "foo"},
},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if tc.changedFiles == nil {
tc.changedFiles = &changedFilesAgent{
changeCache: map[changeCacheKey][]string{},
}
for _, pr := range tc.prs {
key := changeCacheKey{
org: string(pr.Repository.Owner.Login),
repo: string(pr.Repository.Name),
number: int(pr.Number),
sha: string(pr.HeadRefOID),
}
tc.changedFiles.changeCache[key] = []string{}
}
}
if err := config.SetPresubmitRegexes(tc.jobs); err != nil {
t.Fatalf("failed to set presubmit regexes: %v", err)
}
inrepoconfig := config.InRepoConfig{}
if tc.prowYAMLGetter != nil {
inrepoconfig.Enabled = map[string]*bool{"*": utilpointer.BoolPtr(true)}
}
c := &Controller{
changedFiles: tc.changedFiles,
config: func() *config.Config {
return &config.Config{
JobConfig: config.JobConfig{
PresubmitsStatic: map[string][]config.Presubmit{
"org/repo": tc.jobs,
},
ProwYAMLGetter: tc.prowYAMLGetter,
},
ProwConfig: config.ProwConfig{
InRepoConfig: inrepoconfig,
},
}
},
logger: logrus.WithField("test", tc.name),
}
presubmits, err := c.presubmitsForBatch(tc.prs, "org", "repo", "baseSHA", defaultBranch)
if err != nil {
t.Fatalf("failed to get presubmits for batch: %v", err)
}
// Clear regexes, otherwise DeepEqual comparison wont work
config.ClearCompiledRegexes(presubmits)
if !equality.Semantic.DeepEqual(tc.expected, presubmits) {
t.Errorf("returned presubmits do not match expected, diff: %v\n", diff.ObjectReflectDiff(tc.expected, presubmits))
}
})
}
} | explode_data.jsonl/42794 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2482
} | [
2830,
3393,
14367,
392,
44703,
2461,
21074,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
198,
197,
25653,
82,
310,
3056,
36068,
1900,
198,
197,
197,
17353,
10809,
256,
353,
17353,
10809,
1681... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaxEPSSampler(t *testing.T) {
for _, testCase := range []struct {
name string
events []*pb.Span
maxEPS float64
pastEPS float64
expectedSampleRate float64
deltaPct float64
}{
{"low", generateTestEvents(1000), 100, 50, 1., 0},
{"limit", generateTestEvents(1000), 100, 100, 1., 0},
{"overload", generateTestEvents(1000), 100, 150, 100. / 150., 0.1},
} {
t.Run(testCase.name, func(t *testing.T) {
assert := assert.New(t)
counter := &MockRateCounter{
GetRateResult: testCase.pastEPS,
}
testSampler := newMaxEPSSampler(testCase.maxEPS)
testSampler.rateCounter = counter
testSampler.Start()
sampled := 0
for _, event := range testCase.events {
sample, rate := testSampler.Sample(event)
if sample {
sampled++
}
assert.EqualValues(testCase.expectedSampleRate, rate)
}
testSampler.Stop()
assert.InDelta(testCase.expectedSampleRate, float64(sampled)/float64(len(testCase.events)), testCase.expectedSampleRate*testCase.deltaPct)
})
}
} | explode_data.jsonl/2269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 471
} | [
2830,
3393,
5974,
9197,
1220,
34501,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
54452,
1669,
2088,
3056,
1235,
341,
197,
11609,
2290,
914,
198,
197,
90873,
1797,
29838,
16650,
85309,
198,
197,
22543,
45177,
1797,
2224,
21,
19,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestJoinPath(t *testing.T) {
assert.Equal(t, "/", JoinPath("/"))
assert.Equal(t, "/", JoinPath("/", "/"))
assert.Equal(t, "/", JoinPath("/", ""))
assert.Equal(t, "/", JoinPath("/", "/", "", "/"))
assert.Equal(t, "/qwe", JoinPath("/", "/qwe"))
assert.Equal(t, "/qwe/asd", JoinPath("/", "qwe", "asd"))
assert.Equal(t, "/qwe/asd", JoinPath("/", "/qwe", "/asd"))
assert.Equal(t, "/qwe/asd", JoinPath("/", "qwe/", "/asd"))
assert.Equal(t, "/qwe/asd", JoinPath("/", "qwe", "/asd"))
assert.Equal(t, "/qwe/asd/", JoinPath("/", "qwe/", "asd/"))
assert.Equal(t, "/qwe/asd/", JoinPath("/", "qwe/", "asd", "/"))
assert.Equal(t, "/", JoinPath("/", "..", ".."))
assert.Equal(t, "/", JoinPath("..", ".."))
assert.Equal(t, "/a", JoinPath("..", "..", "a"))
assert.Equal(t, "/qwe/asd/", JoinPath("/", "qwe/", ".", "asd", "/"))
assert.Equal(t, "/asd/", JoinPath("/", "qwe/", "..", "asd", "/"))
assert.Equal(t, "/asd/", JoinPath("/", "qwe/", "..", "..", "asd/"))
} | explode_data.jsonl/2718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 459
} | [
2830,
3393,
12292,
1820,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
64657,
16471,
1820,
4283,
5455,
6948,
12808,
1155,
11,
64657,
16471,
1820,
35460,
3521,
5455,
6948,
12808,
1155,
11,
64657,
16471,
1820,
35460,
77561,
6948,
128... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPeriodFunc(t *testing.T) {
assert.NotPanics(t, func() {
out := make(chan bool, 1)
mjob, _ := PeriodFunc(0, time.Millisecond, func() {
out <- true
}, nil)
<-out
v := <-out
assert.True(t, v)
mjob.Cancel()
})
} | explode_data.jsonl/56060 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
23750,
9626,
1155,
353,
8840,
836,
8,
341,
6948,
15000,
35693,
1211,
1155,
11,
2915,
368,
341,
197,
13967,
1669,
1281,
35190,
1807,
11,
220,
16,
340,
197,
2109,
8799,
11,
716,
1669,
25492,
9626,
7,
15,
11,
882,
71482,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCliRun(t *testing.T) {
type testcase struct {
name string
input []string
expect int
}
cases := []testcase{
{"no args", []string{}, ExitArgError},
{"show Version", []string{"-V"}, ExitOK},
{"help", []string{"-h"}, ExitOK},
}
nullbuf := bytes.NewBuffer([]byte{})
for _, v := range cases {
args := []string{"program-name"}
args = append(args, v.input...)
cli := &CLI{OutStream: nullbuf, ErrStream: nullbuf, quiet: true}
ret := cli.Run(args)
if ret != v.expect {
t.Errorf("%s:given %d expect %d", v.name, ret, v.expect)
}
}
} | explode_data.jsonl/2295 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
87014,
6727,
1155,
353,
8840,
836,
8,
341,
13158,
70080,
2036,
341,
197,
11609,
256,
914,
198,
197,
22427,
220,
3056,
917,
198,
197,
24952,
526,
198,
197,
630,
1444,
2264,
1669,
3056,
1944,
5638,
515,
197,
197,
4913,
2152,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomFlagsUnused(t *testing.T) {
app := &App{
Flags: []Flag{&customBoolFlag{"custom"}},
}
err := app.Run([]string{"foo"})
if err != nil {
t.Errorf("Run returned unexpected error: %v", err)
}
} | explode_data.jsonl/52596 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
10268,
9195,
94033,
1155,
353,
8840,
836,
8,
341,
28236,
1669,
609,
2164,
515,
197,
197,
9195,
25,
3056,
12135,
90,
5,
9163,
11233,
12135,
4913,
9163,
48085,
197,
630,
9859,
1669,
906,
16708,
10556,
917,
4913,
7975,
23625,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTimeWithZone(t *testing.T) {
var format = "2006-01-02 15:04:05 -0700"
var times []time.Time
GMT8, _ := time.LoadLocation("Asia/Shanghai")
times = append(times, time.Date(2013, 02, 19, 1, 51, 49, 123456789, GMT8))
times = append(times, time.Date(2013, 02, 18, 17, 51, 49, 123456789, time.UTC))
for index, vtime := range times {
name := "time_with_zone_" + strconv.Itoa(index)
user := User{Name: name, Birthday: &vtime}
if !DialectHasTzSupport() {
// If our driver dialect doesn't support TZ's, just use UTC for everything here.
utcBirthday := user.Birthday.UTC()
user.Birthday = &utcBirthday
}
DB.Save(&user)
expectedBirthday := "2013-02-18 17:51:49 +0000"
foundBirthday := user.Birthday.UTC().Format(format)
if foundBirthday != expectedBirthday {
t.Errorf("User's birthday should not be changed after save for name=%s, expected bday=%+v but actual value=%+v", name, expectedBirthday, foundBirthday)
}
var findUser, findUser2, findUser3 User
DB.First(&findUser, "name = ?", name)
foundBirthday = findUser.Birthday.UTC().Format(format)
if foundBirthday != expectedBirthday {
t.Errorf("User's birthday should not be changed after find for name=%s, expected bday=%+v but actual value=%+v", name, expectedBirthday, foundBirthday)
}
if DB.Where("id = ? AND birthday >= ?", findUser.Id, user.Birthday.Add(-time.Minute)).First(&findUser2).RecordNotFound() {
t.Errorf("User should be found")
}
if !DB.Where("id = ? AND birthday >= ?", findUser.Id, user.Birthday.Add(time.Minute)).First(&findUser3).RecordNotFound() {
t.Errorf("User should not be found")
}
}
} | explode_data.jsonl/28059 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
1462,
2354,
15363,
1155,
353,
8840,
836,
8,
341,
2405,
3561,
284,
330,
17,
15,
15,
21,
12,
15,
16,
12,
15,
17,
220,
16,
20,
25,
15,
19,
25,
15,
20,
481,
15,
22,
15,
15,
698,
2405,
3039,
3056,
1678,
16299,
198,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestErrors(t *testing.T) {
o := testclient.NewObjects(kapi.Scheme, kapi.Codecs.UniversalDecoder())
o.Add(&kapi.List{
Items: []runtime.Object{
&(errors.NewNotFound(deployapi.Resource("DeploymentConfigList"), "").(*errors.StatusError).ErrStatus),
&(errors.NewForbidden(deployapi.Resource("DeploymentConfigList"), "", nil).(*errors.StatusError).ErrStatus),
},
})
oc, _ := NewFixtureClients(o)
_, err := oc.DeploymentConfigs("test").List(kapi.ListOptions{})
if !errors.IsNotFound(err) {
t.Fatalf("unexpected error: %v", err)
}
t.Logf("error: %#v", err.(*errors.StatusError).Status())
_, err = oc.DeploymentConfigs("test").List(kapi.ListOptions{})
if !errors.IsForbidden(err) {
t.Fatalf("unexpected error: %v", err)
}
} | explode_data.jsonl/64989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
13877,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
1273,
2972,
7121,
11543,
5969,
2068,
92719,
11,
595,
2068,
20274,
4837,
10616,
33952,
20732,
2398,
22229,
1904,
2099,
74,
2068,
5814,
515,
197,
197,
4353,
25,
3056,
22255,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHasPort(t *testing.T) {
for host, want := range hasPortTests {
if got := hasPort(host); got != want {
t.Errorf("%q: got %t, want %t", host, got, want)
}
}
} | explode_data.jsonl/14660 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
10281,
7084,
1155,
353,
8840,
836,
8,
341,
2023,
3468,
11,
1366,
1669,
2088,
702,
7084,
18200,
341,
197,
743,
2684,
1669,
702,
7084,
19973,
1215,
2684,
961,
1366,
341,
298,
3244,
13080,
4430,
80,
25,
2684,
1018,
83,
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
] | 3 |
func TestMapProxy_ForceUnlock(t *testing.T) {
mp.Put("testingKey", "testingValue")
ok, err := mp.TryLockWithTimeoutAndLease("testingKey", 1, time.Second, 20, time.Second)
AssertEqualf(t, err, ok, true, "Try Lock failed")
mp.ForceUnlock("testingKey")
locked, err := mp.IsLocked("testingKey")
AssertEqualf(t, err, locked, false, "Key should not be locked.")
mp.Unlock("testingKey")
mp.Clear()
} | explode_data.jsonl/56996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
2227,
16219,
1400,
16316,
49679,
1155,
353,
8840,
836,
8,
341,
53230,
39825,
445,
8840,
1592,
497,
330,
8840,
1130,
1138,
59268,
11,
1848,
1669,
10490,
19824,
11989,
2354,
7636,
3036,
2304,
519,
445,
8840,
1592,
497,
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 |
func TestExtensionStage(t *testing.T) {
always := true
manager := Manager{
hooks: map[string]*current.Hook{
"a.json": {
Version: current.Version,
Hook: rspec.Hook{
Path: "/a/b/c",
},
When: current.When{
Always: &always,
},
Stages: []string{"prestart", "poststop", "a", "b"},
},
},
extensionStages: []string{"poststop", "a", "b", "c"},
}
config := &rspec.Spec{}
extensionStageHooks, err := manager.Hooks(config, map[string]string{}, false)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, &rspec.Hooks{
Prestart: []rspec.Hook{
{
Path: "/a/b/c",
},
},
}, config.Hooks)
assert.Equal(t, map[string][]rspec.Hook{
"poststop": {
{
Path: "/a/b/c",
},
},
"a": {
{
Path: "/a/b/c",
},
},
"b": {
{
Path: "/a/b/c",
},
},
}, extensionStageHooks)
} | explode_data.jsonl/25019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
12049,
19398,
1155,
353,
8840,
836,
8,
341,
197,
32122,
1669,
830,
198,
92272,
1669,
10567,
515,
197,
9598,
14685,
25,
2415,
14032,
8465,
3231,
3839,
1941,
515,
298,
197,
56693,
4323,
788,
341,
571,
77847,
25,
1482,
35842,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSet(t *testing.T) {
seq := newSequence()
seq.set(1)
id := seq.get()
if id != 1 {
t.Error("set() should set a new value.")
}
} | explode_data.jsonl/62905 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 62
} | [
2830,
3393,
1649,
1155,
353,
8840,
836,
8,
341,
78561,
1669,
501,
14076,
741,
78561,
980,
7,
16,
340,
15710,
1669,
12981,
670,
741,
743,
877,
961,
220,
16,
341,
197,
3244,
6141,
445,
746,
368,
1265,
738,
264,
501,
897,
13053,
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
] | 2 |
func Test_DecryptLoginPacket(t *testing.T) {
packet := "testing packet"
encrypted := noscryptoclt.EncryptLoginPacket(packet)
decrypted := DecryptLoginPacket(encrypted)
assert.Equal(t, packet, decrypted, "Decrypted packet should be the same as the one encrypted by client encryption algorithm")
} | explode_data.jsonl/22227 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 90
} | [
2830,
3393,
78668,
3571,
6231,
16679,
1155,
353,
8840,
836,
8,
341,
68802,
1669,
330,
8840,
10151,
698,
197,
36444,
1669,
11891,
48125,
509,
4832,
26598,
3571,
6231,
16679,
37441,
340,
197,
8169,
14026,
1669,
89146,
6231,
16679,
7,
36444,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_validateProtocol(t *testing.T) {
testCases := []struct {
protocol string
valid bool
desc string
}{
{ // case[0]
protocol: "foo",
valid: false,
},
{ // case[1]
protocol: ProtocolTCP,
valid: true,
},
{ // case[2]
protocol: ProtocolUDP,
valid: true,
},
{ // case[3]
protocol: "ipv4",
valid: false,
},
{ // case[4]
protocol: "ipv6",
valid: false,
},
{ // case[5]
protocol: "TCP",
valid: false,
desc: "should be low case",
},
{ // case[6]
protocol: "UDP",
valid: false,
desc: "should be low case",
},
{ // case[7]
protocol: "",
valid: false,
},
{ // case[8]
protocol: ProtocolSCTP,
valid: true,
},
}
for i := range testCases {
valid := validateProtocol(testCases[i].protocol)
if valid != testCases[i].valid {
t.Errorf("case [%d]: unexpected mismatch, expect valid[%v], got valid[%v], desc: %s", i, testCases[i].valid, valid, testCases[i].desc)
}
}
} | explode_data.jsonl/74019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 505
} | [
2830,
3393,
42681,
20689,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
17014,
914,
198,
197,
56322,
262,
1807,
198,
197,
41653,
257,
914,
198,
197,
59403,
197,
197,
90,
442,
1142,
58,
15,
921,
298,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRSAPublicKey(t *testing.T) {
ctx := &MockCtx{}
s := &Session{ctx, 0}
// test attribute retrieval failing
ctx.GetAttributeValueFunc = func(pkcs11.SessionHandle, pkcs11.ObjectHandle, []*pkcs11.Attribute) ([]*pkcs11.Attribute, error) {
return nil, errors.New("yup")
}
_, err := s.GetRSAPublicKey(0)
test.AssertError(t, err, "rsaPub didn't fail on GetAttributeValue error")
// test we fail to construct key with missing modulus and exp
ctx.GetAttributeValueFunc = func(pkcs11.SessionHandle, pkcs11.ObjectHandle, []*pkcs11.Attribute) ([]*pkcs11.Attribute, error) {
return []*pkcs11.Attribute{}, nil
}
_, err = s.GetRSAPublicKey(0)
test.AssertError(t, err, "rsaPub didn't fail with empty attribute list")
// test we don't fail with the correct attributes
ctx.GetAttributeValueFunc = func(pkcs11.SessionHandle, pkcs11.ObjectHandle, []*pkcs11.Attribute) ([]*pkcs11.Attribute, error) {
return []*pkcs11.Attribute{
pkcs11.NewAttribute(pkcs11.CKA_PUBLIC_EXPONENT, []byte{1, 0, 1}),
pkcs11.NewAttribute(pkcs11.CKA_MODULUS, []byte{255}),
}, nil
}
_, err = s.GetRSAPublicKey(0)
test.AssertNotError(t, err, "rsaPub failed with valid attributes")
} | explode_data.jsonl/1153 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 463
} | [
2830,
3393,
11451,
2537,
475,
1592,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
609,
11571,
23684,
16094,
1903,
1669,
609,
5283,
90,
3773,
11,
220,
15,
630,
197,
322,
1273,
7035,
56370,
21394,
198,
20985,
2234,
78554,
9626,
284,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewRespMessage(t *testing.T) {
m := NewRespMessage(uuid.NewString(), "test", []byte("test"))
if m.Type != RespMessage {
t.Fatalf("expected ReqMessage but got %s", m.Type)
}
} | explode_data.jsonl/63186 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
3564,
36555,
2052,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1532,
36555,
2052,
41458,
7121,
703,
1507,
330,
1944,
497,
3056,
3782,
445,
1944,
28075,
743,
296,
10184,
961,
79786,
2052,
341,
197,
3244,
30762,
445,
7325,
82458... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreScanInconsistentResolvesIntents(t *testing.T) {
defer leaktest.AfterTest(t)
// This test relies on having a committed Txn record and open intents on
// the same Range. This only works with auto-gc turned off; alternatively
// the test could move to splitting its underlying Range.
defer setTxnAutoGC(false)()
var intercept atomic.Value
intercept.Store(true)
TestingCommandFilter = func(args roachpb.Request, _ roachpb.Header) error {
if _, ok := args.(*roachpb.ResolveIntentRequest); ok && intercept.Load().(bool) {
return util.Errorf("error on purpose")
}
return nil
}
store, _, stopper := createTestStore(t)
defer func() { TestingCommandFilter = nil }()
defer stopper.Stop()
// Lay down 10 intents to scan over.
txn := newTransaction("test", roachpb.Key("foo"), 1, roachpb.SERIALIZABLE, store.ctx.Clock)
bt, btH := beginTxnArgs(txn.Key, txn)
if _, err := client.SendWrappedWith(store.testSender(), nil, btH, &bt); err != nil {
t.Fatal(err)
}
keys := []roachpb.Key{}
for j := 0; j < 10; j++ {
key := roachpb.Key(fmt.Sprintf("key%02d", j))
keys = append(keys, key)
args := putArgs(key, []byte(fmt.Sprintf("value%02d", j)))
txn.Sequence++
if _, err := client.SendWrappedWith(store.testSender(), nil, roachpb.Header{Txn: txn}, &args); err != nil {
t.Fatal(err)
}
}
// Now, commit txn without resolving intents. If we hadn't disabled auto-gc
// of Txn entries in this test, the Txn entry would be removed and later
// attempts to resolve the intents would fail.
etArgs, h := endTxnArgs(txn, true)
txn.Sequence++
if _, err := client.SendWrappedWith(store.testSender(), nil, h, &etArgs); err != nil {
t.Fatal(err)
}
intercept.Store(false) // allow async intent resolution
// Scan the range repeatedly until we've verified count.
sArgs := scanArgs(keys[0], keys[9].Next())
util.SucceedsWithin(t, time.Second, func() error {
if reply, err := client.SendWrappedWith(store.testSender(), nil, roachpb.Header{
ReadConsistency: roachpb.INCONSISTENT,
}, &sArgs); err != nil {
return err
} else if sReply := reply.(*roachpb.ScanResponse); len(sReply.Rows) != 10 {
return util.Errorf("could not read rows as expected")
}
return nil
})
} | explode_data.jsonl/44484 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 813
} | [
2830,
3393,
6093,
26570,
641,
78399,
1061,
18186,
1072,
805,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
197,
322,
1096,
1273,
33644,
389,
3432,
264,
11163,
39850,
77,
3255,
323,
1787,
93515,
389,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCopyPairFormat(t *testing.T) {
pairOne := NewCurrencyPair("BTC", "USD")
pairOne.Delimiter = "-"
pairTwo := NewCurrencyPair("LTC", "USD")
var pairs []CurrencyPair
pairs = append(pairs, pairOne)
pairs = append(pairs, pairTwo)
testPair := NewCurrencyPair("BTC", "USD")
testPair.Delimiter = "~"
result := CopyPairFormat(testPair, pairs, false)
if result.Pair().String() != "BTC-USD" {
t.Error("Test failed. TestCopyPairFormat: Expected pair was not found")
}
result = CopyPairFormat(NewCurrencyPair("ETH", "USD"), pairs, true)
if result.Pair().String() != "" {
t.Error("Test failed. TestCopyPairFormat: Unexpected non empty pair returned")
}
} | explode_data.jsonl/55841 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
12106,
12443,
4061,
1155,
353,
8840,
836,
8,
341,
3223,
1310,
3966,
1669,
1532,
26321,
12443,
445,
59118,
497,
330,
26749,
1138,
3223,
1310,
3966,
909,
301,
17700,
284,
67773,
3223,
1310,
11613,
1669,
1532,
26321,
12443,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetFilePath(t *testing.T) {
expected := "blah.json"
result := GetFilePath("blah.json")
if result != "blah.json" {
t.Errorf("Test failed. TestGetFilePath: expected %s got %s", expected, result)
}
expected = ConfigTestFile
result = GetFilePath("")
if result != expected {
t.Errorf("Test failed. TestGetFilePath: expected %s got %s", expected, result)
}
} | explode_data.jsonl/21906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
1949,
19090,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
330,
70614,
4323,
698,
9559,
1669,
2126,
19090,
445,
70614,
4323,
1138,
743,
1102,
961,
330,
70614,
4323,
1,
341,
197,
3244,
13080,
445,
2271,
4641,
13,
3393,
1949,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddSetting(t *testing.T) {
t.Parallel()
ctx := context.TODO()
now := time.Now()
later := now.Add(time.Minute)
z, err := zone.New(ctx, t.Name())
require.NoError(t, err)
m, err := mode.New(ctx, z.ID, t.Name(), 60, 80, 1)
require.NoError(t, err)
s, err := New(ctx, z.ID, m.ID, DEFAULT, 1, now, later, 1, 86400)
require.NoError(t, err)
assert.Equal(t, DEFAULT, s.Priority)
assert.Equal(t, 1, s.DayOfWeek)
assert.Equal(t, now, s.StartDay)
assert.Equal(t, later, s.EndDay)
assert.Equal(t, 1, s.StartTime)
assert.Equal(t, 86400, s.EndTime)
} | explode_data.jsonl/13334 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
2212,
15400,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20985,
1669,
2266,
90988,
741,
80922,
1669,
882,
13244,
741,
8810,
962,
1669,
1431,
1904,
9730,
75770,
692,
20832,
11,
1848,
1669,
10143,
7121,
7502,
11,
259... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatusSlaveIONotRunning(t *testing.T) {
input := &SlaveStatus{
SlaveIORunning: false,
SlaveSQLRunning: true,
}
want := false
if got := input.SlaveRunning(); got != want {
t.Errorf("%#v.SlaveRunning() = %v, want %v", input, got, want)
}
} | explode_data.jsonl/44689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
2522,
95960,
1271,
354,
18990,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
609,
95960,
2522,
515,
197,
197,
95960,
42896,
11216,
25,
220,
895,
345,
197,
197,
95960,
6688,
18990,
25,
830,
345,
197,
532,
50780,
1669,
895,
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 TestConfigAnalyzer_Required(t *testing.T) {
tests := []struct {
name string
filePath string
want bool
}{
{
name: "CloudFormation yaml",
filePath: "main.yaml",
want: true,
},
{
name: "Cloudformation JSON",
filePath: "main.json",
want: true,
},
{
name: "non CloudFormation yaml",
filePath: "k8s.yaml",
want: true,
},
{
name: "non CloudFormation json",
filePath: "random.yaml",
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := ConfigAnalyzer{}
got := a.Required(tt.filePath, nil)
assert.Equal(t, tt.want, got)
})
}
} | explode_data.jsonl/34121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
2648,
54911,
62,
8164,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
17661,
1820,
914,
198,
197,
50780,
257,
1807,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
257,
330,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestKubeconfigContent(t *testing.T) {
expectedData := []byte(testValidKubeconfig)
fSys := fs.NewDocumentFs()
kubeconf := kubeconfig.NewKubeConfig(
kubeconfig.FromByte(expectedData),
kubeconfig.InjectFileSystem(fSys),
kubeconfig.InjectTempRoot("."))
path, clean, err := kubeconf.GetFile()
require.NoError(t, err)
defer clean()
actualData, err := fSys.ReadFile(path)
require.NoError(t, err)
assert.Equal(t, expectedData, actualData)
} | explode_data.jsonl/31792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
42,
3760,
1676,
2762,
1155,
353,
8840,
836,
8,
341,
42400,
1043,
1669,
3056,
3782,
8623,
4088,
42,
3760,
1676,
340,
1166,
32792,
1669,
8619,
7121,
7524,
48300,
741,
16463,
3760,
6135,
1669,
80958,
1676,
7121,
42,
3760,
2648,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCacheCNAME(t *testing.T) {
testCache := &cache{}
// Fill the cache
reply := (&dns.Msg{
MsgHdr: dns.MsgHdr{
Response: true,
},
Answer: []dns.RR{newRR(t, "google.com. 3600 IN CNAME test.google.com.")},
}).SetQuestion("google.com.", dns.TypeA)
testCache.set(&cacheItem{
m: reply,
u: testUpsAddr,
})
// Create a DNS request.
request := (&dns.Msg{}).SetQuestion("google.com.", dns.TypeA)
t.Run("no_cnames", func(t *testing.T) {
r, expired, key := testCache.get(request)
assert.False(t, expired)
assert.Nil(t, key)
assert.Nil(t, r)
})
// Now fill the cache with a cacheable CNAME response.
reply.Answer = append(reply.Answer, newRR(t, "google.com. 3600 IN A 8.8.8.8"))
testCache.set(&cacheItem{
m: reply,
u: testUpsAddr,
})
// We are testing that a proper CNAME response gets cached
t.Run("cnames_exist", func(t *testing.T) {
r, expired, key := testCache.get(request)
assert.False(t, expired)
assert.Equal(t, key, msgToKey(request))
require.NotNil(t, r)
assert.Equal(t, testUpsAddr, r.u)
})
} | explode_data.jsonl/18906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 449
} | [
2830,
3393,
8233,
34,
7535,
1155,
353,
8840,
836,
8,
341,
18185,
8233,
1669,
609,
9360,
31483,
197,
322,
21979,
279,
6500,
198,
86149,
1669,
15899,
45226,
30365,
515,
197,
197,
6611,
88367,
25,
44077,
30365,
88367,
515,
298,
69604,
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 TestPod(t *testing.T) {
trueB := true
resourceQuantityCmp := cmp.Comparer(func(x, y resource.Quantity) bool {
return x.Cmp(y) == 0
})
volume := corev1.Volume{
Name: "tools-volume",
VolumeSource: corev1.VolumeSource{},
}
pod := tb.Pod("foo-pod-123456", "foo",
tb.PodAnnotation("annotation", "annotation-value"),
tb.PodLabel("label", "label-value"),
tb.PodOwnerReference("TaskRun", "taskrun-foo",
tb.OwnerReferenceAPIVersion("a1")),
tb.PodSpec(
tb.PodServiceAccountName("sa"),
tb.PodRestartPolicy(corev1.RestartPolicyNever),
tb.PodContainer("nop", "nop:latest"),
tb.PodInitContainer("basic", "ubuntu",
tb.Command("/bin/sh"),
tb.Args("-c", "ls -l"),
tb.WorkingDir("/workspace"),
tb.EnvVar("HOME", "/builder/home"),
tb.VolumeMount("tools-volume", "/tools"),
tb.Resources(
tb.Limits(tb.Memory("1.5Gi")),
tb.Requests(
tb.CPU("100m"),
tb.Memory("1Gi"),
tb.EphemeralStorage("500Mi"),
),
),
),
tb.PodVolumes(volume),
),
)
expectedPod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "foo",
Name: "foo-pod-123456",
Annotations: map[string]string{
"annotation": "annotation-value",
},
Labels: map[string]string{
"label": "label-value",
},
OwnerReferences: []metav1.OwnerReference{{
Kind: "TaskRun",
Name: "taskrun-foo",
APIVersion: "a1",
Controller: &trueB,
BlockOwnerDeletion: &trueB,
}},
},
Spec: corev1.PodSpec{
ServiceAccountName: "sa",
RestartPolicy: corev1.RestartPolicyNever,
Containers: []corev1.Container{{
Name: "nop",
Image: "nop:latest",
}},
InitContainers: []corev1.Container{{
Name: "basic",
Image: "ubuntu",
Command: []string{"/bin/sh"},
Args: []string{"-c", "ls -l"},
WorkingDir: "/workspace",
Env: []corev1.EnvVar{{
Name: "HOME",
Value: "/builder/home",
}},
VolumeMounts: []corev1.VolumeMount{{
Name: "tools-volume",
MountPath: "/tools",
}},
Resources: corev1.ResourceRequirements{
Limits: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("1.5Gi"),
},
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("100m"),
corev1.ResourceMemory: resource.MustParse("1Gi"),
corev1.ResourceEphemeralStorage: resource.MustParse("500Mi"),
},
},
}},
Volumes: []corev1.Volume{volume},
},
}
if d := cmp.Diff(expectedPod, pod, resourceQuantityCmp); d != "" {
t.Fatalf("Pod diff -want, +got: %v", d)
}
} | explode_data.jsonl/39308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1295
} | [
2830,
3393,
23527,
1155,
353,
8840,
836,
8,
341,
42808,
33,
1669,
830,
198,
50346,
17342,
34,
1307,
1669,
26089,
2961,
61119,
18552,
2075,
11,
379,
5101,
66267,
8,
1807,
341,
197,
853,
856,
727,
1307,
7021,
8,
621,
220,
15,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBonding(t *testing.T) {
bondingStats, err := readBondingStats("fixtures/bonding")
if err != nil {
t.Fatal(err)
}
if bondingStats["bond0"][0] != 0 || bondingStats["bond0"][1] != 0 {
t.Fatal("bond0 in unexpected state")
}
if bondingStats["int"][0] != 2 || bondingStats["int"][1] != 1 {
t.Fatal("int in unexpected state")
}
if bondingStats["dmz"][0] != 2 || bondingStats["dmz"][1] != 2 {
t.Fatal("dmz in unexpected state")
}
} | explode_data.jsonl/61793 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
89844,
287,
1155,
353,
8840,
836,
8,
341,
2233,
2111,
287,
16635,
11,
1848,
1669,
1349,
89844,
287,
16635,
445,
45247,
3470,
2111,
287,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
743,
63086,
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... | 8 |
func TestMonitor(t *testing.T) {
intervalTicker := ticker.NewForce(time.Hour)
mock := newMockCheck(t)
shutdown := make(chan struct{})
// Create our config for monitoring. We will use a 0 back off so that
// out test does not need to wait.
cfg := &Config{
Checks: []*Observation{
{
Check: mock.call,
Interval: intervalTicker,
Attempts: 2,
Backoff: 0,
Timeout: time.Hour,
},
},
Shutdown: func(string, ...interface{}) {
shutdown <- struct{}{}
},
}
monitor := NewMonitor(cfg)
require.NoError(t, monitor.Start(), "could not start monitor")
// Tick is a helper we will use to tick our interval.
tick := func() {
select {
case intervalTicker.Force <- testTime:
case <-time.After(timeout):
t.Fatal("could not tick timer")
}
}
// Tick our timer and provide our error channel with a nil error. This
// mocks our check function succeeding on the first call.
tick()
mock.sendError(nil)
// Now we tick our timer again. This time send a non-nil error, followed
// by a nil error. This tests our retry logic, because we allow 2
// retries, so should recover without needing to shutdown.
tick()
mock.sendError(errNonNil)
mock.sendError(nil)
// Finally, we tick our timer once more, and send two non-nil errors
// into our error channel. This mocks our check function failing twice.
tick()
mock.sendError(errNonNil)
mock.sendError(errNonNil)
// Since we have failed within our allowed number of retries, we now
// expect a call to our shutdown function.
select {
case <-shutdown:
case <-time.After(timeout):
t.Fatal("expected shutdown")
}
require.NoError(t, monitor.Stop(), "could not stop monitor")
} | explode_data.jsonl/20301 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 578
} | [
2830,
3393,
30098,
1155,
353,
8840,
836,
8,
341,
2084,
6152,
87278,
1669,
46987,
7121,
18573,
9730,
73550,
692,
77333,
1669,
501,
11571,
3973,
1155,
340,
36196,
18452,
1669,
1281,
35190,
2036,
6257,
692,
197,
322,
4230,
1039,
2193,
369,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateOrUpdateThrottle(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
response := &http.Response{
StatusCode: http.StatusTooManyRequests,
Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))),
}
throttleErr := &retry.Error{
HTTPStatusCode: http.StatusTooManyRequests,
RawError: fmt.Errorf("error"),
Retriable: true,
RetryAfter: time.Unix(100, 0),
}
testVM := getTestVM("vm1")
armClient := mockarmclient.NewMockInterface(ctrl)
armClient.EXPECT().PutResource(gomock.Any(), to.String(testVM.ID), testVM).Return(response, throttleErr).Times(1)
armClient.EXPECT().CloseResponse(gomock.Any(), gomock.Any()).Times(1)
vmClient := getTestVMClient(armClient)
rerr := vmClient.CreateOrUpdate(context.TODO(), "rg", "vm1", testVM, "test")
assert.NotNil(t, rerr)
assert.Equal(t, throttleErr, rerr)
} | explode_data.jsonl/16705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
4021,
56059,
1001,
27535,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
21735,
1669,
609,
1254,
12574,
515,
197,
197,
15872,
25,
1758,
10538,
31246,
8441,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRound(t *testing.T) {
assert.Equal(t, 0.0, Round(0.0))
assert.Equal(t, 0.0, Round(0.4))
assert.Equal(t, 1.0, Round(0.5))
assert.Equal(t, 5.0, Round(5.4))
assert.Equal(t, 6.0, Round(5.5))
assert.Equal(t, -5.0, Round(-5.4))
assert.Equal(t, -6.0, Round(-5.5))
} | explode_data.jsonl/75135 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
27497,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
220,
15,
13,
15,
11,
17097,
7,
15,
13,
15,
4390,
6948,
12808,
1155,
11,
220,
15,
13,
15,
11,
17097,
7,
15,
13,
19,
1171,
6948,
12808,
1155,
11,
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 TestFlip64(t *testing.T) {
bm := New()
bm.AddInt(0)
bm.Flip(1, 2)
i := bm.Iterator()
if assert.True(t, i.HasNext()) {
assert.EqualValues(t, 0, i.Next())
if assert.True(t, i.HasNext()) {
assert.EqualValues(t, 1, i.Next())
assert.False(t, i.HasNext())
}
}
} | explode_data.jsonl/20326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
46808,
21,
19,
1155,
353,
8840,
836,
8,
341,
2233,
76,
1669,
1532,
741,
2233,
76,
1904,
1072,
7,
15,
340,
2233,
76,
991,
33115,
7,
16,
11,
220,
17,
340,
8230,
1669,
34868,
40846,
2822,
743,
2060,
32443,
1155,
11,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestJSONEscape(t *testing.T) {
const SCRIPT = `
var a = "\\+1";
JSON.stringify(a);
`
testScript1(SCRIPT, asciiString(`"\\+1"`), t)
} | explode_data.jsonl/10485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 68
} | [
2830,
3393,
5370,
48124,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
264,
284,
26468,
10,
16,
876,
197,
5370,
10052,
2877,
317,
197,
19324,
18185,
5910,
16,
7,
24787,
11,
47120,
703,
5809,
1,
3422,
10,
16,
39917,
70... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.