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 TestIntLimit(t *testing.T) {
const (
min = 0
max = 10
)
cases := []struct {
n int
expected int
}{
{5, 5},
{-1, 0},
{11, 10},
}
for _, c := range cases {
assert.Equal(t, c.expected, LimitInt(c.n, min, max))
}
} | explode_data.jsonl/24828 | {
"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,
1072,
16527,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
25320,
284,
220,
15,
198,
197,
22543,
284,
220,
16,
15,
198,
197,
340,
1444,
2264,
1669,
3056,
1235,
341,
197,
9038,
286,
526,
198,
197,
42400,
526,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPrepareMaxParamCountCheck(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (v int)")
normalSQL, normalParams := generateBatchSQL(math.MaxUint16)
_, err := tk.Exec(normalSQL, normalParams...)
require.NoError(t, err)
bigSQL, bigParams := generateBatchSQL(math.MaxUint16 + 2)
_, err = tk.Exec(bigSQL, bigParams...)
require.Error(t, err)
require.EqualError(t, err, "[executor:1390]Prepared statement contains too many placeholders")
} | explode_data.jsonl/38142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
50590,
5974,
2001,
2507,
3973,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTeamsService_AddTeamRepoByID_noAccess(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/organizations/1/team/1/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
w.WriteHeader(http.StatusUnprocessableEntity)
})
ctx := context.Background()
_, err := client.Teams.AddTeamRepoByID(ctx, 1, 1, "owner", "repo", nil)
if err == nil {
t.Errorf("Expcted error to be returned")
}
} | explode_data.jsonl/4536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
60669,
1860,
21346,
14597,
25243,
60572,
6536,
6054,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
69253,
14,
16,
78015,
14,
16,
49505,
14,
811... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTypes(t *testing.T) {
testConvert(t, `
file_to_generate: "foo.proto"
proto_file <
name: "foo.proto"
package: "example_package.nested"
message_type <
name: "FooProto"
field < name: "i32" number: 1 type: TYPE_INT32 label: LABEL_OPTIONAL >
field < name: "i64" number: 2 type: TYPE_INT64 label: LABEL_OPTIONAL >
field < name: "ui32" number: 3 type: TYPE_UINT32 label: LABEL_OPTIONAL >
field < name: "ui64" number: 4 type: TYPE_UINT64 label: LABEL_OPTIONAL >
field < name: "si32" number: 5 type: TYPE_SINT32 label: LABEL_OPTIONAL >
field < name: "si64" number: 6 type: TYPE_SINT64 label: LABEL_OPTIONAL >
field < name: "ufi32" number: 7 type: TYPE_FIXED32 label: LABEL_OPTIONAL >
field < name: "ufi64" number: 8 type: TYPE_FIXED64 label: LABEL_OPTIONAL >
field < name: "sfi32" number: 9 type: TYPE_SFIXED32 label: LABEL_OPTIONAL >
field < name: "sfi64" number: 10 type: TYPE_SFIXED64 label: LABEL_OPTIONAL >
field < name: "d" number: 11 type: TYPE_DOUBLE label: LABEL_OPTIONAL >
field < name: "f" number: 12 type: TYPE_FLOAT label: LABEL_OPTIONAL >
field < name: "bool" number: 16 type: TYPE_BOOL label: LABEL_OPTIONAL >
field < name: "str" number: 13 type: TYPE_STRING label: LABEL_OPTIONAL >
field < name: "bytes" number: 14 type: TYPE_BYTES label: LABEL_OPTIONAL >
field <
name: "enum1" number: 15 type: TYPE_ENUM label: LABEL_OPTIONAL
type_name: ".example_package.nested.FooProto.Enum1"
>
field <
name: "enum2" number: 16 type: TYPE_ENUM label: LABEL_OPTIONAL
type_name: "FooProto.Enum1"
>
field <
name: "grp1" number: 17 type: TYPE_GROUP label: LABEL_OPTIONAL
type_name: ".example_package.nested.FooProto.Group1"
>
field <
name: "grp2" number: 18 type: TYPE_GROUP label: LABEL_OPTIONAL
type_name: "FooProto.Group1"
>
field <
name: "msg1" number: 19 type: TYPE_MESSAGE label: LABEL_OPTIONAL
type_name: ".example_package.nested.FooProto.Nested1"
>
field <
name: "msg2" number: 20 type: TYPE_MESSAGE label: LABEL_OPTIONAL
type_name: "FooProto.Nested1"
>
field <
name: "msg3" number: 21 type: TYPE_MESSAGE label: LABEL_OPTIONAL
type_name: ".example_package.nested2.BarProto"
>
field <
name: "msg4" number: 22 type: TYPE_MESSAGE label: LABEL_OPTIONAL
type_name: "nested2.BarProto"
>
field <
name: "msg2" number: 23 type: TYPE_MESSAGE label: LABEL_OPTIONAL
type_name: "FooProto.EmptyNested1"
>
nested_type <
name: "Group1"
field < name: "i1" number: 1 type: TYPE_INT32 label: LABEL_OPTIONAL >
>
nested_type <
name: "Nested1"
field < name: "i1" number: 1 type: TYPE_INT32 label: LABEL_OPTIONAL >
>
nested_type <
name: "EmptyNested1"
>
enum_type < name: "Enum1" value < name: "E1" number: 1 > value < name: "E2" number: 2 > >
options < [gen_bq_schema.bigquery_opts] <table_name: "foo_table"> >
>
>
proto_file <
name: "bar.proto"
package: "example_package.nested2"
message_type <
name: "BarProto"
field < name: "i1" number: 1 type: TYPE_INT32 label: LABEL_OPTIONAL >
field < name: "i2" number: 2 type: TYPE_INT32 label: LABEL_OPTIONAL >
field < name: "i3" number: 3 type: TYPE_INT32 label: LABEL_OPTIONAL >
>
>
`,
map[string]string{
"example_package/nested/foo_table.schema": `[
{ "name": "i32", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "i64", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "ui32", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "ui64", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "si32", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "si64", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "ufi32", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "ufi64", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "sfi32", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "sfi64", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "d", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "f", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "bool", "type": "BOOLEAN", "mode": "NULLABLE" },
{ "name": "str", "type": "STRING", "mode": "NULLABLE" },
{ "name": "bytes", "type": "BYTES", "mode": "NULLABLE" },
{ "name": "enum1", "type": "STRING", "mode": "NULLABLE" },
{ "name": "enum2", "type": "STRING", "mode": "NULLABLE" },
{
"name": "grp1", "type": "RECORD", "mode": "NULLABLE",
"fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }]
},
{
"name": "grp2", "type": "RECORD", "mode": "NULLABLE",
"fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }]
},
{
"name": "msg1", "type": "RECORD", "mode": "NULLABLE",
"fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }]
},
{
"name": "msg2", "type": "RECORD", "mode": "NULLABLE",
"fields": [{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" }]
},
{
"name": "msg3", "type": "RECORD", "mode": "NULLABLE",
"fields": [
{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "i2", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "i3", "type": "INTEGER", "mode": "NULLABLE" }
]
},
{
"name": "msg4", "type": "RECORD", "mode": "NULLABLE",
"fields": [
{ "name": "i1", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "i2", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "i3", "type": "INTEGER", "mode": "NULLABLE" }
]
}
]`,
})
} | explode_data.jsonl/41115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2792
} | [
2830,
3393,
4173,
1155,
353,
8840,
836,
8,
341,
18185,
12012,
1155,
11,
22074,
298,
17661,
2346,
48851,
25,
330,
7975,
57322,
698,
298,
197,
15110,
2458,
77565,
571,
11609,
25,
330,
7975,
57322,
698,
571,
197,
1722,
25,
330,
8687,
263... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDispatchError(t *testing.T) {
assertRoundtrip(t, DispatchError{HasModule: true, Module: 0xf1, Error: 0xa2})
assertRoundtrip(t, DispatchError{HasModule: false, Error: 0xa2})
} | explode_data.jsonl/68332 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
11283,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
27497,
32981,
1155,
11,
21133,
1454,
90,
10281,
3332,
25,
830,
11,
13711,
25,
220,
15,
5848,
16,
11,
4600,
25,
220,
15,
9591,
17,
3518,
6948,
27497,
32981,
1155,
11,
21133... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache_autoExpiry(t *testing.T) {
monitorTicker := helper.NewManualTicker()
c := newCache(time.Hour, 10, monitorTicker)
defer c.Stop()
cfg, repo, _ := testcfg.BuildWithRepo(t)
// Add a process that has expired already.
key0 := mustCreateKey(t, "0", repo)
value0, cancel := mustCreateCacheable(t, cfg, repo)
c.objectReaders.Add(key0, value0, time.Now().Add(-time.Millisecond), cancel)
requireProcessesValid(t, &c.objectReaders)
require.Contains(t, keys(t, &c.objectReaders), key0, "key should still be in map")
require.False(t, value0.isClosed(), "value should not have been closed")
// We need to tick thrice to get deterministic results: the first tick is discarded before
// the monitor enters the loop, the second tick will be consumed and kicks off the eviction
// but doesn't yet guarantee that the eviction has finished, and the third tick will then
// start another eviction, which means that the previous eviction is done.
monitorTicker.Tick()
monitorTicker.Tick()
monitorTicker.Tick()
require.Empty(t, keys(t, &c.objectReaders), "key should no longer be in map")
require.True(t, value0.isClosed(), "value should be closed after eviction")
} | explode_data.jsonl/81953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
8233,
27740,
840,
48209,
1155,
353,
8840,
836,
8,
341,
197,
32225,
87278,
1669,
13137,
7121,
52092,
87278,
2822,
1444,
1669,
501,
8233,
9730,
73550,
11,
220,
16,
15,
11,
8718,
87278,
340,
16867,
272,
30213,
2822,
50286,
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 TestVirtualService_NoListeners(t *testing.T) {
g := NewGomegaWithT(t)
o := processing.ProcessorOptions{
DomainSuffix: "cluster.local",
MeshConfig: meshcfg.Default(),
}
xforms := GetProviders().Create(o)
g.Expect(xforms).To(HaveLen(2))
src := &fixtures.Source{}
xform := xforms[0]
src.Dispatch(xform)
xform.Start()
defer xform.Stop()
src.Handlers.Handle(event.FullSyncFor(collections.K8SExtensionsV1Beta1Ingresses))
src.Handlers.Handle(event.Event{Kind: event.Reset})
src.Handlers.Handle(event.AddFor(collections.K8SExtensionsV1Beta1Ingresses, ingress1()))
// No crash
} | explode_data.jsonl/71126 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
33026,
1860,
36989,
31570,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
692,
22229,
1669,
8692,
29012,
269,
3798,
515,
197,
10957,
3121,
40177,
25,
330,
18855,
11033,
756,
197,
9209,
4288,
2648,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReadSymlinkedDirectoryToFile(t *testing.T) {
var err error
var file *os.File
if file, err = os.Create("/tmp/testReadSymlinkToFile"); err != nil {
t.Fatalf("failed to create file: %s", err)
}
file.Close()
if err = os.Symlink("/tmp/testReadSymlinkToFile", "/tmp/fileLinkTest"); err != nil {
t.Errorf("failed to create symlink: %s", err)
}
var path string
if path, err = ReadSymlinkedDirectory("/tmp/fileLinkTest"); err == nil {
t.Fatalf("ReadSymlinkedDirectory on a symlink to a file should've failed")
}
if path != "" {
t.Fatalf("path should've been empty: %s", path)
}
if err = os.Remove("/tmp/testReadSymlinkToFile"); err != nil {
t.Errorf("failed to remove file: %s", err)
}
if err = os.Remove("/tmp/fileLinkTest"); err != nil {
t.Errorf("failed to remove symlink: %s", err)
}
} | explode_data.jsonl/57528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
4418,
34667,
44243,
291,
9310,
41550,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
2405,
1034,
353,
436,
8576,
271,
743,
1034,
11,
1848,
284,
2643,
7251,
4283,
5173,
12697,
4418,
34667,
44243,
41550,
5038,
1848,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestNamedMapOpts(t *testing.T) {
tmpMap := make(map[string]string)
o := NewNamedMapOpts("max-name", tmpMap, nil)
o.Set("max-size=1")
if o.String() != "map[max-size:1]" {
t.Errorf("%s != [map[max-size:1]", o.String())
}
if o.Name() != "max-name" {
t.Errorf("%s != max-name", o.Name())
}
if _, exist := tmpMap["max-size"]; !exist {
t.Errorf("expected map-size to be in the values, got %v", tmpMap)
}
} | explode_data.jsonl/26385 | {
"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,
15810,
2227,
43451,
1155,
353,
8840,
836,
8,
341,
20082,
2227,
1669,
1281,
9147,
14032,
30953,
340,
22229,
1669,
1532,
15810,
2227,
43451,
445,
2810,
11494,
497,
4174,
2227,
11,
2092,
692,
22229,
4202,
445,
2810,
7174,
28,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestColorRenderExample(t *testing.T) {
renderer := New(true)
expected := "\x1b[32mExample\x1b[0m\n"
actual := renderer.RenderExample("Example")
assert.Equal(t, expected, actual)
} | explode_data.jsonl/12223 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 71
} | [
2830,
3393,
1636,
6750,
13314,
1155,
353,
8840,
836,
8,
341,
83509,
1669,
1532,
3715,
340,
42400,
1669,
2917,
87,
16,
65,
58,
18,
17,
76,
13314,
3462,
16,
65,
58,
15,
76,
1699,
698,
88814,
1669,
19715,
27386,
13314,
445,
13314,
1138... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestProductionUsage(t *testing.T) {
defer ensureNoGoroutineLeak(t)()
// This test configures the client in a similar fashion as will be
// in production, and tests against a live gRPC server.
os := mocks.NewOrderer(5612, t)
os.SetNextExpectedSeek(5)
connFact := func(endpoint string) (*grpc.ClientConn, error) {
return grpc.Dial(endpoint, grpc.WithInsecure(), grpc.WithBlock())
}
prod := comm.NewConnectionProducer(connFact, []string{"localhost:5612"})
clFact := func(cc *grpc.ClientConn) orderer.AtomicBroadcastClient {
return orderer.NewAtomicBroadcastClient(cc)
}
onConnect := func(bd blocksprovider.BlocksDeliverer) error {
env, err := utils.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE,
"TEST",
&signerMock{}, newTestSeekInfo(), 0, 0)
assert.NoError(t, err)
return bd.Send(env)
}
retryPol := func(attemptNum int, elapsedTime time.Duration) (time.Duration, bool) {
return time.Second * 3, attemptNum < 2
}
cl := NewBroadcastClient(prod, clFact, onConnect, retryPol)
go os.SendBlock(5)
resp, err := cl.Recv()
assert.NoError(t, err)
assert.NotNil(t, resp)
assert.Equal(t, uint64(5), resp.GetBlock().Header.Number)
os.Shutdown()
cl.Close()
} | explode_data.jsonl/38323 | {
"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,
44967,
14783,
1155,
353,
8840,
836,
8,
341,
16867,
5978,
2753,
38,
269,
14159,
2304,
585,
1155,
8,
741,
197,
322,
1096,
1273,
2193,
1413,
279,
2943,
304,
264,
4428,
11153,
438,
686,
387,
198,
197,
322,
304,
5670,
11,
323... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExecutePaginatedQuery(t *testing.T) {
for _, testEnv := range testEnvs {
// Query is only supported and tested on the CouchDB testEnv
if testEnv.getName() == couchDBtestEnvName {
t.Logf("Running test for TestEnv = %s", testEnv.getName())
testLedgerID := "testexecutepaginatedquery"
testEnv.init(t, testLedgerID, nil)
testExecutePaginatedQuery(t, testEnv)
testEnv.cleanup()
}
}
} | explode_data.jsonl/63612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 167
} | [
2830,
3393,
17174,
47712,
15479,
2859,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
14359,
1669,
2088,
1273,
1702,
11562,
341,
197,
197,
322,
11361,
374,
1172,
7248,
323,
12510,
389,
279,
61128,
3506,
1273,
14359,
198,
197,
743,
1273... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Service_Listener(t *testing.T) {
bkoff := backoff.NewExponentialBackOff()
bkoff.MaxElapsedTime = time.Second * 15
err := backoff.Retry(func() error {
logger, _ := test.NewNullLogger()
logger.SetLevel(logrus.DebugLevel)
c := service.NewContainer(logger)
c.Register(ID, &Service{})
err := c.Init(&testCfg{httpCfg: `{
"enable": true,
"address": ":6033",
"maxRequestSize": 1024,
"uploads": {
"dir": ` + tmpDir() + `,
"forbid": []
},
"workers":{
"command": "php ../../tests/http/client.php echo pipes",
"relay": "pipes",
"pool": {
"numWorkers": 1,
"allocateTimeout": 10000000,
"destroyTimeout": 10000000
}
}
}`})
if err != nil {
return err
}
s, st := c.Get(ID)
assert.NotNil(t, s)
assert.Equal(t, service.StatusOK, st)
stop := make(chan interface{})
s.(*Service).AddListener(func(event int, ctx interface{}) {
if event == roadrunner.EventServerStart {
stop <- nil
}
})
go func() {
err := c.Serve()
if err != nil {
t.Errorf("serve error: %v", err)
}
}()
time.Sleep(time.Millisecond * 500)
c.Stop()
assert.True(t, true)
return nil
}, bkoff)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/34502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 563
} | [
2830,
3393,
52548,
62,
2743,
1155,
353,
8840,
836,
8,
341,
2233,
74,
1847,
1669,
1182,
1847,
7121,
840,
59825,
3707,
4596,
741,
2233,
74,
1847,
14535,
98483,
284,
882,
32435,
353,
220,
16,
20,
271,
9859,
1669,
1182,
1847,
2013,
15149,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTypeCloseGracefully(t *testing.T) {
conf := NewConfig()
conf.Input.Type = input.TypeNanomsg
conf.Output.Type = output.TypeNanomsg
strm, err := New(conf)
if err != nil {
t.Fatal(err)
}
if err = strm.stopGracefully(time.Second); err != nil {
t.Error(err)
}
conf.Buffer.Type = "memory"
strm, err = New(conf)
if err != nil {
t.Fatal(err)
}
if err = strm.stopGracefully(time.Second); err != nil {
t.Error(err)
}
conf.Pipeline.Processors = []processor.Config{
processor.NewConfig(),
}
strm, err = New(conf)
if err != nil {
t.Fatal(err)
}
if err = strm.stopGracefully(time.Second); err != nil {
t.Error(err)
}
} | explode_data.jsonl/78328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 284
} | [
2830,
3393,
929,
7925,
86543,
3641,
1155,
353,
8840,
836,
8,
341,
67850,
1669,
1532,
2648,
741,
67850,
16130,
10184,
284,
1946,
10184,
45,
276,
316,
1991,
198,
67850,
34246,
10184,
284,
2550,
10184,
45,
276,
316,
1991,
271,
11355,
76,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunUnknownJob(t *testing.T) {
ctx := context.Background()
s, err := standard.New(ctx, standard.WithLogLevel(zerolog.Disabled), standard.WithMonitor(&nullmetrics.Service{}))
require.NoError(t, err)
require.NotNil(t, s)
assert.EqualError(t, s.RunJob(ctx, "Unknown job"), scheduler.ErrNoSuchJob.Error())
} | explode_data.jsonl/44215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
6727,
13790,
12245,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
1903,
11,
1848,
1669,
5297,
7121,
7502,
11,
5297,
26124,
72676,
7,
7070,
1609,
89576,
701,
5297,
26124,
30098,
2099,
2921,
43262,
13860,
6257,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParser(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
// test for https://github.com/pingcap/tidb/pull/177
tk.MustExec("CREATE TABLE `t1` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;")
tk.MustExec("CREATE TABLE `t2` ( `a` char(3) NOT NULL default '', `b` char(3) NOT NULL default '', `c` char(3) NOT NULL default '', PRIMARY KEY (`a`,`b`,`c`)) ENGINE=InnoDB;")
tk.MustExec(`INSERT INTO t1 VALUES (1,1,1);`)
tk.MustExec(`INSERT INTO t2 VALUES (1,1,1);`)
tk.MustExec(`PREPARE my_stmt FROM "SELECT t1.b, count(*) FROM t1 group by t1.b having count(*) > ALL (SELECT COUNT(*) FROM t2 WHERE t2.a=1 GROUP By t2.b)";`)
tk.MustExec(`EXECUTE my_stmt;`)
tk.MustExec(`EXECUTE my_stmt;`)
tk.MustExec(`deallocate prepare my_stmt;`)
tk.MustExec(`drop table t1,t2;`)
} | explode_data.jsonl/5786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 424
} | [
2830,
3393,
6570,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTomlOutputValues(t *testing.T) {
assert := assert.New(t)
settings := testutil.Settings().WithSections().With(&print.Settings{
OutputValues: true,
}).Build()
expected, err := testutil.GetExpected("toml", "toml-OutputValues")
assert.Nil(err)
options, err := module.NewOptions().With(&module.Options{
OutputValues: true,
OutputValuesPath: "output_values.json",
})
assert.Nil(err)
module, err := testutil.GetModule(options)
assert.Nil(err)
printer := NewTOML(settings)
actual, err := printer.Print(module, settings)
assert.Nil(err)
assert.Equal(expected, actual)
} | explode_data.jsonl/36771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 216
} | [
2830,
3393,
24732,
75,
5097,
6227,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
62930,
1669,
1273,
1314,
27000,
1005,
2354,
38122,
1005,
2354,
2099,
1350,
27000,
515,
197,
80487,
6227,
25,
830,
345,
197,
16630,
11066... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIgnoreAdmission(t *testing.T) {
namespace := "test"
mockClient := newMockClientForTest([]string{})
handler, informerFactory, err := newHandlerForTest(mockClient)
if err != nil {
t.Errorf("unexpected error initializing handler: %v", err)
}
informerFactory.Start(wait.NeverStop)
chainHandler := admission.NewChainHandler(handler)
pod := newPod(namespace)
err = chainHandler.Admit(admission.NewAttributesRecord(&pod, nil, api.Kind("Pod").WithVersion("version"), pod.Namespace, pod.Name, api.Resource("pods").WithVersion("version"), "", admission.Update, nil))
if err != nil {
t.Errorf("unexpected error returned from admission handler")
}
if hasCreateNamespaceAction(mockClient) {
t.Errorf("unexpected create namespace action")
}
} | explode_data.jsonl/9273 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
12497,
2589,
2728,
1155,
353,
8840,
836,
8,
341,
56623,
1669,
330,
1944,
698,
77333,
2959,
1669,
501,
11571,
2959,
2461,
2271,
10556,
917,
37790,
53326,
11,
6051,
261,
4153,
11,
1848,
1669,
501,
3050,
2461,
2271,
30389,
2959... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRootRouteHasNoMatcher(t *testing.T) {
in := `
route:
receiver: 'team-X'
match:
severity: critical
receivers:
- name: 'team-X'
`
_, err := Load(in)
expected := "root route must not have any matchers"
if err == nil {
t.Fatalf("no error returned, expected:\n%q", expected)
}
if err.Error() != expected {
t.Errorf("\nexpected:\n%q\ngot:\n%q", expected, err.Error())
}
} | explode_data.jsonl/72902 | {
"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,
8439,
4899,
10281,
2753,
37554,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
22074,
8966,
510,
220,
13964,
25,
364,
9196,
30550,
1248,
220,
2432,
510,
262,
29920,
25,
9023,
271,
53387,
1945,
510,
12,
829,
25,
364,
9196,
3055... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrometheusProvider_IsOnline(t *testing.T) {
t.Run("fail", func(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadGateway)
}))
defer ts.Close()
clients := prometheusFake()
template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{})
require.NoError(t, err)
template.Spec.Provider.Address = ts.URL
template.Spec.Provider.SecretRef = nil
prom, err := NewPrometheusProvider(template.Spec.Provider, nil)
require.NoError(t, err)
ok, err := prom.IsOnline()
assert.Error(t, err, "Got no error wanted %v", http.StatusBadGateway)
assert.False(t, ok)
})
t.Run("ok", func(t *testing.T) {
expected := `vector(1)`
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
promql := r.URL.Query()["query"][0]
assert.Equal(t, expected, promql)
header, ok := r.Header["Authorization"]
if assert.True(t, ok, "Authorization header not found") {
assert.True(t, strings.Contains(header[0], "Basic"), "Basic authorization header not found")
}
json := `{"status":"success","data":{"resultType":"vector","result":[{"metric":{},"value":[1545905245.458,"1"]}]}}`
w.Write([]byte(json))
}))
defer ts.Close()
clients := prometheusFake()
template, err := clients.flaggerClient.FlaggerV1beta1().MetricTemplates("default").Get(context.TODO(), "prometheus", metav1.GetOptions{})
require.NoError(t, err)
template.Spec.Provider.Address = ts.URL
secret, err := clients.kubeClient.CoreV1().Secrets("default").Get(context.TODO(), "prometheus", metav1.GetOptions{})
require.NoError(t, err)
prom, err := NewPrometheusProvider(template.Spec.Provider, secret.Data)
require.NoError(t, err)
ok, err := prom.IsOnline()
require.NoError(t, err)
assert.Equal(t, true, ok)
})
} | explode_data.jsonl/23615 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
35186,
39705,
5179,
31879,
19598,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
18403,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSelectEntry_MinSize(t *testing.T) {
smallOptions := []string{"A", "B", "C"}
largeOptions := []string{"Large Option A", "Larger Option B", "Very Large Option C"}
largeOptionsMinWidth := optionsMinSize(largeOptions).Width
minTextHeight := widget.NewLabel("W").MinSize().Height
tests := map[string]struct {
placeholder string
value string
options []string
want fyne.Size
}{
"empty": {
want: fyne.NewSize(emptyTextWidth()+dropDownIconWidth()+4*theme.Padding(), minTextHeight+2*theme.Padding()),
},
"empty + small options": {
options: smallOptions,
want: fyne.NewSize(emptyTextWidth()+dropDownIconWidth()+4*theme.Padding(), minTextHeight+2*theme.Padding()),
},
"empty + large options": {
options: largeOptions,
want: fyne.NewSize(largeOptionsMinWidth+2*theme.Padding(), minTextHeight+2*theme.Padding()),
},
"value": {
value: "foo",
want: widget.NewLabel("foo").MinSize().Add(fyne.NewSize(dropDownIconWidth()+4*theme.Padding(), 2*theme.Padding())),
},
"large value + small options": {
value: "large",
options: smallOptions,
want: widget.NewLabel("large").MinSize().Add(fyne.NewSize(dropDownIconWidth()+4*theme.Padding(), 2*theme.Padding())),
},
"small value + large options": {
value: "small",
options: largeOptions,
want: fyne.NewSize(largeOptionsMinWidth+2*theme.Padding(), minTextHeight+2*theme.Padding()),
},
"placeholder": {
placeholder: "example",
want: widget.NewLabel("example").MinSize().Add(fyne.NewSize(dropDownIconWidth()+4*theme.Padding(), 2*theme.Padding())),
},
"large placeholder + small options": {
placeholder: "large",
options: smallOptions,
want: widget.NewLabel("large").MinSize().Add(fyne.NewSize(dropDownIconWidth()+4*theme.Padding(), 2*theme.Padding())),
},
"small placeholder + large options": {
placeholder: "small",
options: largeOptions,
want: fyne.NewSize(largeOptionsMinWidth+2*theme.Padding(), minTextHeight+2*theme.Padding()),
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
e := widget.NewSelectEntry(tt.options)
e.PlaceHolder = tt.placeholder
e.Text = tt.value
assert.Equal(t, tt.want, e.MinSize())
})
}
} | explode_data.jsonl/42146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 898
} | [
2830,
3393,
3379,
5874,
62122,
1695,
1155,
353,
8840,
836,
8,
341,
1903,
29532,
3798,
1669,
3056,
917,
4913,
32,
497,
330,
33,
497,
330,
34,
63159,
8810,
2744,
3798,
1669,
3056,
917,
4913,
34253,
6959,
362,
497,
330,
43,
41776,
6959,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChmodWithRecur(t *testing.T) {
fileName := recursiveDirRoot + "/chmod.txt"
err := Touch(fileName)
if err != nil {
panic(err)
}
t.Cleanup(func() {
_ = RemoveWithRecur(dirRoot)
})
if !Exists(fileName) {
t.Error("ChmodWithRecur test failed!")
}
err = ChmodWithRecur(dirRoot, 0755)
if err != nil {
panic(err)
}
} | explode_data.jsonl/34176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
1143,
2593,
2354,
693,
2352,
1155,
353,
8840,
836,
8,
341,
17661,
675,
1669,
30819,
6184,
8439,
488,
3521,
56274,
3909,
1837,
9859,
1669,
19338,
23014,
340,
743,
1848,
961,
2092,
341,
197,
30764,
3964,
340,
197,
630,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDbNameOverride(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
conn, err := mysql.Connect(ctx, &vtParams)
require.Nil(t, err)
defer conn.Close()
qr, err := conn.ExecuteFetch("SELECT database() FROM information_schema.tables WHERE table_schema = database()", 1000, true)
require.Nil(t, err)
require.Equal(t, 1, len(qr.Rows), "did not get enough rows back")
require.Equal(t, dbName, qr.Rows[0][0].ToString())
} | explode_data.jsonl/37407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
7994,
675,
2177,
1155,
353,
8840,
836,
8,
341,
16867,
10652,
1069,
31270,
3050,
1155,
340,
20985,
1669,
2266,
19047,
741,
32917,
11,
1848,
1669,
10564,
43851,
7502,
11,
609,
9708,
4870,
340,
17957,
59678,
1155,
11,
1848,
340... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSetBootable(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
MockSetBootableResponse(t)
options := volumeactions.BootableOpts{
Bootable: true,
}
err := volumeactions.SetBootable(client.ServiceClient(), "cd281d77-8217-4830-be95-9528227c105c", options).ExtractErr()
th.AssertNoErr(t, err)
} | explode_data.jsonl/20635 | {
"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,
1649,
17919,
480,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
9209,
1176,
1649,
17919,
480,
2582,
1155,
692,
35500,
1669,
8123,
4020,
13,
17919,
480,
43451,
515,
197,
197,
179... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPageStats_String(t *testing.T) {
v := PageStats{
TotalPages: Int(0),
}
want := `github.PageStats{TotalPages:0}`
if got := v.String(); got != want {
t.Errorf("PageStats.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33265 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
2665,
16635,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
5755,
16635,
515,
197,
197,
7595,
17713,
25,
1333,
7,
15,
1326,
197,
532,
50780,
1669,
1565,
5204,
17558,
16635,
90,
7595,
17713,
25,
15,
31257,
743,
2684,
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 TestIsBool(t *testing.T) {
var v *Value
v = &Value{data: bool(true)}
assert.True(t, v.IsBool())
v = &Value{data: []bool{bool(true)}}
assert.True(t, v.IsBoolSlice())
} | explode_data.jsonl/23402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
3872,
11233,
1155,
353,
8840,
836,
8,
1476,
2405,
348,
353,
1130,
271,
5195,
284,
609,
1130,
90,
691,
25,
1807,
3715,
10569,
6948,
32443,
1155,
11,
348,
4506,
11233,
12367,
5195,
284,
609,
1130,
90,
691,
25,
3056,
2641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubmitContainerStateChangeReason(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
client, _, mockSubmitStateClient := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient(), nil)
exitCode := 20
reason := strings.Repeat("a", ecsMaxReasonLength)
mockSubmitStateClient.EXPECT().SubmitContainerStateChange(&containerSubmitInputMatcher{
ecs.SubmitContainerStateChangeInput{
Cluster: strptr(configuredCluster),
Task: strptr("arn"),
ContainerName: strptr("cont"),
Status: strptr("STOPPED"),
ExitCode: int64ptr(&exitCode),
Reason: strptr(reason),
NetworkBindings: []*ecs.NetworkBinding{},
},
})
err := client.SubmitContainerStateChange(api.ContainerStateChange{
TaskArn: "arn",
ContainerName: "cont",
Status: apicontainerstatus.ContainerStopped,
ExitCode: &exitCode,
Reason: reason,
})
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/61442 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
8890,
4502,
1397,
4072,
25139,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
741,
25291,
11,
8358,
7860,
8890,
1397,
2959,
1669,
1532,
11571,
2959,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAddrOfIndex(t *testing.T) {
// golang.org/issue/14916.
// Before index worked on reflect.Values, the .String could not be
// found on the (incorrectly unaddressable) V value,
// in contrast to range, which worked fine.
// Also testing that passing a reflect.Value to tmpl.Execute works.
texts := []string{
`{{range .}}{{.String}}{{end}}`,
`{{with index . 0}}{{.String}}{{end}}`,
}
for _, text := range texts {
tmpl := Must(New("tmpl").Parse(text))
var buf bytes.Buffer
err := tmpl.Execute(&buf, reflect.ValueOf([]V{{1}}))
if err != nil {
t.Fatalf("%s: Execute: %v", text, err)
}
if buf.String() != "<1>" {
t.Fatalf("%s: template output = %q, want %q", text, &buf, "<1>")
}
}
} | explode_data.jsonl/41535 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
13986,
2124,
1552,
1155,
353,
8840,
836,
8,
341,
197,
322,
342,
37287,
2659,
14,
11159,
14,
16,
19,
24,
16,
21,
624,
197,
322,
13235,
1922,
6439,
389,
8708,
35145,
11,
279,
659,
703,
1410,
537,
387,
198,
197,
322,
1730... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLdapClose(t *testing.T) {
m := newMockLdap()
d := &ldapBackend{l: m}
d.Close()
if len(m.MethodsCalled) != 1 || len(m.MethodsCalled["Close"]) != 1 {
t.Error("expected close method to be called on backend")
}
} | explode_data.jsonl/9455 | {
"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,
43,
91294,
7925,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
501,
11571,
43,
91294,
741,
2698,
1669,
609,
38665,
29699,
94617,
25,
296,
532,
2698,
10421,
741,
743,
2422,
1255,
20798,
82,
20960,
8,
961,
220,
16,
1369,
2422,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLogsReceiver_error(t *testing.T) {
zcore, logObserver := observer.New(zapcore.ErrorLevel)
logger := zap.New(zcore)
expectedErr := errors.New("handler error")
c := kafkaLogsConsumer{
nextConsumer: consumertest.NewNop(),
logger: logger,
consumerGroup: &testConsumerGroup{err: expectedErr},
}
require.NoError(t, c.Start(context.Background(), componenttest.NewNopHost()))
require.NoError(t, c.Shutdown(context.Background()))
assert.Eventually(t, func() bool {
return logObserver.FilterField(zap.Error(expectedErr)).Len() > 0
}, 10*time.Second, time.Millisecond*100)
} | explode_data.jsonl/79402 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
51053,
25436,
4096,
1155,
353,
8840,
836,
8,
341,
20832,
2153,
11,
1487,
17151,
1669,
22067,
7121,
13174,
391,
2153,
6141,
4449,
340,
17060,
1669,
32978,
7121,
13174,
2153,
692,
42400,
7747,
1669,
5975,
7121,
445,
17905,
1465,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShouldUpdateLoadBalancer(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
testCases := []struct {
desc string
lbHasDeletionTimestamp bool
existsLb bool
expectedOutput bool
}{
{
desc: "should update a load balancer that does not have a deletion timestamp and exists in Azure",
lbHasDeletionTimestamp: false,
existsLb: true,
expectedOutput: true,
},
{
desc: "should not update a load balancer that is being deleted / already deleted in K8s",
lbHasDeletionTimestamp: true,
existsLb: true,
expectedOutput: false,
},
{
desc: "should not update a load balancer that does not exist in Azure",
lbHasDeletionTimestamp: false,
existsLb: false,
expectedOutput: false,
},
{
desc: "should not update a load balancer that has a deletion timestamp and does not exist in Azure",
lbHasDeletionTimestamp: true,
existsLb: false,
expectedOutput: false,
},
}
for i, test := range testCases {
az := GetTestCloud(ctrl)
service := getTestService("test1", v1.ProtocolTCP, nil, false, 80)
setMockPublicIPs(az, ctrl, 1)
mockLBsClient := mockloadbalancerclient.NewMockInterface(ctrl)
az.LoadBalancerClient = mockLBsClient
mockLBsClient.EXPECT().CreateOrUpdate(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
if test.lbHasDeletionTimestamp {
service.ObjectMeta.DeletionTimestamp = &metav1.Time{Time: time.Now()}
}
if test.existsLb {
lb := network.LoadBalancer{
Name: to.StringPtr("lb1"),
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
FrontendIPConfigurations: &[]network.FrontendIPConfiguration{
{
Name: to.StringPtr("atest1"),
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.PublicIPAddress{ID: to.StringPtr("testCluster-aservice1")},
},
},
},
},
}
err := az.LoadBalancerClient.CreateOrUpdate(context.TODO(), "rg", *lb.Name, lb, "")
if err != nil {
t.Fatalf("TestCase[%d] meets unexpected error: %v", i, err)
}
mockLBsClient.EXPECT().List(gomock.Any(), "rg").Return([]network.LoadBalancer{lb}, nil)
} else {
mockLBsClient.EXPECT().List(gomock.Any(), "rg").Return(nil, nil)
}
shouldUpdateLoadBalancer := az.shouldUpdateLoadBalancer(testClusterName, &service)
assert.Equal(t, test.expectedOutput, shouldUpdateLoadBalancer, "TestCase[%d]: %s", i, test.desc)
}
} | explode_data.jsonl/34009 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1175
} | [
2830,
3393,
14996,
4289,
5879,
93825,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
2822,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
4293,
914,
198,
197,
8810,
65,
1028... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatchFutureRev(t *testing.T) {
b, tmpPath := backend.NewDefaultTmpBackend()
s := newWatchableStore(zap.NewExample(), b, &lease.FakeLessor{}, nil, StoreConfig{})
defer func() {
s.store.Close()
os.Remove(tmpPath)
}()
testKey := []byte("foo")
testValue := []byte("bar")
w := s.NewWatchStream()
wrev := int64(10)
w.Watch(0, testKey, nil, wrev)
for i := 0; i < 10; i++ {
rev := s.Put(testKey, testValue, lease.NoLease)
if rev >= wrev {
break
}
}
select {
case resp := <-w.Chan():
if resp.Revision != wrev {
t.Fatalf("rev = %d, want %d", resp.Revision, wrev)
}
if len(resp.Events) != 1 {
t.Fatalf("failed to get events from the response")
}
if resp.Events[0].Kv.ModRevision != wrev {
t.Fatalf("kv.rev = %d, want %d", resp.Events[0].Kv.ModRevision, wrev)
}
case <-time.After(time.Second):
t.Fatal("failed to receive event in 1 second.")
}
} | explode_data.jsonl/67206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 386
} | [
2830,
3393,
14247,
24206,
36184,
1155,
353,
8840,
836,
8,
341,
2233,
11,
4174,
1820,
1669,
19163,
7121,
3675,
35986,
29699,
741,
1903,
1669,
501,
14247,
480,
6093,
13174,
391,
7121,
13314,
1507,
293,
11,
609,
1623,
991,
726,
43,
8309,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterpretRecursiveValueString(t *testing.T) {
t.Parallel()
inter := parseCheckAndInterpret(t, `
fun test(): AnyStruct {
let map: {String: AnyStruct} = {}
let mapRef = &map as &{String: AnyStruct}
mapRef["mapRef"] = mapRef
return map
}
`)
mapValue, err := inter.Invoke("test")
require.NoError(t, err)
require.Equal(t,
`{"mapRef": {"mapRef": ...}}`,
mapValue.String(),
)
require.IsType(t, &interpreter.DictionaryValue{}, mapValue)
require.Equal(t,
`{"mapRef": ...}`,
mapValue.(*interpreter.DictionaryValue).
GetKey(inter, interpreter.ReturnEmptyLocationRange, interpreter.NewStringValue("mapRef")).
String(),
)
} | explode_data.jsonl/73414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
3306,
8043,
78542,
1130,
703,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
58915,
1669,
4715,
3973,
3036,
3306,
8043,
1155,
11,
22074,
414,
2464,
1273,
4555,
5765,
9422,
341,
688,
1077,
2415,
25,
314,
703,
25,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContext2Plan_createBeforeDestroy_depends_datasource(t *testing.T) {
m := testModule(t, "plan-cbd-depends-datasource")
p := testProvider("aws")
p.GetSchemaReturn = &ProviderSchema{
ResourceTypes: map[string]*configschema.Block{
"aws_instance": {
Attributes: map[string]*configschema.Attribute{
"num": {Type: cty.String, Optional: true},
"computed": {Type: cty.String, Optional: true, Computed: true},
},
},
},
DataSources: map[string]*configschema.Block{
"aws_vpc": {
Attributes: map[string]*configschema.Attribute{
"id": {Type: cty.String, Computed: true},
"foo": {Type: cty.Number, Optional: true},
},
},
},
}
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) providers.PlanResourceChangeResponse {
computedVal := req.ProposedNewState.GetAttr("computed")
if computedVal.IsNull() {
computedVal = cty.UnknownVal(cty.String)
}
return providers.PlanResourceChangeResponse{
PlannedState: cty.ObjectVal(map[string]cty.Value{
"num": req.ProposedNewState.GetAttr("num"),
"computed": computedVal,
}),
}
}
p.ReadDataSourceFn = func(req providers.ReadDataSourceRequest) providers.ReadDataSourceResponse {
return providers.ReadDataSourceResponse{
Diagnostics: tfdiags.Diagnostics(nil).Append(fmt.Errorf("ReadDataSource called, but should not have been")),
}
}
ctx := testContext2(t, &ContextOpts{
Config: m,
ProviderResolver: providers.ResolverFixed(
map[string]providers.Factory{
"aws": testProviderFuncFixed(p),
},
),
})
// We're skipping ctx.Refresh here, which simulates what happens when
// running "terraform plan -refresh=false". As a result, we don't get our
// usual opportunity to read the data source during the refresh step and
// thus the plan call below is forced to produce a deferred read action.
plan, diags := ctx.Plan()
if p.ReadDataSourceCalled {
t.Errorf("ReadDataSource was called on the provider, but should not have been because we didn't refresh")
}
if diags.HasErrors() {
t.Fatalf("unexpected errors: %s", diags.Err())
}
seenAddrs := make(map[string]struct{})
for _, res := range plan.Changes.Resources {
var schema *configschema.Block
switch res.Addr.Resource.Resource.Mode {
case addrs.DataResourceMode:
schema = p.GetSchemaReturn.DataSources[res.Addr.Resource.Resource.Type]
case addrs.ManagedResourceMode:
schema = p.GetSchemaReturn.ResourceTypes[res.Addr.Resource.Resource.Type]
}
ric, err := res.Decode(schema.ImpliedType())
if err != nil {
t.Fatal(err)
}
seenAddrs[ric.Addr.String()] = struct{}{}
t.Run(ric.Addr.String(), func(t *testing.T) {
switch i := ric.Addr.String(); i {
case "aws_instance.foo[0]":
if res.Action != plans.Create {
t.Fatalf("resource %s should be created, got %s", ric.Addr, ric.Action)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
"num": cty.StringVal("2"),
"computed": cty.UnknownVal(cty.String),
}), ric.After)
case "aws_instance.foo[1]":
if res.Action != plans.Create {
t.Fatalf("resource %s should be created, got %s", ric.Addr, ric.Action)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
"num": cty.StringVal("2"),
"computed": cty.UnknownVal(cty.String),
}), ric.After)
case "data.aws_vpc.bar[0]":
if res.Action != plans.Read {
t.Fatalf("resource %s should be read, got %s", ric.Addr, ric.Action)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
// In a normal flow we would've read an exact value in
// ReadDataSource, but because this test doesn't run
// cty.Refresh we have no opportunity to do that lookup
// and a deferred read is forced.
"id": cty.UnknownVal(cty.String),
"foo": cty.StringVal("0"),
}), ric.After)
case "data.aws_vpc.bar[1]":
if res.Action != plans.Read {
t.Fatalf("resource %s should be read, got %s", ric.Addr, ric.Action)
}
checkVals(t, objectVal(t, schema, map[string]cty.Value{
// In a normal flow we would've read an exact value in
// ReadDataSource, but because this test doesn't run
// cty.Refresh we have no opportunity to do that lookup
// and a deferred read is forced.
"id": cty.UnknownVal(cty.String),
"foo": cty.StringVal("1"),
}), ric.After)
default:
t.Fatal("unknown instance:", i)
}
})
}
wantAddrs := map[string]struct{}{
"aws_instance.foo[0]": struct{}{},
"aws_instance.foo[1]": struct{}{},
"data.aws_vpc.bar[0]": struct{}{},
"data.aws_vpc.bar[1]": struct{}{},
}
if !cmp.Equal(seenAddrs, wantAddrs) {
t.Errorf("incorrect addresses in changeset:\n%s", cmp.Diff(wantAddrs, seenAddrs))
}
} | explode_data.jsonl/28718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1925
} | [
2830,
3393,
1972,
17,
20485,
8657,
10227,
14245,
49258,
1412,
46530,
919,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1273,
3332,
1155,
11,
330,
10393,
1786,
8940,
6810,
79,
1412,
1737,
19346,
919,
1138,
3223,
1669,
1273,
5179,
445,
8635,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApiTest_AddsTextBodyToRequest(t *testing.T) {
handler := http.NewServeMux()
handler.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
data, _ := ioutil.ReadAll(r.Body)
if string(data) != `hello` {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
})
apitest.New().
Handler(handler).
Put("/hello").
Body(`hello`).
Expect(t).
Status(http.StatusOK).
End()
} | explode_data.jsonl/54786 | {
"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,
6563,
2271,
21346,
82,
1178,
5444,
1249,
1900,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
1758,
7121,
60421,
44,
2200,
741,
53326,
63623,
4283,
14990,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
89... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIsValidBST(t *testing.T) {
cases := []struct {
root *TreeNode
want bool
}{
{
&TreeNode{Val: 2, Left: &TreeNode{Val: 1}, Right: &TreeNode{Val: 3}},
true,
},
{
&TreeNode{Val: 5, Left: &TreeNode{Val: 1}, Right: &TreeNode{Val: 4, Left: &TreeNode{Val: 3}, Right: &TreeNode{Val: 6}}},
false,
},
{
&TreeNode{Val: 0},
true,
},
{
&TreeNode{Val: 5, Left: &TreeNode{Val: 4}, Right: &TreeNode{Val: 6, Left: &TreeNode{Val: 3}, Right: &TreeNode{Val: 7}}},
false,
},
}
for _, c := range cases {
got := isValidBST(c.root)
if c.want != got {
t.Errorf("want:%t instead got:%t", c.want, got)
}
}
} | explode_data.jsonl/44694 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
55470,
61006,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
33698,
353,
26597,
198,
197,
50780,
1807,
198,
197,
59403,
197,
197,
515,
298,
197,
5,
26597,
90,
2208,
25,
220,
17,
11,
13727,
25,
609,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBaseConfigValidateBasic(t *testing.T) {
cfg := TestBaseConfig()
assert.NoError(t, cfg.ValidateBasic())
// tamper with log format
cfg.LogFormat = "invalid"
assert.Error(t, cfg.ValidateBasic())
} | explode_data.jsonl/66915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
3978,
2648,
17926,
15944,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
3393,
3978,
2648,
741,
6948,
35699,
1155,
11,
13286,
47667,
15944,
12367,
197,
322,
25476,
712,
448,
1487,
3561,
198,
50286,
5247,
4061,
284,
330,
11808,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestPKIOperationGET(t *testing.T) {
server, _, teardown := newServer(t)
defer teardown()
pkcsreq := loadTestFile(t, "../scep/testdata/PKCSReq.der")
message := base64.StdEncoding.EncodeToString(pkcsreq)
req, err := http.NewRequest("GET", server.URL+"/scep", nil)
if err != nil {
t.Fatal(err)
}
params := req.URL.Query()
params.Set("operation", "PKIOperation")
params.Set("message", message)
req.URL.RawQuery = params.Encode()
resp, err := http.DefaultClient.Do(req)
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != http.StatusOK {
t.Error("expected", http.StatusOK, "got", resp.StatusCode)
}
} | explode_data.jsonl/70656 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
22242,
3810,
91774,
3806,
1155,
353,
8840,
836,
8,
341,
41057,
11,
8358,
49304,
1669,
501,
5475,
1155,
340,
16867,
49304,
741,
3223,
74,
4837,
2958,
1669,
2795,
2271,
1703,
1155,
11,
7005,
82,
31652,
12697,
691,
16341,
42,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCertificate_expiredCache(t *testing.T) {
// Make an expired cert and cache it.
pk, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
t.Fatal(err)
}
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: exampleDomain},
NotAfter: time.Now(),
}
pub, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &pk.PublicKey, pk)
if err != nil {
t.Fatal(err)
}
tlscert := &tls.Certificate{
Certificate: [][]byte{pub},
PrivateKey: pk,
}
man := &Manager{Prompt: AcceptTOS, Cache: newMemCache(t)}
defer man.stopRenew()
if err := man.cachePut(context.Background(), exampleCertKey, tlscert); err != nil {
t.Fatalf("man.cachePut: %v", err)
}
// The expired cached cert should trigger a new cert issuance
// and return without an error.
hello := clientHelloInfo(exampleDomain, true)
testGetCertificate(t, man, exampleDomain, hello)
} | explode_data.jsonl/65048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
1949,
33202,
80221,
8233,
1155,
353,
8840,
836,
8,
341,
197,
322,
7405,
458,
26391,
2777,
323,
6500,
432,
624,
3223,
74,
11,
1848,
1669,
384,
4385,
9081,
57582,
1592,
7,
613,
11442,
292,
1069,
17,
20,
21,
1507,
10382,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubscriptions(t *testing.T) {
mch := &operatorsv1.MultiClusterHub{
ObjectMeta: metav1.ObjectMeta{Namespace: "test"},
Spec: operatorsv1.MultiClusterHubSpec{
ImagePullSecret: "test",
},
}
ovr := map[string]string{}
tests := []struct {
name string
got *unstructured.Unstructured
}{
{"ApplicationUI subscription", ApplicationUI(mch, ovr)},
{"AssistedService subscription", AssistedService(mch, ovr)},
{"Console subscription", Console(mch, ovr, "")},
{"Cluster Proxy Addon subscription", ClusterProxyAddon(mch, ovr, "")},
{"GRC subscription", GRC(mch, ovr)},
{"Insights subscription", Insights(mch, ovr, "")},
{"Discovery subscription", Discovery(mch, ovr)},
{"ManagementIngress subscription", ManagementIngress(mch, ovr, "")},
{"cluster-lifecycle subscription", ClusterLifecycle(mch, ovr)},
{"Search subscription", Search(mch, ovr)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if _, err := tt.got.MarshalJSON(); err != nil {
t.Error("Subscription does not marshal properly")
}
_, err := yaml.Marshal(tt.got.Object["spec"])
if err != nil {
t.Error("Issue parsing subscription values")
}
})
}
} | explode_data.jsonl/16278 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 456
} | [
2830,
3393,
3136,
29966,
1155,
353,
8840,
836,
8,
341,
2109,
331,
1669,
609,
32838,
85,
16,
57706,
28678,
19316,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
90,
22699,
25,
330,
1944,
7115,
197,
7568,
992,
25,
19624,
85,
16,
57706,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppendListenerFallthroughRoute(t *testing.T) {
push := &model.PushContext{
Mesh: &meshconfig.MeshConfig{},
}
tests := []struct {
name string
listener *xdsapi.Listener
listenerOpts *buildListenerOpts
node *model.Proxy
hostname string
}{
{
name: "Registry_Only",
listener: &xdsapi.Listener{},
listenerOpts: &buildListenerOpts{
push: push,
},
node: &model.Proxy{
ID: "foo.bar",
Metadata: &model.NodeMetadata{},
SidecarScope: &model.SidecarScope{
OutboundTrafficPolicy: &networking.OutboundTrafficPolicy{
Mode: networking.OutboundTrafficPolicy_REGISTRY_ONLY,
},
},
},
hostname: util.BlackHoleCluster,
},
{
name: "Allow_Any",
listener: &xdsapi.Listener{},
listenerOpts: &buildListenerOpts{
push: push,
},
node: &model.Proxy{
ID: "foo.bar",
Metadata: &model.NodeMetadata{},
SidecarScope: &model.SidecarScope{
OutboundTrafficPolicy: &networking.OutboundTrafficPolicy{
Mode: networking.OutboundTrafficPolicy_ALLOW_ANY,
},
},
},
hostname: util.PassthroughCluster,
},
}
for idx := range tests {
t.Run(tests[idx].name, func(t *testing.T) {
appendListenerFallthroughRoute(tests[idx].listener, tests[idx].listenerOpts,
tests[idx].node, nil)
if len(tests[idx].listenerOpts.filterChainOpts) != 1 {
t.Errorf("Expected exactly 1 filter chain options")
}
if !tests[idx].listenerOpts.filterChainOpts[0].isFallThrough {
t.Errorf("Expected fall through to be set")
}
if len(tests[idx].listenerOpts.filterChainOpts[0].networkFilters) != 1 {
t.Errorf("Expected exactly 1 network filter in the chain")
}
filter := tests[idx].listenerOpts.filterChainOpts[0].networkFilters[0]
var tcpProxy tcp_proxy.TcpProxy
cfg := filter.GetTypedConfig()
_ = ptypes.UnmarshalAny(cfg, &tcpProxy)
if tcpProxy.StatPrefix != tests[idx].hostname {
t.Errorf("Expected stat prefix %s but got %s\n", tests[idx].hostname, tcpProxy.StatPrefix)
}
if tcpProxy.GetCluster() != tests[idx].hostname {
t.Errorf("Expected cluster %s but got %s\n", tests[idx].hostname, tcpProxy.GetCluster())
}
if len(tests[idx].listener.FilterChains) != 1 {
t.Errorf("Expected exactly 1 filter chain on the tests[idx].listener")
}
})
}
} | explode_data.jsonl/61276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1030
} | [
2830,
3393,
23877,
2743,
49772,
19742,
4899,
1155,
353,
8840,
836,
8,
341,
43155,
1669,
609,
2528,
34981,
1972,
515,
197,
9209,
4288,
25,
609,
23506,
1676,
50155,
2648,
38837,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestXor(t *testing.T) {
t.Parallel()
xor := ID{
Address: address,
PublicKey: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
}
result := id1.Xor(id3)
if !xor.Equals(result) {
t.Errorf("Xor() = %v, want %v", xor, result)
}
} | explode_data.jsonl/7131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
55,
269,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
10225,
269,
1669,
3034,
515,
197,
98090,
25,
256,
2621,
345,
197,
73146,
1592,
25,
3056,
3782,
90,
15,
11,
220,
15,
11,
220,
15,
11,
220,
15,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestShouldURLEncodeRedirectionURLParameter(t *testing.T) {
mock := mocks.NewMockAutheliaCtx(t)
defer mock.Close()
mock.Clock.Set(time.Now())
userSession := mock.Ctx.GetSession()
userSession.Username = testUsername
userSession.AuthenticationLevel = authentication.NotAuthenticated
userSession.RefreshTTL = mock.Clock.Now().Add(5 * time.Minute)
err := mock.Ctx.SaveSession(userSession)
require.NoError(t, err)
mock.Ctx.Request.Header.Set("X-Original-URL", "https://two-factor.example.com")
mock.Ctx.Request.SetHost("mydomain.com")
mock.Ctx.Request.SetRequestURI("/?rd=https://auth.mydomain.com")
VerifyGet(verifyGetCfg)(mock.Ctx)
assert.Equal(t, "Found. Redirecting to https://auth.mydomain.com?rd=https%3A%2F%2Ftwo-factor.example.com",
string(mock.Ctx.Response.Body()))
} | explode_data.jsonl/20197 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 304
} | [
2830,
3393,
14996,
1511,
867,
1016,
534,
6033,
2866,
3144,
4971,
1155,
353,
8840,
836,
8,
341,
77333,
1669,
68909,
7121,
11571,
5087,
35929,
23684,
1155,
340,
16867,
7860,
10421,
2822,
77333,
79248,
4202,
9730,
13244,
12367,
19060,
5283,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFetch_withCache(t *testing.T) {
dir := tmpDir(t)
//goland:noinspection GoUnhandledErrorResult
defer os.RemoveAll(dir)
start := time.Now()
if err := FetchNative(dir); err != nil {
t.Fatalf("fetchEngine 1 failed: %s", err)
}
log.Printf("first fetchEngine took %s", time.Since(start))
start = time.Now()
if err := FetchNative(dir); err != nil {
t.Fatalf("fetchEngine 2 failed: %s", err)
}
log.Printf("second fetchEngine took %s", time.Since(start))
if time.Since(start) > 10*time.Millisecond {
t.Fatalf("second fetchEngine took more than 10ms")
}
} | explode_data.jsonl/15514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
20714,
6615,
8233,
1155,
353,
8840,
836,
8,
341,
48532,
1669,
4174,
6184,
1155,
340,
197,
322,
70,
96440,
66479,
53395,
5994,
95539,
1454,
2077,
198,
16867,
2643,
84427,
14161,
692,
21375,
1669,
882,
13244,
741,
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,
1... | 4 |
func TestVSphereKubernetes120UbuntuUpgradeFromLatestMinorRelease(t *testing.T) {
provider := framework.NewVSphere(t, framework.WithVSphereFillers(
api.WithTemplateForAllMachines(""), // Use default template from bundle
api.WithOsFamilyForAllMachines(anywherev1.Ubuntu),
))
test := framework.NewClusterE2ETest(
t,
provider,
framework.WithClusterFiller(api.WithKubernetesVersion(anywherev1.Kube120)),
framework.WithClusterFiller(api.WithExternalEtcdTopology(1)),
framework.WithClusterFiller(api.WithControlPlaneCount(1)),
framework.WithClusterFiller(api.WithWorkerNodeCount(1)),
)
runUpgradeFromLatestReleaseFlow(
test,
anywherev1.Kube120,
provider.WithProviderUpgrade(
framework.UpdateUbuntuTemplate120Var(), // Set the template so it doesn't get autoimported
),
)
} | explode_data.jsonl/6563 | {
"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,
26050,
8023,
42,
29827,
16,
17,
15,
75652,
43861,
3830,
31992,
57024,
16077,
1155,
353,
8840,
836,
8,
341,
197,
19979,
1669,
12626,
7121,
26050,
8023,
1155,
11,
12626,
26124,
26050,
8023,
14449,
388,
1006,
197,
54299,
26124,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPushConditionCheckForPessimisticTxn(t *testing.T) {
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk1 := testkit.NewTestKit(t, store)
tk1.MustExec("use test")
defer tk.MustExec("drop table if exists t")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t (i int key)")
tk.MustExec("insert into t values (1)")
tk.MustExec("set tidb_txn_mode = 'pessimistic'")
tk.MustExec("begin")
tk1.MustExec("delete from t where i = 1")
tk.MustExec("insert into t values (1) on duplicate key update i = values(i)")
tk.MustExec("commit")
tk.MustQuery("select * from t").Check(testkit.Rows("1"))
} | explode_data.jsonl/12468 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
16644,
10547,
3973,
2461,
47,
66733,
4532,
31584,
77,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1855,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetIPByNodeName(t *testing.T) {
testCases := []struct {
description string
scaleSet string
vmList []string
nodeName string
expected []string
expectError bool
}{
{
description: "GetIPByNodeName should get node's privateIP and publicIP",
scaleSet: "ss",
vmList: []string{"vmssee6c2000000", "vmssee6c2000001"},
nodeName: "vmssee6c2000000",
expected: []string{fakePrivateIP, fakePublicIP},
},
{
description: "GetIPByNodeName should return error for non-exist nodes",
scaleSet: "ss",
vmList: []string{"vmssee6c2000000", "vmssee6c2000001"},
nodeName: "agente6c2000005",
expectError: true,
},
}
for _, test := range testCases {
ss, err := newTestScaleSet(test.scaleSet, "", 0, test.vmList)
assert.NoError(t, err, test.description)
privateIP, publicIP, err := ss.GetIPByNodeName(test.nodeName)
if test.expectError {
assert.Error(t, err, test.description)
continue
}
assert.NoError(t, err, test.description)
assert.Equal(t, test.expected, []string{privateIP, publicIP}, test.description)
}
} | explode_data.jsonl/17947 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 458
} | [
2830,
3393,
1949,
3298,
1359,
1955,
675,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
70780,
1649,
262,
914,
198,
197,
54879,
852,
414,
3056,
917,
198,
197,
20831,
675,
262,
914,
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... | 3 |
func Test200WithErrorUnmarshalError(t *testing.T) {
s := s3.New(unit.Session)
s.Handlers.Send.Clear()
s.Handlers.Send.PushBack(func(r *request.Request) {
r.HTTPResponse = &http.Response{
StatusCode: 200,
Header: http.Header{"X-Amz-Request-Id": []string{"abc123"}},
Body: ioutil.NopCloser(strings.NewReader(completeMultiErrResp)),
ContentLength: -1,
}
r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode)
})
_, err := s.CompleteMultipartUpload(&s3.CompleteMultipartUploadInput{
Bucket: aws.String("bucket"), Key: aws.String("key"),
UploadId: aws.String("id"),
MultipartUpload: &s3.CompletedMultipartUpload{Parts: []*s3.CompletedPart{
{ETag: aws.String("etag"), PartNumber: aws.Int64(1)},
}},
})
assert.Error(t, err)
assert.Equal(t, "SomeException", err.(awserr.Error).Code())
assert.Equal(t, "Exception message", err.(awserr.Error).Message())
assert.Equal(t, "abc123", err.(awserr.RequestFailure).RequestID())
} | explode_data.jsonl/69506 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 412
} | [
2830,
3393,
17,
15,
15,
66102,
1806,
27121,
1454,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
274,
18,
7121,
24144,
20674,
340,
1903,
35308,
9254,
20176,
13524,
741,
1903,
35308,
9254,
20176,
34981,
3707,
18552,
2601,
353,
2035,
9659,
8,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDestroyEdgeTransformer_selfRef(t *testing.T) {
g := Graph{Path: addrs.RootModuleInstance}
g.Add(testDestroyNode("test_object.A"))
tf := &DestroyEdgeTransformer{
Config: testModule(t, "transform-destroy-edge-self-ref"),
Schemas: simpleTestSchemas(),
}
if err := tf.Transform(&g); err != nil {
t.Fatalf("err: %s", err)
}
actual := strings.TrimSpace(g.String())
expected := strings.TrimSpace(testTransformDestroyEdgeSelfRefStr)
if actual != expected {
t.Fatalf("wrong result\n\ngot:\n%s\n\nwant:\n%s", actual, expected)
}
} | explode_data.jsonl/46936 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
14245,
11656,
46358,
25637,
3945,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
12165,
90,
1820,
25,
912,
5428,
45345,
3332,
2523,
532,
3174,
1904,
8623,
14245,
1955,
445,
1944,
5314,
875,
5455,
3244,
69,
1669,
609,
14245,
11656... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecimal_FromBytes_min_byte_error(t *testing.T) {
d := new(Decimal)
buf := utils.RandomSlice(7)
err := d.SetBytes(buf)
assert.Error(t, err)
assert.True(t, errors.IsOfType(ErrInvalidDecimal, err))
} | explode_data.jsonl/31238 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
11269,
53157,
7078,
7260,
19737,
4096,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
501,
7,
11269,
340,
26398,
1669,
12439,
26709,
33236,
7,
22,
340,
9859,
1669,
294,
4202,
7078,
10731,
340,
6948,
6141,
1155,
11,
1848,
340,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestPlaceSwapOrder(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("skipping test, either api keys or manipulaterealorders isnt set correctly")
}
_, err := c.PlaceSwapOrder(swapTestPair,
order.Buy.Lower(),
"limit",
"fixed",
"12345",
1,
1,
2)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/42944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
17371,
46179,
4431,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
1369,
753,
4814,
92876,
6334,
12768,
24898,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
11,
2987,
6330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScopedService_Parent(t *testing.T) {
t.Parallel()
tests := []struct {
sg Scoped
wantCurrentScope scope.Type
wantCurrentId uint32
wantParentScope scope.Type
wantParentID uint32
}{
{makeScoped(nil, 33, 1), scope.Store, 1, scope.Website, 33},
{makeScoped(nil, 3, 0), scope.Website, 3, scope.Default, 0},
{makeScoped(nil, 0, 0), scope.Default, 0, scope.Default, 0},
}
for _, test := range tests {
haveScp, haveID := test.sg.ParentID().Unpack()
if have, want := haveScp, test.wantParentScope; have != want {
t.Errorf("ParentScope: Have: %v Want: %v", have, want)
}
if have, want := haveID, test.wantParentID; have != want {
t.Errorf("ParentScopeID: Have: %v Want: %v", have, want)
}
haveScp, haveID = test.sg.ScopeID().Unpack()
if have, want := haveScp, test.wantCurrentScope; have != want {
t.Errorf("Scope: Have: %v Want: %v", have, want)
}
if have, want := haveID, test.wantCurrentId; have != want {
t.Errorf("ScopeID: Have: %v Want: %v", have, want)
}
}
} | explode_data.jsonl/18713 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 432
} | [
2830,
3393,
39437,
1860,
1088,
1390,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
78216,
1669,
3056,
1235,
341,
197,
1903,
70,
2290,
98687,
198,
197,
50780,
5405,
10803,
6891,
10184,
198,
197,
50780,
5405,
764,
262,
2622,
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... | 6 |
func TestRandomizedGenState1(t *testing.T) {
interfaceRegistry := codectypes.NewInterfaceRegistry()
cdc := codec.NewProtoCodec(interfaceRegistry)
s := rand.NewSource(1)
r := rand.New(s)
// all these tests will panic
tests := []struct {
simState module.SimulationState
panicMsg string
}{
{ // panic => reason: incomplete initialization of the simState
module.SimulationState{}, "invalid memory address or nil pointer dereference"},
{ // panic => reason: incomplete initialization of the simState
module.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: cdc,
Rand: r,
}, "assignment to entry in nil map"},
}
for _, tt := range tests {
require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg)
}
} | explode_data.jsonl/67876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
13999,
1506,
9967,
1397,
16,
1155,
353,
8840,
836,
8,
341,
58915,
1564,
15603,
1669,
20329,
439,
1804,
7121,
5051,
15603,
741,
1444,
7628,
1669,
34647,
7121,
31549,
36913,
75487,
15603,
692,
1903,
1669,
10382,
7121,
3608,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValue(t *testing.T) {
table := map[Version]int64{
Version{8, 5, 1, 0}: 8005001000,
Version{4, 7, 0, 0}: 4007000000,
Version{0, 23, 0, 0}: 23000000,
Version{14, 0, 0, 100}: 14000000100,
Version{0, 0, 0, 0}: 0,
Version{0, 0, 1, 1}: 1001,
Version{0, 1, 0, 0}: 1000000,
Version{1, 0, 0, 0}: 1000000000,
}
for input, expected := range table {
got, err := input.Value()
if err != nil {
t.Errorf("failed to retrieve value from %#v: %v", input, err)
}
if expected != got {
t.Errorf("failed to retrieve value %#v: expected %d, got %d", input, expected, got)
}
}
} | explode_data.jsonl/74328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 281
} | [
2830,
3393,
1130,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
2415,
58,
5637,
63025,
21,
19,
515,
197,
77847,
90,
23,
11,
220,
20,
11,
220,
16,
11,
220,
15,
16097,
262,
220,
23,
15,
15,
20,
15,
15,
16,
15,
15,
15,
345,
197,
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... | 4 |
func TestTransactionFetcherSingletonRequesting(t *testing.T) {
testTransactionFetcherParallel(t, txFetcherTest{
init: func() *TxFetcher {
return NewTxFetcher(
func(common.Hash) bool { return false },
nil,
func(string, []common.Hash) error { return nil },
)
},
steps: []interface{}{
// Push an initial announcement through to the scheduled stage
doTxNotify{peer: "A", hashes: []common.Hash{{0x01}, {0x02}}},
isWaiting(map[string][]common.Hash{
"A": {{0x01}, {0x02}},
}),
isScheduled{tracking: nil, fetching: nil},
doWait{time: txArriveTimeout, step: true},
isWaiting(nil),
isScheduled{
tracking: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
},
fetching: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
},
},
// Announce a new set of transactions from the same peer and ensure
// they do not start fetching since the peer is already busy
doTxNotify{peer: "A", hashes: []common.Hash{{0x03}, {0x04}}},
isWaiting(map[string][]common.Hash{
"A": {{0x03}, {0x04}},
}),
isScheduled{
tracking: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
},
fetching: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
},
},
doWait{time: txArriveTimeout, step: true},
isWaiting(nil),
isScheduled{
tracking: map[string][]common.Hash{
"A": {{0x01}, {0x02}, {0x03}, {0x04}},
},
fetching: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
},
},
// Announce a duplicate set of transactions from a new peer and ensure
// uniquely new ones start downloading, even if clashing.
doTxNotify{peer: "B", hashes: []common.Hash{{0x02}, {0x03}, {0x05}, {0x06}}},
isWaiting(map[string][]common.Hash{
"B": {{0x05}, {0x06}},
}),
isScheduled{
tracking: map[string][]common.Hash{
"A": {{0x01}, {0x02}, {0x03}, {0x04}},
"B": {{0x02}, {0x03}},
},
fetching: map[string][]common.Hash{
"A": {{0x01}, {0x02}},
"B": {{0x03}},
},
},
},
})
} | explode_data.jsonl/52211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 968
} | [
2830,
3393,
8070,
97492,
25915,
1900,
287,
1155,
353,
8840,
836,
8,
341,
18185,
8070,
97492,
16547,
1155,
11,
259,
9770,
2995,
261,
2271,
515,
197,
28248,
25,
2915,
368,
353,
51,
9770,
2995,
261,
341,
298,
853,
1532,
51,
9770,
2995,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchema_AddField(t *testing.T) {
type fields struct {
Fields []Field
Options Options
}
type args struct {
f Field
}
tests := []struct {
name string
fields fields
args args
want *Schema
}{
{"nil", fields{nil, DefaultOptions}, args{NewTextField("text-field")}, &Schema{Fields: []Field{NewTextField("text-field")}, Options: DefaultOptions}},
{"empty", fields{[]Field{}, DefaultOptions}, args{NewTextField("text-field")}, &Schema{Fields: []Field{NewTextField("text-field")}, Options: DefaultOptions}},
{"1-field", fields{[]Field{NewTextField("field1")}, DefaultOptions}, args{NewTextField("field2")}, &Schema{Fields: []Field{NewTextField("field1"), NewTextField("field2")}, Options: DefaultOptions}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := &Schema{
Fields: tt.fields.Fields,
Options: tt.fields.Options,
}
if got := m.AddField(tt.args.f); !reflect.DeepEqual(got, tt.want) {
t.Errorf("AddField() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/72800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
8632,
21346,
1877,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
8941,
220,
3056,
1877,
198,
197,
197,
3798,
14566,
198,
197,
532,
13158,
2827,
2036,
341,
197,
1166,
8601,
198,
197,
532,
78216,
1669,
3056... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPopUp_Move_ConstrainedWindowToSmall(t *testing.T) {
label := NewLabel("Hi")
win := test.NewWindow(NewLabel("OK"))
win.Resize(fyne.NewSize(10, 5))
pop := NewPopUp(label, win.Canvas())
pos := fyne.NewPos(20, 10)
pop.Move(pos)
innerPos := pop.Content.Position()
assert.Equal(t, theme.Padding(), innerPos.X, "content X position is adjusted but the window is too small")
assert.Equal(t, theme.Padding(), innerPos.Y, "content Y position is adjusted but the window is too small")
} | explode_data.jsonl/65217 | {
"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,
11598,
2324,
66352,
15100,
57727,
4267,
1249,
25307,
1155,
353,
8840,
836,
8,
341,
29277,
1669,
1532,
2476,
445,
13048,
1138,
68452,
1669,
1273,
7121,
4267,
35063,
2476,
445,
3925,
5455,
68452,
77707,
955,
81708,
7121,
1695,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetIndexByID(t *testing.T) {
if testing.Short() {
t.Skip()
}
dbtesting.SetupGlobalTestDB(t)
db := testDB()
// Index does not exist initially
if _, exists, err := db.GetIndexByID(context.Background(), 1); err != nil {
t.Fatalf("unexpected error getting index: %s", err)
} else if exists {
t.Fatal("unexpected record")
}
queuedAt := time.Unix(1587396557, 0).UTC()
startedAt := queuedAt.Add(time.Minute)
expected := Index{
ID: 1,
Commit: makeCommit(1),
QueuedAt: queuedAt,
State: "processing",
FailureSummary: nil,
FailureStacktrace: nil,
StartedAt: &startedAt,
FinishedAt: nil,
RepositoryID: 123,
Rank: nil,
}
insertIndexes(t, dbconn.Global, expected)
if index, exists, err := db.GetIndexByID(context.Background(), 1); err != nil {
t.Fatalf("unexpected error getting index: %s", err)
} else if !exists {
t.Fatal("expected record to exist")
} else if diff := cmp.Diff(expected, index); diff != "" {
t.Errorf("unexpected index (-want +got):\n%s", diff)
}
} | explode_data.jsonl/11065 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 474
} | [
2830,
3393,
1949,
1552,
60572,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
741,
197,
532,
20939,
8840,
39820,
11646,
2271,
3506,
1155,
340,
20939,
1669,
1273,
3506,
2822,
197,
322,
8008,
1558,
537,
3000,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetricCornerCases(t *testing.T) {
assert.Equal(t, min(1, 2), 1)
assert.Equal(t, min(2, 1), 1)
assert.Equal(t, min(1, 1), 1)
var label KeyValues
label.Append("a", "b")
assert.Equal(t, label.String(), "a#$#b")
} | explode_data.jsonl/48128 | {
"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,
54310,
50352,
37302,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
1308,
7,
16,
11,
220,
17,
701,
220,
16,
340,
6948,
12808,
1155,
11,
1308,
7,
17,
11,
220,
16,
701,
220,
16,
340,
6948,
12808,
1155,
11,
1308,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_getWorkflowHandler_CheckPermission(t *testing.T) {
api, db, _ := newTestAPI(t)
u, pass := assets.InsertLambdaUser(t, api.mustDB())
proj := assets.InsertTestProject(t, db, api.Cache, sdk.RandomString(10), sdk.RandomString(10))
require.NoError(t, group.InsertLinkGroupUser(context.TODO(), api.mustDB(), &group.LinkGroupUser{
GroupID: proj.ProjectGroups[0].Group.ID,
AuthentifiedUserID: u.ID,
Admin: true,
}))
pip := sdk.Pipeline{
ProjectID: proj.ID,
ProjectKey: proj.Key,
Name: "pip1",
}
test.NoError(t, pipeline.InsertPipeline(api.mustDB(), &pip))
wf := sdk.Workflow{
Name: "workflow1",
ProjectID: proj.ID,
ProjectKey: proj.Key,
WorkflowData: sdk.WorkflowData{
Node: sdk.Node{
Name: "root",
Context: &sdk.NodeContext{
PipelineID: pip.ID,
},
},
},
}
test.NoError(t, workflow.Insert(context.TODO(), api.mustDB(), api.Cache, *proj, &wf))
vars := map[string]string{
"key": proj.Key,
"permWorkflowName": "workflow1",
}
uri := api.Router.GetRoute("GET", api.getWorkflowHandler, vars)
test.NotEmpty(t, uri)
req := assets.NewAuthentifiedRequest(t, u, pass, "GET", uri, nil)
//Do the request
w := httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfGet := sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfGet))
assert.Equal(t, true, wfGet.Permissions.Readable, "readable should be true")
assert.Equal(t, true, wfGet.Permissions.Writable, "writable should be true")
assert.Equal(t, true, wfGet.Permissions.Executable, "writable should be true")
var err error
userAdmin, passAdmin := assets.InsertAdminUser(t, db)
uri = api.Router.GetRoute(http.MethodGet, api.getWorkflowHandler, vars)
req, err = http.NewRequest(http.MethodGet, uri, nil)
test.NoError(t, err)
assets.AuthentifyRequest(t, req, userAdmin, passAdmin)
// Do the request
w = httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfGet = sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfGet))
assert.Equal(t, true, wfGet.Permissions.Readable, "readable should be true")
assert.Equal(t, true, wfGet.Permissions.Writable, "writable should be true")
assert.Equal(t, true, wfGet.Permissions.Executable, "executable should be true")
userMaintainer, passMaintainer := assets.InsertMaintainerUser(t, db)
uri = api.Router.GetRoute("GET", api.getWorkflowHandler, vars)
req, err = http.NewRequest("GET", uri, nil)
test.NoError(t, err)
assets.AuthentifyRequest(t, req, userMaintainer, passMaintainer)
// Do the request
w = httptest.NewRecorder()
api.Router.Mux.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
wfGet = sdk.Workflow{}
test.NoError(t, json.Unmarshal(w.Body.Bytes(), &wfGet))
assert.Equal(t, true, wfGet.Permissions.Readable, "readable should be true")
assert.Equal(t, false, wfGet.Permissions.Writable, "writable should be false")
assert.Equal(t, false, wfGet.Permissions.Executable, "executable should be false")
} | explode_data.jsonl/31069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1273
} | [
2830,
3393,
3062,
62768,
3050,
28188,
14966,
1155,
353,
8840,
836,
8,
341,
54299,
11,
2927,
11,
716,
1669,
501,
2271,
7082,
1155,
692,
10676,
11,
1494,
1669,
11770,
23142,
58266,
1474,
1155,
11,
6330,
69419,
3506,
2398,
197,
30386,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSonobuoyVersion(t *testing.T) {
stdout := mustRunSonobuoyCommand(t, "version")
lines := strings.Split(stdout.String(), "\n")
for _, line := range lines {
versionComponents := strings.Split(line, ":")
// If a Kubeconfig is not provided, a warning is included that the API version check is skipped.
// Only check lines where a split on ":" actually happened.
if len(versionComponents) == 2 && strings.TrimSpace(versionComponents[1]) == "" {
t.Errorf("expected value for %v to be set, but was empty", versionComponents[0])
}
}
} | explode_data.jsonl/54729 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
45614,
674,
84,
2253,
5637,
1155,
353,
8840,
836,
8,
341,
6736,
411,
1669,
1969,
6727,
45614,
674,
84,
2253,
4062,
1155,
11,
330,
4366,
5130,
78390,
1669,
9069,
19823,
29376,
6431,
1507,
2917,
77,
1138,
2023,
8358,
1555,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarkStart(t *testing.T) {
Convey("With a task, build and version", t, func() {
require.NoError(t, db.ClearCollections(task.Collection, build.Collection, VersionCollection),
"Error clearing task and build collections")
displayName := "testName"
b := &build.Build{
Id: "buildtest",
Status: evergreen.BuildCreated,
Version: "abc",
}
v := &Version{
Id: b.Version,
Status: evergreen.VersionCreated,
Config: "identifier: sample",
}
testTask := &task.Task{
Id: "testTask",
DisplayName: displayName,
Activated: true,
BuildId: b.Id,
Project: "sample",
Status: evergreen.TaskUndispatched,
Version: b.Version,
}
b.Tasks = []build.TaskCache{
{
Id: testTask.Id,
Status: evergreen.TaskUndispatched,
},
}
So(b.Insert(), ShouldBeNil)
So(testTask.Insert(), ShouldBeNil)
So(v.Insert(), ShouldBeNil)
Convey("when calling MarkStart, the task, version and build should be updated", func() {
updates := StatusChanges{}
err := MarkStart(testTask, &updates)
So(updates.BuildNewStatus, ShouldBeEmpty)
So(updates.PatchNewStatus, ShouldBeEmpty)
So(err, ShouldBeNil)
testTask, err = task.FindOne(task.ById(testTask.Id))
So(err, ShouldBeNil)
So(testTask.Status, ShouldEqual, evergreen.TaskStarted)
b, err = build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(b.Status, ShouldEqual, evergreen.BuildStarted)
So(b.Tasks, ShouldNotBeNil)
So(len(b.Tasks), ShouldEqual, 1)
So(b.Tasks[0].Status, ShouldEqual, evergreen.TaskStarted)
v, err = VersionFindOne(VersionById(v.Id))
So(err, ShouldBeNil)
So(v.Status, ShouldEqual, evergreen.VersionStarted)
})
})
Convey("with a task that is part of a display task", t, func() {
b := &build.Build{
Id: "displayBuild",
Project: "sample",
Version: "version1",
Tasks: []build.TaskCache{
{Id: "displayTask", Activated: false, Status: evergreen.TaskUndispatched},
},
}
So(b.Insert(), ShouldBeNil)
v := &Version{
Id: b.Version,
Status: evergreen.VersionStarted,
Config: "identifier: sample",
}
So(v.Insert(), ShouldBeNil)
dt := &task.Task{
Id: "displayTask",
Activated: true,
BuildId: b.Id,
Status: evergreen.TaskUndispatched,
Version: v.Id,
DisplayOnly: true,
ExecutionTasks: []string{"execTask"},
}
So(dt.Insert(), ShouldBeNil)
t1 := &task.Task{
Id: "execTask",
Activated: true,
BuildId: b.Id,
Version: v.Id,
Status: evergreen.TaskUndispatched,
}
So(t1.Insert(), ShouldBeNil)
So(MarkStart(t1, &StatusChanges{}), ShouldBeNil)
t1FromDb, err := task.FindOne(task.ById(t1.Id))
So(err, ShouldBeNil)
So(t1FromDb.Status, ShouldEqual, evergreen.TaskStarted)
dtFromDb, err := task.FindOne(task.ById(dt.Id))
So(err, ShouldBeNil)
So(dtFromDb.Status, ShouldEqual, evergreen.TaskStarted)
dbBuild, err := build.FindOne(build.ById(b.Id))
So(err, ShouldBeNil)
So(dbBuild.Tasks[0].Status, ShouldEqual, evergreen.TaskStarted)
})
} | explode_data.jsonl/60435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1376
} | [
2830,
3393,
8949,
3479,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2354,
264,
3383,
11,
1936,
323,
2319,
497,
259,
11,
2915,
368,
341,
197,
17957,
35699,
1155,
11,
2927,
13524,
52730,
17483,
28629,
11,
1936,
28629,
11,
6079,
6482... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTPTimeout(t *testing.T) {
t.Parallel()
reg := apiRegMutWrapper{mut: &http.ServeMux{}}
mgr, err := manager.New(manager.NewConfig(), reg, log.Noop(), metrics.Noop())
if err != nil {
t.Fatal(err)
}
conf := input.NewConfig()
conf.HTTPServer.Path = "/testpost"
conf.HTTPServer.Timeout = "1ms"
h, err := input.NewHTTPServer(conf, mgr, log.Noop(), metrics.Noop())
if err != nil {
t.Fatal(err)
}
server := httptest.NewServer(reg.mut)
defer server.Close()
var res *http.Response
res, err = http.Post(
server.URL+"/testpost",
"application/octet-stream",
bytes.NewBuffer([]byte("hello world")),
)
if err != nil {
t.Fatal(err)
}
if exp, act := http.StatusRequestTimeout, res.StatusCode; exp != act {
t.Errorf("Unexpected status code: %v != %v", exp, act)
}
h.CloseAsync()
if err := h.WaitForClose(time.Second * 5); err != nil {
t.Error(err)
}
} | explode_data.jsonl/40360 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
9230,
7636,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
37013,
1669,
6330,
3477,
51440,
11542,
90,
6984,
25,
609,
1254,
83535,
44,
2200,
6257,
532,
2109,
901,
11,
1848,
1669,
6645,
7121,
55168,
7121,
2648,
1507,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestTaskListEmpty(t *testing.T) {
cs, _ := pipelinetest.SeedTestData(pipelinetest.Data{})
p := &test.Params{Tekton: cs.Pipeline}
task := Command(p)
_, err := test.ExecuteCommand(task, "list", "-n", "foo")
if err == nil {
t.Errorf("No errors was defined")
}
if d := cmp.Diff(emptyMsg, err.Error()); d != "" {
t.Errorf("Unexpected output mismatch: %s", d)
}
} | explode_data.jsonl/72533 | {
"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,
6262,
852,
3522,
1155,
353,
8840,
836,
8,
341,
71899,
11,
716,
1669,
23626,
301,
29876,
477,
5732,
291,
83920,
1295,
81079,
29876,
477,
3336,
37790,
3223,
1669,
609,
1944,
58268,
90,
55715,
777,
25,
10532,
1069,
8790,
630,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllCases(t *testing.T) {
recorder := record.NewBroadcaster().NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName})
for _, tc := range testCases {
c := tc.GetClient()
dc := tc.GetDynamicClient()
r := &reconciler{
client: c,
dynamicClient: dc,
restConfig: &rest.Config{},
recorder: recorder,
}
tc.ReconcileKey = fmt.Sprintf("%s/%s", testNS, subscriptionName)
tc.IgnoreTimes = true
t.Run(tc.Name, tc.Runner(t, r, c))
}
} | explode_data.jsonl/70586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
2403,
37302,
1155,
353,
8840,
836,
8,
341,
67904,
1358,
1669,
3255,
7121,
68324,
32020,
1005,
3564,
47023,
1141,
8058,
92719,
11,
6200,
85,
16,
6904,
3608,
90,
2189,
25,
6461,
16810,
675,
8824,
2023,
8358,
17130,
1669,
2088,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMiscFunc_Apply1(t *testing.T) {
var tests = []struct {
sql string
data *xsql.Tuple
result []map[string]interface{}
}{
{
sql: "SELECT md5(a) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"a": "The quick brown fox jumps over the lazy dog",
"b": "myb",
"c": "myc",
},
},
result: []map[string]interface{}{{
"a": strings.ToLower("9E107D9D372BB6826BD81D3542A419D6"),
}},
},
{
sql: "SELECT sha1(a) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"a": "The quick brown fox jumps over the lazy dog",
"b": "myb",
"c": "myc",
},
},
result: []map[string]interface{}{{
"a": strings.ToLower("2FD4E1C67A2D28FCED849EE1BB76E7391B93EB12"),
}},
},
{
sql: "SELECT sha256(a) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"a": "The quick brown fox jumps over the lazy dog",
"b": "myb",
"c": "myc",
},
},
result: []map[string]interface{}{{
"a": strings.ToLower("D7A8FBB307D7809469CA9ABCB0082E4F8D5651E46D3CDB762D02D0BF37C9E592"),
}},
},
{
sql: "SELECT sha384(a) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"a": "The quick brown fox jumps over the lazy dog",
"b": "myb",
"c": "myc",
},
},
result: []map[string]interface{}{{
"a": strings.ToLower("CA737F1014A48F4C0B6DD43CB177B0AFD9E5169367544C494011E3317DBF9A509CB1E5DC1E85A941BBEE3D7F2AFBC9B1"),
}},
},
{
sql: "SELECT sha512(a) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"a": "The quick brown fox jumps over the lazy dog",
"b": "myb",
"c": "myc",
},
},
result: []map[string]interface{}{{
"a": strings.ToLower("07E547D9586F6A73F73FBAC0435ED76951218FB7D0C8D788A309D785436BBB642E93A252A954F23912547D1E8A3B5ED6E1BFD7097821233FA0538F3DB854FEE6"),
}},
},
{
sql: "SELECT mqtt(topic) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{},
Metadata: xsql.Metadata{
"topic": "devices/device_001/message",
},
},
result: []map[string]interface{}{{
"a": "devices/device_001/message",
}},
},
{
sql: "SELECT mqtt(topic) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{},
Metadata: xsql.Metadata{
"topic": "devices/device_001/message",
},
},
result: []map[string]interface{}{{
"a": "devices/device_001/message",
}},
},
{
sql: "SELECT topic, mqtt(topic) AS a FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"topic": "fff",
},
Metadata: xsql.Metadata{
"topic": "devices/device_001/message",
},
},
result: []map[string]interface{}{{
"topic": "fff",
"a": "devices/device_001/message",
}},
},
{
sql: "SELECT cardinality(arr) as r FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"temperature": 43.2,
"arr": []int{},
},
},
result: []map[string]interface{}{{
"r": float64(0),
}},
},
{
sql: "SELECT cardinality(arr) as r FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"temperature": 43.2,
"arr": []int{1, 2, 3, 4, 5},
},
},
result: []map[string]interface{}{{
"r": float64(5),
}},
},
{
sql: "SELECT isNull(arr) as r FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"temperature": 43.2,
"arr": []int{},
},
},
result: []map[string]interface{}{{
"r": false,
}},
},
{
sql: "SELECT isNull(arr) as r FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"temperature": 43.2,
"arr": []float64(nil),
},
},
result: []map[string]interface{}{{
"r": true,
}},
},
{
sql: "SELECT isNull(rec) as r FROM test",
data: &xsql.Tuple{
Emitter: "test",
Message: xsql.Message{
"temperature": 43.2,
"rec": map[string]interface{}(nil),
},
},
result: []map[string]interface{}{{
"r": true,
}},
},
}
fmt.Printf("The test bucket size is %d.\n\n", len(tests))
contextLogger := common.Log.WithField("rule", "TestMiscFunc_Apply1")
ctx := contexts.WithValue(contexts.Background(), contexts.LoggerKey, contextLogger)
for i, tt := range tests {
stmt, err := xsql.NewParser(strings.NewReader(tt.sql)).Parse()
if err != nil || stmt == nil {
t.Errorf("parse sql %s error %v", tt.sql, err)
}
pp := &ProjectOp{Fields: stmt.Fields}
pp.isTest = true
fv, afv := xsql.NewFunctionValuersForOp(nil)
result := pp.Apply(ctx, tt.data, fv, afv)
var mapRes []map[string]interface{}
if v, ok := result.([]byte); ok {
err := json.Unmarshal(v, &mapRes)
if err != nil {
t.Errorf("Failed to parse the input into map.\n")
continue
}
if !reflect.DeepEqual(tt.result, mapRes) {
t.Errorf("%d. %q\n\nresult mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", i, tt.sql, tt.result, mapRes)
}
} else {
t.Errorf("The returned result is not type of []byte\n")
}
}
} | explode_data.jsonl/446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2685
} | [
2830,
3393,
50979,
9626,
36117,
398,
16,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
30633,
262,
914,
198,
197,
8924,
256,
353,
87,
3544,
836,
6061,
198,
197,
9559,
3056,
2186,
14032,
31344,
16094,
197,
59403,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestUnmarshalProof(t *testing.T) {
for _, test := range []struct {
desc string
m string
want log.Proof
wantErr bool
}{
{
desc: "valid one",
m: "b25l\ndHdv\ndGhyZWU=\n",
want: log.Proof{[]byte("one"), []byte("two"), []byte("three")},
}, {
desc: "valid two",
m: "Zm91cg==\nZml2ZQ==\nc2l4\nc2V2ZW4=\nZWlnaHQ=\n",
want: log.Proof{[]byte("four"), []byte("five"), []byte("six"), []byte("seven"), []byte("eight")},
}, {
desc: "invalid - missing newline after last hash",
m: "c2l4\nc2V2ZW4=\nZWlnaHQ=",
wantErr: true,
}, {
desc: "invalid base64",
m: "c2l4=\nNOT-BASE64!\nZWlnaHQ=\n",
wantErr: true,
},
} {
t.Run(test.desc, func(t *testing.T) {
var got log.Proof
if gotErr := got.Unmarshal([]byte(test.m)); (gotErr != nil) != test.wantErr {
t.Fatalf("Unmarshal = %q, wantErr: %T", gotErr, test.wantErr)
}
if diff := cmp.Diff(test.want, got); len(diff) != 0 {
t.Fatalf("Unmarshal = diff %s", diff)
}
})
}
} | explode_data.jsonl/61514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 545
} | [
2830,
3393,
1806,
27121,
31076,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
3056,
1235,
341,
197,
41653,
262,
914,
198,
197,
2109,
981,
914,
198,
197,
50780,
262,
1487,
7763,
1055,
198,
197,
50780,
7747,
1807,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRemoveSpaceAuditorByUsername(t *testing.T) {
Convey("Remove auditor by username", t, func() {
setup(MockRoute{"DELETE", "/v2/spaces/bc7b4caf-f4b8-4d85-b126-0729b9351e56/auditors", "", "", 200, "", nil}, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
space := &Space{
Guid: "bc7b4caf-f4b8-4d85-b126-0729b9351e56",
c: client,
}
err = space.RemoveAuditorByUsername("user-name")
So(err, ShouldBeNil)
})
} | explode_data.jsonl/59993 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
13021,
9914,
52949,
1919,
91519,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
13021,
53306,
553,
5934,
497,
259,
11,
2915,
368,
341,
197,
84571,
66436,
4899,
4913,
14424,
497,
3521,
85,
17,
26734,
2434,
3470,
66,
22,
65... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveNonExistantOffer(t *testing.T) {
tt := test.Start(t)
defer tt.Finish()
test.ResetHorizonDB(t, tt.HorizonDB)
q := &Q{tt.HorizonSession()}
numAffected, err := q.RemoveOffers([]int64{12345}, 1236)
tt.Assert.NoError(err)
tt.Assert.Equal(int64(0), numAffected)
} | explode_data.jsonl/69698 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
13021,
8121,
840,
11202,
39462,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
1273,
12101,
1155,
340,
16867,
17853,
991,
18176,
741,
18185,
36660,
39601,
16973,
3506,
1155,
11,
17853,
3839,
269,
16973,
3506,
340,
18534,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCreateEntityCreated(t *testing.T) {
ts := httptest.NewServer(
http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/v2") {
apiResourcesHandler(w, r)
} else {
if r.Header.Get("Content-Type") != "application/json" {
t.Fatal("Missing application/json Content-Type header")
}
if r.URL.Query().Get("options") != "upsert" {
t.Fatalf("Expected upsert options value, got: '%v'", r.URL.Query().Get("options"))
}
if b, err := ioutil.ReadAll(r.Body); err != nil {
t.Fatalf("Unexpected error: '%v'", err)
} else if len(string(b)) < 1 {
t.Fatal("Request doesn't contain data")
}
w.Header().Set("Location", "/v2/entities/Bcn-Welt?type=Room")
w.WriteHeader(http.StatusCreated)
}
}))
defer ts.Close()
cli, err := client.NewNgsiV2Client(client.SetUrl(ts.URL))
if err != nil {
t.Fatalf("Unexpected error: '%v'", err)
}
if loc, upsert, err := cli.CreateEntity(sampleEntity(), client.CreateEntitySetOptionsUpsert()); err != nil {
t.Fatalf("Unexpected error: '%v'", err)
} else {
if loc != "/v2/entities/Bcn-Welt?type=Room" {
t.Fatalf("Expected '%s' location, got '%s'", "/v2/entities/Bcn-Welt?type=Room", loc)
}
if upsert {
t.Fatalf("Expected no upsert, but got an upsert")
}
}
} | explode_data.jsonl/64662 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 593
} | [
2830,
3393,
4021,
3030,
11694,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
1006,
197,
28080,
89164,
1006,
298,
29244,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
571,
743,
9069,
16152,
40177,
2601,
2089... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunNonRoot(t *testing.T) {
for _, conf := range configs(kvm) {
t.Logf("Running test with conf: %+v", conf)
spec := testutil.NewSpecWithArgs("/bin/true")
spec.Process.User.UID = 343
spec.Process.User.GID = 2401
// User that container runs as can't list '$TMP/blocked' and would fail to
// mount it.
dir, err := ioutil.TempDir("", "blocked")
if err != nil {
t.Fatalf("ioutil.TempDir() failed: %v", err)
}
if err := os.Chmod(dir, 0700); err != nil {
t.Fatalf("os.MkDir(%q) failed: %v", dir, err)
}
dir = path.Join(dir, "test")
if err := os.Mkdir(dir, 0755); err != nil {
t.Fatalf("os.MkDir(%q) failed: %v", dir, err)
}
// We generate files in the host temporary directory.
spec.Mounts = append(spec.Mounts, specs.Mount{
Destination: dir,
Source: dir,
Type: "bind",
})
if err := run(spec, conf); err != nil {
t.Fatalf("error running sadbox: %v", err)
}
}
} | explode_data.jsonl/48925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
6727,
8121,
8439,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2335,
1669,
2088,
42309,
5969,
7338,
8,
341,
197,
3244,
98954,
445,
18990,
1273,
448,
2335,
25,
68524,
85,
497,
2335,
692,
197,
98100,
1669,
1273,
1314,
7121,
832... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransformMultiField(t *testing.T) {
f := common.Field{
Name: "context",
Type: "",
MultiFields: common.Fields{
common.Field{Name: "keyword", Type: "keyword"},
common.Field{Name: "text", Type: "text"},
},
}
trans, _ := newFieldsTransformer(version, common.Fields{f})
transformed, err := trans.transform()
assert.NoError(t, err)
out := transformed["fields"].([]common.MapStr)
assert.Equal(t, "context", out[0]["name"])
assert.Equal(t, "context.keyword", out[1]["name"])
assert.Equal(t, "context.text", out[2]["name"])
assert.Equal(t, "string", out[0]["type"])
assert.Equal(t, "string", out[1]["type"])
assert.Equal(t, "string", out[2]["type"])
} | explode_data.jsonl/37639 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 279
} | [
2830,
3393,
8963,
20358,
1877,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
4185,
17087,
515,
197,
21297,
25,
330,
2147,
756,
197,
27725,
25,
8324,
197,
9209,
7068,
8941,
25,
4185,
42809,
515,
298,
83825,
17087,
63121,
25,
330,
19863,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBoolCondition(t *testing.T) {
cases := []struct {
name string
input ConditionBuilder
expectedNode exprNode
err condErrorMode
}{
{
name: "basic method and",
input: Name("foo").Equal(Value(5)).And(Name("bar").Equal(Value("baz"))),
expectedNode: exprNode{
children: []exprNode{
{
children: []exprNode{
{
names: []string{"foo"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
N: aws.String("5"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"bar"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
S: aws.String("baz"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
},
fmtExpr: "($c) AND ($c)",
},
},
{
name: "basic method or",
input: Name("foo").Equal(Value(5)).Or(Name("bar").Equal(Value("baz"))),
expectedNode: exprNode{
children: []exprNode{
{
children: []exprNode{
{
names: []string{"foo"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
N: aws.String("5"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"bar"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
S: aws.String("baz"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
},
fmtExpr: "($c) OR ($c)",
},
},
{
name: "variadic function and",
input: And(Name("foo").Equal(Value(5)), Name("bar").Equal(Value("baz")), Name("qux").Equal(Value(true))),
expectedNode: exprNode{
children: []exprNode{
{
children: []exprNode{
{
names: []string{"foo"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
N: aws.String("5"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"bar"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
S: aws.String("baz"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"qux"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
BOOL: aws.Bool(true),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
},
fmtExpr: "($c) AND ($c) AND ($c)",
},
},
{
name: "variadic function or",
input: Or(Name("foo").Equal(Value(5)), Name("bar").Equal(Value("baz")), Name("qux").Equal(Value(true))),
expectedNode: exprNode{
children: []exprNode{
{
children: []exprNode{
{
names: []string{"foo"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
N: aws.String("5"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"bar"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
S: aws.String("baz"),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
{
children: []exprNode{
{
names: []string{"qux"},
fmtExpr: "$n",
},
{
values: []dynamodb.AttributeValue{
{
BOOL: aws.Bool(true),
},
},
fmtExpr: "$v",
},
},
fmtExpr: "$c = $c",
},
},
fmtExpr: "($c) OR ($c) OR ($c)",
},
},
{
name: "invalid operand error And",
input: Name("").Size().GreaterThanEqual(Value(5)).And(Name("[5]").Between(Value(3), Value(9))),
err: invalidConditionOperand,
},
{
name: "invalid operand error Or",
input: Name("").Size().GreaterThanEqual(Value(5)).Or(Name("[5]").Between(Value(3), Value(9))),
err: invalidConditionOperand,
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
actual, err := c.input.buildTree()
if c.err != noConditionError {
if err == nil {
t.Errorf("expect error %q, got no error", c.err)
} else {
if e, a := string(c.err), err.Error(); !strings.Contains(a, e) {
t.Errorf("expect %q error message to be in %q", e, a)
}
}
} else {
if err != nil {
t.Errorf("expect no error, got unexpected Error %q", err)
}
if e, a := c.expectedNode, actual; !reflect.DeepEqual(a, e) {
t.Errorf("expect %v, got %v", e, a)
}
}
})
}
} | explode_data.jsonl/27674 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3107
} | [
2830,
3393,
11233,
10547,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
22427,
286,
15180,
3297,
198,
197,
42400,
1955,
15169,
1955,
198,
197,
9859,
688,
9756,
1454,
3636,
198,
197,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestIssue17726(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 t0")
tk.MustExec("create table t0 (c1 DATE, c2 TIME, c3 DATETIME, c4 TIMESTAMP)")
tk.MustExec("insert into t0 values ('1000-01-01', '-838:59:59', '1000-01-01 00:00:00', '1970-01-01 08:00:01')")
tk.MustExec("insert into t0 values ('9999-12-31', '838:59:59', '9999-12-31 23:59:59', '2038-01-19 11:14:07')")
result := tk.MustQuery("select avg(c1), avg(c2), avg(c3), avg(c4) from t0")
result.Check(testkit.Rows("54995666 0 54995666117979.5 20040110095704"))
} | explode_data.jsonl/65563 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 282
} | [
2830,
3393,
42006,
16,
22,
22,
17,
21,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPluginPushError(t *testing.T) {
client := &Client{
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
}
_, err := client.PluginPush(context.Background(), "plugin_name", "")
if !errdefs.IsSystem(err) {
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} | explode_data.jsonl/31929 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
11546,
16644,
1454,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
609,
2959,
515,
197,
25291,
25,
501,
11571,
2959,
6390,
11571,
19886,
66760,
11,
330,
5475,
1465,
30154,
197,
630,
197,
6878,
1848,
1669,
2943,
64378,
16644,
537... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRocksdbKV_Dummy(t *testing.T) {
name := "/tmp/rocksdb_dummy"
rocksdbkv, err := rocksdbkv.NewRocksdbKV(name)
assert.Nil(t, err)
defer rocksdbkv.Close()
defer rocksdbkv.RemoveWithPrefix("")
rocksdbkv.DB = nil
_, err = rocksdbkv.Load("")
assert.Error(t, err)
_, _, err = rocksdbkv.LoadWithPrefix("")
assert.Error(t, err)
_, err = rocksdbkv.MultiLoad(nil)
assert.Error(t, err)
err = rocksdbkv.Save("", "")
assert.Error(t, err)
err = rocksdbkv.MultiSave(nil)
assert.Error(t, err)
err = rocksdbkv.RemoveWithPrefix("")
assert.Error(t, err)
err = rocksdbkv.Remove("")
assert.Error(t, err)
err = rocksdbkv.MultiRemove(nil)
assert.Error(t, err)
err = rocksdbkv.MultiSaveAndRemove(nil, nil)
assert.Error(t, err)
err = rocksdbkv.DeleteRange("", "")
assert.Error(t, err)
rocksdbkv.ReadOptions = nil
_, err = rocksdbkv.Load("dummy")
assert.Error(t, err)
} | explode_data.jsonl/71523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 395
} | [
2830,
3393,
49,
25183,
1999,
82707,
1557,
8574,
1155,
353,
8840,
836,
8,
341,
11609,
1669,
3521,
5173,
14,
299,
14553,
1999,
60321,
698,
197,
299,
14553,
1999,
43408,
11,
1848,
1669,
23035,
1999,
43408,
7121,
49,
25183,
1999,
82707,
315... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_discordLogger_buildPayload(t *testing.T) {
t.Run("default titles and colors", func(t *testing.T) {
l := &discordLogger{
titles: discordTitles,
colors: discordColors,
}
tests := []struct {
name string
msg *message
wantTitle string
wantDesc string
wantColor int
}{
{
name: "trace",
msg: &message{
level: LevelTrace,
body: "[TRACE] test message",
},
wantTitle: discordTitles[0],
wantDesc: "test message",
wantColor: discordColors[0],
},
{
name: "info",
msg: &message{
level: LevelInfo,
body: "[ INFO] test message",
},
wantTitle: discordTitles[1],
wantDesc: "test message",
wantColor: discordColors[1],
},
{
name: "warn",
msg: &message{
level: LevelWarn,
body: "[ WARN] test message",
},
wantTitle: discordTitles[2],
wantDesc: "test message",
wantColor: discordColors[2],
},
{
name: "error",
msg: &message{
level: LevelError,
body: "[ERROR] test message",
},
wantTitle: discordTitles[3],
wantDesc: "test message",
wantColor: discordColors[3],
},
{
name: "fatal",
msg: &message{
level: LevelFatal,
body: "[FATAL] test message",
},
wantTitle: discordTitles[4],
wantDesc: "test message",
wantColor: discordColors[4],
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
payload, err := l.buildPayload(tt.msg)
assert.Nil(t, err)
obj := &discordPayload{}
assert.Nil(t, json.Unmarshal([]byte(payload), obj))
assert.Len(t, obj.Embeds, 1)
assert.Equal(t, tt.wantTitle, obj.Embeds[0].Title)
assert.Equal(t, tt.wantDesc, obj.Embeds[0].Description)
assert.NotEmpty(t, obj.Embeds[0].Timestamp)
assert.Equal(t, tt.wantColor, obj.Embeds[0].Color)
})
}
})
t.Run("custom titles and colors", func(t *testing.T) {
l := &discordLogger{
titles: []string{"1", "2", "3", "4", "5"},
colors: []int{1, 2, 3, 4, 5},
}
tests := []struct {
name string
msg *message
wantTitle string
wantDesc string
wantColor int
}{
{
name: "trace",
msg: &message{
level: LevelTrace,
body: "[TRACE] test message",
},
wantTitle: l.titles[0],
wantDesc: "test message",
wantColor: l.colors[0],
},
{
name: "info",
msg: &message{
level: LevelInfo,
body: "[ INFO] test message",
},
wantTitle: l.titles[1],
wantDesc: "test message",
wantColor: l.colors[1],
},
{
name: "warn",
msg: &message{
level: LevelWarn,
body: "[ WARN] test message",
},
wantTitle: l.titles[2],
wantDesc: "test message",
wantColor: l.colors[2],
},
{
name: "error",
msg: &message{
level: LevelError,
body: "[ERROR] test message",
},
wantTitle: l.titles[3],
wantDesc: "test message",
wantColor: l.colors[3],
},
{
name: "fatal",
msg: &message{
level: LevelFatal,
body: "[FATAL] test message",
},
wantTitle: l.titles[4],
wantDesc: "test message",
wantColor: l.colors[4],
},
{
name: "trace",
msg: &message{
level: LevelTrace,
body: "test message",
},
wantTitle: l.titles[0],
wantDesc: "test message",
wantColor: l.colors[0],
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
payload, err := l.buildPayload(tt.msg)
assert.Nil(t, err)
obj := &discordPayload{}
assert.Nil(t, json.Unmarshal([]byte(payload), obj))
assert.Len(t, obj.Embeds, 1)
assert.Equal(t, tt.wantTitle, obj.Embeds[0].Title)
assert.Equal(t, tt.wantDesc, obj.Embeds[0].Description)
assert.NotEmpty(t, obj.Embeds[0].Timestamp)
assert.Equal(t, tt.wantColor, obj.Embeds[0].Color)
})
}
})
} | explode_data.jsonl/58521 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1921
} | [
2830,
3393,
37745,
539,
7395,
20801,
29683,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2258,
15311,
323,
7987,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
8810,
1669,
609,
42579,
7395,
515,
298,
3244,
41243,
25,
31041,
48255,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_getCompactionTasksBySignalID(t *testing.T) {
type fields struct {
plans map[int64]*compactionTask
}
type args struct {
signalID int64
}
tests := []struct {
name string
fields fields
args args
want []*compactionTask
}{
{
"test get compaction tasks",
fields{
plans: map[int64]*compactionTask{
1: {
triggerInfo: &compactionSignal{id: 1},
state: executing,
},
2: {
triggerInfo: &compactionSignal{id: 1},
state: completed,
},
3: {
triggerInfo: &compactionSignal{id: 1},
state: timeout,
},
},
},
args{1},
[]*compactionTask{
{
triggerInfo: &compactionSignal{id: 1},
state: executing,
},
{
triggerInfo: &compactionSignal{id: 1},
state: completed,
},
{
triggerInfo: &compactionSignal{id: 1},
state: timeout,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := &compactionPlanHandler{
plans: tt.fields.plans,
}
got := h.getCompactionTasksBySignalID(tt.args.signalID)
assert.ElementsMatch(t, tt.want, got)
})
}
} | explode_data.jsonl/9515 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 598
} | [
2830,
3393,
3062,
13552,
1311,
25449,
1359,
26810,
915,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
72213,
596,
2415,
18640,
21,
19,
8465,
5689,
1311,
6262,
198,
197,
532,
13158,
2827,
2036,
341,
197,
81319,
915,
526,
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 TestDecode(t *testing.T) {
for _, tc := range testCases {
t.Logf("Testing %s\n", tc.b62)
if n := Decode(tc.b62); n != tc.n {
t.Fatalf("%s decoded to %d (should be %d)", tc.b62, n, tc.n)
}
}
} | explode_data.jsonl/165 | {
"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,
32564,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
1273,
37302,
341,
197,
3244,
98954,
445,
16451,
1018,
82,
1699,
497,
17130,
948,
21,
17,
340,
197,
743,
308,
1669,
50194,
44415,
948,
21,
17,
1215,
308,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRejectFrameOnIdle_WindowUpdate(t *testing.T) {
testRejectRequestWithProtocolError(t, func(st *serverTester) {
st.fr.WriteWindowUpdate(123, 456)
})
} | explode_data.jsonl/71632 | {
"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,
78413,
4369,
1925,
41370,
60649,
4289,
1155,
353,
8840,
836,
8,
341,
18185,
78413,
1900,
2354,
20689,
1454,
1155,
11,
2915,
5895,
353,
4030,
58699,
8,
341,
197,
18388,
18798,
4073,
4267,
4289,
7,
16,
17,
18,
11,
220,
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 |
func TestGetFuturesPublicTrades(t *testing.T) {
t.Parallel()
_, err := b.GetFuturesPublicTrades(context.Background(), currency.NewPairWithDelimiter("BTCUSD", "PERP", "_"), 5)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
1949,
37,
74606,
12676,
1282,
3452,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
2234,
37,
74606,
12676,
1282,
3452,
5378,
19047,
1507,
11413,
7121,
12443,
2354,
91098,
445,
59118,
26749,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMultipleRulesMissingSingleVerbResourceCombination(t *testing.T) {
escalationTest{
ownerRules: []authorizationapi.PolicyRule{
{Verbs: sets.NewString("delete", "update"), Resources: sets.NewString("builds", "deployments")},
{Verbs: sets.NewString("delete"), Resources: sets.NewString("pods")},
},
servantRules: []authorizationapi.PolicyRule{
{Verbs: sets.NewString("delete", "update"), Resources: sets.NewString("builds", "deployments", "pods")},
},
expectedCovered: false,
expectedUncoveredRules: []authorizationapi.PolicyRule{
{Verbs: sets.NewString("update"), Resources: sets.NewString("pods")},
},
}.test(t)
} | explode_data.jsonl/9046 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 224
} | [
2830,
3393,
32089,
26008,
25080,
10888,
66946,
4783,
36192,
2554,
1155,
353,
8840,
836,
8,
341,
80629,
278,
367,
2271,
515,
197,
197,
8118,
26008,
25,
3056,
39554,
2068,
1069,
8018,
11337,
515,
298,
197,
90,
10141,
1279,
25,
7289,
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... | 1 |
func TestMetricSlice_Resize(t *testing.T) {
es := generateTestMetricSlice()
emptyVal := NewMetric()
emptyVal.InitEmpty()
// Test Resize less elements.
const resizeSmallLen = 4
expectedEs := make(map[*otlpmetrics.Metric]bool, resizeSmallLen)
for i := 0; i < resizeSmallLen; i++ {
expectedEs[*(es.At(i).orig)] = true
}
assert.EqualValues(t, resizeSmallLen, len(expectedEs))
es.Resize(resizeSmallLen)
assert.EqualValues(t, resizeSmallLen, es.Len())
foundEs := make(map[*otlpmetrics.Metric]bool, resizeSmallLen)
for i := 0; i < es.Len(); i++ {
foundEs[*(es.At(i).orig)] = true
}
assert.EqualValues(t, expectedEs, foundEs)
// Test Resize more elements.
const resizeLargeLen = 7
oldLen := es.Len()
expectedEs = make(map[*otlpmetrics.Metric]bool, oldLen)
for i := 0; i < oldLen; i++ {
expectedEs[*(es.At(i).orig)] = true
}
assert.EqualValues(t, oldLen, len(expectedEs))
es.Resize(resizeLargeLen)
assert.EqualValues(t, resizeLargeLen, es.Len())
foundEs = make(map[*otlpmetrics.Metric]bool, oldLen)
for i := 0; i < oldLen; i++ {
foundEs[*(es.At(i).orig)] = true
}
assert.EqualValues(t, expectedEs, foundEs)
for i := oldLen; i < resizeLargeLen; i++ {
assert.EqualValues(t, emptyVal, es.At(i))
}
// Test Resize 0 elements.
es.Resize(0)
assert.EqualValues(t, NewMetricSlice(), es)
} | explode_data.jsonl/19508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
54310,
33236,
62,
30561,
1155,
353,
8840,
836,
8,
341,
78966,
1669,
6923,
2271,
54310,
33236,
741,
197,
3194,
2208,
1669,
1532,
54310,
741,
197,
3194,
2208,
26849,
3522,
741,
197,
322,
3393,
63343,
2686,
5424,
624,
4777,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWithFormat(t *testing.T) {
type test struct {
name string
str string
checkFunc func(Option) error
}
tests := []test{
{
name: "set success when str is JSON",
str: format.JSON.String(),
checkFunc: func(opt Option) error {
got := new(logger)
opt(got)
if got.format != format.JSON {
return errors.New("invalid params was set")
}
return nil
},
},
{
name: "returns nothing when str is empty",
checkFunc: func(opt Option) error {
got := &logger{
format: format.RAW,
}
opt(got)
if got.format != format.RAW {
return errors.New("invalid params was set")
}
return nil
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opt := WithFormat(tt.str)
if err := tt.checkFunc(opt); err != nil {
t.Error(err)
}
})
}
} | explode_data.jsonl/2665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
2354,
4061,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
2036,
341,
197,
11609,
414,
914,
198,
197,
11355,
981,
914,
198,
197,
25157,
9626,
2915,
7,
5341,
8,
1465,
198,
197,
630,
78216,
1669,
3056,
1944,
515,
197,
197,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteAtOffset(t *testing.T) {
data := []byte("Hi there")
toWrite := uint32(0x20212121)
data, e := WriteAtOffset(data, uint64(len(data)), binary.BigEndian,
toWrite)
if e != nil {
t.Logf("Failed writing data at offset: %s\n", e)
t.FailNow()
}
if string(data) != "Hi there !!!" {
t.Logf("Got wrong data after writing: %s\n", data)
t.FailNow()
}
} | explode_data.jsonl/56512 | {
"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,
7985,
1655,
6446,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
445,
13048,
1052,
1138,
31709,
7985,
1669,
2622,
18,
17,
7,
15,
87,
17,
15,
17,
16,
17,
16,
17,
16,
340,
8924,
11,
384,
1669,
9645,
1655,
6446,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessCancelCommand_Success(t *testing.T) {
ctx := context.NewMockDefault()
sendCommandPoolMock := new(task.MockedPool)
docState := contracts.DocumentState{}
docState.CancelInformation.CancelMessageID = "messageID"
sendCommandPoolMock.On("Cancel", "messageID").Return(true)
docMock := new(DocumentMgrMock)
docMock.On("MoveDocumentState", "", appconfig.DefaultLocationOfPending, appconfig.DefaultLocationOfCurrent)
docMock.On("RemoveDocumentState", "", appconfig.DefaultLocationOfCurrent, mock.Anything)
processCancelCommand(ctx, sendCommandPoolMock, &docState, docMock)
sendCommandPoolMock.AssertExpectations(t)
docMock.AssertExpectations(t)
assert.Equal(t, docState.DocumentInformation.DocumentStatus, contracts.ResultStatusSuccess)
} | explode_data.jsonl/533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
7423,
9269,
4062,
87161,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
7121,
11571,
3675,
741,
32817,
4062,
10551,
11571,
1669,
501,
17483,
24664,
291,
10551,
340,
59536,
1397,
1669,
17080,
26256,
1397,
16094,
59536,
1397,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetRegistry(t *testing.T) {
api, router, mockCtl := initRegistryAPI(t)
defer mockCtl.Finish()
sSecret := ms.NewMockSecretService(mockCtl)
api.AppCombinedService = &service.AppCombinedService{
Secret: sSecret,
}
mConf := &models.Registry{
Namespace: "default",
Name: "abc",
}
mConf2 := &specV1.Secret{
Namespace: "default",
Name: "abc",
Labels: map[string]string{
specV1.SecretLabel: specV1.SecretRegistry,
},
}
sSecret.EXPECT().Get(mConf.Namespace, mConf.Name, "").Return(mConf2, nil)
sSecret.EXPECT().Get(mConf.Namespace, "cba", "").Return(nil, fmt.Errorf("error"))
// 200
req, _ := http.NewRequest(http.MethodGet, "/v1/registries/abc", nil)
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
// 404
req, _ = http.NewRequest(http.MethodGet, "/v1/registries/cba", nil)
w2 := httptest.NewRecorder()
router.ServeHTTP(w2, req)
assert.Equal(t, http.StatusInternalServerError, w2.Code)
} | explode_data.jsonl/41103 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 415
} | [
2830,
3393,
1949,
15603,
1155,
353,
8840,
836,
8,
341,
54299,
11,
9273,
11,
7860,
94252,
1669,
2930,
15603,
7082,
1155,
340,
16867,
7860,
94252,
991,
18176,
2822,
1903,
19773,
1669,
9829,
7121,
11571,
19773,
1860,
30389,
94252,
340,
54299... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCPUTime(t *testing.T) {
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
if _, err := c.CPUTime(); err != nil {
t.Errorf(err.Error())
}
} | explode_data.jsonl/2790 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
34,
6221,
545,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
4502,
75145,
675,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
743,
8358,
1848,
1669,
272,
727,
6221,
545,
2129,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestNamespaceCreateDelete(t *testing.T) {
defer func() {
exec.Command("kubectl", "-n", "foobar", "delete", "networkpolicy", "baz").Run()
exec.Command("kubectl", "delete", "namespace", "foobar").Run()
}()
setupClient(t)
r := NewRuntime()
// Create a namespace
testNamespace, err := runtime.NewNamespace("foobar")
assert.NoError(t, err)
if err := r.Create(testNamespace); err != nil {
t.Fatalf("Unexpected error creating Namespace: %v", err)
}
// Check that the namespace exists
if !namespaceExists(t, "foobar") {
t.Fatalf("Namespace foobar not found")
}
// Create a networkpolicy:
testNetworkPolicy, err := runtime.NewNetworkPolicy("baz", "foobar", nil)
assert.NoError(t, err)
if err := r.Create(testNetworkPolicy); err != nil {
t.Fatalf("Unexpected error creating NetworkPolicy: %v", err)
}
// Check that the networkpolicy exists:
if !networkPolicyExists(t, "foobar", "baz") {
t.Fatalf("NetworkPolicy foobar.baz not found")
}
// Create a resourcequota:
testResourceQuota, err := runtime.NewResourceQuota("caps", "foobar")
assert.NoError(t, err)
if err := r.Create(testResourceQuota); err != nil {
t.Fatalf("Unexpected error creating ResourceQuota: %v", err)
}
// Check that the ResourceQuota exists:
if !resourceQuotaExists(t, "foobar", "caps") {
t.Fatalf("ResourceQuota foobar.caps not found")
}
// Tidy up
if err := r.Delete(testResourceQuota); err != nil {
t.Fatalf("Unexpected error deleting ResourceQuota: %v", err)
}
if resourceQuotaExists(t, "foobar", "caps") {
t.Fatalf("ResourceQuota foobar.caps still exists")
}
if err := r.Delete(testNetworkPolicy); err != nil {
t.Fatalf("Unexpected error deleting NetworkPolicy: %v", err)
}
if networkPolicyExists(t, "foobar", "baz") {
t.Fatalf("NetworkPolicy foobar.baz still exists")
}
if err := r.Delete(testNamespace); err != nil {
t.Fatalf("Unexpected error deleting Namespace: %v", err)
}
if namespaceExists(t, "foobar") {
t.Fatalf("Namespace foobar still exists")
}
} | explode_data.jsonl/42237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 723
} | [
2830,
3393,
22699,
4021,
6435,
1155,
353,
8840,
836,
8,
341,
16867,
2915,
368,
341,
197,
67328,
12714,
445,
79971,
497,
6523,
77,
497,
330,
50267,
497,
330,
4542,
497,
330,
17511,
34790,
497,
330,
42573,
1827,
6727,
741,
197,
67328,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseAzureEnvironment(t *testing.T) {
cases := []struct {
cloudName string
resourceManagerEndpoint string
identitySystem string
expected *azure.Environment
}{
{
cloudName: "",
resourceManagerEndpoint: "",
identitySystem: "",
expected: &azure.PublicCloud,
},
{
cloudName: "AZURECHINACLOUD",
resourceManagerEndpoint: "",
identitySystem: "",
expected: &azure.ChinaCloud,
},
}
for _, c := range cases {
env, err := ParseAzureEnvironment(c.cloudName, c.resourceManagerEndpoint, c.identitySystem)
assert.NoError(t, err)
assert.Equal(t, env, c.expected)
}
} | explode_data.jsonl/30653 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
14463,
78107,
12723,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
197,
12361,
675,
2290,
914,
198,
197,
50346,
2043,
27380,
914,
198,
197,
197,
16912,
2320,
688,
914,
198,
197,
42400,
394,
353,
394... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseServerInfo(t *testing.T) {
inputFiles := []string{
"negative-space.xml",
"na-values.xml",
}
for _, inputFile := range inputFiles {
inputFile := inputFile
t.Run(inputFile, func(t *testing.T) {
t.Parallel()
reader, err := os.Open("testdata/" + inputFile)
if err != nil {
t.Fatalf("error opening test data: %s", err)
}
if _, err := Parse(reader); err != nil {
t.Errorf("got error %q", err)
}
})
}
} | explode_data.jsonl/3754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
14463,
5475,
1731,
1155,
353,
8840,
836,
8,
341,
22427,
10809,
1669,
3056,
917,
515,
197,
197,
1,
42224,
27947,
9028,
756,
197,
197,
1,
3376,
69050,
9028,
756,
197,
630,
2023,
8358,
76208,
1669,
2088,
1946,
10809,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSeedLocalCache(t *testing.T) {
t.Parallel()
err := b.SeedLocalCache(context.Background(), currency.NewPair(currency.BTC, currency.USDT))
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/76697 | {
"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,
41471,
7319,
8233,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
9859,
1669,
293,
5732,
291,
7319,
8233,
5378,
19047,
1507,
11413,
7121,
12443,
90475,
1785,
7749,
11,
11413,
67672,
10599,
1171,
743,
1848,
961,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestDirtySet(t *testing.T) {
var set DirtySet
set.MarkDirty(memmap.MappableRange{0, 2 * usermem.PageSize})
set.KeepDirty(memmap.MappableRange{usermem.PageSize, 2 * usermem.PageSize})
set.MarkClean(memmap.MappableRange{0, 2 * usermem.PageSize})
want := &DirtySegmentDataSlices{
Start: []uint64{usermem.PageSize},
End: []uint64{2 * usermem.PageSize},
Values: []DirtyInfo{{Keep: true}},
}
if got := set.ExportSortedSlices(); !reflect.DeepEqual(got, want) {
t.Errorf("set:\n\tgot %v,\n\twant %v", got, want)
}
} | explode_data.jsonl/14786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
36485,
1649,
1155,
353,
8840,
836,
8,
341,
2405,
738,
54291,
1649,
198,
8196,
75888,
36485,
39908,
2186,
1321,
86384,
6046,
90,
15,
11,
220,
17,
353,
1196,
10536,
93189,
3518,
8196,
13,
19434,
36485,
39908,
2186,
1321,
86384... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMustNewTestInterfaceRoundRobinPool(t *testing.T) {
assert.Panics(t, func() {
MustNewTestInterfaceRoundRobinPool()
})
assert.NotPanics(t, func() {
MustNewTestInterfaceRoundRobinPool(&testImpl{})
})
} | explode_data.jsonl/24524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
31776,
3564,
2271,
5051,
27497,
76671,
10551,
1155,
353,
8840,
836,
8,
341,
6948,
1069,
276,
1211,
1155,
11,
2915,
368,
341,
197,
9209,
590,
3564,
2271,
5051,
27497,
76671,
10551,
741,
197,
8824,
6948,
15000,
35693,
1211,
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 |
func TestDeleteJobShouldSetJobObjectToExpire(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
job := addLeasedJob(t, r, "queue1", "cluster1")
expiryStatuses, err := r.getExpiryStatus([]*api.Job{job})
if err != nil {
t.Fatalf("getting expiry status failed with error %s", err)
}
assert.False(t, expiryStatuses[job])
result, err := r.DeleteJobs([]*api.Job{job})
if err != nil {
t.Fatalf("deleting jobs failed with error %s", err)
}
err, deletionOccurred := result[job]
assert.Nil(t, err)
assert.True(t, deletionOccurred)
expiryStatuses, err = r.getExpiryStatus([]*api.Job{job})
if err != nil {
t.Fatalf("getting expiry status failed with error %s", err)
}
assert.True(t, expiryStatuses[job])
})
} | explode_data.jsonl/32048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
6435,
12245,
14996,
1649,
12245,
1190,
1249,
8033,
554,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
68577,
1669,
912,
2304,
1475,
12245,
1155,
11,
435,
11,
330,
4584,
16,
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... | 4 |
func TestUpdateDescription(t *testing.T) {
d1 := Description{
Website: "https://validator.cosmos",
Details: "Test validator",
}
d2 := Description{
Moniker: DoNotModifyDesc,
Identity: DoNotModifyDesc,
Website: DoNotModifyDesc,
Details: DoNotModifyDesc,
}
d3 := Description{
Moniker: "",
Identity: "",
Website: "",
Details: "",
}
d, err := d1.UpdateDescription(d2)
require.Nil(t, err)
require.Equal(t, d, d1)
d, err = d1.UpdateDescription(d3)
require.Nil(t, err)
require.Equal(t, d, d3)
} | explode_data.jsonl/733 | {
"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,
4289,
5009,
1155,
353,
8840,
836,
8,
341,
2698,
16,
1669,
7662,
515,
197,
197,
30051,
25,
330,
2428,
1110,
16112,
21147,
8631,
756,
197,
197,
7799,
25,
330,
2271,
22935,
756,
197,
630,
2698,
17,
1669,
7662,
515,
197,
920... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConcurrency(t *testing.T) {
// Create a mathworker kite
mathKite := newXhrKite("mathworker", "0.0.1")
mathKite.Config.DisableAuthentication = true
mathKite.Config.Port = 3637
mathKite.HandleFunc("ping", func(r *Request) (interface{}, error) {
time.Sleep(time.Second)
return "pong", nil
})
go mathKite.Run()
<-mathKite.ServerReadyNotify()
defer mathKite.Close()
// number of exp kites that will call mathworker kite
clientNumber := 3
clients := make([]*Client, clientNumber)
for i := range clients {
c := newXhrKite("exp", "0.0.1").NewClient("http://127.0.0.1:3637/kite")
if err := c.Dial(); err != nil {
t.Fatal(err)
}
clients[i] = c
defer c.Close()
}
var wg sync.WaitGroup
for i := range clients {
wg.Add(1)
go func(i int) {
defer wg.Done()
result, err := clients[i].TellWithTimeout("ping", 4*time.Second)
if err != nil {
t.Fatal(err)
}
if result.MustString() != "pong" {
t.Errorf("Got %s want: pong", result.MustString())
}
}(i)
}
wg.Wait()
} | explode_data.jsonl/68245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 442
} | [
2830,
3393,
79611,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
264,
6888,
21462,
98119,
198,
2109,
587,
42,
632,
1669,
88803,
4079,
42,
632,
445,
10374,
21462,
497,
330,
15,
13,
15,
13,
16,
1138,
2109,
587,
42,
632,
10753,
10166,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInit(t *testing.T) {
c := qt.New(t)
var found bool
var ns *internal.TemplateFuncsNamespace
for _, nsf := range internal.TemplateFuncsNamespaceRegistry {
ns = nsf(&deps.Deps{Log: loggers.NewIgnorableLogger(loggers.NewErrorLogger())})
if ns.Name == name {
found = true
break
}
}
c.Assert(found, qt.Equals, true)
ctx, err := ns.Context()
c.Assert(err, qt.IsNil)
c.Assert(ctx, hqt.IsSameType, &Namespace{})
} | explode_data.jsonl/55800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
3803,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
38949,
7121,
1155,
340,
2405,
1730,
1807,
198,
2405,
12268,
353,
10481,
52530,
9626,
82,
22699,
271,
2023,
8358,
12268,
69,
1669,
2088,
5306,
52530,
9626,
82,
22699,
15603,
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... | 3 |
func TestXHeader_StableMarshal(t *testing.T) {
xheaderFrom := generateXHeader("X-Header-Key", "X-Header-Value")
t.Run("non empty", func(t *testing.T) {
wire, err := xheaderFrom.StableMarshal(nil)
require.NoError(t, err)
xheaderTo := new(session.XHeader)
require.NoError(t, xheaderTo.Unmarshal(wire))
require.Equal(t, xheaderFrom, xheaderTo)
})
} | explode_data.jsonl/79969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
55,
4047,
70645,
480,
55438,
1155,
353,
8840,
836,
8,
341,
10225,
2708,
3830,
1669,
6923,
55,
4047,
445,
55,
12,
4047,
94321,
497,
330,
55,
12,
4047,
12,
1130,
5130,
3244,
16708,
445,
6280,
4287,
497,
2915,
1155,
353,
88... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseExp(t *testing.T) {
now := time.Unix(time.Now().Unix(), 0)
claims := map[string]interface{}{
expClaim: float64(now.Unix()),
}
exp, err := parseExp(claims)
if err != nil {
t.Errorf("parseExp: %v", err)
}
if exp != now {
t.Errorf("parseExp float got: %v, want: %v", exp, now)
}
claims[expClaim] = strconv.FormatInt(time.Now().Unix(), 10)
exp, err = parseExp(claims)
if err != nil {
t.Errorf("parseExp: %v", err)
}
if exp != now {
t.Errorf("parseExp string got: %v, want: %v", exp, now)
}
claims[expClaim] = "badexp"
_, err = parseExp(claims)
if err == nil {
t.Error("parseExp should have gotten an error")
}
} | explode_data.jsonl/67150 | {
"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,
14463,
8033,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
10616,
941,
9730,
13244,
1005,
55832,
1507,
220,
15,
692,
197,
48561,
1669,
2415,
14032,
31344,
67066,
197,
48558,
45544,
25,
2224,
21,
19,
32263,
10616,
941,
1470... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.