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 TestBackgroundTLFUpdater(t *testing.T) {
tc := libkb.SetupTest(t, "TestBackgroundTLFUpdater", 1)
defer tc.Cleanup()
_, err := kbtest.CreateAndSignupFakeUser("gregr", tc.G)
require.NoError(t, err)
api := &testAPIServer{}
u := NewBackgroundTLFUpdater(tc.G)
u.testingDisableKBFS = true
u.testingAPIServer = api
u.testingChatHelper = &testChatHelper{}
upgradeCh := make(chan keybase1.TLFID, 5)
u.upgradeCh = &upgradeCh
refTLFID := keybase1.TLFID("hi")
f := func() getUpgradeRes {
return getUpgradeRes{
GetTLFForUpgradeRes: NewGetTLFForUpgradeResWithTlfavailable(GetTLFForUpgradeAvailableRes{
TlfID: refTLFID,
})}
}
api.responseFn = f
clock := clockwork.NewFakeClock()
u.clock = clock
u.Run()
attempt := func(attempt int) {
clock.BlockUntil(attempt)
clock.Advance(time.Hour)
select {
case tlfID := <-upgradeCh:
require.Equal(t, refTLFID, tlfID)
case <-time.After(20 * time.Second):
require.Fail(t, "no upgrade")
}
}
attempt(1)
mctx := libkb.NewMetaContextForTest(tc)
err = u.Shutdown(mctx)
require.NoError(t, err)
} | explode_data.jsonl/3433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 453
} | [
2830,
3393,
8706,
13470,
37,
79854,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
3051,
21310,
39820,
2271,
1155,
11,
330,
2271,
8706,
13470,
37,
79854,
497,
220,
16,
340,
16867,
17130,
727,
60639,
741,
197,
6878,
1848,
1669,
38653,
1944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAttrsUpdateV2SafeString(t *testing.T) {
c := setupTest([]string{"update", "attrs", "--host", "orion", "--id", "urn:ngsi-ld:Product:010", "--data", "{\"specialOffer\":{\"value\": true}}", "--safeString", "on"})
reqRes := helper.MockHTTPReqRes{}
reqRes.Res.StatusCode = http.StatusNoContent
reqRes.Path = "/v2/entities/urn:ngsi-ld:Product:010/attrs"
helper.SetClientHTTP(c, reqRes)
err := attrsUpdate(c, c.Ngsi, c.Client)
assert.NoError(t, err)
} | explode_data.jsonl/33072 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
53671,
4289,
53,
17,
25663,
703,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
6505,
2271,
10556,
917,
4913,
2386,
497,
330,
20468,
497,
14482,
3790,
497,
330,
269,
290,
497,
14482,
307,
497,
330,
399,
25,
968,
6321,
12,
507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterByFirstLineOnlyGivesFirstLineOfInput(t *testing.T) {
t.Parallel()
p := script.Echo("hello\nworld").Filter(func(r io.Reader, w io.Writer) error {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
fmt.Fprintln(w, scanner.Text())
break
}
return scanner.Err()
})
want := "hello\n"
got, err := p.String()
if err != nil {
t.Fatal(err)
}
if want != got {
t.Error(cmp.Diff(want, got))
}
} | explode_data.jsonl/51473 | {
"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,
5632,
1359,
5338,
2460,
7308,
38,
1886,
5338,
2460,
2124,
2505,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1669,
5316,
5142,
958,
445,
14990,
1699,
14615,
1827,
5632,
18552,
2601,
6399,
47431,
11,
289,
6399,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnv(t *testing.T) {
for i, element := range EnvCases {
input := element.Input
output := element.Output
t.Run("case "+strconv.Itoa(i), func(t *testing.T) {
t.Parallel()
got := ExecuteEnvsDetectionPlugin(input.pluginDetails, input.RuntimeVersion, input.Root)
if !reflect.DeepEqual(got, output) {
t.Error("expected this ", output, "\n got this ", got)
}
})
}
} | explode_data.jsonl/21420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
14359,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
2392,
1669,
2088,
37039,
37302,
341,
197,
22427,
1669,
2392,
16130,
198,
197,
21170,
1669,
2392,
34246,
198,
197,
3244,
16708,
445,
5638,
6630,
51848,
64109,
1956,
701,
291... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalEscape(t *testing.T) {
for testName, test := range escapeTests {
t.Run(testName, func(t *testing.T) {
var result string
err := phpserialize.Unmarshal([]byte(test.Serialized), &result)
expectErrorToNotHaveOccurred(t, err)
if test.Unserialized != result {
t.Errorf("Expected:\n %#+v\nGot:\n %#+v", test.Unserialized, result)
}
})
}
} | explode_data.jsonl/27034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
1806,
27121,
48124,
1155,
353,
8840,
836,
8,
341,
2023,
94396,
11,
1273,
1669,
2088,
12449,
18200,
341,
197,
3244,
16708,
8623,
675,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
2405,
1102,
914,
198,
298,
9859,
1669,
24362... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNullTypeString(t *testing.T) {
var b Sqlizer
var name sql.NullString
b = Eq{"name": name}
sql, args, err := b.ToSql()
assert.NoError(t, err)
assert.Empty(t, args)
assert.Equal(t, "name IS NULL", sql)
name.Scan("Name")
b = Eq{"name": name}
sql, args, err = b.ToSql()
assert.NoError(t, err)
assert.Equal(t, []interface{}{"Name"}, args)
assert.Equal(t, "name = ?", sql)
} | explode_data.jsonl/44171 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
3280,
929,
703,
1155,
353,
8840,
836,
8,
341,
2405,
293,
7224,
3135,
198,
2405,
829,
5704,
23979,
703,
271,
2233,
284,
33122,
4913,
606,
788,
829,
532,
30633,
11,
2827,
11,
1848,
1669,
293,
3274,
8269,
2822,
6948,
35699,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokenConfig_Success(t *testing.T) {
assert := assertlib.New(t)
globalConfig := viper.New()
monkey.Patch(token.Initialize, func(config *viper.Viper) (*token.Config, error) {
return &token.Config{PlatformName: "test"}, nil
})
defer monkey.UnpatchAll()
config, err := TokenConfig(globalConfig)
assert.NoError(err)
assert.Equal("test", config.PlatformName)
} | explode_data.jsonl/61940 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
3323,
2648,
87161,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
2740,
7121,
1155,
340,
18842,
2648,
1669,
95132,
7121,
741,
197,
96016,
1069,
754,
13274,
45829,
11,
2915,
8754,
353,
85,
12858,
5058,
12858,
8,
4609,
5839,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchemaParser_SimpleTypeInheritingMultipleInterfaces(t *testing.T) {
body := `type Hello implements Wo, rld { }`
astDoc := parse(t, body)
expected := &ast.Document{
Loc: testLoc(0, 33),
Definitions: []ast.Node{
&ast.ObjectDefinition{
Loc: testLoc(0, 33),
Name: &ast.Name{
Value: "Hello",
Loc: testLoc(5, 10),
},
Interfaces: []*ast.Named{
{
Name: &ast.Name{
Value: "Wo",
Loc: testLoc(22, 24),
},
Loc: testLoc(22, 24),
},
{
Name: &ast.Name{
Value: "rld",
Loc: testLoc(26, 29),
},
Loc: testLoc(26, 29),
},
},
Fields: []*ast.FieldDefinition{},
},
},
}
if !reflect.DeepEqual(astDoc, expected) {
t.Fatalf("unexpected document, expected: %s, got: %s", jsonString(expected), jsonString(astDoc))
}
} | explode_data.jsonl/51221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 422
} | [
2830,
3393,
8632,
6570,
1098,
6456,
929,
641,
1923,
5853,
32089,
41066,
1155,
353,
8840,
836,
8,
341,
35402,
1669,
1565,
1313,
21927,
5169,
27258,
11,
435,
507,
314,
335,
3989,
88836,
9550,
1669,
4715,
1155,
11,
2487,
340,
42400,
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 TestDefinitionListItemNodeType(t *testing.T) {
n := &DefinitionListItemNode{Type: NodeDefinitionListItem}
if n.NodeType() != NodeDefinitionListItem {
t.Error("n.Type != NodeDefinitionListItem")
}
} | explode_data.jsonl/1874 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
10398,
19045,
66137,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
609,
10398,
19045,
1955,
90,
929,
25,
6018,
10398,
19045,
532,
743,
308,
21714,
929,
368,
961,
6018,
10398,
19045,
341,
197,
3244,
6141,
445,
77,
10184,
961,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestGetSchedulable_Invalid(t *testing.T) {
g := testGraph(t)
tcs := []struct {
name string
finished []string
}{{
// x can't be completed on its own b/c it depends on a
name: "only-x",
finished: []string{"x"},
}, {
// y can't be completed on its own b/c it depends on a and x
name: "only-y",
finished: []string{"y"},
}, {
// w can't be completed on its own b/c it depends on y and b
name: "only-w",
finished: []string{"w"},
}, {
name: "only-y-and-x",
finished: []string{"y", "x"},
}, {
name: "only-y-and-w",
finished: []string{"y", "w"},
}, {
name: "only-x-and-w",
finished: []string{"x", "w"},
}}
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
_, err := dag.GetSchedulable(g, tc.finished...)
if err == nil {
t.Fatalf("Expected error for invalid done tasks %v but got none", tc.finished)
}
})
}
} | explode_data.jsonl/69246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 405
} | [
2830,
3393,
1949,
50,
2397,
360,
480,
62,
7928,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1273,
11212,
1155,
340,
3244,
4837,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
1166,
24657,
3056,
917,
198,
197,
15170,
515,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIssue18(t *testing.T) {
p := UGCPolicy()
p.AllowAttrs("color").OnElements("font")
p.AllowElements("font")
tt := test{
in: `<font face="Arial">No link here. <a href="http://link.com">link here</a>.</font> Should not be linked here.`,
expected: `No link here. <a href="http://link.com" rel="nofollow">link here</a>. Should not be linked here.`,
}
out := p.Sanitize(tt.in)
if out != tt.expected {
t.Errorf(
"test failed;\ninput : %s\noutput : %s\nexpected: %s",
tt.in,
out,
tt.expected)
}
} | explode_data.jsonl/28800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
42006,
16,
23,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
547,
38,
7123,
8018,
2822,
3223,
29081,
53671,
445,
3423,
1827,
1925,
11868,
445,
4026,
1138,
3223,
29081,
11868,
445,
4026,
5130,
3244,
83,
1669,
1273,
515,
197,
17... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClustersUpdate_Run(t *testing.T) {
ctrl := gomock.NewController(t)
mockStore := mocks.NewMockClusterStore(ctrl)
defer ctrl.Finish()
expected := &mongodbatlas.Cluster{
ProviderSettings: &mongodbatlas.ProviderSettings{},
}
t.Run("flags run", func(t *testing.T) {
updateOpts := &ClustersUpdateOpts{
name: "ProjectBar",
tier: atlasM2,
diskSizeGB: 10,
mdbVersion: currentMDBVersion,
store: mockStore,
}
mockStore.
EXPECT().
Cluster(updateOpts.ProjectID, updateOpts.name).
Return(expected, nil).
Times(1)
updateOpts.patchOpts(expected)
mockStore.
EXPECT().
UpdateCluster(updateOpts.ConfigProjectID(), updateOpts.name, expected).Return(expected, nil).
Times(1)
err := updateOpts.Run()
if err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
})
t.Run("file run", func(t *testing.T) {
appFS := afero.NewMemMapFs()
// create test file
fileYML := `{
"name": "ProjectBar",
"diskSizeGB": 10,
"numShards": 1,
"providerSettings": {
"providerName": "AWS",
"instanceSizeName": "M2",
"regionName": "US"
},
"clusterType" : "REPLICASET",
"replicationFactor": 3,
"replicationSpecs": [{
"numShards": 1,
"regionsConfig": {
"US_EAST_1": {
"analyticsNodes": 0,
"electableNodes": 3,
"priority": 7,
"readOnlyNodes": 0
}
},
"zoneName": "Zone 1"
}],
"backupEnabled": false,
"providerBackupEnabled" : false
}`
fileName := "atlas_cluster_update_test.json"
_ = afero.WriteFile(appFS, fileName, []byte(fileYML), 0600)
updateOpts := &ClustersUpdateOpts{
filename: fileName,
fs: appFS,
store: mockStore,
}
cluster, _ := updateOpts.cluster()
mockStore.
EXPECT().
UpdateCluster(updateOpts.ConfigProjectID(), "ProjectBar", cluster).
Return(expected, nil).
Times(1)
err := updateOpts.Run()
if err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
})
} | explode_data.jsonl/51346 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 876
} | [
2830,
3393,
94992,
4289,
84158,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
77333,
6093,
1669,
68909,
7121,
11571,
28678,
6093,
62100,
692,
16867,
23743,
991,
18176,
741,
42400,
1669,
609,
71155,
347,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_DirectedCycle(t *testing.T) {
gb := NewGraphBuilder(BuilderOptions{IsDirected: true})
gb.AddNode(1)
gb.AddNode(2)
gb.AddNode(3)
gb.AddEdge(1, 2)
gb.AddEdge(2, 3)
gb.AddEdge(3, 1)
actual_graph, err := gb.Build()
assert.NoError(t, err)
expected_graph := rawDirectedGraph{
Nodes: map[NodeID]*rawDirectedNode{
1: {ID: 1, Outgoing: []NodeID{2}, Incoming: []NodeID{3}},
2: {ID: 2, Outgoing: []NodeID{3}, Incoming: []NodeID{1}},
3: {ID: 3, Outgoing: []NodeID{1}, Incoming: []NodeID{2}},
},
FromToEdges: map[NodeID]map[NodeID]*rawDirectedEdge{
1: {
2: {From: 1, To: 2},
},
2: {
3: {From: 2, To: 3},
},
3: {
1: {From: 3, To: 1},
},
},
}
AssertGraphEquals(t, expected_graph, actual_graph)
} | explode_data.jsonl/81783 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 373
} | [
2830,
3393,
1557,
74612,
44820,
1155,
353,
8840,
836,
8,
341,
3174,
65,
1669,
1532,
11212,
3297,
7,
3297,
3798,
90,
3872,
92669,
25,
830,
3518,
3174,
65,
1904,
1955,
7,
16,
340,
3174,
65,
1904,
1955,
7,
17,
340,
3174,
65,
1904,
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 TestDistSQLDrainingHosts(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
const numNodes = 2
tc := serverutils.StartTestCluster(
t,
numNodes,
base.TestClusterArgs{
ReplicationMode: base.ReplicationManual,
ServerArgs: base.TestServerArgs{Knobs: base.TestingKnobs{DistSQL: &execinfra.TestingKnobs{DrainFast: true}}, UseDatabase: "test"},
},
)
ctx := context.Background()
defer tc.Stopper().Stop(ctx)
conn := tc.ServerConn(0)
sqlutils.CreateTable(
t,
conn,
"nums",
"num INT",
numNodes, /* numRows */
sqlutils.ToRowFn(sqlutils.RowIdxFn),
)
db := tc.ServerConn(0)
db.SetMaxOpenConns(1)
r := sqlutils.MakeSQLRunner(db)
// Force the query to be distributed.
r.Exec(t, "SET DISTSQL = ON")
// Shortly after starting a cluster, the first server's StorePool may not be
// fully initialized and ready to do rebalancing yet, so wrap this in a
// SucceedsSoon.
testutils.SucceedsSoon(t, func() error {
_, err := db.Exec(
fmt.Sprintf(`ALTER TABLE nums SPLIT AT VALUES (1);
ALTER TABLE nums EXPERIMENTAL_RELOCATE VALUES (ARRAY[%d], 1);`,
tc.Server(1).GetFirstStoreID(),
),
)
return err
})
// Ensure that the range cache is populated (see #31235).
r.Exec(t, "SHOW RANGES FROM TABLE nums")
const query = "SELECT count(*) FROM NUMS"
expectPlan := func(expectedPlan [][]string) {
planQuery := fmt.Sprintf(`SELECT url FROM [EXPLAIN (DISTSQL) %s]`, query)
testutils.SucceedsSoon(t, func() error {
resultPlan := r.QueryStr(t, planQuery)
if !reflect.DeepEqual(resultPlan, expectedPlan) {
return errors.Errorf("\nexpected:%v\ngot:%v", expectedPlan, resultPlan)
}
return nil
})
}
// Verify distribution.
expectPlan([][]string{{"https://cockroachdb.github.io/distsqlplan/decode.html#eJyskd-Lm0AQx9_7V8g8mbKHWZO-7NMd1xSEnF7Vo4UgYesOIphduz-gJfi_F7WQGBKblj46O9_5fJw5gvneAINss908557TjfcpTV683ebr6_Ypij3_Y5Tl2eftwvvdUionrf9-MfZJdzAFEJBKYMwPaIDtgAKBEAoCrVYlGqN0Xz4OTZH4AWxJoJats325IFAqjcCOYGvbIDDI-bcGU-QCdbAEAgItr5thdM97bHV94PonEMhaLg3zHoIemTjLvFhJhKIjoJw9EYzlFQKjHbnf4qmqNFbcKh2EU4nn5C3O92nyJfMXN1nhTdYJ4aTSAjWKyfyim7dZT22yt5d9FOf-I70ts5rI0PvXT-9Zf0Af_mH9f7A4--HVf13_FVaKplXS4MUZrk9e9udBUeF4S6OcLvFVq3LAjJ_JkBsKAo0dX-n4EcnxqRc8D9PZcDgJ08twOBv-ME9ezYbX8-H1X2kX3btfAQAA__9aEHOO"}})
// Drain the second node and expect the query to be planned on only the
// first node.
distServer := tc.Server(1).DistSQLServer().(*distsql.ServerImpl)
distServer.Drain(ctx, 0 /* flowDrainWait */, nil /* reporter */)
expectPlan([][]string{{"https://cockroachdb.github.io/distsqlplan/decode.html#eJyUkM9Kw0AYxO8-xTKnVlba9LgnS60QqElNIgolyJp8hEC6G_cPKCHvLkkErVDR4843M79hO9jXBgLpdrfdZMybht0m8R07bJ_2u3UYsdlNmGbp_W7OPi2F9srNLueTT_mjzcGhdEmRPJKFOCBAztEaXZC12gxSNxrC8g1iyVGr1rtBzjkKbQiig6tdQxDI5EtDCcmSzGIJjpKcrJuxdmBdt6Y-SvMOjrSVygp2BY7YO8EirQh5z6G9--q3TlYEEfT87xvWVWWokk6bRXA6YRM_RNlzEj-ms_lZ1uo_rIRsq5WlE8655mWfc1BZ0fSnVntT0N7oYsRMz3jMjUJJ1k3XYHqEajoNA7-Hg1_Dqx_hvL_4CAAA__-lY7ge"}})
// Verify correctness.
var res int
if err := db.QueryRow(query).Scan(&res); err != nil {
t.Fatal(err)
}
if res != numNodes {
t.Fatalf("expected %d rows but got %d", numNodes, res)
}
} | explode_data.jsonl/43683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1582
} | [
2830,
3393,
23356,
6688,
8847,
2056,
9296,
82,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
4777,
1629,
12288,
284,
220,
17,
198,
78255,
1669,
3538,
6031,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPopulateCluster_APIServerCount(t *testing.T) {
c := buildMinimalCluster()
full, err := build(c)
if err != nil {
t.Fatalf("error during build: %v", err)
}
if fi.Int32Value(full.Spec.KubeAPIServer.APIServerCount) != 3 {
t.Fatalf("Unexpected APIServerCount: %v", fi.Int32Value(full.Spec.KubeAPIServer.APIServerCount))
}
} | explode_data.jsonl/75047 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
11598,
6334,
28678,
21899,
1637,
2836,
2507,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
88328,
28678,
2822,
94042,
11,
1848,
1669,
1936,
1337,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
2337,
1936,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestHelloExtensionUnmarshal(t *testing.T) {
buf := bytes.NewBuffer([]byte{
// extension[0] type
0x10, 0x11,
// extension[0] length
0x00, 0x05,
// extension[0] data
0x20, 0x21, 0x22, 0x23, 0x24,
// debris
0x30,
})
var val recordfmt.HelloExtension
if err := val.Decode(buf); err != nil {
t.Fatal(err)
}
if val.ExtensionType != 0x1011 {
t.Fatal(val)
}
if bytes.Compare(val.ExtensionData, []byte{0x20, 0x21, 0x22, 0x23, 0x24}) != 0 {
t.Fatal(val)
}
if v := buf.Bytes(); bytes.Compare(v, []byte{0x30}) != 0 {
t.Fatal(v)
}
} | explode_data.jsonl/53622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
9707,
12049,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
26398,
1669,
5820,
7121,
4095,
10556,
3782,
515,
197,
197,
322,
8894,
58,
15,
60,
943,
198,
197,
197,
15,
87,
16,
15,
11,
220,
15,
87,
16,
16,
345,
197,
197,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseLevelError(t *testing.T) {
verifyLevelError := func(levels ...string) {
for _, level := range levels {
_, err := ParseLevel(level)
require.Error(t, err, "not supposed to succeed while parsing level string [%s]", level)
}
}
verifyLevelError("", "D", "DE BUG", ".")
} | explode_data.jsonl/79298 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
14463,
4449,
1454,
1155,
353,
8840,
836,
8,
1476,
93587,
4449,
1454,
1669,
2915,
98008,
2503,
917,
8,
341,
197,
2023,
8358,
2188,
1669,
2088,
5866,
341,
298,
197,
6878,
1848,
1669,
14775,
4449,
23669,
340,
298,
17957,
6141,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalExact(t *testing.T) {
vip := New()
target := &testUnmarshalExtra{}
vip.SetConfigType("yaml")
r := bytes.NewReader(yamlExampleWithExtras)
vip.ReadConfig(r)
err := vip.UnmarshalExact(target)
if err == nil {
t.Fatal("UnmarshalExact should error when populating a struct from a conf that contains unused fields")
}
} | explode_data.jsonl/5546 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
1806,
27121,
57954,
1155,
353,
8840,
836,
8,
341,
5195,
573,
1669,
1532,
741,
28861,
1669,
609,
1944,
1806,
27121,
11612,
16094,
5195,
573,
4202,
2648,
929,
445,
41466,
1138,
7000,
1669,
5820,
68587,
7021,
9467,
13314,
2354,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergePodSpec(t *testing.T) {
g := gomega.NewGomegaWithT(t)
scenarios := map[string]struct {
podSpecBase *v1alpha1.ServingRuntimePodSpec
podSpecOverride *v1beta1.PodSpec
expected *v1.PodSpec
}{
"BasicMerge": {
podSpecBase: &v1alpha1.ServingRuntimePodSpec{
NodeSelector: map[string]string{
"foo": "bar",
"aaa": "bbb",
},
Tolerations: []v1.Toleration{
{Key: "key1", Operator: v1.TolerationOpExists, Effect: v1.TaintEffectNoSchedule},
},
Volumes: []v1.Volume{
{
Name: "foo",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "bar",
},
},
},
{
Name: "aaa",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "bbb",
},
},
},
},
},
podSpecOverride: &v1beta1.PodSpec{
NodeSelector: map[string]string{
"foo": "baz",
"xxx": "yyy",
},
ServiceAccountName: "testAccount",
Volumes: []v1.Volume{
{
Name: "foo",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "baz",
},
},
},
{
Name: "xxx",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "yyy",
},
},
},
},
},
expected: &v1.PodSpec{
NodeSelector: map[string]string{
"foo": "baz",
"xxx": "yyy",
"aaa": "bbb",
},
Tolerations: []v1.Toleration{
{Key: "key1", Operator: v1.TolerationOpExists, Effect: v1.TaintEffectNoSchedule},
},
ServiceAccountName: "testAccount",
Volumes: []v1.Volume{
{
Name: "foo",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "baz",
},
},
},
{
Name: "xxx",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "yyy",
},
},
},
{
Name: "aaa",
VolumeSource: v1.VolumeSource{
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
ClaimName: "bbb",
},
},
},
},
},
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
res, _ := MergePodSpec(scenario.podSpecBase, scenario.podSpecOverride)
if !g.Expect(res).To(gomega.Equal(scenario.expected)) {
t.Errorf("got %v, want %v", res, scenario.expected)
}
})
}
} | explode_data.jsonl/54485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1349
} | [
2830,
3393,
52096,
23527,
8327,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
29928,
60494,
1669,
2415,
14032,
60,
1235,
341,
197,
3223,
347,
8327,
3978,
257,
353,
85,
16,
7141,
16,
808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSvcatWithNamespacedBrokerFeatureDisabled(t *testing.T) {
// Verify that commands work with the feature disabled, and don't return errors
testcases := []struct {
cmd string
wantOutput string
}{
{"get brokers", "my-cluster-broker"},
{"get classes", "my-cluster-class"},
{"get class my-cluster-class", "my-cluster-class"},
{"get plans", "my-cluster-plan"},
{"get plan --scope cluster my-cluster-plan", "my-cluster-plan"},
}
for _, tc := range testcases {
t.Run(tc.cmd, func(t *testing.T) {
// Setup fake data for the app
var fakes = []runtime.Object{
&v1beta1.ClusterServiceBroker{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster-broker",
},
},
&v1beta1.ClusterServiceClass{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster-class",
Labels: map[string]string{
v1beta1.GroupName + "/" + v1beta1.FilterSpecExternalName: util.GenerateSHA("my-cluster-class"),
},
},
Spec: v1beta1.ClusterServiceClassSpec{
CommonServiceClassSpec: v1beta1.CommonServiceClassSpec{
ExternalName: "my-cluster-class",
},
},
},
&v1beta1.ClusterServicePlan{
ObjectMeta: metav1.ObjectMeta{
Name: "my-cluster-plan",
Labels: map[string]string{
v1beta1.GroupName + "/" + v1beta1.FilterSpecExternalName: util.GenerateSHA("my-cluster-plan"),
},
},
Spec: v1beta1.ClusterServicePlanSpec{
CommonServicePlanSpec: v1beta1.CommonServicePlanSpec{
ExternalName: "my-cluster-plan",
},
ClusterServiceClassRef: v1beta1.ClusterObjectReference{
Name: "my-cluster-class",
},
},
},
}
svcatClient := svcatfake.NewSimpleClientset(fakes...)
// When the feature flag isn't enabled, the server will return resource not found
svcatClient.PrependReactor("list", "servicebrokers",
func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, k8serrors.NewNotFound(v1beta1.Resource("servicebrokers"), "")
})
svcatClient.PrependReactor("list", "serviceclasses",
func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, k8serrors.NewNotFound(v1beta1.Resource("serviceclasses"), "")
})
svcatClient.PrependReactor("list", "serviceplans",
func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, k8serrors.NewNotFound(v1beta1.Resource("serviceplans"), "")
})
cxt := newContext()
cxt.App = &svcat.App{
CurrentNamespace: "default",
SvcatClient: &servicecatalog.SDK{ServiceCatalogClient: svcatClient},
}
gotOutput := executeFakeCommand(t, tc.cmd, cxt, false)
if !strings.Contains(gotOutput, tc.wantOutput) {
t.Fatalf("unexpected command output \n\nWANT:\n%q\n\nGOT:\n%q\n", tc.wantOutput, gotOutput)
}
})
}
} | explode_data.jsonl/71173 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1216
} | [
2830,
3393,
1949,
50,
85,
4616,
2354,
7980,
68552,
65545,
13859,
25907,
1155,
353,
8840,
836,
8,
341,
197,
322,
25429,
429,
11293,
975,
448,
279,
4565,
8386,
11,
323,
1513,
944,
470,
5975,
198,
18185,
23910,
1669,
3056,
1235,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_part1(t *testing.T) {
type args struct {
in []string
}
tests := []struct {
name string
args args
want int
}{
{"Test Input", args{testInput}, 35},
{"Given Input", args{input.GetInputStrings()}, 5622},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := part1(tt.args.in); got != tt.want {
t.Errorf("part1() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
10495,
16,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
17430,
3056,
917,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
198,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParseFilesWithDependencies(t *testing.T) {
// Create some file contents that import a non-well-known proto.
// (One of the protos in internal/testprotos is fine.)
contents := map[string]string{
"test.proto": `
syntax = "proto3";
import "desc_test_wellknowntypes.proto";
message TestImportedType {
testprotos.TestWellKnownTypes imported_field = 1;
}
`,
}
baseResolver := ResolverFunc(func(f string) (SearchResult, error) {
s, ok := contents[f]
if !ok {
return SearchResult{}, os.ErrNotExist
}
return SearchResult{Source: strings.NewReader(s)}, nil
})
wktDesc, err := protoregistry.GlobalFiles.FindFileByPath("desc_test_wellknowntypes.proto")
assert.Nil(t, err)
wktDescProto := protodesc.ToFileDescriptorProto(wktDesc)
ctx := context.Background()
// Establish that we *can* parse the source file with a parser that
// registers the dependency.
t.Run("DependencyIncluded", func(t *testing.T) {
// Create a dependency-aware compiler.
compiler := Compiler{
Resolver: ResolverFunc(func(f string) (SearchResult, error) {
if f == "desc_test_wellknowntypes.proto" {
return SearchResult{Desc: wktDesc}, nil
}
return baseResolver.FindFileByPath(f)
}),
}
_, err := compiler.Compile(ctx, "test.proto")
assert.Nil(t, err, "%v", err)
})
t.Run("DependencyIncludedProto", func(t *testing.T) {
// Create a dependency-aware compiler.
compiler := Compiler{
Resolver: WithStandardImports(ResolverFunc(func(f string) (SearchResult, error) {
if f == "desc_test_wellknowntypes.proto" {
return SearchResult{Proto: wktDescProto}, nil
}
return baseResolver.FindFileByPath(f)
})),
}
_, err := compiler.Compile(ctx, "test.proto")
assert.Nil(t, err, "%v", err)
})
// Establish that we *can not* parse the source file with a parser that
// did not register the dependency.
t.Run("DependencyExcluded", func(t *testing.T) {
// Create a dependency-UNaware parser.
compiler := Compiler{Resolver: baseResolver}
_, err := compiler.Compile(ctx, "test.proto")
assert.NotNil(t, err, "expected parse to fail")
})
// Establish that the accessor has precedence over LookupImport.
t.Run("AccessorWins", func(t *testing.T) {
// Create a dependency-aware parser that should never be called.
compiler := Compiler{
Resolver: ResolverFunc(func(f string) (SearchResult, error) {
if f == "test.proto" {
return SearchResult{Source: strings.NewReader(`syntax = "proto3";`)}, nil
}
t.Errorf("resolved was called for unexpected filename %q", f)
return SearchResult{}, os.ErrNotExist
}),
}
_, err := compiler.Compile(ctx, "test.proto")
assert.Nil(t, err)
})
} | explode_data.jsonl/18031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1032
} | [
2830,
3393,
14463,
10809,
2354,
48303,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
1045,
1034,
8794,
429,
1159,
264,
2477,
2630,
613,
21309,
18433,
624,
197,
322,
320,
3966,
315,
279,
1724,
436,
304,
5306,
12697,
4391,
436,
374,
691... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNodeToStringNoLabels(t *testing.T) {
node := neo4j.Node{
Id: 2,
Labels: []string{},
Props: map[string]interface{}{
"Prop1": 2,
"Prop2": "Hello world",
},
}
actual := input.ToString(node)
expected := `( {"Prop1":2,"Prop2":"Hello world"})`
if actual != expected {
t.Fatalf(`expected '%v' but got '%v'`, expected, actual)
}
} | explode_data.jsonl/7075 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
1955,
5870,
2753,
23674,
1155,
353,
8840,
836,
8,
341,
20831,
1669,
35082,
19,
73,
21714,
515,
197,
67211,
25,
257,
220,
17,
345,
197,
197,
23674,
25,
3056,
917,
38837,
197,
197,
5992,
25,
2415,
14032,
31344,
67066,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSearchProducts(t *testing.T) {
t.Parallel()
migration := sqltest.New(t, sqltest.Options{
Force: *force,
Path: "../../migrations",
})
pool := migration.Setup(context.Background(), "")
db := &DB{
Postgres: pool,
}
// On this test, reuse the same connection for executing SQL commands
// to check acquiring and releasing a connection passed via context is working as expected.
dbCtx, err := db.WithAcquire(context.Background())
if err != nil {
t.Fatalf("unexpected DB.WithAcquire() error = %v", err)
}
defer db.Release(dbCtx)
createProducts(t, db, []inventory.CreateProductParams{
{
ID: "desk",
Name: "plain desk (home)",
Description: "A plain desk",
Price: 140,
},
{
ID: "chair",
Name: "office chair",
Description: "Office chair",
Price: 80,
},
{
ID: "table",
Name: "dining home table",
Description: "dining table",
Price: 120,
},
{
ID: "bed",
Name: "bed",
Description: "small bed",
Price: 100,
},
})
type args struct {
ctx context.Context
params inventory.SearchProductsParams
}
tests := []struct {
name string
args args
want *inventory.SearchProductsResponse
wantErr string
}{
{
name: "product",
args: args{
ctx: dbCtx,
params: inventory.SearchProductsParams{
QueryString: "plain desk",
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{
{
ID: "desk",
Name: "plain desk (home)",
Description: "A plain desk",
Price: 140,
CreatedAt: time.Now(),
ModifiedAt: time.Now(),
},
},
Total: 1,
},
wantErr: "",
},
{
name: "product_very_expensive",
args: args{
ctx: dbCtx,
params: inventory.SearchProductsParams{
QueryString: "plain desk",
MinPrice: 900,
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{},
Total: 0,
},
wantErr: "",
},
{
name: "home",
args: args{
ctx: dbCtx,
params: inventory.SearchProductsParams{
QueryString: "home",
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{
{
ID: "table",
Name: "dining home table",
Description: "dining table",
Price: 120,
CreatedAt: time.Now(),
ModifiedAt: time.Now(),
},
{
ID: "desk",
Name: "plain desk (home)",
Description: "A plain desk",
Price: 140,
CreatedAt: time.Now(),
ModifiedAt: time.Now(),
},
},
Total: 2,
},
wantErr: "",
},
{
name: "home_paginated",
args: args{
ctx: dbCtx,
params: inventory.SearchProductsParams{
QueryString: "home",
Pagination: inventory.Pagination{
Limit: 1,
Offset: 1,
},
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{
{
ID: "desk",
Name: "plain desk (home)",
Description: "A plain desk",
Price: 140,
CreatedAt: time.Now(),
ModifiedAt: time.Now(),
},
},
Total: 2,
},
wantErr: "",
},
{
name: "home_cheaper",
args: args{
ctx: dbCtx,
params: inventory.SearchProductsParams{
QueryString: "home",
MaxPrice: 130,
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{
{
ID: "table",
Name: "dining home table",
Description: "dining table",
Price: 120,
CreatedAt: time.Now(),
ModifiedAt: time.Now(),
},
},
Total: 1,
},
wantErr: "",
},
{
name: "not_found",
args: args{
ctx: context.Background(),
params: inventory.SearchProductsParams{
QueryString: "xyz",
},
},
want: &inventory.SearchProductsResponse{
Items: []*inventory.Product{},
Total: 0,
},
},
{
name: "canceled_ctx",
args: args{
ctx: canceledContext(),
},
wantErr: "context canceled",
},
{
name: "deadline_exceeded_ctx",
args: args{
ctx: deadlineExceededContext(),
},
wantErr: "context deadline exceeded",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := db.SearchProducts(tt.args.ctx, tt.args.params)
if err == nil && tt.wantErr != "" || err != nil && tt.wantErr != err.Error() {
t.Errorf("DB.SearchProducts() error = %v, wantErr %v", err, tt.wantErr)
}
if err != nil {
return
}
if !cmp.Equal(tt.want, got, cmpopts.EquateApproxTime(time.Minute)) {
t.Errorf("value returned by DB.SearchProducts() doesn't match: %v", cmp.Diff(tt.want, got))
}
})
}
} | explode_data.jsonl/25452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2363
} | [
2830,
3393,
5890,
17746,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2109,
5033,
1669,
5704,
1944,
7121,
1155,
11,
5704,
1944,
22179,
515,
197,
197,
18573,
25,
353,
8833,
345,
197,
69640,
25,
220,
10208,
76,
17824,
756,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAutofollowBasedOnRootPost(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
os.Setenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS")
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ThreadAutoFollow = true
*cfg.ServiceSettings.CollapsedThreads = model.COLLAPSED_THREADS_DEFAULT_ON
})
channel := th.BasicChannel
user := th.BasicUser
user2 := th.BasicUser2
appErr := th.App.JoinChannel(th.Context, channel, user.Id)
require.Nil(t, appErr)
appErr = th.App.JoinChannel(th.Context, channel, user2.Id)
require.Nil(t, appErr)
p1, err := th.App.CreatePost(th.Context, &model.Post{UserId: user.Id, ChannelId: channel.Id, Message: "Hi @" + user2.Username}, channel, false, false)
require.Nil(t, err)
m, e := th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
require.NoError(t, e)
require.Len(t, m, 0)
_, err2 := th.App.CreatePost(th.Context, &model.Post{RootId: p1.Id, UserId: user.Id, ChannelId: channel.Id, Message: "Hola"}, channel, false, false)
require.Nil(t, err2)
m, e = th.App.GetThreadMembershipsForUser(user2.Id, th.BasicTeam.Id)
require.NoError(t, e)
require.Len(t, m, 1)
} | explode_data.jsonl/26445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 493
} | [
2830,
3393,
19602,
1055,
1544,
28715,
1925,
8439,
4133,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
25078,
4202,
3160,
445,
8035,
30827,
32748,
74317,
2537,
20275,
47519,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocalhost(t *testing.T) {
if !setup(t) {
return
}
h := &Handler{
mcPool: NewPool("localhost:11213", 8, 100),
}
testWithClient(t, h)
} | explode_data.jsonl/19460 | {
"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,
7319,
3790,
1155,
353,
8840,
836,
8,
341,
743,
753,
15188,
1155,
8,
341,
197,
853,
198,
197,
532,
9598,
1669,
609,
3050,
515,
197,
97662,
10551,
25,
1532,
10551,
445,
8301,
25,
16,
16,
17,
16,
18,
497,
220,
23,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func Test_IfdByteEncoder_encodeTagToBytes_childIfd__withoutAllocate(t *testing.T) {
ibe := NewIfdByteEncoder()
im := NewIfdMapping()
err := LoadStandardIfds(im)
log.PanicIf(err)
ti := NewTagIndex()
ib := NewIfdBuilder(im, ti, exifcommon.IfdPathStandard, exifcommon.TestDefaultByteOrder)
b := new(bytes.Buffer)
bw := NewByteWriter(b, exifcommon.TestDefaultByteOrder)
addressableOffset := uint32(0x1234)
ida := newIfdDataAllocator(addressableOffset)
childIb := NewIfdBuilder(im, ti, exifcommon.IfdPathStandardExif, exifcommon.TestDefaultByteOrder)
tagValue := NewIfdBuilderTagValueFromIfdBuilder(childIb)
bt := NewChildIfdBuilderTag(exifcommon.IfdPathStandard, exifcommon.IfdExifId, tagValue)
nextIfdOffsetToWrite := uint32(0)
childIfdBlock, err := ibe.encodeTagToBytes(ib, bt, bw, ida, nextIfdOffsetToWrite)
log.PanicIf(err)
if childIfdBlock != nil {
t.Fatalf("no child-IFDs were expected to be allocated")
} else if bytes.Compare(b.Bytes(), []byte{0x87, 0x69, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}) != 0 {
t.Fatalf("encoded tag-entry with child-IFD not correct")
} else if ida.NextOffset() != addressableOffset {
t.Fatalf("allocation offset not expected")
}
} | explode_data.jsonl/52749 | {
"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,
62,
2679,
67,
7153,
19921,
11224,
5668,
1249,
7078,
17268,
2679,
67,
563,
28996,
75380,
1155,
353,
8840,
836,
8,
341,
197,
23549,
1669,
1532,
2679,
67,
7153,
19921,
2822,
54892,
1669,
1532,
2679,
67,
6807,
2822,
9859,
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... | 4 |
func TestIgnoresInvalidBackend(t *testing.T) {
dc := testdataclient.New([]*eskip.Route{{Id: "route1", Path: "/some-path", Backend: "invalid backend"}})
tr, err := newTestRouting(dc)
if err != nil {
t.Error(err)
}
defer tr.close()
if err = tr.log.WaitFor("invalid backend", time.Second); err != nil {
t.Error(err)
}
} | explode_data.jsonl/58577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 135
} | [
2830,
3393,
40,
70,
2152,
416,
7928,
29699,
1155,
353,
8840,
836,
8,
341,
87249,
1669,
1273,
691,
2972,
7121,
85288,
288,
13389,
58004,
2979,
764,
25,
330,
8966,
16,
497,
7933,
25,
3521,
14689,
33095,
497,
55260,
25,
330,
11808,
19163... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFromHex(t *testing.T) {
if clr, err := FromHex("8e0cf2"); err != nil {
t.Error("failed parsing hex:", err)
} else if !rgbaEquals(clr, refClr) {
t.Errorf("color is unequal ref color: %+v", clr)
}
if clr, err := FromHex("#8e0cf2"); err != nil {
t.Error("failed parsing hex:", err)
} else if !rgbaEquals(clr, refClr) {
t.Errorf("color is unequal ref color: %+v", clr)
}
if clr, err := FromHex("#8e0cf2ff"); err != nil {
t.Error("failed parsing hex:", err)
} else if !rgbaEquals(clr, refClr) {
t.Errorf("color is unequal ref color: %+v", clr)
}
if _, err := FromHex(""); err == nil {
t.Error("no error returned on empty string")
}
if _, err := FromHex("zzzzzz"); err == nil {
t.Error("no error returned on invalid hex val")
}
} | explode_data.jsonl/37824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
3830,
20335,
1155,
353,
8840,
836,
8,
341,
743,
62127,
11,
1848,
1669,
5542,
20335,
445,
23,
68,
15,
9792,
17,
5038,
1848,
961,
2092,
341,
197,
3244,
6141,
445,
16091,
22314,
12371,
12147,
1848,
340,
197,
92,
770,
421,
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... | 9 |
func TestTimestamp(t *testing.T) {
require := require.New(t)
now := time.Now().UTC()
v, err := Timestamp.Convert(now)
require.Nil(err)
require.Equal(now, v)
v, err = Timestamp.Convert(now.Format(TimestampLayout))
require.Nil(err)
require.Equal(
now.Format(TimestampLayout),
v.(time.Time).Format(TimestampLayout),
)
v, err = Timestamp.Convert(now.Unix())
require.Nil(err)
require.Equal(
now.Format(TimestampLayout),
v.(time.Time).Format(TimestampLayout),
)
sql := Timestamp.SQL(now)
require.Equal([]byte(now.Format(TimestampLayout)), sql.Raw())
after := now.Add(time.Second)
lt(t, Timestamp, now, after)
eq(t, Timestamp, now, now)
gt(t, Timestamp, after, now)
} | explode_data.jsonl/54302 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
20812,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
80922,
1669,
882,
13244,
1005,
21183,
741,
5195,
11,
1848,
1669,
32758,
36179,
32263,
340,
17957,
59678,
3964,
340,
17957,
12808,
32263,
11,
348,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterPluginsWithNominatedPods(t *testing.T) {
tests := []struct {
name string
preFilterPlugin *TestPlugin
filterPlugin *TestPlugin
pod *v1.Pod
nominatedPod *v1.Pod
node *v1.Node
nodeInfo *framework.NodeInfo
wantStatus *framework.Status
}{
{
name: "node has no nominated pod",
preFilterPlugin: nil,
filterPlugin: nil,
pod: lowPriorityPod,
nominatedPod: nil,
node: node,
nodeInfo: framework.NewNodeInfo(pod),
wantStatus: nil,
},
{
name: "node has a high-priority nominated pod and all filters succeed",
preFilterPlugin: &TestPlugin{
name: "TestPlugin1",
inj: injectedResult{
PreFilterAddPodStatus: int(framework.Success),
},
},
filterPlugin: &TestPlugin{
name: "TestPlugin2",
inj: injectedResult{
FilterStatus: int(framework.Success),
},
},
pod: lowPriorityPod,
nominatedPod: highPriorityPod,
node: node,
nodeInfo: framework.NewNodeInfo(pod),
wantStatus: nil,
},
{
name: "node has a high-priority nominated pod and pre filters fail",
preFilterPlugin: &TestPlugin{
name: "TestPlugin1",
inj: injectedResult{
PreFilterAddPodStatus: int(framework.Error),
},
},
filterPlugin: nil,
pod: lowPriorityPod,
nominatedPod: highPriorityPod,
node: node,
nodeInfo: framework.NewNodeInfo(pod),
wantStatus: framework.AsStatus(fmt.Errorf(`running AddPod on PreFilter plugin "TestPlugin1": %w`, errInjectedStatus)),
},
{
name: "node has a high-priority nominated pod and filters fail",
preFilterPlugin: &TestPlugin{
name: "TestPlugin1",
inj: injectedResult{
PreFilterAddPodStatus: int(framework.Success),
},
},
filterPlugin: &TestPlugin{
name: "TestPlugin2",
inj: injectedResult{
FilterStatus: int(framework.Error),
},
},
pod: lowPriorityPod,
nominatedPod: highPriorityPod,
node: node,
nodeInfo: framework.NewNodeInfo(pod),
wantStatus: framework.AsStatus(fmt.Errorf(`running "TestPlugin2" filter plugin: %w`, errInjectedFilterStatus)).WithFailedPlugin("TestPlugin2"),
},
{
name: "node has a low-priority nominated pod and pre filters return unschedulable",
preFilterPlugin: &TestPlugin{
name: "TestPlugin1",
inj: injectedResult{
PreFilterAddPodStatus: int(framework.Unschedulable),
},
},
filterPlugin: &TestPlugin{
name: "TestPlugin2",
inj: injectedResult{
FilterStatus: int(framework.Success),
},
},
pod: highPriorityPod,
nominatedPod: lowPriorityPod,
node: node,
nodeInfo: framework.NewNodeInfo(pod),
wantStatus: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
registry := Registry{}
cfgPls := &config.Plugins{}
if tt.preFilterPlugin != nil {
if err := registry.Register(tt.preFilterPlugin.name,
func(_ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
return tt.preFilterPlugin, nil
}); err != nil {
t.Fatalf("fail to register preFilter plugin (%s)", tt.preFilterPlugin.name)
}
cfgPls.PreFilter.Enabled = append(
cfgPls.PreFilter.Enabled,
config.Plugin{Name: tt.preFilterPlugin.name},
)
}
if tt.filterPlugin != nil {
if err := registry.Register(tt.filterPlugin.name,
func(_ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
return tt.filterPlugin, nil
}); err != nil {
t.Fatalf("fail to register filter plugin (%s)", tt.filterPlugin.name)
}
cfgPls.Filter.Enabled = append(
cfgPls.Filter.Enabled,
config.Plugin{Name: tt.filterPlugin.name},
)
}
podNominator := internalqueue.NewPodNominator()
if tt.nominatedPod != nil {
podNominator.AddNominatedPod(tt.nominatedPod, nodeName)
}
f, err := newFrameworkWithQueueSortAndBind(registry, cfgPls, emptyArgs, WithPodNominator(podNominator))
if err != nil {
t.Fatalf("fail to create framework: %s", err)
}
tt.nodeInfo.SetNode(tt.node)
gotStatus := f.RunFilterPluginsWithNominatedPods(context.TODO(), nil, tt.pod, tt.nodeInfo)
if !reflect.DeepEqual(gotStatus, tt.wantStatus) {
t.Errorf("Unexpected status. got: %v, want: %v", gotStatus, tt.wantStatus)
}
})
}
} | explode_data.jsonl/35744 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1918
} | [
2830,
3393,
5632,
45378,
2354,
45,
49515,
23527,
82,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
40346,
5632,
11546,
353,
2271,
11546,
198,
197,
50108,
11546,
262,
353,
2271,
11546,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSyncDeploymentDontDoAnythingDuringDeletion(t *testing.T) {
f := newFixture(t)
d := newDeployment("foo", 1, nil, nil, nil, map[string]string{"foo": "bar"})
now := metav1.Now()
d.DeletionTimestamp = &now
f.dLister = append(f.dLister, d)
f.objects = append(f.objects, d)
f.expectUpdateDeploymentStatusAction(d)
f.run(testutil.GetKey(d, t))
} | explode_data.jsonl/66036 | {
"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,
12154,
75286,
35,
544,
5404,
77303,
16014,
1912,
52625,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
692,
2698,
1669,
501,
75286,
445,
7975,
497,
220,
16,
11,
2092,
11,
2092,
11,
2092,
11,
2415,
14032,
30953... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHoverUnexported(t *testing.T) {
const proxy = `
-- golang.org/x/structs@v1.0.0/go.mod --
module golang.org/x/structs
go 1.12
-- golang.org/x/structs@v1.0.0/types.go --
package structs
type Mixed struct {
Exported int
unexported string
}
`
const mod = `
-- go.mod --
module mod.com
go 1.12
require golang.org/x/structs v1.0.0
-- go.sum --
golang.org/x/structs v1.0.0 h1:oxD5q25qV458xBbXf5+QX+Johgg71KFtwuJzt145c9A=
golang.org/x/structs v1.0.0/go.mod h1:47gkSIdo5AaQaWJS0upVORsxfEr1LL1MWv9dmYF3iq4=
-- main.go --
package main
import "golang.org/x/structs"
func main() {
var _ structs.Mixed
}
`
// TODO: use a nested workspace folder here.
WithOptions(
ProxyFiles(proxy),
).Run(t, mod, func(t *testing.T, env *Env) {
env.OpenFile("main.go")
got, _ := env.Hover("main.go", env.RegexpSearch("main.go", "Mixed"))
if !strings.Contains(got.Value, "unexported") {
t.Errorf("Hover: missing expected field 'unexported'. Got:\n%q", got.Value)
}
})
} | explode_data.jsonl/68797 | {
"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,
34379,
1806,
1533,
291,
1155,
353,
8840,
836,
8,
341,
4777,
13291,
284,
22074,
313,
342,
37287,
2659,
10776,
14,
1235,
82,
31,
85,
16,
13,
15,
13,
15,
25525,
10929,
39514,
4352,
342,
37287,
2659,
10776,
14,
1235,
82,
271... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStrokedPathBevelFlat(t *testing.T) {
run(t, func(o *op.Ops) {
const width = 2.5
sty := clip.StrokeStyle{
Cap: clip.FlatCap,
Join: clip.BevelJoin,
}
p := new(clip.Path)
p.Begin(o)
p.Move(f32.Pt(10, 50))
p.Line(f32.Pt(10, 0))
p.Arc(f32.Pt(10, 0), f32.Pt(20, 0), math.Pi)
p.Line(f32.Pt(10, 0))
p.Line(f32.Pt(10, 10))
p.Arc(f32.Pt(0, 30), f32.Pt(0, 30), 2*math.Pi)
p.Line(f32.Pt(-20, 0))
p.Quad(f32.Pt(-10, -10), f32.Pt(-30, 30))
p.Stroke(width, sty).Add(o)
paint.Fill(o, colornames.Red)
}, func(r result) {
r.expect(0, 0, colornames.White)
r.expect(10, 50, colornames.Red)
})
} | explode_data.jsonl/18108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
623,
299,
47159,
1820,
3430,
889,
31019,
1155,
353,
8840,
836,
8,
341,
56742,
1155,
11,
2915,
10108,
353,
453,
8382,
1690,
8,
341,
197,
4777,
2374,
284,
220,
17,
13,
20,
198,
197,
18388,
88,
1669,
12327,
7758,
7441,
2323... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCredentialIssued_ExecuteInbound(t *testing.T) {
followup, action, err := (&credentialIssued{}).ExecuteInbound(&metaData{})
require.NoError(t, err)
require.Equal(t, &noOp{}, followup)
require.NoError(t, action(nil))
} | explode_data.jsonl/53010 | {
"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,
48265,
28216,
3260,
83453,
641,
10891,
1155,
353,
8840,
836,
8,
341,
1166,
1544,
454,
11,
1917,
11,
1848,
1669,
15899,
66799,
28216,
3260,
6257,
568,
17174,
641,
10891,
2099,
5490,
1043,
37790,
17957,
35699,
1155,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestBlockedRetrieval(t *testing.T) {
tev, fl := initialize(t)
defer tev.tearDown()
it, num := fl.Iterator(&ab.SeekPosition{Type: &ab.SeekPosition_Specified{Specified: &ab.SeekSpecified{Number: 1}}})
assert.Equal(t, uint64(1), num, "Expected block iterator at 1, but got %d", num)
signal := it.ReadyChan()
select {
case <-signal:
t.Fatalf("Should not be ready for block read")
default:
}
fl.Append(ledger.CreateNextBlock(fl, []*cb.Envelope{{Payload: []byte("My Data")}}))
select {
case <-signal:
default:
t.Fatalf("Should now be ready for block read")
}
block, status := it.Next()
assert.Equal(t, cb.Status_SUCCESS, status, "Expected to successfully read the second block")
assert.Equal(t, uint64(1), block.Header.Number, "Expected to successfully retrieve the second block")
go func() {
// Add explicit sleep here to make sure `it.Next` is actually blocked waiting
// for new block. According to Golang sched, `it.Next()` is run before this
// goroutine, however it's not guaranteed to run till the channel operation
// we desire, due to I/O operation in the middle. Consider making the
// implementation more testable so we don't need to sleep here.
time.Sleep(100 * time.Millisecond)
fl.Append(ledger.CreateNextBlock(fl, []*cb.Envelope{{Payload: []byte("Another Data")}}))
}()
block, status = it.Next()
assert.Equal(t, cb.Status_SUCCESS, status, "Expected to successfully read the third block")
assert.Equal(t, uint64(2), block.Header.Number, "Expected to successfully retrieve the third block")
} | explode_data.jsonl/35031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 527
} | [
2830,
3393,
95847,
12020,
7231,
831,
1155,
353,
8840,
836,
8,
341,
197,
665,
85,
11,
1320,
1669,
9468,
1155,
340,
16867,
1013,
85,
31853,
59342,
741,
23374,
11,
1629,
1669,
1320,
40846,
2099,
370,
76465,
3812,
90,
929,
25,
609,
370,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterMatchMultipleWildcards(t *testing.T) {
p, err := graphite.NewParser([]string{
"*.* .wrong.measurement*",
"servers.* .host.measurement*", // should match this
"servers.localhost .wrong.measurement*",
"*.localhost .wrong.measurement*",
}, nil)
if err != nil {
t.Fatalf("unexpected error creating parser, got %v", err)
}
exp := models.MustNewPoint("cpu_load",
models.NewTags(map[string]string{"host": "server01"}),
models.Fields{"value": float64(11)},
time.Unix(1435077219, 0))
pt, err := p.Parse("servers.server01.cpu_load 11 1435077219")
if err != nil {
t.Fatalf("parse error: %v", err)
}
if exp.String() != pt.String() {
t.Errorf("parse mismatch: got %v, exp %v", pt.String(), exp.String())
}
} | explode_data.jsonl/32185 | {
"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,
5632,
8331,
32089,
40603,
25024,
1155,
353,
8840,
836,
8,
341,
3223,
11,
1848,
1669,
94173,
7121,
6570,
10556,
917,
515,
197,
197,
61593,
4908,
659,
34870,
17326,
24359,
9,
756,
197,
197,
40787,
18729,
4908,
659,
3790,
17326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTimer_Exit(t *testing.T) {
gtest.Case(t, func() {
timer := New()
array := garray.New()
timer.Add(200*time.Millisecond, func() {
array.Append(1)
gtimer.Exit()
})
time.Sleep(1000*time.Millisecond)
gtest.Assert(array.Len(), 1)
})
} | explode_data.jsonl/3727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
10105,
62,
15339,
1155,
353,
8840,
836,
8,
341,
256,
342,
1944,
727,
519,
1155,
11,
2915,
368,
341,
981,
9021,
1669,
1532,
741,
981,
1334,
1669,
342,
1653,
7121,
741,
981,
9021,
1904,
7,
17,
15,
15,
77053,
71482,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetDashboard(t *testing.T) {
client := newClientAndRunServer(t)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
res, err := client.GetDashboard(ctx, &api.GetDashboardRequest{WorkPageSize: 50})
if err != nil {
t.Fatal(err)
}
if expected := 5; expected != len(res.Dashboard.WatchedWorks) {
t.Errorf("expected number of works is %d, but got %d", expected, len(res.Dashboard.WatchedWorks))
}
if expected := 5; expected != len(res.Dashboard.WatchingWorks) {
t.Errorf("expected number of works is %d, but got %d", expected, len(res.Dashboard.WatchingWorks))
}
if res.WorkNextPageToken == "" {
t.Errorf("NextPageToken should not be empty")
}
} | explode_data.jsonl/50632 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
1949,
26947,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
2959,
3036,
6727,
5475,
1155,
692,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
18,
77053,
32435,
340,
16867,
9121,
2822,
10202,
11,
1848,
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... | 5 |
func TestMatchOutputsOnlyMatchingLinesOfInput(t *testing.T) {
t.Parallel()
input := "This is the first line in the file.\nHello, world.\nThis is another line in the file.\n"
tcs := []struct {
match, want string
}{
{
match: "line",
want: "This is the first line in the file.\nThis is another line in the file.\n",
},
{
match: "another",
want: "This is another line in the file.\n",
},
{
match: "definitely won't match any lines",
want: "",
},
}
for _, tc := range tcs {
got, err := script.Echo(input).Match(tc.match).String()
if err != nil {
t.Fatal(err)
}
if tc.want != got {
t.Error(cmp.Diff(tc.want, got))
}
}
} | explode_data.jsonl/51493 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
8331,
61438,
7308,
64430,
16794,
2124,
2505,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22427,
1669,
330,
1986,
374,
279,
1156,
1555,
304,
279,
1034,
7110,
77,
9707,
11,
1879,
7110,
77,
1986,
374,
2441,
1555,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestHandler_listCharts(t *testing.T) {
loggerWriter := logrus.StandardLogger().Out
logrus.SetOutput(ioutil.Discard)
defer logrus.SetOutput(loggerWriter)
tcs := []struct {
svc *fakeService
repoName string
expectedStatus int
expectedCharts []model.ChartInfo
expectedErrCode sgerrors.ErrorCode
}{
{ // TC#1
repoName: "listChartError",
svc: &fakeService{
err: errFake,
},
expectedStatus: http.StatusInternalServerError,
expectedErrCode: sgerrors.UnknownError,
},
{ // TC#2
repoName: "sgRepo",
svc: &fakeService{
chrtList: []model.ChartInfo{
{
Name: "sgChart",
Repo: "sgRepo",
},
},
},
expectedStatus: http.StatusOK,
expectedCharts: []model.ChartInfo{
{
Name: "sgChart",
Repo: "sgRepo",
},
},
},
}
for i, tc := range tcs {
// setup handler
h := &Handler{svc: tc.svc}
// prepare
req, err := http.NewRequest("", "", nil)
require.Equalf(t, nil, err, "TC#%d: create request: %v", i+1, err)
w := httptest.NewRecorder()
// run
http.HandlerFunc(h.listCharts).ServeHTTP(w, req)
// check
require.Equalf(t, tc.expectedStatus, w.Code, "TC#%d", i+1)
if w.Code == http.StatusOK {
charts := []model.ChartInfo{}
require.Nilf(t, json.NewDecoder(w.Body).Decode(&charts), "TC#%d: decode repos", i+1)
require.Equalf(t, tc.expectedCharts, charts, "TC#%d: check repos", i+1)
} else {
apiErr := &message.Message{}
require.Nilf(t, json.NewDecoder(w.Body).Decode(apiErr), "TC#%d: decode message", i+1)
require.Equalf(t, tc.expectedErrCode, apiErr.ErrorCode, "TC#%d: check error code", i+1)
}
}
} | explode_data.jsonl/12102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 753
} | [
2830,
3393,
3050,
2019,
64878,
1155,
353,
8840,
836,
8,
341,
17060,
6492,
1669,
1487,
20341,
53615,
7395,
1005,
2662,
198,
90822,
4202,
5097,
1956,
30158,
909,
47560,
340,
16867,
1487,
20341,
4202,
5097,
37833,
6492,
692,
3244,
4837,
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... | 3 |
func TestOCMProvider_GetCloudProviderRegions(t *testing.T) {
type fields struct {
ocmClient ocm.Client
}
type args struct {
providerInfo types.CloudProviderInfo
}
providerId1 := "provider-id-1"
providerName1 := "provider-name-1"
providerDisplayName1 := "provider-display-name-1"
regionId1 := "region-id-1"
regionName1 := "region-name-1"
regionDisplayName1 := "region-display-name-1"
regionSupportsMultiAZ1 := true
tests := []struct {
name string
fields fields
args args
want *types.CloudProviderRegionInfoList
wantErr bool
}{
{
name: "should return cloud providers when there are no cloud providers returned from ocm",
fields: fields{
ocmClient: &ocm.ClientMock{
GetRegionsFunc: func(provider *clustersmgmtv1.CloudProvider) (*clustersmgmtv1.CloudRegionList, error) {
Expect(provider.ID()).To(Equal(providerId1))
Expect(provider.Name()).To(Equal(providerName1))
Expect(provider.DisplayName()).To(Equal(providerDisplayName1))
return clustersmgmtv1.NewCloudRegionList().Build()
},
},
},
args: args{providerInfo: types.CloudProviderInfo{
ID: providerId1,
Name: providerName1,
DisplayName: providerDisplayName1,
}},
want: &types.CloudProviderRegionInfoList{Items: nil},
wantErr: false,
},
{
name: "should return cloud providers when there are cloud providers returned from ocm",
fields: fields{
ocmClient: &ocm.ClientMock{
GetRegionsFunc: func(provider *clustersmgmtv1.CloudProvider) (*clustersmgmtv1.CloudRegionList, error) {
Expect(provider.ID()).To(Equal(providerId1))
Expect(provider.Name()).To(Equal(providerName1))
Expect(provider.DisplayName()).To(Equal(providerDisplayName1))
p := clustersmgmtv1.NewCloudProvider().ID(providerId1)
r := clustersmgmtv1.NewCloudRegion().ID(regionId1).CloudProvider(p).Name(regionName1).DisplayName(regionDisplayName1).SupportsMultiAZ(regionSupportsMultiAZ1)
return clustersmgmtv1.NewCloudRegionList().Items(r).Build()
},
},
},
args: args{providerInfo: types.CloudProviderInfo{
ID: providerId1,
Name: providerName1,
DisplayName: providerDisplayName1,
}},
want: &types.CloudProviderRegionInfoList{
Items: []types.CloudProviderRegionInfo{
{
ID: regionId1,
CloudProviderID: providerId1,
Name: regionName1,
DisplayName: regionDisplayName1,
SupportsMultiAZ: regionSupportsMultiAZ1,
},
},
},
wantErr: false,
},
{
name: "should return error when failed to get cloud provider regions",
fields: fields{
ocmClient: &ocm.ClientMock{
GetRegionsFunc: func(provider *clustersmgmtv1.CloudProvider) (*clustersmgmtv1.CloudRegionList, error) {
return nil, errors.Errorf("failed get cloud provider regions")
},
},
},
wantErr: true,
want: nil,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
RegisterTestingT(t)
p := newOCMProvider(test.fields.ocmClient, nil, &ocm.OCMConfig{})
resp, err := p.GetCloudProviderRegions(test.args.providerInfo)
Expect(resp).To(Equal(test.want))
if test.wantErr {
Expect(err).NotTo(BeNil())
}
})
}
} | explode_data.jsonl/4843 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1389
} | [
2830,
3393,
7612,
44,
5179,
13614,
16055,
5179,
79284,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
509,
76,
2959,
297,
6226,
11716,
198,
197,
630,
13158,
2827,
2036,
341,
197,
197,
19979,
1731,
4494,
94492,
5179,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCounterRoundTrip(t *testing.T) {
var (
pb metricpb.TimedMetric
res Metric
)
inputs := []Metric{testMetric1, testMetric2}
for i := 0; i < len(inputs); i++ {
require.NoError(t, inputs[i].ToProto(&pb))
require.NoError(t, res.FromProto(pb))
require.Equal(t, inputs[i], res)
}
} | explode_data.jsonl/75078 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
14099,
27497,
56352,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
3223,
65,
220,
18266,
16650,
836,
75485,
54310,
198,
197,
10202,
52458,
198,
197,
340,
22427,
82,
1669,
3056,
54310,
90,
1944,
54310,
16,
11,
1273,
54310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPad(t *testing.T) {
signal, err := newInput("TestPad", 1, 16)
if err != nil {
t.Fatalf("error setting up test; %s", err)
}
for _, tc := range []struct {
desc string
ok bool
rfErr error // MockReadFile error.
spiValue int // Current SPI value.
isEnabled bool
}{
// Supported states.
{"off", true, nil, 0, false},
{"on", true, nil, 1, true},
// Error states.
{desc: "unsupported spi value", spiValue: 123},
{desc: "readfile error", rfErr: fmt.Errorf("mock ReadFile error")},
} {
t.Run(fmt.Sprintf("Pad() %s", tc.desc), func(t *testing.T) {
helpers.ResetMockReadWrite()
helpers.PrepareMockReadFile([]byte{}, tc.rfErr)
signal.Pad().spi.Write(tc.spiValue)
got, err := signal.Pad().IsEnabled()
if err != nil && tc.ok {
t.Fatalf("unexpected error; %s", err)
}
if err == nil && !tc.ok {
t.Fatalf("expected an error")
}
if !tc.ok {
return
}
if want := tc.isEnabled; got != want {
t.Errorf("= %t, want %t", got, want)
}
})
}
} | explode_data.jsonl/34844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
13731,
1155,
353,
8840,
836,
8,
341,
81319,
11,
1848,
1669,
501,
2505,
445,
2271,
13731,
497,
220,
16,
11,
220,
16,
21,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
6243,
705,
1273,
26,
1018,
82,
497,
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... | 7 |
func TestFetchDepositAddress(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := f.FetchDepositAddress(context.Background(), currency.NewCode("tUsD"))
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15180 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
20714,
78982,
4286,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
741,
197,
532,
197,
6878,
1848,
1669,
282,
78506,
78982,
4286,
5378,
19047,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestDate(t *testing.T) {
GenerateValuesAsYaml(t, "date.test.schema.json",
func(console *tests.ConsoleWrapper, donec chan struct{}) {
defer close(donec)
// Test boolean type
console.ExpectString("Enter a value for dateValue")
console.SendLine("abc")
console.ExpectString("Sorry, your reply was invalid: abc is not a RFC 3339 full-date formatted string, " +
"it should be like 2006-01-02")
console.ExpectString("Enter a value for dateValue")
console.SendLine("2006-01-02")
console.ExpectEOF()
})
} | explode_data.jsonl/61764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
1916,
1155,
353,
8840,
836,
8,
341,
197,
31115,
6227,
2121,
56,
9467,
1155,
11,
330,
1028,
5958,
30892,
4323,
756,
197,
29244,
52818,
353,
23841,
46298,
11542,
11,
2814,
66,
26023,
2036,
28875,
341,
298,
16867,
3265,
34232,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_ELFHash(t *testing.T) {
var x uint32 = 7244206
gtest.C(t, func(t *gtest.T) {
j := ghash.ELFHash(strBasic)
t.Assert(j, x)
})
} | explode_data.jsonl/60236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
2089,
22609,
6370,
1155,
353,
8840,
836,
8,
341,
2405,
856,
2622,
18,
17,
284,
220,
22,
17,
19,
19,
17,
15,
21,
198,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
12428,
1669,
342,
8296,
13,
27... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSourceRefBuildSourceURI(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
name: "URL without hash",
input: "https://github.com/openshift/ruby-hello-world.git",
expected: "https://github.com/openshift/ruby-hello-world.git",
},
{
name: "URL with hash",
input: "https://github.com/openshift/ruby-hello-world.git#testref",
expected: "https://github.com/openshift/ruby-hello-world.git",
},
}
for _, tst := range tests {
u, _ := url.Parse(tst.input)
s := SourceRef{
URL: u,
}
buildSource, _ := s.BuildSource()
if buildSource.Git.URI != tst.expected {
t.Errorf("%s: unexpected build source URI: %s. Expected: %s", tst.name, buildSource.Git.URI, tst.expected)
}
}
} | explode_data.jsonl/23742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
3608,
3945,
11066,
3608,
10301,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
22427,
262,
914,
198,
197,
42400,
914,
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... | 3 |
func TestDelegationEqual(t *testing.T) {
d1 := NewDelegation(sdk.AccAddress(addr1), addr2, sdk.NewDec(100))
d2 := d1
ok := d1.Equal(d2)
require.True(t, ok)
d2.ValidatorAddress = addr3
d2.Shares = sdk.NewDec(200)
ok = d1.Equal(d2)
require.False(t, ok)
} | explode_data.jsonl/58934 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
1912,
87566,
2993,
1155,
353,
8840,
836,
8,
341,
2698,
16,
1669,
1532,
1912,
87566,
1141,
7584,
77538,
4286,
24497,
16,
701,
10789,
17,
11,
45402,
7121,
4900,
7,
16,
15,
15,
1171,
2698,
17,
1669,
294,
16,
271,
59268,
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 TestNewOnlineDDL(t *testing.T) {
migrationContext := "354b-11eb-82cd-f875a4d24e90"
tt := []struct {
sql string
isError bool
}{
{
sql: "drop table t",
},
{
sql: "create table t (id int primary key)",
},
{
sql: "alter table t engine=innodb",
},
{
sql: "revert 4e5dcf80_354b_11eb_82cd_f875a4d24e90", // legacy syntax; kept one release version for backwards compatibility. Can remove after v11.0 is released
},
{
sql: "revert vitess_migration '4e5dcf80_354b_11eb_82cd_f875a4d24e90'",
},
{
sql: "alter vitess_migration '4e5dcf80_354b_11eb_82cd_f875a4d24e90' cancel",
isError: true,
},
{
sql: "select id from t",
isError: true,
},
}
strategies := []*DDLStrategySetting{
NewDDLStrategySetting(DDLStrategyDirect, ""),
NewDDLStrategySetting(DDLStrategyOnline, ""),
NewDDLStrategySetting(DDLStrategyOnline, "-singleton"),
}
require.False(t, strategies[0].IsSkipTopo())
require.False(t, strategies[1].IsSkipTopo())
require.True(t, strategies[2].IsSkipTopo())
for _, ts := range tt {
t.Run(ts.sql, func(t *testing.T) {
for _, stgy := range strategies {
t.Run(stgy.ToString(), func(t *testing.T) {
onlineDDL, err := NewOnlineDDL("test_ks", "t", ts.sql, stgy, migrationContext)
if ts.isError {
assert.Error(t, err)
return
}
assert.NoError(t, err)
if stgy.IsSkipTopo() {
// onlineDDL.SQL enriched with /*vt+ ... */ comment
assert.Contains(t, onlineDDL.SQL, hex.EncodeToString([]byte(onlineDDL.UUID)))
assert.Contains(t, onlineDDL.SQL, hex.EncodeToString([]byte(migrationContext)))
assert.Contains(t, onlineDDL.SQL, hex.EncodeToString([]byte(string(stgy.Strategy))))
} else {
assert.NotContains(t, onlineDDL.SQL, hex.EncodeToString([]byte(onlineDDL.UUID)))
assert.NotContains(t, onlineDDL.SQL, hex.EncodeToString([]byte(migrationContext)))
assert.NotContains(t, onlineDDL.SQL, hex.EncodeToString([]byte(string(stgy.Strategy))))
}
})
}
})
}
} | explode_data.jsonl/42829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 918
} | [
2830,
3393,
3564,
19598,
58781,
1155,
353,
8840,
836,
8,
341,
2109,
5033,
1972,
1669,
330,
18,
20,
19,
65,
12,
16,
16,
3065,
12,
23,
17,
4385,
2220,
23,
22,
20,
64,
19,
67,
17,
19,
68,
24,
15,
698,
3244,
83,
1669,
3056,
1235,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_removePath(t *testing.T) {
tests := []struct {
name string
patchMap map[string]interface{}
path contract.Path
want map[string]interface{}
}{
{
name: "Remove value",
patchMap: map[string]interface{}{
"foo": "123",
},
path: contract.Path([]string{"foo"}),
want: map[string]interface{}{},
},
{
name: "Remove map",
patchMap: map[string]interface{}{
"foo": map[string]interface{}{
"bar": "123",
},
},
path: contract.Path([]string{"foo"}),
want: map[string]interface{}{},
},
{
name: "Remove nested value",
patchMap: map[string]interface{}{
"foo": map[string]interface{}{
"bar": "123",
"baz": "123",
},
},
path: contract.Path([]string{"foo", "bar"}),
want: map[string]interface{}{
"foo": map[string]interface{}{
"baz": "123",
},
},
},
{
name: "Remove nested map",
patchMap: map[string]interface{}{
"foo": map[string]interface{}{
"bar": map[string]interface{}{
"baz": "123",
},
"baz": "123",
},
},
path: contract.Path([]string{"foo", "bar"}),
want: map[string]interface{}{
"foo": map[string]interface{}{
"baz": "123",
},
},
},
{
name: "Ignore partial match",
patchMap: map[string]interface{}{
"foo": map[string]interface{}{
"bar": "123",
},
},
path: contract.Path([]string{"foo", "bar", "baz"}),
want: map[string]interface{}{
"foo": map[string]interface{}{
"bar": "123",
},
},
},
{
name: "Cleanup empty maps",
patchMap: map[string]interface{}{
"foo": map[string]interface{}{
"baz": map[string]interface{}{
"bar": "123",
},
},
},
path: contract.Path([]string{"foo", "baz", "bar"}),
want: map[string]interface{}{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
removePath(tt.patchMap, tt.path)
g.Expect(tt.patchMap).To(Equal(tt.want))
})
}
} | explode_data.jsonl/29457 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 958
} | [
2830,
3393,
18193,
1820,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
3223,
754,
2227,
2415,
14032,
31344,
16094,
197,
26781,
257,
5116,
17474,
198,
197,
50780,
257,
2415,
14032,
31344,
160... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUAccountForcedOrders(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("skipping test: api keys not set")
}
_, err := b.UAccountForcedOrders(context.Background(), currency.NewPair(currency.BTC, currency.USDT), "ADL", 5, time.Time{}, time.Time{})
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
52,
7365,
2461,
1998,
24898,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
6330,
6894,
537,
738,
1138,
197,
532,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestClientReceiveTimeout(t *testing.T) {
s, c := makeTestServer()
c.SetTimeout(time.Second)
c.SetRetries(2)
s.readHandler = func(filename string, rf io.ReaderFrom) error {
r := &slowReader{
r: io.LimitReader(newRandReader(rand.NewSource(42)), 80000),
n: 3,
delay: 8 * time.Second,
}
_, err := rf.ReadFrom(r)
return err
}
defer s.Shutdown()
filename := "test-client-receive-timeout"
mode := "octet"
readTransfer, err := c.Receive(filename, mode)
if err != nil {
t.Fatalf("requesting read %s: %v", filename, err)
}
buf := &bytes.Buffer{}
_, err = readTransfer.WriteTo(buf)
netErr, ok := err.(net.Error)
if !ok {
t.Fatalf("network error expected: %T", err)
}
if !netErr.Timeout() {
t.Fatalf("timout is expected: %v", err)
}
} | explode_data.jsonl/17561 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
2959,
14742,
7636,
1155,
353,
8840,
836,
8,
341,
1903,
11,
272,
1669,
1281,
2271,
5475,
741,
1444,
4202,
7636,
9730,
32435,
340,
1444,
4202,
12020,
4019,
7,
17,
340,
1903,
4125,
3050,
284,
2915,
10961,
914,
11,
36026,
6399... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLegacyQueryIndicators(t *testing.T) {
input := CreateTestInput(t)
querier := NewLegacyQuerier(input.TreasuryKeeper, input.Cdc)
sh := staking.NewHandler(input.StakingKeeper)
stakingAmt := sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction)
addr, val := ValAddrs[0], ValPubKeys[0]
addr1, val1 := ValAddrs[1], ValPubKeys[1]
_, err := sh(input.Ctx, NewTestMsgCreateValidator(addr, val, stakingAmt))
require.NoError(t, err)
_, err = sh(input.Ctx, NewTestMsgCreateValidator(addr1, val1, stakingAmt))
require.NoError(t, err)
staking.EndBlocker(input.Ctx.WithBlockHeight(int64(core.BlocksPerWeek)-1), input.StakingKeeper)
proceedsAmt := sdk.NewInt(1000000000000)
taxProceeds := sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, proceedsAmt))
input.TreasuryKeeper.RecordEpochTaxProceeds(input.Ctx, taxProceeds)
targetIndicators := types.IndicatorQueryResponse{
TRLYear: proceedsAmt.ToDec().QuoInt(stakingAmt.MulRaw(2)),
TRLMonth: proceedsAmt.ToDec().QuoInt(stakingAmt.MulRaw(2)),
}
queriedIndicators := getQueriedIndicators(t, input.Ctx, input.Cdc, querier)
require.Equal(t, targetIndicators, queriedIndicators)
// Update indicators
input.TreasuryKeeper.UpdateIndicators(input.Ctx)
// Record same tax proceeds to get same trl
input.TreasuryKeeper.RecordEpochTaxProceeds(input.Ctx, taxProceeds)
// Change context to next epoch
input.Ctx = input.Ctx.WithBlockHeight(int64(core.BlocksPerWeek))
queriedIndicators = getQueriedIndicators(t, input.Ctx, input.Cdc, querier)
require.Equal(t, targetIndicators, queriedIndicators)
} | explode_data.jsonl/6694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 587
} | [
2830,
3393,
77415,
2859,
1425,
42052,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
2505,
1155,
340,
197,
15959,
1268,
1669,
1532,
77415,
2183,
261,
1268,
5384,
836,
265,
26102,
77233,
11,
1946,
727,
7628,
340,
36196,
1669,
357... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBucketStore_e2e(t *testing.T) {
bkt, cleanup := testutil.NewObjectStoreBucket(t)
defer cleanup()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
dir, err := ioutil.TempDir("", "test_bucketstore_e2e")
testutil.Ok(t, err)
defer os.RemoveAll(dir)
series := []labels.Labels{
labels.FromStrings("a", "1", "b", "1"),
labels.FromStrings("a", "1", "b", "2"),
labels.FromStrings("a", "2", "b", "1"),
labels.FromStrings("a", "2", "b", "2"),
labels.FromStrings("a", "1", "c", "1"),
labels.FromStrings("a", "1", "c", "2"),
labels.FromStrings("a", "2", "c", "1"),
labels.FromStrings("a", "2", "c", "2"),
}
start := time.Now()
now := start
minTime := int64(0)
maxTime := int64(0)
for i := 0; i < 3; i++ {
mint := timestamp.FromTime(now)
now = now.Add(2 * time.Hour)
maxt := timestamp.FromTime(now)
if minTime == 0 {
minTime = mint
}
maxTime = maxt
// Create two blocks per time slot. Only add 10 samples each so only one chunk
// gets created each. This way we can easily verify we got 10 chunks per series below.
id1, err := testutil.CreateBlock(dir, series[:4], 10, mint, maxt)
testutil.Ok(t, err)
id2, err := testutil.CreateBlock(dir, series[4:], 10, mint, maxt)
testutil.Ok(t, err)
dir1, dir2 := filepath.Join(dir, id1.String()), filepath.Join(dir, id2.String())
// Add labels to the meta of the second block.
meta, err := block.ReadMetaFile(dir2)
testutil.Ok(t, err)
meta.Thanos.Labels = map[string]string{"ext": "value"}
testutil.Ok(t, block.WriteMetaFile(dir2, meta))
// TODO(fabxc): remove the component dependency by factoring out the block interface.
testutil.Ok(t, objstore.UploadDir(ctx, bkt, dir1, id1.String()))
testutil.Ok(t, objstore.UploadDir(ctx, bkt, dir2, id2.String()))
testutil.Ok(t, os.RemoveAll(dir1))
testutil.Ok(t, os.RemoveAll(dir2))
}
store, err := NewBucketStore(nil, nil, bkt, dir, 100, 0)
testutil.Ok(t, err)
go func() {
runutil.Repeat(100*time.Millisecond, ctx.Done(), func() error {
return store.SyncBlocks(ctx)
})
}()
ctx, _ = context.WithTimeout(ctx, 30*time.Second)
err = runutil.Retry(100*time.Millisecond, ctx.Done(), func() error {
if store.numBlocks() < 6 {
return errors.New("not all blocks loaded")
}
return nil
})
testutil.Ok(t, err)
mint, maxt := store.TimeRange()
testutil.Equals(t, minTime, mint)
testutil.Equals(t, maxTime, maxt)
vals, err := store.LabelValues(ctx, &storepb.LabelValuesRequest{Label: "a"})
testutil.Ok(t, err)
testutil.Equals(t, []string{"1", "2"}, vals.Values)
pbseries := [][]storepb.Label{
{{Name: "a", Value: "1"}, {Name: "b", Value: "1"}},
{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}},
{{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext", Value: "value"}},
{{Name: "a", Value: "1"}, {Name: "c", Value: "2"}, {Name: "ext", Value: "value"}},
{{Name: "a", Value: "2"}, {Name: "b", Value: "1"}},
{{Name: "a", Value: "2"}, {Name: "b", Value: "2"}},
{{Name: "a", Value: "2"}, {Name: "c", Value: "1"}, {Name: "ext", Value: "value"}},
{{Name: "a", Value: "2"}, {Name: "c", Value: "2"}, {Name: "ext", Value: "value"}},
}
srv := newStoreSeriesServer(ctx)
err = store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_RE, Name: "a", Value: "1|2"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))
for i, s := range srv.SeriesSet {
testutil.Equals(t, pbseries[i], s.Labels)
testutil.Equals(t, 3, len(s.Chunks))
}
pbseries = [][]storepb.Label{
{{Name: "a", Value: "1"}, {Name: "b", Value: "2"}},
{{Name: "a", Value: "2"}, {Name: "b", Value: "2"}},
}
srv = newStoreSeriesServer(ctx)
err = store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "b", Value: "2"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))
for i, s := range srv.SeriesSet {
testutil.Equals(t, pbseries[i], s.Labels)
testutil.Equals(t, 3, len(s.Chunks))
}
// Matching by external label should work as well.
pbseries = [][]storepb.Label{
{{Name: "a", Value: "1"}, {Name: "c", Value: "1"}, {Name: "ext", Value: "value"}},
{{Name: "a", Value: "1"}, {Name: "c", Value: "2"}, {Name: "ext", Value: "value"}},
}
srv = newStoreSeriesServer(ctx)
err = store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
{Type: storepb.LabelMatcher_EQ, Name: "ext", Value: "value"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
testutil.Equals(t, len(pbseries), len(srv.SeriesSet))
for i, s := range srv.SeriesSet {
testutil.Equals(t, pbseries[i], s.Labels)
testutil.Equals(t, 3, len(s.Chunks))
}
srv = newStoreSeriesServer(ctx)
err = store.Series(&storepb.SeriesRequest{
Matchers: []storepb.LabelMatcher{
{Type: storepb.LabelMatcher_EQ, Name: "a", Value: "1"},
{Type: storepb.LabelMatcher_EQ, Name: "ext", Value: "wrong-value"},
},
MinTime: timestamp.FromTime(start),
MaxTime: timestamp.FromTime(now),
}, srv)
testutil.Ok(t, err)
testutil.Equals(t, 0, len(srv.SeriesSet))
} | explode_data.jsonl/39687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2281
} | [
2830,
3393,
36018,
6093,
2204,
17,
68,
1155,
353,
8840,
836,
8,
341,
2233,
5840,
11,
21290,
1669,
1273,
1314,
7121,
1190,
6093,
36018,
1155,
340,
16867,
21290,
2822,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
91... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTypeSystem_UnionsMustRepresentObjectTypes_RejectsAUnionOfNonObjectTypes(t *testing.T) {
_, err := schemaWithUnionOfType(nil)
expectedError := `BadUnion may only contain Object types, it cannot contain: <nil>.`
if err == nil || err.Error() != expectedError {
t.Fatalf("Expected error: %v, got %v", expectedError, err)
}
} | explode_data.jsonl/79181 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
929,
2320,
40687,
908,
31776,
65743,
1190,
4173,
50693,
583,
82,
32,
32658,
2124,
8121,
1190,
4173,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
10802,
2354,
32658,
34696,
27907,
340,
42400,
1454,
1669,
1565,
17082,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Parser(t *testing.T) {
parser := NewDefault()
document, err := parser.Parse("test.tf", []byte(have))
require.NoError(t, err)
require.Len(t, document, 1)
require.Contains(t, document[0], "resource")
require.Contains(t, document[0]["resource"], "aws_s3_bucket")
} | explode_data.jsonl/40761 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
1088,
10425,
1155,
353,
8840,
836,
8,
341,
55804,
1669,
1532,
3675,
741,
17470,
11,
1848,
1669,
6729,
8937,
445,
1944,
68994,
497,
3056,
3782,
3203,
523,
4390,
17957,
35699,
1155,
11,
1848,
340,
17957,
65819,
1155,
11,
2197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnalyzeNextRawErrorNoLeak(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("create table t1(id int, c varchar(32))")
tk.MustExec("set @@session.tidb_analyze_version = 2")
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/distsql/mockNextRawError", `return(true)`))
err := tk.ExecToErr("analyze table t1")
require.EqualError(t, err, "mockNextRawError")
} | explode_data.jsonl/38157 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
2082,
55856,
5847,
20015,
1454,
2753,
2304,
585,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAdmin_BlockedList(t *testing.T) {
srv, ts := prep(t)
assert.NotNil(t, srv)
defer cleanup(ts)
client := http.Client{}
// block user1
req, err := http.NewRequest(http.MethodPut,
fmt.Sprintf("%s/api/v1/admin/user/%s?site=radio-t&block=%d", ts.URL, "user1", 1), nil)
assert.Nil(t, err)
req.SetBasicAuth("dev", "password")
_, err = client.Do(req)
require.Nil(t, err)
// block user2
req, err = http.NewRequest(http.MethodPut,
fmt.Sprintf("%s/api/v1/admin/user/%s?site=radio-t&block=%d", ts.URL, "user2", 1), nil)
assert.Nil(t, err)
req.SetBasicAuth("dev", "password")
_, err = client.Do(req)
require.Nil(t, err)
res, code := getWithAuth(t, ts.URL+"/api/v1/admin/blocked?site=radio-t")
require.Equal(t, 200, code, res)
users := []store.BlockedUser{}
err = json.Unmarshal([]byte(res), &users)
assert.Nil(t, err)
assert.Equal(t, 2, len(users), "two users blocked")
assert.Equal(t, "user1", users[0].ID)
assert.Equal(t, "user2", users[1].ID)
} | explode_data.jsonl/70320 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
7210,
1668,
24633,
852,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
11,
10591,
1669,
21327,
1155,
340,
6948,
93882,
1155,
11,
43578,
340,
16867,
21290,
35864,
692,
25291,
1669,
1758,
11716,
31483,
197,
322,
2504,
1196,
16,
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 TestRingBufferCapacity(t *testing.T) {
// prepare
buffer := newRingBuffer(5)
// test
traceIDs := []pdata.TraceID{
{1, 2, 3, 4},
{2, 3, 4, 5},
{3, 4, 5, 6},
{4, 5, 6, 7},
{5, 6, 7, 8},
{6, 7, 8, 9},
}
for _, traceID := range traceIDs {
buffer.put(traceID)
}
// verify
for i := 5; i > 0; i-- { // last 5 traces
traceID := traceIDs[i]
assert.True(t, buffer.contains(traceID))
}
// the first trace should have been evicted
assert.False(t, buffer.contains(traceIDs[0]))
} | explode_data.jsonl/74367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 230
} | [
2830,
3393,
43466,
4095,
29392,
1155,
353,
8840,
836,
8,
341,
197,
322,
10549,
198,
31122,
1669,
501,
43466,
4095,
7,
20,
692,
197,
322,
1273,
198,
65058,
30466,
1669,
3056,
57796,
46920,
915,
515,
197,
197,
90,
16,
11,
220,
17,
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 TestRemoveImage(t *testing.T) {
dm, err := getDockerManager()
if err != nil {
t.Errorf("test new docker manager failed. %v ", err)
}
newImage := kubecontainer.ImageSpec{"willRemove:latest"}
_, err = dm.PullImage(newImage, []v1.Secret{})
if err != nil {
t.Errorf("TestRemoveImage failed, pull Image(%v) failed", newImage)
}
id := getImageIdByName(dm, newImage.Image)
if id == "" {
t.Errorf("TestRemoveImage failed, getImageIdByName failed")
}
err = dm.RemoveImage(kubecontainer.ImageSpec{id})
if err != nil {
t.Errorf("TestRemoveImage failed, image: %v, err: %v", newImage, err)
}
notExistImage := kubecontainer.ImageSpec{Image: "1234"}
err = dm.RemoveImage(notExistImage)
if err == nil {
t.Errorf("TestRemoveImage failed, image: %v, err: %v", notExistImage, err)
}
} | explode_data.jsonl/24911 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
13021,
1906,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
1848,
1669,
633,
35,
13659,
2043,
741,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
1944,
501,
26588,
6645,
4641,
13,
1018,
85,
3670,
1848,
340,
197,
630,
863... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderingServicePermanentCrash(t *testing.T) {
testOrderingServicePermanentCrash(t, blockDelivererConsumerWithRecv)
testOrderingServicePermanentCrash(t, blockDelivererConsumerWithSend)
assert.Equal(t, 0, connNumber)
} | explode_data.jsonl/38316 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
4431,
287,
1860,
78793,
16001,
988,
1155,
353,
8840,
836,
8,
341,
18185,
4431,
287,
1860,
78793,
16001,
988,
1155,
11,
2504,
16532,
1524,
261,
29968,
2354,
63483,
340,
18185,
4431,
287,
1860,
78793,
16001,
988,
1155,
11,
250... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBytes8_EncodedLength(t *testing.T) {
assertEncodedLength(t, []encodedLengthAssert{
{NewBytes8([8]byte{}), 8},
{NewBytes8([8]byte{7, 6, 5, 4, 3, 2, 1, 0}), 8},
})
} | explode_data.jsonl/70600 | {
"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,
7078,
23,
93529,
6737,
4373,
1155,
353,
8840,
836,
8,
341,
6948,
46795,
4373,
1155,
11,
3056,
19329,
4373,
8534,
515,
197,
197,
90,
3564,
7078,
23,
2561,
23,
90184,
6257,
701,
220,
23,
1583,
197,
197,
90,
3564,
7078,
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 TestRegistry_TLS(t *testing.T) {
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet || r.URL.Path != "/v2/" {
t.Errorf("unexpected access: %s %s", r.Method, r.URL)
w.WriteHeader(http.StatusNotFound)
return
}
}))
defer ts.Close()
uri, err := url.Parse(ts.URL)
if err != nil {
t.Fatalf("invalid test http server: %v", err)
}
reg, err := NewRegistry(uri.Host)
if err != nil {
t.Fatalf("NewRegistry() error = %v", err)
}
reg.Client = ts.Client()
ctx := context.Background()
if err := reg.Ping(ctx); err != nil {
t.Errorf("Registry.Ping() error = %v", err)
}
} | explode_data.jsonl/82486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 280
} | [
2830,
3393,
15603,
69067,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
1758,
20798,
1949,
1369,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestDaoTxUpdateAttrTagRes(t *testing.T) {
var (
tid = int64(0)
oid = int64(0)
tp = int32(0)
attr = int32(0)
)
convey.Convey("TxUpdateAttrTagRes", t, func(ctx convey.C) {
tx, err := d.BeginTran(context.TODO())
if err != nil {
return
}
rowsCount, err := d.TxUpdateAttrTagRes(tx, tid, oid, tp, attr)
ctx.Convey("Then err should be nil.rowsCount should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(rowsCount, convey.ShouldBeGreaterThanOrEqualTo, 0)
})
tx.Rollback()
})
} | explode_data.jsonl/46402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
12197,
31584,
4289,
13371,
5668,
1061,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
3244,
307,
220,
284,
526,
21,
19,
7,
15,
340,
197,
197,
588,
220,
284,
526,
21,
19,
7,
15,
340,
197,
73423,
256,
284,
526,
18,
17,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateHash(t *testing.T) {
var tests = []struct {
input string
expectedOutput string
}{
{"test", "098f6bcd4621d373cade4e832627b4f6"},
{"log", "dc1d71bbb5c4d2a5e936db79ef10c19f"},
{"log", "dc1d71bbb5c4d2a5e936db79ef10c19f"},
}
for _, test := range tests {
if output := createHash(test.input); string(output) != test.expectedOutput {
t.Error("Test failed: input:{} expectedOutput:{} output:{}", test.input, test.expectedOutput, output)
}
}
} | explode_data.jsonl/46189 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
4021,
6370,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
22427,
688,
914,
198,
197,
42400,
5097,
914,
198,
197,
59403,
197,
197,
4913,
1944,
497,
330,
15,
24,
23,
69,
21,
91490,
19,
21,
17,
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... | 3 |
func TestRemittanceOriginatorNameAlphaNumeric(t *testing.T) {
ro := mockRemittanceOriginator()
ro.RemittanceData.Name = "®"
err := ro.Validate()
require.EqualError(t, err, fieldError("Name", ErrNonAlphanumeric, ro.RemittanceData.Name).Error())
} | explode_data.jsonl/32921 | {
"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,
6590,
87191,
13298,
850,
675,
19384,
36296,
1155,
353,
8840,
836,
8,
341,
197,
299,
1669,
7860,
6590,
87191,
13298,
850,
741,
197,
299,
11398,
87191,
1043,
2967,
284,
330,
11909,
1837,
9859,
1669,
926,
47667,
2822,
17957,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRCWithAuth(t *testing.T) {
tests := []testRun{{
Name: "core-command",
URL: "core/command",
Method: "POST",
Body: `command=version`,
ContentType: "application/x-www-form-urlencoded",
Status: http.StatusOK,
Expected: fmt.Sprintf(`{
"error": false,
"result": "rclone %s\n"
}
`, fs.Version),
}, {
Name: "core-command-bad-returnType",
URL: "core/command",
Method: "POST",
Body: `command=version&returnType=POTATO`,
ContentType: "application/x-www-form-urlencoded",
Status: http.StatusInternalServerError,
Expected: `{
"error": "Unknown returnType \"POTATO\"",
"input": {
"command": "version",
"returnType": "POTATO"
},
"path": "core/command",
"status": 500
}
`,
}, {
Name: "core-command-stream",
URL: "core/command",
Method: "POST",
Body: `command=version&returnType=STREAM`,
ContentType: "application/x-www-form-urlencoded",
Status: http.StatusOK,
Expected: fmt.Sprintf(`rclone %s
{}
`, fs.Version),
}, {
Name: "core-command-stream-error",
URL: "core/command",
Method: "POST",
Body: `command=unknown_command&returnType=STREAM`,
ContentType: "application/x-www-form-urlencoded",
Status: http.StatusOK,
Expected: fmt.Sprintf(`rclone %s
Unknown command
{
"error": "exit status 1",
"input": {
"command": "unknown_command",
"returnType": "STREAM"
},
"path": "core/command",
"status": 500
}
`, fs.Version),
}}
opt := newTestOpt()
opt.Serve = true
opt.Files = testFs
opt.NoAuth = true
testServer(t, tests, &opt)
} | explode_data.jsonl/12962 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 740
} | [
2830,
3393,
7380,
2354,
5087,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1944,
6727,
90,
515,
197,
21297,
25,
286,
330,
2153,
48419,
756,
197,
79055,
25,
260,
330,
2153,
83205,
756,
197,
84589,
25,
414,
330,
2946,
756,
197,
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 TestGetDimensionsReturnsNotFound(t *testing.T) {
t.Parallel()
Convey("Get dimensions returns not found", t, func() {
r, err := createRequestWithToken("GET", "http://localhost:21800/instances/123/dimensions", nil)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
mockedDataStore, isLocked := storeMockWithLock(false)
mockedDataStore.GetDimensionsFromInstanceFunc = func(ctx context.Context, id string, offset, limit int) ([]*models.DimensionOption, int, error) {
So(*isLocked, ShouldBeTrue)
return nil, 0, errs.ErrDimensionNodeNotFound
}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
datasetAPI.Router.ServeHTTP(w, r)
So(w.Code, ShouldEqual, http.StatusNotFound)
So(w.Body.String(), ShouldContainSubstring, errs.ErrDimensionNodeNotFound.Error())
So(mockedDataStore.GetInstanceCalls(), ShouldHaveLength, 1)
So(mockedDataStore.GetInstanceCalls()[0].ID, ShouldEqual, "123")
So(mockedDataStore.GetDimensionsFromInstanceCalls(), ShouldHaveLength, 1)
So(mockedDataStore.GetDimensionsFromInstanceCalls()[0].ID, ShouldEqual, "123")
validateLock(mockedDataStore, "123")
So(*isLocked, ShouldBeFalse)
})
} | explode_data.jsonl/20840 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 436
} | [
2830,
3393,
1949,
21351,
16446,
10372,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
93070,
5617,
445,
1949,
15336,
4675,
537,
1730,
497,
259,
11,
2915,
368,
341,
197,
7000,
11,
1848,
1669,
1855,
1900,
2354,
3323,
445,
3806,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestComment(t *testing.T) {
orgMember := "cjwagner"
bot := "k8s-ci-robot"
type testCase struct {
name string
action github.GenericCommentEventAction
body string
expectedMessages map[string][]string
issueLabels []string
repoLabels []string
commenter string
}
testcases := []testCase{
{
name: "If sig mentioned then we send a message to the sig with the body of the comment",
action: github.GenericCommentActionCreated,
body: "@kubernetes/sig-node-misc This issue needs update.",
expectedMessages: map[string][]string{"sig-node": {"This issue needs update."}},
commenter: orgMember,
},
{
name: "Don't sent message if comment isn't new.",
action: github.GenericCommentActionEdited,
body: "@kubernetes/sig-node-misc This issue needs update.",
expectedMessages: map[string][]string{},
commenter: orgMember,
},
{
name: "Don't sent message if commenter is the bot.",
action: github.GenericCommentActionEdited,
body: "@kubernetes/sig-node-misc This issue needs update.",
expectedMessages: map[string][]string{},
commenter: bot,
},
{
name: "If multiple sigs mentioned, we send a message to each sig with the body of the comment",
action: github.GenericCommentActionCreated,
body: "@kubernetes/sig-node-misc, @kubernetes/sig-api-machinery-misc Message sent to multiple sigs.",
expectedMessages: map[string][]string{"sig-api-machinery": {"Message sent to multiple sigs."}, "sig-node": {"Message sent to multiple sigs."}},
commenter: orgMember,
},
{
name: "If multiple sigs mentioned, but only one channel is whitelisted, only send to one channel.",
action: github.GenericCommentActionCreated,
body: "@kubernetes/sig-node-misc, @kubernetes/sig-testing-misc Message sent to multiple sigs.",
expectedMessages: map[string][]string{"sig-node": {"Message sent to multiple sigs."}},
issueLabels: []string{},
commenter: orgMember,
},
{
name: "Message should not be sent if the pattern for the channel does not match",
action: github.GenericCommentActionCreated,
body: "@kubernetes/node-misc No message sent",
expectedMessages: map[string][]string{},
commenter: orgMember,
},
{
name: "Message sent only if the pattern for the channel match",
action: github.GenericCommentActionCreated,
body: "@kubernetes/node-misc @kubernetes/sig-api-machinery-bugs Message sent to matching sigs.",
expectedMessages: map[string][]string{"sig-api-machinery": {"Message sent to matching sigs."}},
commenter: orgMember,
},
}
for _, tc := range testcases {
fakeSlackClient := &FakeClient{
SentMessages: make(map[string][]string),
}
client := client{
GitHubClient: &fakegithub.FakeClient{},
SlackClient: fakeSlackClient,
SlackConfig: plugins.Slack{MentionChannels: []string{"sig-node", "sig-api-machinery"}},
}
e := github.GenericCommentEvent{
Action: tc.action,
Body: tc.body,
User: github.User{Login: tc.commenter},
}
if err := echoToSlack(client, e); err != nil {
t.Fatalf("For case %s, didn't expect error from label test: %v", tc.name, err)
}
if len(tc.expectedMessages) != len(fakeSlackClient.SentMessages) {
t.Fatalf("The number of messages sent do not tally. Expecting %d messages but received %d messages.",
len(tc.expectedMessages), len(fakeSlackClient.SentMessages))
}
for k, v := range tc.expectedMessages {
if _, ok := fakeSlackClient.SentMessages[k]; !ok {
t.Fatalf("Messages is not sent to channel %s", k)
}
if len(v) != len(fakeSlackClient.SentMessages[k]) {
t.Fatalf("All messages are not delivered to the channel %s", k)
}
}
}
} | explode_data.jsonl/52610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1677
} | [
2830,
3393,
10677,
1155,
353,
8840,
836,
8,
341,
87625,
9366,
1669,
330,
79446,
86,
39438,
698,
2233,
354,
1669,
330,
74,
23,
82,
62384,
12,
18247,
698,
13158,
54452,
2036,
341,
197,
11609,
1797,
914,
198,
197,
38933,
1843,
31004,
434... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInvokeRequest(t *testing.T) {
req := NewInvokeMethodRequest("test_method")
assert.Equal(t, internalv1pb.APIVersion_V1, req.r.GetVer())
assert.Equal(t, "test_method", req.r.Message.GetMethod())
} | explode_data.jsonl/46237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
17604,
1900,
1155,
353,
8840,
836,
8,
341,
24395,
1669,
1532,
17604,
3523,
1900,
445,
1944,
9032,
5130,
6948,
12808,
1155,
11,
5306,
85,
16,
16650,
24922,
5637,
2334,
16,
11,
4232,
1746,
2234,
10141,
2398,
6948,
12808,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestTextDocumentSyncKind_String(t *testing.T) {
tests := []struct {
name string
k TextDocumentSyncKind
want string
}{
{
name: "NoneKind",
k: None,
want: "None",
},
{
name: "FullKind",
k: Full,
want: "Full",
},
{
name: "IncrementalKind",
k: Incremental,
want: "Incremental",
},
{
name: "UnknownKind",
k: TextDocumentSyncKind(99),
want: "99",
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if got := tt.k.String(); got != tt.want {
t.Errorf("TextDocumentSyncKind.String() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/10252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
1178,
7524,
12154,
10629,
31777,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
16463,
262,
2918,
7524,
12154,
10629,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCrDoubleResolutionRmTree(t *testing.T) {
test(t,
users("alice", "bob", "charlie"),
as(alice,
write("a/b/c/d/e", "test1"),
write("a/b/c/d/f", "test2"),
),
as(bob,
disableUpdates(),
),
as(charlie,
disableUpdates(),
),
as(alice,
write("g", "hello"),
),
as(bob, noSync(),
// Remove a tree of files.
rm("a/b/c/d/e"),
rm("a/b/c/d/f"),
rm("a/b/c/d"),
rm("a/b/c"),
reenableUpdates(),
lsdir("", m{"a": "DIR", "g": "FILE"}),
lsdir("a", m{"b": "DIR"}),
lsdir("a/b", m{}),
read("g", "hello"),
),
as(alice,
lsdir("", m{"a": "DIR", "g": "FILE"}),
lsdir("a", m{"b": "DIR"}),
lsdir("a/b", m{}),
read("g", "hello"),
),
as(charlie, noSync(),
// Touch a subdirectory that was removed by bob.
// Unfortunately even though these are just rmOps, they
// still re-create "c/d". Tracking a fix for that in
// KBFS-1423.
rm("a/b/c/d/e"),
rm("a/b/c/d/f"),
reenableUpdates(),
lsdir("", m{"a": "DIR", "g": "FILE"}),
lsdir("a", m{"b": "DIR"}),
lsdir("a/b", m{"c": "DIR"}),
lsdir("a/b/c", m{"d": "DIR"}),
lsdir("a/b/c/d", m{}),
read("g", "hello"),
),
as(alice,
lsdir("", m{"a": "DIR", "g": "FILE"}),
lsdir("a", m{"b": "DIR"}),
lsdir("a/b", m{"c": "DIR"}),
lsdir("a/b/c", m{"d": "DIR"}),
lsdir("a/b/c/d", m{}),
read("g", "hello"),
),
as(bob,
lsdir("", m{"a": "DIR", "g": "FILE"}),
lsdir("a", m{"b": "DIR"}),
lsdir("a/b", m{"c": "DIR"}),
lsdir("a/b/c", m{"d": "DIR"}),
lsdir("a/b/c/d", m{}),
read("g", "hello"),
),
)
} | explode_data.jsonl/31370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 866
} | [
2830,
3393,
16001,
7378,
38106,
49,
76,
6533,
1155,
353,
8840,
836,
8,
341,
18185,
1155,
345,
197,
90896,
445,
63195,
497,
330,
47086,
497,
330,
1762,
11567,
4461,
197,
60451,
17643,
558,
345,
298,
24945,
445,
64,
3470,
2899,
3446,
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 TestRecipientChannelIDNotStartWithAt(t *testing.T) {
testData := []struct {
channel string
expected string
}{
{channel: "channel", expected: "@channel"},
{channel: "@channel", expected: "@channel"},
{channel: "107401628", expected: "107401628"}, // numeric ChanID should be preserved
{channel: "-1001484738202", expected: "-1001484738202"},
}
for i, entry := range testData {
t.Run(strconv.Itoa(i), func(t *testing.T) {
got := recipient{chatID: entry.channel} // nolint
assert.Equal(t, entry.expected, got.Recipient())
})
}
} | explode_data.jsonl/50728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
74432,
9629,
915,
2623,
3479,
2354,
1655,
1155,
353,
8840,
836,
8,
341,
18185,
1043,
1669,
3056,
1235,
341,
197,
71550,
220,
914,
198,
197,
42400,
914,
198,
197,
59403,
197,
197,
90,
10119,
25,
330,
10119,
497,
3601,
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 TestPVCControlUpdateMetaInfoConflictSuccess(t *testing.T) {
g := NewGomegaWithT(t)
tc := newTidbCluster()
pvc := newPVC(tc)
oldPVC := newPVC(tc)
pod := newPod(tc)
fakeClient, pvcLister, pvcIndexer, recorder := newFakeClientAndRecorder()
pvcIndexer.Add(oldPVC)
control := NewRealPVCControl(fakeClient, recorder, pvcLister)
conflict := false
fakeClient.AddReactor("update", "persistentvolumeclaims", func(action core.Action) (bool, runtime.Object, error) {
update := action.(core.UpdateAction)
if !conflict {
conflict = true
return true, oldPVC, apierrors.NewConflict(action.GetResource().GroupResource(), pvc.Name, errors.New("conflict"))
}
return true, update.GetObject(), nil
})
updatePVC, err := control.UpdateMetaInfo(tc, pvc, pod)
g.Expect(err).To(Succeed())
g.Expect(updatePVC.Annotations[label.AnnPodNameKey]).To(Equal(pod.GetName()))
} | explode_data.jsonl/66722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 333
} | [
2830,
3393,
47,
11287,
3273,
4289,
12175,
1731,
57974,
7188,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
340,
78255,
1669,
501,
51,
307,
65,
28678,
741,
3223,
7362,
1669,
501,
47,
11287,
44415,
340,
6182... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateRemoteUUID(t *testing.T) {
require.NoError(t, os.MkdirAll("data", 0777))
defer os.RemoveAll("data")
s := DefaultServer()
m := memory.Open()
uuid, err := getOrSetUUID("./data", "./data")
require.NoError(t, err)
s.UUID = uuid
err = s.updateRemoteUUID(m)
require.NoError(t, err)
exists, err := m.Exists(context.Background(), "immudb.identifier")
require.NoError(t, err)
require.True(t, exists)
data, err := m.Get(context.Background(), "immudb.identifier", 0, -1)
require.NoError(t, err)
defer data.Close()
readUUID, err := ioutil.ReadAll(data)
require.NoError(t, err)
require.Equal(t, uuid.Bytes(), readUUID)
} | explode_data.jsonl/38344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 265
} | [
2830,
3393,
4289,
24703,
24754,
1155,
353,
8840,
836,
8,
341,
17957,
35699,
1155,
11,
2643,
1321,
12438,
2403,
445,
691,
497,
220,
15,
22,
22,
22,
1171,
16867,
2643,
84427,
445,
691,
5130,
1903,
1669,
7899,
5475,
741,
2109,
1669,
4938... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeletePanic(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (c int)")
tk.MustExec("insert into t values (1), (2), (3)")
tk.MustExec("delete from `t` where `c` = ?", 1)
tk.MustExec("delete from `t` where `c` = ?", 2)
} | explode_data.jsonl/5772 | {
"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,
6435,
47,
31270,
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,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExpiration(t *testing.T) {
expirationDate := time.Now().Add(time.Minute)
id1 := &pmsp.SerializedIdentity{
Mspid: "X509BasedMSP",
IdBytes: []byte("X509BasedIdentity"),
}
x509IdentityBytes, _ := proto.Marshal(id1)
id2 := &pmsp.SerializedIdentity{
Mspid: "nonX509BasedMSP",
IdBytes: []byte("nonX509RawIdentity"),
}
nonX509IdentityBytes, _ := proto.Marshal(id2)
deserializersManager := &mocks.DeserializersManager{
LocalDeserializer: &mocks.IdentityDeserializer{
Identity: []byte{1, 2, 3},
Msg: []byte{1, 2, 3},
},
ChannelDeserializers: map[string]msp.IdentityDeserializer{
"X509BasedMSP": &mocks.IdentityDeserializerWithExpiration{
Expiration: expirationDate,
IdentityDeserializer: &mocks.IdentityDeserializer{
Identity: x509IdentityBytes,
Msg: []byte("x509IdentityBytes"),
},
},
"nonX509BasedMSP": &mocks.IdentityDeserializer{
Identity: nonX509IdentityBytes,
Msg: []byte("nonX509IdentityBytes"),
},
},
}
cryptoProvider, err := sw.NewDefaultSecurityLevelWithKeystore(sw.NewDummyKeyStore())
require.NoError(t, err)
msgCryptoService := NewMCS(
&mocks.ChannelPolicyManagerGetterWithManager{},
&mocks.Id2IdentitiesFetcherMock{},
&mocks.SignerSerializer{},
deserializersManager,
cryptoProvider,
)
// Green path I check the expiration date is as expected
exp, err := msgCryptoService.Expiration(x509IdentityBytes)
require.NoError(t, err)
require.Equal(t, expirationDate.Second(), exp.Second())
// Green path II - a non-x509 identity has a zero expiration time
exp, err = msgCryptoService.Expiration(nonX509IdentityBytes)
require.NoError(t, err)
require.Zero(t, exp)
// Bad path I - corrupt the x509 identity and make sure error is returned
x509IdentityBytes = append(x509IdentityBytes, 0, 0, 0, 0, 0, 0)
exp, err = msgCryptoService.Expiration(x509IdentityBytes)
require.Error(t, err)
require.Contains(t, err.Error(), "No MSP found able to do that")
require.Zero(t, exp)
} | explode_data.jsonl/20528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 782
} | [
2830,
3393,
66301,
1155,
353,
8840,
836,
8,
341,
48558,
19629,
1916,
1669,
882,
13244,
1005,
2212,
9730,
75770,
340,
15710,
16,
1669,
609,
79,
92545,
13412,
1506,
18558,
515,
197,
9209,
2154,
307,
25,
256,
330,
55,
20,
15,
24,
28715,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTokenResponseMap(t *testing.T) {
r := NewTokenResponse("foo", "bar", 1)
r.RefreshToken = "baz"
r.Scope = Scope{"qux"}
r.State = "quuz"
assert.Equal(t, map[string]string{
"token_type": "foo",
"access_token": "bar",
"expires_in": "1",
"refresh_token": "baz",
"scope": "qux",
"state": "quuz",
}, r.Map())
} | explode_data.jsonl/1727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
3323,
2582,
2227,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
3323,
2582,
445,
7975,
497,
330,
2257,
497,
220,
16,
340,
7000,
49841,
3323,
284,
330,
42573,
698,
7000,
77940,
284,
34920,
4913,
446,
87,
16707,
7000,
1894... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBytes_EncodeDecode(t *testing.T) {
assertRoundtrip(t, NewBytes(MustHexDecodeString("0x00")))
assertRoundtrip(t, NewBytes(MustHexDecodeString("0xab1234")))
assertRoundtrip(t, NewBytes(MustHexDecodeString("0x0001")))
} | explode_data.jsonl/70592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 89
} | [
2830,
3393,
7078,
93529,
534,
32564,
1155,
353,
8840,
836,
8,
341,
6948,
27497,
32981,
1155,
11,
1532,
7078,
3189,
590,
20335,
32564,
703,
445,
15,
87,
15,
15,
29836,
6948,
27497,
32981,
1155,
11,
1532,
7078,
3189,
590,
20335,
32564,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMempoolProgressInHigherRound(t *testing.T) {
config := ResetConfig("consensus_mempool_txs_available_test")
defer os.RemoveAll(config.RootDir)
config.Consensus.CreateEmptyBlocks = false
state, privVals := randGenesisState(1, false, 10)
cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication())
assertMempool(cs.txNotifier).EnableTxsAvailable()
height, round := cs.Height, cs.Round
newBlockCh := subscribe(cs.eventBus, types.EventQueryNewBlock)
newRoundCh := subscribe(cs.eventBus, types.EventQueryNewRound)
timeoutCh := subscribe(cs.eventBus, types.EventQueryTimeoutPropose)
cs.setProposal = func(proposal *types.Proposal) error {
if cs.Height == 2 && cs.Round == 0 {
// dont set the proposal in round 0 so we timeout and
// go to next round
cs.Logger.Info("Ignoring set proposal at height 2, round 0")
return nil
}
return cs.defaultSetProposal(proposal)
}
startTestRound(cs, height, round)
ensureNewRound(newRoundCh, height, round) // first round at first height
ensureNewEventOnChannel(newBlockCh) // first block gets committed
height++ // moving to the next height
round = 0
ensureNewRound(newRoundCh, height, round) // first round at next height
deliverTxsRange(cs, 0, 1) // we deliver txs, but dont set a proposal so we get the next round
ensureNewTimeout(timeoutCh, height, round, cs.config.TimeoutPropose.Nanoseconds())
round++ // moving to the next round
ensureNewRound(newRoundCh, height, round) // wait for the next round
ensureNewEventOnChannel(newBlockCh) // now we can commit the block
} | explode_data.jsonl/23670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
44,
3262,
1749,
9496,
641,
87445,
27497,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
16932,
2648,
445,
6254,
13626,
717,
3262,
1749,
17805,
82,
26962,
4452,
1138,
16867,
2643,
84427,
8754,
45345,
6184,
340,
25873,
94594,
13626,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Middleware_BasicAuth(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{
Users: map[string]string{
"john": "doe",
"admin": "123456",
},
}))
app.Get("/testauth", func(c *fiber.Ctx) error {
username := c.Locals("username").(string)
password := c.Locals("password").(string)
return c.SendString(username + password)
})
tests := []struct {
url string
statusCode int
username string
password string
}{
{
url: "/testauth",
statusCode: 200,
username: "john",
password: "doe",
},
{
url: "/testauth",
statusCode: 200,
username: "admin",
password: "123456",
},
{
url: "/testauth",
statusCode: 401,
username: "ee",
password: "123456",
},
}
for _, tt := range tests {
// Base64 encode credentials for http auth header
creds := b64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", tt.username, tt.password)))
req := httptest.NewRequest("GET", "/testauth", nil)
req.Header.Add("Authorization", "Basic "+creds)
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, tt.statusCode, resp.StatusCode)
if tt.statusCode == 200 {
utils.AssertEqual(t, fmt.Sprintf("%s%s", tt.username, tt.password), string(body))
}
}
} | explode_data.jsonl/8244 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 618
} | [
2830,
3393,
1245,
11603,
1668,
5971,
5087,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
28236,
1669,
23788,
7121,
2822,
28236,
9046,
35063,
33687,
515,
197,
197,
7137,
25,
2415,
14032,
30953,
515,
298,
197,
1,
47817,
788,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSupportedTimezones(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
supportedTimezonesFromConfig := th.App.Timezones()
supportedTimezones, resp := Client.GetSupportedTimezone()
CheckNoError(t, resp)
assert.Equal(t, supportedTimezonesFromConfig, supportedTimezones)
} | explode_data.jsonl/10693 | {
"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,
34636,
1462,
67534,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
271,
1903,
12513,
1462,
67534,
3830,
2648,
1669,
270,
5105,
16299,
67534,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommandLine_LoginLogout(t *testing.T) {
options := server.Options{}.WithAuth(true).WithInMemoryStore(true).WithAdminPassword(auth.SysAdminPassword)
bs := servertest.NewBufconnServer(options)
bs.Start()
cl := commandline{}
cmd, _ := cl.NewCmd()
dialOptions := []grpc.DialOption{
grpc.WithContextDialer(bs.Dialer), grpc.WithInsecure(),
}
cliopt := Options().WithDialOptions(&dialOptions)
cliopt.Tkns = client.NewTokenService().WithHds(client.NewHomedirService()).WithTokenFileName("token_admin")
cmdl := commandline{
config: helper.Config{Name: "immuadmin"},
options: cliopt,
immuClient: &scIClientInnerMock{cliopt, *new(client.ImmuClient)},
passwordReader: pwReaderMock,
context: context.Background(),
ts: client.NewTokenService().WithHds(client.NewHomedirService()).WithTokenFileName("token_admin"),
newImmuClient: client.NewImmuClient,
}
cmdl.login(cmd)
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"login", "immudb"})
// remove ConfigChain method to avoid override options
cmd.PersistentPreRunE = nil
logincmd := cmd.Commands()[0]
logincmd.PersistentPreRunE = nil
cmd.Execute()
out, err := ioutil.ReadAll(b)
if err != nil {
t.Fatal(err)
}
assert.Contains(t, string(out), "logged in")
cmdlo := commandline{
config: helper.Config{Name: "immuadmin"},
options: cliopt,
immuClient: &scIClientMock{*new(client.ImmuClient)},
passwordReader: pwReaderMock,
context: context.Background(),
ts: client.NewTokenService().WithHds(client.NewHomedirService()).WithTokenFileName("token_admin"),
}
b1 := bytes.NewBufferString("")
cl = commandline{}
logoutcmd, _ := cl.NewCmd()
logoutcmd.SetOut(b1)
logoutcmd.SetArgs([]string{"logout"})
cmdlo.logout(logoutcmd)
// remove ConfigChain method to avoid override options
logoutcmd.PersistentPreRunE = nil
logoutcmdin := logoutcmd.Commands()[0]
logoutcmdin.PersistentPreRunE = nil
logoutcmd.Execute()
out1, err1 := ioutil.ReadAll(b1)
if err1 != nil {
t.Fatal(err1)
}
assert.Contains(t, string(out1), "logged out")
} | explode_data.jsonl/54119 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 858
} | [
2830,
3393,
71885,
79232,
27958,
1155,
353,
8840,
836,
8,
341,
35500,
1669,
3538,
22179,
46391,
2354,
5087,
3715,
568,
2354,
641,
10642,
6093,
3715,
568,
2354,
7210,
4876,
27435,
59418,
7210,
4876,
340,
93801,
1669,
1420,
1621,
477,
7121,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestShouldNotFindSliceDifferencesDelta(t *testing.T) {
before := []string{"abc", "onetwothree"}
after := []string{"abc", "onetwothree"}
added, removed := StringSlicesDelta(before, after)
require.Len(t, added, 0)
require.Len(t, removed, 0)
} | explode_data.jsonl/45964 | {
"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,
14996,
2623,
9885,
33236,
35,
58326,
20277,
1155,
353,
8840,
836,
8,
341,
63234,
1669,
3056,
917,
4913,
13683,
497,
330,
68686,
1126,
27856,
16707,
197,
10694,
1669,
3056,
917,
4913,
13683,
497,
330,
68686,
1126,
27856,
63159,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListCommandRunEClosure(t *testing.T) {
assert := assert.New(t)
cli := test.NewCLI()
client := cli.Client.(*client.MockClient)
resources := []corev2.User{}
client.On("List", mock.Anything, &resources, mock.Anything, mock.Anything).Return(nil).Run(
func(args mock.Arguments) {
resources := args[1].(*[]corev2.User)
*resources = []corev2.User{
*corev2.FixtureUser("one"),
*corev2.FixtureUser("two"),
}
},
)
cmd := ListCommand(cli)
out, err := test.RunCmd(cmd, []string{})
assert.NotEmpty(out)
assert.Nil(err)
assert.NotContains(out, "==")
} | explode_data.jsonl/11553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 239
} | [
2830,
3393,
852,
4062,
6727,
7498,
11653,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
86448,
1669,
1273,
7121,
63959,
741,
25291,
1669,
21348,
11716,
41399,
2972,
24664,
2959,
340,
10202,
2360,
1669,
3056,
98645,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWebhookHandler2(t *testing.T) {
g := gomega.NewGomegaWithT(t)
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"})
g.Expect(err).NotTo(gomega.HaveOccurred())
c = mgr.GetClient()
stopMgr, mgrStopped := StartTestManager(mgr, g)
defer func() {
close(stopMgr)
mgrStopped.Wait()
}()
listener, err := CreateWebhookListener(cfg, cfg, scheme.Scheme, "", "", false)
g.Expect(err).NotTo(gomega.HaveOccurred())
subscription := &appv1alpha1.Subscription{}
err = yaml.Unmarshal([]byte(subscriptionYAML), &subscription)
g.Expect(err).NotTo(gomega.HaveOccurred())
err = c.Create(context.TODO(), subscription)
g.Expect(err).NotTo(gomega.HaveOccurred())
reqBody, err := json.Marshal(map[string]string{
"name": "joe",
"age": "19",
})
g.Expect(err).NotTo(gomega.HaveOccurred())
req2, err := http.NewRequest("POST", "/webhook", bytes.NewBuffer(reqBody))
g.Expect(err).NotTo(gomega.HaveOccurred())
req2.Header.Set("Content-Type", "application/json")
req2.Header.Set("X-Github-Event", "ping")
rr := httptest.NewRecorder()
handler := http.HandlerFunc(listener.HandleWebhook)
handler.ServeHTTP(rr, req2)
g.Expect(rr.Code).To(gomega.Equal(http.StatusOK))
key := types.NamespacedName{
Name: "test-subscription",
Namespace: "test",
}
subscription2 := &appv1alpha1.Subscription{}
err = c.Get(context.TODO(), key, subscription)
g.Expect(err).NotTo(gomega.HaveOccurred())
subAnnotations := subscription2.GetAnnotations()
g.Expect(subAnnotations[appv1alpha1.AnnotationWebhookEventCount]).To(gomega.BeEmpty())
err = c.Delete(context.TODO(), subscription)
g.Expect(err).NotTo(gomega.HaveOccurred())
} | explode_data.jsonl/59424 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 670
} | [
2830,
3393,
5981,
20873,
3050,
17,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
692,
2109,
901,
11,
1848,
1669,
6645,
7121,
28272,
11,
6645,
22179,
90,
27328,
9950,
4286,
25,
330,
15,
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,
1... | 1 |
func TestParseHexColor(t *testing.T) {
colorTestCases := []struct {
test string
valid bool // If valid format
R byte
G byte
B byte
}{
{"#123", false, 0, 0, 0},
{"#1234567", false, 0, 0, 0},
{"$123456", false, 0, 0, 0},
{"#12345+", false, 0, 0, 0},
{"#fFGG00", false, 0, 0, 0},
{"", false, 0, 0, 0},
{"#123456", true, 0x12, 0x34, 0x56},
{"#C0FfeE", true, 0xc0, 0xff, 0xee},
}
// Perform the table driven tests.
for _, ct := range colorTestCases {
color, err := parseHexColor(ct.test)
if !ct.valid && err == nil {
t.Fatalf("Invalid color string: %s, should return "+
"error, but did not", ct.test)
}
if ct.valid && err != nil {
t.Fatalf("Color %s valid to parse: %s", ct.test, err)
}
// Ensure that the string to hex decoding is working properly.
if color.R != ct.R || color.G != ct.G || color.B != ct.B {
t.Fatalf("Color %s incorrectly parsed as %v", ct.test, color)
}
}
} | explode_data.jsonl/15899 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 430
} | [
2830,
3393,
14463,
20335,
1636,
1155,
353,
8840,
836,
8,
341,
21481,
2271,
37302,
1669,
3056,
1235,
341,
197,
18185,
220,
914,
198,
197,
56322,
1807,
442,
1416,
2697,
3561,
198,
197,
11143,
257,
4922,
198,
197,
9600,
257,
4922,
198,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestJSONLoadConfig(t *testing.T) {
factories, err := componenttest.NopFactories()
assert.Nil(t, err)
factory := NewFactory()
factories.Exporters[config.Type(typeStr)] = factory
cfg, err := servicetest.LoadConfig(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)
assert.Equal(t, 3, len(cfg.Exporters))
actualCfg := cfg.Exporters[config.NewComponentIDWithName(typeStr, "json")].(*Config)
expectedCfg := Config{
ExporterSettings: config.NewExporterSettings(config.NewComponentIDWithName(typeStr, "json")),
HTTPClientSettings: confighttp.HTTPClientSettings{
Headers: map[string]string{},
Endpoint: "https://loki:3100/loki/api/v1/push",
TLSSetting: configtls.TLSClientSetting{
TLSSetting: configtls.TLSSetting{
CAFile: "",
CertFile: "",
KeyFile: "",
},
Insecure: false,
},
ReadBufferSize: 0,
WriteBufferSize: 524288,
Timeout: time.Second * 30,
},
RetrySettings: exporterhelper.RetrySettings{
Enabled: true,
InitialInterval: 5 * time.Second,
MaxInterval: 30 * time.Second,
MaxElapsedTime: 5 * time.Minute,
},
QueueSettings: exporterhelper.QueueSettings{
Enabled: true,
NumConsumers: 10,
QueueSize: 5000,
},
TenantID: "example",
Labels: LabelsConfig{
Attributes: map[string]string{},
ResourceAttributes: map[string]string{},
},
Format: "json",
}
require.Equal(t, &expectedCfg, actualCfg)
} | explode_data.jsonl/73121 | {
"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,
5370,
5879,
2648,
1155,
353,
8840,
836,
8,
341,
1166,
52893,
11,
1848,
1669,
3692,
1944,
2067,
453,
17417,
2433,
741,
6948,
59678,
1155,
11,
1848,
692,
1166,
2919,
1669,
1532,
4153,
741,
1166,
52893,
81077,
388,
58,
1676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTranscodingMOV(t *testing.T) {
var inputPath = "/tmp/ffmpeg/mov"
var outputPath = "/tmp/ffmpeg/out/mov.mp4"
trans := new(transcoder.Transcoder)
err := trans.Initialize(inputPath, outputPath)
assert.Nil(t, err)
done := trans.Run(false)
err = <-done
assert.Nil(t, err)
} | explode_data.jsonl/57661 | {
"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,
3167,
48367,
66022,
1155,
353,
8840,
836,
8,
1476,
2405,
1946,
1820,
284,
3521,
5173,
14,
72422,
3183,
859,
698,
2405,
95017,
284,
3521,
5173,
14,
72422,
48316,
3183,
859,
16870,
19,
1837,
72453,
1669,
501,
33089,
40170,
118... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCACaps(t *testing.T) {
server, _, teardown := newServer(t)
defer teardown()
url := server.URL + "/scep?operation=GetCACaps"
resp, err := http.Get(url)
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != http.StatusOK {
t.Error("expected", http.StatusOK, "got", resp.StatusCode)
}
} | explode_data.jsonl/70653 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
92832,
2625,
1155,
353,
8840,
836,
8,
341,
41057,
11,
8358,
49304,
1669,
501,
5475,
1155,
340,
16867,
49304,
741,
19320,
1669,
3538,
20893,
488,
3521,
82,
31652,
30,
9262,
28,
1949,
92832,
2625,
698,
34653,
11,
1848,
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... | 3 |
func TestChangeTokenOwnerHandler(t *testing.T) {
var (
aliceCond = weavetest.NewCondition()
bobbyCond = weavetest.NewCondition()
)
cases := map[string]struct {
Tx weave.Tx
Auth x.Authenticator
WantCheckErr *errors.Error
WantDeliverErr *errors.Error
}{
"success": {
Tx: &weavetest.Tx{
Msg: &TransferTokenMsg{
Metadata: &weave.Metadata{Schema: 1},
Username: "alice*iov",
NewOwner: bobbyCond.Address(),
},
},
Auth: &weavetest.Auth{Signer: aliceCond},
},
"only the owner can change the token": {
Tx: &weavetest.Tx{
Msg: &TransferTokenMsg{
Metadata: &weave.Metadata{Schema: 1},
Username: "alice*iov",
NewOwner: bobbyCond.Address(),
},
},
WantCheckErr: errors.ErrUnauthorized,
WantDeliverErr: errors.ErrUnauthorized,
Auth: &weavetest.Auth{Signer: bobbyCond},
},
"token must exist": {
Tx: &weavetest.Tx{
Msg: &TransferTokenMsg{
Metadata: &weave.Metadata{Schema: 1},
Username: "does-not-exist*iov",
NewOwner: bobbyCond.Address(),
},
},
WantCheckErr: errors.ErrNotFound,
WantDeliverErr: errors.ErrNotFound,
Auth: &weavetest.Auth{Signer: bobbyCond},
},
"change to the same owner (no change) is allowed": {
Tx: &weavetest.Tx{
Msg: &TransferTokenMsg{
Metadata: &weave.Metadata{Schema: 1},
Username: "alice*iov",
NewOwner: aliceCond.Address(),
},
},
Auth: &weavetest.Auth{Signer: aliceCond},
},
}
for testName, tc := range cases {
t.Run(testName, func(t *testing.T) {
db := store.MemStore()
migration.MustInitPkg(db, "username")
b := NewTokenBucket()
_, err := b.Put(db, []byte("alice*iov"), &Token{
Metadata: &weave.Metadata{Schema: 1},
Targets: []BlockchainAddress{
{BlockchainID: "unichain", Address: "some-unichain-address"},
},
Owner: aliceCond.Address(),
})
assert.Nil(t, err)
h := transferTokenHandler{
auth: tc.Auth,
bucket: b,
}
cache := db.CacheWrap()
if _, err := h.Check(context.TODO(), cache, tc.Tx); !tc.WantCheckErr.Is(err) {
t.Fatalf("unexpected check error: %s", err)
}
cache.Discard()
if _, err := h.Deliver(context.TODO(), db, tc.Tx); !tc.WantDeliverErr.Is(err) {
t.Fatalf("unexpected deliver error: %s", err)
}
})
}
} | explode_data.jsonl/1791 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1100
} | [
2830,
3393,
4072,
3323,
13801,
3050,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
197,
63195,
49696,
284,
582,
402,
57824,
7121,
10547,
741,
197,
2233,
10317,
49696,
284,
582,
402,
57824,
7121,
10547,
741,
197,
692,
1444,
2264,
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... | 3 |
func TestGenerateName(t *testing.T) {
cookieName := GenerateName("containous")
assert.Len(t, "_8a7bc", 6)
assert.Equal(t, "_8a7bc", cookieName)
} | explode_data.jsonl/58889 | {
"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,
31115,
675,
1155,
353,
8840,
836,
8,
341,
197,
16236,
675,
1669,
19813,
675,
445,
52095,
782,
5130,
6948,
65819,
1155,
11,
9000,
23,
64,
22,
8904,
497,
220,
21,
340,
6948,
12808,
1155,
11,
9000,
23,
64,
22,
8904,
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 |
func TestPlaceMultipleSpotOrdersOverPairLimits(t *testing.T) {
ord := okgroup.PlaceOrderRequest{
InstrumentID: spotCurrency,
Type: order.Limit.Lower(),
Side: order.Buy.Lower(),
Size: "-100",
Price: "1",
}
request := []okgroup.PlaceOrderRequest{
ord,
}
pairs := currency.Pairs{
currency.NewPair(currency.LTC, currency.USDT),
currency.NewPair(currency.ETH, currency.USDT),
currency.NewPair(currency.BCH, currency.USDT),
currency.NewPair(currency.XMR, currency.USDT),
}
for x := range pairs {
ord.InstrumentID = pairs[x].Format("-", false).String()
request = append(request, ord)
}
_, errs := o.PlaceMultipleSpotOrders(request)
if errs[0].Error() != "up to 4 trading pairs" {
t.Error("Expecting an error when more than 4 trading pairs supplied", errs[0])
}
} | explode_data.jsonl/30159 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
17371,
32089,
47049,
24898,
1918,
12443,
94588,
1155,
353,
8840,
836,
8,
341,
197,
539,
1669,
5394,
4074,
86675,
4431,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
27725,
25,
260,
1973,
1214,
2353,
1214,
1202,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStatResponse(t *testing.T) {
res := &StatResponse{
CanLongPoll: true,
}
enc, err := json.MarshalIndent(res, " ", "")
if err != nil {
t.Fatal(err)
}
if got := string(enc); !strings.Contains(got, `"stat": []`) {
t.Errorf("Wanted stat to have value []; got %s", got)
}
} | explode_data.jsonl/16530 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
15878,
2582,
1155,
353,
8840,
836,
8,
341,
10202,
1669,
609,
15878,
2582,
515,
197,
6258,
276,
6583,
49207,
25,
830,
345,
197,
532,
197,
954,
11,
1848,
1669,
2951,
37271,
42729,
4590,
11,
330,
220,
3670,
14676,
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... | 3 |
func TestConsulRunnerRunBadUpdaterFlags(t *testing.T) {
ctrl := gomock.NewController(assert.Tracing(t))
defer ctrl.Finish()
mockUpdaterFromFlags := rotor.NewMockUpdaterFromFlags(ctrl)
mockUpdaterFromFlags.EXPECT().Validate().Return(errors.New("bad updater flags"))
cmd := Cmd(mockUpdaterFromFlags)
cmd.Flags.Parse([]string{})
r := cmd.Runner.(*consulRunner)
r.consulSettings.consulDC = "dc"
cmdErr := r.Run(cmd, nil)
assert.StringContains(t, cmdErr.Message, "bad updater flags")
} | explode_data.jsonl/71905 | {
"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,
15220,
360,
19486,
6727,
17082,
79854,
9195,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
75846,
8240,
4527,
1155,
1171,
16867,
23743,
991,
18176,
2822,
77333,
79854,
3830,
9195,
1669,
62025,
7121,
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 TestLessWriter(t *testing.T) {
var builder strings.Builder
w := newLessWriter(&builder, 500)
for i := 0; i < 100; i++ {
_, err := w.Write([]byte("hello"))
assert.Nil(t, err)
}
assert.Equal(t, "hello", builder.String())
} | explode_data.jsonl/59124 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
27451,
6492,
1155,
353,
8840,
836,
8,
341,
2405,
7363,
9069,
15641,
198,
6692,
1669,
501,
27451,
6492,
2099,
17850,
11,
220,
20,
15,
15,
340,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
341,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestServerRemoteAddr(t *testing.T) {
s := &Server{
Handler: func(ctx *RequestCtx) {
h := &ctx.Request.Header
ctx.Success("text/html", []byte(fmt.Sprintf("requestURI=%s, remoteAddr=%s, remoteIP=%s",
h.RequestURI(), ctx.RemoteAddr(), ctx.RemoteIP())))
},
}
rw := &readWriter{}
rw.r.WriteString("GET /foo1 HTTP/1.1\r\nHost: google.com\r\n\r\n")
rwx := &readWriterRemoteAddr{
rw: rw,
addr: &net.TCPAddr{
IP: []byte{1, 2, 3, 4},
Port: 8765,
},
}
ch := make(chan error)
go func() {
ch <- s.ServeConn(rwx)
}()
select {
case err := <-ch:
if err != nil {
t.Fatalf("Unexpected error from serveConn: %s", err)
}
case <-time.After(100 * time.Millisecond):
t.Fatalf("timeout")
}
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, 200, "text/html", "requestURI=/foo1, remoteAddr=1.2.3.4:8765, remoteIP=1.2.3.4")
} | explode_data.jsonl/73310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 404
} | [
2830,
3393,
5475,
24703,
13986,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
609,
5475,
515,
197,
197,
3050,
25,
2915,
7502,
353,
1900,
23684,
8,
341,
298,
9598,
1669,
609,
3773,
9659,
15753,
198,
298,
20985,
33320,
445,
1318,
13739,
497... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNilRemoteDriver(t *testing.T) {
_, err := controller.NewNetwork("framerelay", "dummy",
libnetwork.NetworkOptionGeneric(getEmptyGenericOption()))
if err == nil {
t.Fatal("Expected to fail. But instead succeeded")
}
if _, ok := err.(types.NotFoundError); !ok {
t.Fatalf("Did not fail with expected error. Actual error: %v", err)
}
} | explode_data.jsonl/6352 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
19064,
24703,
11349,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
6461,
7121,
12320,
445,
1626,
15232,
6895,
497,
330,
31390,
756,
197,
93459,
17511,
30149,
5341,
19964,
5433,
3522,
19964,
5341,
12145,
743,
1848,
621,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplicationContext_NestedBean(t *testing.T) {
c := gs.New()
c.Object(new(MyGrouper)).Export((*Grouper)(nil))
c.Object(new(ProxyGrouper))
err := c.Refresh()
assert.Nil(t, err)
} | explode_data.jsonl/17400 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
19736,
1604,
9980,
10437,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
28081,
7121,
741,
1444,
8348,
1755,
37485,
38,
581,
712,
4579,
16894,
26609,
38,
581,
712,
2376,
8385,
1171,
1444,
8348,
1755,
7,
16219,
38,
581,
712,
117... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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.