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 TestRuleMeaninglessWhere(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
{
"select * from tbl where 1 = 1;",
"select * from tbl where 'a' = 'a';",
"select * from tbl where 'a' != 1;",
"select * from tbl where 'a';",
"select * from tbl where 'a' limit 1;",
"select * from tbl where 1;",
"select * from tbl where 1 limit 1;",
},
{
"select * from tbl where 2 = 1;",
"select * from tbl where 'b' = 'a';",
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleMeaninglessWhere()
if rule.Item != "RES.007" {
t.Error("Rule not match:", rule.Item, "Expect : RES.007, SQL: ", sql)
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleMeaninglessWhere()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK, SQL: ", sql)
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76771 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 501
} | [
2830,
3393,
11337,
18783,
287,
1717,
9064,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
515,
298,
197,
1,
1742,
353,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestEncodeToString(t *testing.T) {
for _, pair := range pairs {
got := DefaultCodec.EncodeToString([]byte(pair.decoded))
if got != pair.encoded {
t.Errorf("Encode(%q) = %q, want %q", pair.decoded, got, pair.encoded)
}
}
} | explode_data.jsonl/17243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
32535,
5870,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
6716,
1669,
2088,
13530,
341,
197,
3174,
354,
1669,
7899,
36913,
50217,
5870,
10556,
3782,
39144,
28020,
6737,
1171,
197,
743,
2684,
961,
6716,
13,
19329,
341,
298,
3244... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Web_Written(t *testing.T) {
Convey("Written sign", t, func() {
resp := httptest.NewRecorder()
m := New()
m.Handlers(func(res http.ResponseWriter) {
res.WriteHeader(http.StatusOK)
})
ctx := m.createContext(resp, &http.Request{Method: "GET"})
So(ctx.Written(), ShouldBeFalse)
ctx.run()
So(ctx.Written(), ShouldBeTrue)
})
} | explode_data.jsonl/44979 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
62,
5981,
2763,
12153,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
35624,
1841,
497,
259,
11,
2915,
368,
341,
197,
34653,
1669,
54320,
70334,
7121,
47023,
741,
197,
2109,
1669,
1532,
741,
197,
2109,
35308,
9254,
18552,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomer_RetrieveNotes(t *testing.T) {
key := "test api key"
var mockResponses invdendpoint.Notes
mockResponseId := int64(1523)
mockResponse := new(invdendpoint.Note)
mockResponse.Id = mockResponseId
mockResponse.Notes = "Mock Note"
mockResponses = append(mockResponses, *mockResponse)
server, err := invdmockserver.New(200, mockResponses, "json", true)
if err != nil {
t.Fatal(err)
}
defer server.Close()
conn := mockConnection(key, server)
defaultEntity := conn.NewCustomer()
subjectEntity, err := defaultEntity.RetrieveNotes()
if err != nil {
t.Fatal("Error with note", err)
}
if subjectEntity[0].Notes != "Mock Note" {
t.Fatal("Retrieval not correct")
}
} | explode_data.jsonl/15029 | {
"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,
12792,
2568,
295,
45004,
21667,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
330,
1944,
6330,
1376,
1837,
2405,
7860,
70743,
1529,
67,
32540,
2067,
6295,
198,
77333,
2582,
764,
1669,
526,
21,
19,
7,
16,
20,
17,
18,
340,
77... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocale(t *testing.T) {
trans := New()
expected := "qu_PE"
if trans.Locale() != expected {
t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale())
}
} | explode_data.jsonl/19697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
19231,
1155,
353,
8840,
836,
8,
1476,
72453,
1669,
1532,
741,
42400,
1669,
330,
446,
45784,
1837,
743,
1356,
59094,
368,
961,
3601,
341,
197,
3244,
13080,
445,
18896,
7677,
82,
6,
24528,
7677,
82,
22772,
3601,
11,
1356,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestAssertionUnmarshaledFromYAMLWithNotTrue(t *testing.T) {
assertionsYAML := `
- equal:
not: true
- notEqual:
not: true
- matchRegex:
not: true
- notMatchRegex:
not: true
- contains:
not: true
- notContains:
not: true
- isNull:
not: true
- isNotNull:
not: true
- isEmpty:
not: true
- isNotEmpty:
not: true
- isKind:
not: true
- isAPIVersion:
not: true
- hasDocuments:
not: true
`
assertions := make([]Assertion, 13)
yaml.Unmarshal([]byte(assertionsYAML), &assertions)
a := assert.New(t)
for _, assertion := range assertions {
a.True(assertion.Not)
}
} | explode_data.jsonl/62920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
68639,
1806,
36239,
5838,
3830,
56,
31102,
2354,
2623,
2514,
1155,
353,
8840,
836,
8,
341,
6948,
908,
56,
31102,
1669,
22074,
12,
6144,
510,
220,
537,
25,
830,
198,
12,
537,
2993,
510,
220,
537,
25,
830,
198,
12,
2432,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddRecursive(t *testing.T) {
r := &repo.Mock{
C: config.Config{
Identity: config.Identity{
PeerID: testPeerID, // required by offline node
},
},
D: syncds.MutexWrap(datastore.NewMapDatastore()),
}
node, err := core.NewNode(context.Background(), &core.BuildCfg{Repo: r})
if err != nil {
t.Fatal(err)
}
if k, err := AddR(node, "test/data"); err != nil {
t.Fatal(err)
} else if k != "QmWCCga8AbTyfAQ7pTnGT6JgmRMAB3Qp8ZmTEFi5q5o8jC" {
t.Fatal("keys do not match: ", k)
}
} | explode_data.jsonl/39682 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
2212,
78542,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
609,
23476,
24664,
515,
197,
6258,
25,
2193,
10753,
515,
298,
197,
18558,
25,
2193,
24423,
515,
571,
10025,
34756,
915,
25,
1273,
30888,
915,
11,
442,
2567,
553,
26166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCollectorSet(t *testing.T) {
_ = redisMetric.Set(100, "1", "400")
_ = redisNoLabelsMetric.Set(101)
_ = Get("/metrics", nil)
} | explode_data.jsonl/52688 | {
"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,
53694,
1649,
1155,
353,
8840,
836,
8,
341,
197,
62,
284,
20870,
54310,
4202,
7,
16,
15,
15,
11,
330,
16,
497,
330,
19,
15,
15,
1138,
197,
62,
284,
20870,
2753,
23674,
54310,
4202,
7,
16,
15,
16,
340,
197,
62,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClustersVersion(t *testing.T) {
clusters, mock := createClusters(t)
defer shutdownClusters(t, clusters, mock)
f := func(t *testing.T, c *Cluster) {
v := c.Version()
if v != version.Version.String() {
t.Error("Bad version")
}
}
runF(t, clusters, f)
} | explode_data.jsonl/66600 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
94992,
5637,
1155,
353,
8840,
836,
8,
341,
39407,
14605,
11,
7860,
1669,
1855,
94992,
1155,
340,
16867,
23766,
94992,
1155,
11,
26968,
11,
7860,
340,
1166,
1669,
2915,
1155,
353,
8840,
836,
11,
272,
353,
28678,
8,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_SDBMHash(t *testing.T) {
var x uint32 = 1069170245
gtest.C(t, func(t *gtest.T) {
j := ghash.SDBMHash(strBasic)
t.Assert(j, x)
})
} | explode_data.jsonl/60228 | {
"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,
1098,
3506,
44,
6370,
1155,
353,
8840,
836,
8,
341,
2405,
856,
2622,
18,
17,
284,
220,
16,
15,
21,
24,
16,
22,
15,
17,
19,
20,
198,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
12428,
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 TestNamespacedBuiltins(t *testing.T) {
tests := []struct {
expr string
expected *Term
wantErr bool
}{
{`foo.bar.baz(1, 2)`, MustParseTerm("foo.bar.baz"), false},
{`foo.(1,2)`, nil, true},
{`foo.#.bar(1,2)`, nil, true},
}
for _, tc := range tests {
expr, err := ParseExpr(tc.expr)
if !tc.wantErr {
if err != nil {
t.Fatalf("Unexpected parse error: %v", err)
}
terms, ok := expr.Terms.([]*Term)
if !ok {
t.Fatalf("Expected terms not: %T", expr.Terms)
}
if !terms[0].Equal(tc.expected) {
t.Fatalf("Expected builtin-name to equal %v but got: %v", tc.expected, terms)
}
} else if err == nil {
t.Fatalf("Expected error from %v but got: %v", tc.expr, expr)
}
}
} | explode_data.jsonl/50499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 341
} | [
2830,
3393,
7980,
68552,
54300,
1330,
1155,
353,
8840,
836,
8,
1476,
78216,
1669,
3056,
1235,
341,
197,
8122,
649,
257,
914,
198,
197,
42400,
353,
17249,
198,
197,
50780,
7747,
220,
1807,
198,
197,
59403,
197,
197,
90,
63,
7975,
22001... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestSetsHeaders(t *testing.T) {
server := clientFunc(func(req *http.Request) (*http.Response, error) {
if req.Header.Get("Accept") != "application/other, */*" {
t.Errorf("unexpected headers: %#v", req.Header)
}
return &http.Response{
StatusCode: http.StatusForbidden,
Body: ioutil.NopCloser(bytes.NewReader([]byte{})),
}, nil
})
config := defaultContentConfig()
config.ContentType = "application/other"
serializers := defaultSerializers(t)
r := NewRequest(server, "get", &url.URL{Path: "/path"}, "", config, serializers, nil, nil, 0)
// Check if all "issue" methods are setting headers.
_ = r.Do()
_, _ = r.Watch()
_, _ = r.Stream()
} | explode_data.jsonl/13246 | {
"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,
1900,
30175,
10574,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
2943,
9626,
18552,
6881,
353,
1254,
9659,
8,
4609,
1254,
12574,
11,
1465,
8,
341,
197,
743,
4232,
15753,
2234,
445,
16646,
899,
961,
330,
5132,
14,
1575,
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... | 2 |
func Test_DirectedWithDuplicateNode(t *testing.T) {
gb := NewGraphBuilder(BuilderOptions{AllowDuplicateNodes: false, IsDirected: true})
gb.AddNode(1)
gb.AddNode(1)
_, err := gb.Build()
assert.ErrorIs(t, err, duplicateNodeError{nodeID: 1})
gb = NewGraphBuilder(BuilderOptions{AllowDuplicateNodes: true, IsDirected: true})
gb.AddNode(1)
gb.AddNode(1)
actual_graph, err := gb.Build()
assert.NoError(t, err)
expected_graph := rawDirectedGraph{
Nodes: map[NodeID]*rawDirectedNode{
1: {ID: 1, Incoming: []NodeID{}, Outgoing: []NodeID{}},
},
FromToEdges: map[NodeID]map[NodeID]*rawDirectedEdge{},
}
AssertGraphEquals(t, expected_graph, actual_graph)
} | explode_data.jsonl/81787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
1557,
74612,
2354,
53979,
1955,
1155,
353,
8840,
836,
8,
341,
3174,
65,
1669,
1532,
11212,
3297,
7,
3297,
3798,
90,
18605,
53979,
12288,
25,
895,
11,
2160,
92669,
25,
830,
3518,
3174,
65,
1904,
1955,
7,
16,
340,
3174,
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 TestMasterIsCheckedLinkModeTrue(t *testing.T) {
sourceCluster := MustCreateCluster(t, []greenplum.SegConfig{
{ContentID: -1, DbID: 1, Port: 15432, Hostname: "localhost", DataDir: "/data/qddir/seg-1", Role: "p"},
{ContentID: 0, DbID: 2, Port: 25432, Hostname: "host1", DataDir: "/data/dbfast1/seg1", Role: "p"},
{ContentID: 1, DbID: 3, Port: 25433, Hostname: "host2", DataDir: "/data/dbfast2/seg2", Role: "p"},
})
targetCluster := MustCreateCluster(t, []greenplum.SegConfig{
{ContentID: -1, DbID: 1, Port: 15432, Hostname: "localhost", DataDir: "/data/qddir/seg-1", Role: "p"},
{ContentID: 0, DbID: 2, Port: 25432, Hostname: "host1", DataDir: "/data/dbfast1/seg1", Role: "p"},
{ContentID: 1, DbID: 3, Port: 25433, Hostname: "host2", DataDir: "/data/dbfast2/seg2", Role: "p"},
})
var stateDirExpected = "/some/state/dir"
for _, linkMode := range []bool{true, false} {
t.Run(fmt.Sprintf("check upgrade correctly passes useLinkMode is %v", linkMode), func(t *testing.T) {
conf := &Config{
Source: sourceCluster,
Target: targetCluster,
UseLinkMode: linkMode,
}
s := New(conf, grpc.DialContext, stateDirExpected)
testUpgraderMock := upgraderMock{s}
setUpgrader(testUpgraderMock)
defer resetUpgrader()
err := s.CheckUpgrade(nil, connections)
if err != nil {
t.Errorf("got error: %+v", err) // yes, '%+v'; '%#v' prints opaque multiple errors
}
})
}
} | explode_data.jsonl/35429 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 609
} | [
2830,
3393,
18041,
3872,
12666,
3939,
3636,
2514,
1155,
353,
8840,
836,
8,
341,
47418,
28678,
1669,
15465,
4021,
28678,
1155,
11,
3056,
13250,
500,
372,
808,
791,
2648,
515,
197,
197,
90,
2762,
915,
25,
481,
16,
11,
11988,
915,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestOpenClose(t *testing.T) {
type args struct {
path string
}
path := "testdata/openclosedb"
tests := []struct {
name string
args args
}{
{"CreateNewDB", args{path}},
{"OpenExistingDB", args{path}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Open(tt.args.path)
if err != nil {
t.Errorf("Open() error = %v", err)
return
}
if got == nil {
t.Error("Open(): got == nil")
}
if got.db == nil {
t.Error("Open(): got.db == nil")
}
if got.db.Path() != path {
t.Errorf("Open(): path = %s, expected = %s", got.db.Path(), path)
}
err = got.Close()
if err != nil {
t.Errorf("Cannot close database %s", path)
}
})
}
// Teardown
err := os.Remove(path)
if err != nil {
t.Errorf("Cannot remove %s", path)
}
} | explode_data.jsonl/38329 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 379
} | [
2830,
3393,
5002,
7925,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
26781,
914,
198,
197,
532,
26781,
1669,
330,
92425,
52000,
954,
9259,
65,
698,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func Test23262(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(a year)")
tk.MustExec("insert into t values(2002)")
tk.MustQuery("select * from t where a=2").Check(testkit.Rows("2002"))
tk.MustQuery("select * from t where a='2'").Check(testkit.Rows("2002"))
} | explode_data.jsonl/65573 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
17,
18,
17,
21,
17,
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,
50463,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInitializeContainerOrderingWithLinksAndVolumesFrom(t *testing.T) {
containerWithOnlyVolume := &apicontainer.Container{
Name: "myName",
Image: "image:tag",
VolumesFrom: []apicontainer.VolumeFrom{{SourceContainer: "myName1"}},
}
containerWithOnlyLink := &apicontainer.Container{
Name: "myName1",
Image: "image:tag",
Links: []string{"myName"},
}
containerWithBothVolumeAndLink := &apicontainer.Container{
Name: "myName2",
Image: "image:tag",
VolumesFrom: []apicontainer.VolumeFrom{{SourceContainer: "myName"}},
Links: []string{"myName1"},
}
containerWithNoVolumeOrLink := &apicontainer.Container{
Name: "myName3",
Image: "image:tag",
}
task := &Task{
Arn: "test",
ResourcesMapUnsafe: make(map[string][]taskresource.TaskResource),
Containers: []*apicontainer.Container{containerWithOnlyVolume, containerWithOnlyLink,
containerWithBothVolumeAndLink, containerWithNoVolumeOrLink},
}
err := task.initializeContainerOrderingForVolumes()
assert.NoError(t, err)
err = task.initializeContainerOrderingForLinks()
assert.NoError(t, err)
containerResultWithVolume := task.Containers[0]
assert.Equal(t, "myName1", containerResultWithVolume.DependsOnUnsafe[0].ContainerName)
assert.Equal(t, ContainerOrderingCreateCondition, containerResultWithVolume.DependsOnUnsafe[0].Condition)
containerResultWithLink := task.Containers[1]
assert.Equal(t, "myName", containerResultWithLink.DependsOnUnsafe[0].ContainerName)
assert.Equal(t, ContainerOrderingStartCondition, containerResultWithLink.DependsOnUnsafe[0].Condition)
containerResultWithBothVolumeAndLink := task.Containers[2]
assert.Equal(t, "myName", containerResultWithBothVolumeAndLink.DependsOnUnsafe[0].ContainerName)
assert.Equal(t, ContainerOrderingCreateCondition, containerResultWithBothVolumeAndLink.DependsOnUnsafe[0].Condition)
assert.Equal(t, "myName1", containerResultWithBothVolumeAndLink.DependsOnUnsafe[1].ContainerName)
assert.Equal(t, ContainerOrderingStartCondition, containerResultWithBothVolumeAndLink.DependsOnUnsafe[1].Condition)
containerResultWithNoVolumeOrLink := task.Containers[3]
assert.Equal(t, 0, len(containerResultWithNoVolumeOrLink.DependsOnUnsafe))
} | explode_data.jsonl/37262 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 768
} | [
2830,
3393,
9928,
4502,
4431,
287,
2354,
24089,
3036,
96325,
3830,
1155,
353,
8840,
836,
8,
341,
53290,
2354,
7308,
18902,
1669,
609,
391,
51160,
1743,
33672,
515,
197,
21297,
25,
286,
330,
2408,
675,
756,
197,
53397,
25,
981,
330,
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... | 1 |
func TestArrayErrors(t *testing.T) {
test.RunProfiles(t, func(t *testing.T, profile test.Profile) {
agg, ckpt := new2()
_, err := ckpt.Max()
require.Error(t, err)
require.Equal(t, err, aggregation.ErrNoData)
_, err = ckpt.Min()
require.Error(t, err)
require.Equal(t, err, aggregation.ErrNoData)
_, err = ckpt.Quantile(0.1)
require.Error(t, err)
require.Equal(t, err, aggregation.ErrNoData)
descriptor := test.NewAggregatorTest(metric.ValueRecorderKind, profile.NumberKind)
test.CheckedUpdate(t, agg, metric.Number(0), descriptor)
if profile.NumberKind == metric.Float64NumberKind {
test.CheckedUpdate(t, agg, metric.NewFloat64Number(math.NaN()), descriptor)
}
require.NoError(t, agg.SynchronizedMove(ckpt, descriptor))
count, err := ckpt.Count()
require.Equal(t, int64(1), count, "NaN value was not counted")
require.Nil(t, err)
num, err := ckpt.Quantile(0)
require.Nil(t, err)
require.Equal(t, num, metric.Number(0))
_, err = ckpt.Quantile(-0.0001)
require.Error(t, err)
require.True(t, errors.Is(err, aggregation.ErrInvalidQuantile))
_, err = agg.Quantile(1.0001)
require.Error(t, err)
require.True(t, errors.Is(err, aggregation.ErrNoData))
})
} | explode_data.jsonl/28116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 505
} | [
2830,
3393,
1857,
13877,
1155,
353,
8840,
836,
8,
341,
18185,
16708,
62719,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
5526,
1273,
59872,
8,
341,
197,
197,
15718,
11,
38613,
417,
1669,
501,
17,
2822,
197,
197,
6878,
1848,
1669,
38613,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmpire_Deploy(t *testing.T) {
e := empiretest.NewEmpire(t)
s := new(mockScheduler)
e.Scheduler = s
user := &empire.User{Name: "ejholmes"}
app, err := e.Create(context.Background(), empire.CreateOpts{
User: user,
Name: "acme-inc",
})
assert.NoError(t, err)
img := image.Image{Repository: "remind101/acme-inc"}
s.On("Submit", &twelvefactor.Manifest{
AppID: app.ID,
Name: "acme-inc",
Release: "v1",
Env: map[string]string{
"EMPIRE_APPID": app.ID,
"EMPIRE_APPNAME": "acme-inc",
"EMPIRE_RELEASE": "v1",
},
Labels: map[string]string{
"empire.app.name": "acme-inc",
"empire.app.id": app.ID,
"empire.app.release": "v1",
},
Processes: []*twelvefactor.Process{
{
Type: "scheduled",
Image: img,
Command: []string{"./bin/scheduled"},
Schedule: twelvefactor.CRONSchedule("* * * * * *"),
Quantity: 0,
Memory: 536870912,
CPUShares: 256,
Nproc: 256,
Env: map[string]string{
"EMPIRE_PROCESS": "scheduled",
"EMPIRE_PROCESS_SCALE": "0",
"SOURCE": "acme-inc.scheduled.v1",
},
Labels: map[string]string{
"empire.app.process": "scheduled",
},
},
{
Type: "web",
Image: img,
Command: []string{"./bin/web"},
Exposure: &twelvefactor.Exposure{
Ports: []twelvefactor.Port{
{
Container: 8080,
Host: 80,
Protocol: &twelvefactor.HTTP{},
},
},
},
Quantity: 1,
Memory: 536870912,
CPUShares: 256,
Nproc: 256,
Env: map[string]string{
"EMPIRE_PROCESS": "web",
"EMPIRE_PROCESS_SCALE": "1",
"SOURCE": "acme-inc.web.v1",
"PORT": "8080",
},
Labels: map[string]string{
"empire.app.process": "web",
},
},
{
Type: "worker",
Image: img,
Command: []string{"./bin/worker"},
Quantity: 0,
Memory: 536870912,
CPUShares: 256,
Nproc: 256,
Env: map[string]string{
"EMPIRE_PROCESS": "worker",
"EMPIRE_PROCESS_SCALE": "0",
"SOURCE": "acme-inc.worker.v1",
},
Labels: map[string]string{
"empire.app.process": "worker",
},
},
},
}).Return(nil)
_, err = e.Deploy(context.Background(), empire.DeployOpts{
App: app,
User: user,
Output: empire.NewDeploymentStream(ioutil.Discard),
Image: img,
})
assert.NoError(t, err)
s.AssertExpectations(t)
} | explode_data.jsonl/35282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1344
} | [
2830,
3393,
28731,
554,
90680,
1989,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
31347,
1944,
7121,
28731,
554,
1155,
340,
1903,
1669,
501,
30389,
38878,
340,
7727,
808,
15222,
284,
274,
271,
19060,
1669,
609,
3262,
554,
7344,
63121,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestView(t *testing.T) {
input := CreateTestInput(t)
var newContractAddress sdk.AccAddress
t.Run("deploy a contract with regular code", func(t *testing.T) {
code, err := hex.DecodeString(BasicTestsBytecodeString)
require.Nil(t, err)
result, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], nil, 0, code, []*payload.ContractMeta{}, false, false, false)
require.Nil(t, err2)
require.NotNil(t, result)
newContractAddress = sdk.AccAddress(result)
})
t.Run("write to state while in view mode and ensure it is NOT reflected in updated state", func(t *testing.T) {
setMyFavoriteNumberCall, _, err2 := abi.EncodeFunctionCall(
BasicTestsAbiJsonString,
"setMyFavoriteNumber",
WrapLogger(input.Ctx.Logger()),
777,
)
require.Nil(t, err2)
result, err := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, setMyFavoriteNumberCall, []*payload.ContractMeta{}, true, false, false)
require.NotNil(t, err)
result, err2 = input.CvmKeeper.GetStorage(input.Ctx, crypto.MustAddressFromBytes(newContractAddress), binary.Int64ToWord256(0))
require.Equal(t, new(big.Int).SetBytes(result).Int64(), int64(34))
})
} | explode_data.jsonl/14831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 441
} | [
2830,
3393,
851,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
2505,
1155,
692,
2405,
501,
14067,
4286,
45402,
77538,
4286,
198,
3244,
16708,
445,
35794,
264,
5116,
448,
5792,
2038,
497,
2915,
1155,
353,
8840,
836,
8,
341,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegration_MultiwordV2(t *testing.T) {
t.Parallel()
// Simulate a consumer contract calling to obtain ETH quotes in 3 different currencies
// in a single callback.
config := cltest.NewTestEVMConfig(t)
user, _, operatorAddress, _, consumerContract, operatorContract, b := setupMultiWordContracts(t)
app, cleanup := cltest.NewApplicationWithConfigAndKeyOnSimulatedBlockchain(t, config, b)
defer cleanup()
config.Overrides.EvmHeadTrackerMaxBufferSize = null.IntFrom(100)
config.GeneralConfig.Overrides.SetTriggerFallbackDBPollInterval(100 * time.Millisecond)
sendingKeys, err := app.KeyStore.Eth().SendingKeys()
require.NoError(t, err)
authorizedSenders := []common.Address{sendingKeys[0].Address.Address()}
tx, err := operatorContract.SetAuthorizedSenders(user, authorizedSenders)
require.NoError(t, err)
b.Commit()
cltest.RequireTxSuccessful(t, b, tx.Hash())
// Fund node account with ETH.
n, err := b.NonceAt(context.Background(), user.From, nil)
require.NoError(t, err)
tx = types.NewTransaction(n, sendingKeys[0].Address.Address(), big.NewInt(1000000000000000000), 21000, big.NewInt(1000000000), nil)
signedTx, err := user.Signer(user.From, tx)
require.NoError(t, err)
err = b.SendTransaction(context.Background(), signedTx)
require.NoError(t, err)
b.Commit()
err = app.Start()
require.NoError(t, err)
mockServerUSD, cleanup := cltest.NewHTTPMockServer(t, 200, "GET", `{"USD": 614.64}`)
defer cleanup()
mockServerEUR, cleanup := cltest.NewHTTPMockServer(t, 200, "GET", `{"EUR": 507.07}`)
defer cleanup()
mockServerJPY, cleanup := cltest.NewHTTPMockServer(t, 200, "GET", `{"JPY": 63818.86}`)
defer cleanup()
spec := string(cltest.MustReadFile(t, "../testdata/tomlspecs/multiword-response-spec.toml"))
spec = strings.ReplaceAll(spec, "0x613a38AC1659769640aaE063C651F48E0250454C", operatorAddress.Hex())
j := cltest.CreateJobViaWeb(t, app, []byte(cltest.MustJSONMarshal(t, web.CreateJobRequest{TOML: spec})))
cltest.AwaitJobActive(t, app.JobSpawner(), j.ID, 5*time.Second)
var jobID [32]byte
copy(jobID[:], j.ExternalJobID.Bytes())
tx, err = consumerContract.SetSpecID(user, jobID)
require.NoError(t, err)
b.Commit()
cltest.RequireTxSuccessful(t, b, tx.Hash())
user.GasLimit = 1000000
tx, err = consumerContract.RequestMultipleParametersWithCustomURLs(user,
mockServerUSD.URL, "USD",
mockServerEUR.URL, "EUR",
mockServerJPY.URL, "JPY",
big.NewInt(1000),
)
require.NoError(t, err)
b.Commit()
cltest.RequireTxSuccessful(t, b, tx.Hash())
empty := big.NewInt(0)
assertPricesUint256(t, empty, empty, empty, consumerContract)
stopBlocks := finiteTicker(100*time.Millisecond, func() {
triggerAllKeys(t, app)
b.Commit()
})
defer stopBlocks()
attempts := cltest.WaitForEthTxAttemptCount(t, app.Store, 1)
time.Sleep(3 * time.Second)
cltest.RequireTxSuccessful(t, b, attempts[0].Hash)
assertPricesUint256(t, big.NewInt(61464), big.NewInt(50707), big.NewInt(6381886), consumerContract)
pipelineRuns := cltest.WaitForPipelineComplete(t, 0, j.ID, 1, 14, app.JobORM(), 10*time.Second, 100*time.Millisecond)
pipelineRun := pipelineRuns[0]
cltest.AssertPipelineTaskRunsSuccessful(t, pipelineRun.PipelineTaskRuns)
} | explode_data.jsonl/29843 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1206
} | [
2830,
3393,
52464,
1245,
7068,
1158,
53,
17,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
4467,
6334,
264,
11502,
5116,
8098,
311,
6851,
37742,
17194,
304,
220,
18,
2155,
35602,
198,
197,
322,
304,
264,
3175,
4822,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetricsReporter(t *testing.T) {
pa := kpa(testNamespace, testRevision)
wantTags := map[string]string{
metricskey.LabelRevisionName: testRevision,
metricskey.LabelNamespaceName: testNamespace,
metricskey.LabelServiceName: pa.Labels[serving.ServiceLabelKey],
metricskey.LabelConfigurationName: pa.Labels[serving.ConfigurationLabelKey],
}
pc := podCounts{
want: 1982,
ready: 1984,
notReady: 1988,
pending: 1996,
terminating: 1983,
}
reportMetrics(pa, pc)
metricstest.CheckLastValueData(t, "requested_pods", wantTags, 1982)
metricstest.CheckLastValueData(t, "actual_pods", wantTags, 1984)
metricstest.CheckLastValueData(t, "not_ready_pods", wantTags, 1988)
metricstest.CheckLastValueData(t, "pending_pods", wantTags, 1996)
metricstest.CheckLastValueData(t, "terminating_pods", wantTags, 1983)
// Verify `want` is ignored, when it is equal to -1.
pc.want = -1
pc.terminating = 1955
reportMetrics(pa, pc)
// Basically same values and change to `terminating` to verify reporting has occurred.
metricstest.CheckLastValueData(t, "requested_pods", wantTags, 1982)
metricstest.CheckLastValueData(t, "actual_pods", wantTags, 1984)
metricstest.CheckLastValueData(t, "not_ready_pods", wantTags, 1988)
metricstest.CheckLastValueData(t, "pending_pods", wantTags, 1996)
metricstest.CheckLastValueData(t, "terminating_pods", wantTags, 1955)
} | explode_data.jsonl/35446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 538
} | [
2830,
3393,
27328,
52766,
1155,
353,
8840,
836,
8,
341,
3223,
64,
1669,
595,
6595,
8623,
22699,
11,
1273,
33602,
340,
50780,
15930,
1669,
2415,
14032,
30953,
515,
197,
2109,
13468,
792,
4679,
33602,
675,
25,
414,
1273,
33602,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetVolumeReplicaResource(t *testing.T) {
fakeKubeClient := fake.NewSimpleClientset()
fakeOpenebsClient := openebsFakeClientset.NewSimpleClientset()
kubeInformerFactory := kubeinformers.NewSharedInformerFactory(fakeKubeClient, time.Second*30)
openebsInformerFactory := informers.NewSharedInformerFactory(fakeOpenebsClient, time.Second*30)
// Instantiate the cStor VolumeReplica controllers.
volumeReplicaController := NewCStorVolumeReplicaController(fakeKubeClient, fakeOpenebsClient, kubeInformerFactory,
openebsInformerFactory)
testVolumeReplicaResource := map[string]struct {
expectedName string
test *apis.CStorVolumeReplica
}{
"VolumeReplicaResource1": {
expectedName: "VolumeReplicaResource1",
test: &apis.CStorVolumeReplica{
ObjectMeta: metav1.ObjectMeta{
Name: "VolumeReplicaResource1",
Namespace: "default",
},
Spec: apis.CStorVolumeReplicaSpec{
TargetIP: "10.210.110.121",
Capacity: "100MB",
},
},
},
"VolumeReplicaResource2": {
expectedName: "VolumeReplicaResource2",
test: &apis.CStorVolumeReplica{
ObjectMeta: metav1.ObjectMeta{
Name: "VolumeReplicaResource2",
Namespace: "default",
},
Spec: apis.CStorVolumeReplicaSpec{
TargetIP: "10.210.110.121",
Capacity: "100MB",
},
},
},
}
for desc, ut := range testVolumeReplicaResource {
// Create a volume-replica resource.
_, err := volumeReplicaController.clientset.CstorV1().CStorVolumeReplicas(ut.test.ObjectMeta.Namespace).Create(context.TODO(), ut.test, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Desc:%v, Unable to create resource : %v", desc, ut.test.ObjectMeta.Name)
}
// Get volume replica resource with name
cStorVolumeReplicaObtained, err := volumeReplicaController.getVolumeReplicaResource(ut.test.ObjectMeta.Namespace + "/" + ut.test.ObjectMeta.Name)
if err != nil {
t.Fatalf("Desc:%v, Unable to get resource : %v", desc, ut.test.ObjectMeta.Name)
}
if cStorVolumeReplicaObtained.Name != ut.expectedName {
t.Fatalf("Desc:%v, volName mismatch, Expected:%v, Got:%v", desc, ut.expectedName,
cStorVolumeReplicaObtained.Name)
}
}
} | explode_data.jsonl/61359 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 851
} | [
2830,
3393,
1949,
18902,
18327,
15317,
4783,
1155,
353,
8840,
836,
8,
341,
1166,
726,
42,
3760,
2959,
1669,
12418,
7121,
16374,
2959,
746,
741,
1166,
726,
7125,
1952,
1279,
2959,
1669,
1787,
68,
1279,
52317,
2959,
746,
7121,
16374,
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... | 5 |
func TestSizeEdgeAlignedFitTopEdge(t *testing.T) {
outer := CreateRect(0, 0, 100, 100)
s := Size{10, 10}
p := Point{50, 50}
test.AssertEquals(t, CreateRect(45, 50, 55, 60), s.EdgeAlignedFit(outer, p))
} | explode_data.jsonl/12902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
1695,
11656,
93305,
23346,
5366,
11656,
1155,
353,
8840,
836,
8,
341,
197,
2676,
1669,
4230,
4415,
7,
15,
11,
220,
15,
11,
220,
16,
15,
15,
11,
220,
16,
15,
15,
340,
1903,
1669,
8478,
90,
16,
15,
11,
220,
16,
15,
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 TestPrintPodTemplate(t *testing.T) {
tests := []struct {
podTemplate api.PodTemplate
options printers.GenerateOptions
expected []metav1.TableRow
}{
// Test basic pod template with no containers.
{
podTemplate: api.PodTemplate{
ObjectMeta: metav1.ObjectMeta{Name: "pod-template-1"},
Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "pod-template-1"},
Spec: api.PodSpec{
Containers: []api.Container{},
},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Containers, Images, Pod Labels
expected: []metav1.TableRow{{Cells: []interface{}{"pod-template-1", "", "", "<none>"}}},
},
// Test basic pod template with two containers.
{
podTemplate: api.PodTemplate{
ObjectMeta: metav1.ObjectMeta{Name: "pod-template-2"},
Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Name: "pod-template-2"},
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "fake-container1",
Image: "fake-image1",
},
{
Name: "fake-container2",
Image: "fake-image2",
},
},
},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Containers, Images, Pod Labels
expected: []metav1.TableRow{{Cells: []interface{}{"pod-template-2", "fake-container1,fake-container2", "fake-image1,fake-image2", "<none>"}}},
},
// Test basic pod template with pod labels
{
podTemplate: api.PodTemplate{
ObjectMeta: metav1.ObjectMeta{Name: "pod-template-3"},
Template: api.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-template-3",
Labels: map[string]string{"foo": "bar"},
},
Spec: api.PodSpec{
Containers: []api.Container{},
},
},
},
options: printers.GenerateOptions{},
// Columns: Name, Containers, Images, Pod Labels
expected: []metav1.TableRow{{Cells: []interface{}{"pod-template-3", "", "", "foo=bar"}}},
},
}
for i, test := range tests {
rows, err := printPodTemplate(&test.podTemplate, test.options)
if err != nil {
t.Fatal(err)
}
for i := range rows {
rows[i].Object.Object = nil
}
if !reflect.DeepEqual(test.expected, rows) {
t.Errorf("%d mismatch: %s", i, diff.ObjectReflectDiff(test.expected, rows))
}
}
} | explode_data.jsonl/21602 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 995
} | [
2830,
3393,
8994,
23527,
7275,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
3223,
347,
7275,
6330,
88823,
7275,
198,
197,
35500,
257,
55953,
57582,
3798,
198,
197,
42400,
262,
3056,
4059,
402,
16,
18257,
3102,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGitCommandCommitAmend(t *testing.T) {
gitCmd := newDummyGitCommand()
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
assert.EqualValues(t, "git", cmd)
assert.EqualValues(t, []string{"commit", "--amend", "--allow-empty"}, args)
return exec.Command("echo")
}
_, err := gitCmd.PrepareCommitAmendSubProcess().CombinedOutput()
assert.NoError(t, err)
} | explode_data.jsonl/38359 | {
"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,
46562,
4062,
33441,
6091,
408,
1155,
353,
8840,
836,
8,
341,
90731,
15613,
1669,
501,
43344,
46562,
4062,
741,
90731,
15613,
57054,
4062,
14143,
284,
2915,
14160,
914,
11,
2827,
2503,
917,
8,
353,
11748,
64512,
341,
197,
694... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAESSIVDoesSupport(t *testing.T) {
km, err := registry.GetKeyManager(testutil.AESSIVTypeURL)
if err != nil {
t.Errorf("cannot obtain AESSIV key manager: %s", err)
}
if !km.DoesSupport(testutil.AESSIVTypeURL) {
t.Errorf("AESSIVKeyManager must support %s", testutil.AESSIVTypeURL)
}
if km.DoesSupport("some bad type") {
t.Errorf("AESSIVKeyManager must only support %s", testutil.AESSIVTypeURL)
}
} | explode_data.jsonl/58687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
32,
9996,
3090,
21468,
7916,
1155,
353,
8840,
836,
8,
341,
197,
16017,
11,
1848,
1669,
19424,
51723,
2043,
8623,
1314,
875,
9996,
3090,
929,
3144,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
33260,
6851,
362,
99... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGrantSingleChannel(t *testing.T) {
assert := assert.New(t)
interceptor := stubs.NewInterceptor()
interceptor.AddStub(&stubs.Stub{
Method: "GET",
Path: fmt.Sprintf("/v2/auth/grant/sub-key/%s", pamConfig.SubscribeKey),
Query: "channel=ch1&m=0&r=1&w=1&d=0",
ResponseBody: `{"message":"Success","payload":{"level":"channel","subscribe_key":"sub-c-b9ab9508-43cf-11e8-9967-869954283fb4","ttl":1440,"channels":{"ch1":{"r":1,"w":1,"m":0,"d":0}}},"service":"Access Manager","status":200}`,
IgnoreQueryKeys: []string{"uuid", "pnsdk", "signature", "timestamp"},
ResponseStatusCode: 200,
})
pn := pubnub.NewPubNub(pamConfigCopy())
pn.SetClient(interceptor.GetClient())
if enableDebuggingInTests {
pn.Config.Log = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)
}
res, _, err := pn.Grant().
Read(true).Write(true).
Channels([]string{"ch1"}).
Execute()
assert.Nil(err)
assert.NotNil(res)
assert.True(res.Channels["ch1"].WriteEnabled)
assert.True(res.Channels["ch1"].ReadEnabled)
assert.False(res.Channels["ch1"].ManageEnabled)
} | explode_data.jsonl/43191 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
67971,
10888,
9629,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
58915,
15349,
1669,
13633,
82,
7121,
32786,
741,
58915,
15349,
1904,
33838,
2099,
267,
15738,
7758,
392,
515,
197,
84589,
25,
1797,
330,
38... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSchemaReadInvalidName(t *testing.T) {
conn, cleanup, _ := testserver.NewTestServer(require.New(t), 0, memdb.DisableGC, 0, false, testfixtures.EmptyDatastore)
t.Cleanup(cleanup)
client := v1alpha1.NewSchemaServiceClient(conn)
_, err := client.ReadSchema(context.Background(), &v1alpha1.ReadSchemaRequest{
ObjectDefinitionsNames: []string{"θͺ€γ"},
})
grpcutil.RequireStatus(t, codes.InvalidArgument, err)
} | explode_data.jsonl/54543 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
8632,
4418,
7928,
675,
1155,
353,
8840,
836,
8,
341,
32917,
11,
21290,
11,
716,
1669,
1273,
4030,
7121,
2271,
5475,
23482,
7121,
1155,
701,
220,
15,
11,
1833,
1999,
10166,
480,
22863,
11,
220,
15,
11,
895,
11,
1273,
4524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNew_Send(t *testing.T) {
s, c := conn.TestPair()
defer s.Close()
defer c.Close()
recv := make(chan Message)
w := New("wizard", attr.Attr{Blood: 10}, c, codec.JsonCodec(), recv)
wg := &sync.WaitGroup{}
wg.Add(2)
go func() {
defer wg.Done()
data, err := s.Read()
if err != nil {
t.Error(err)
return
}
m, err := codec.JsonCodec().Decode(data)
if err != nil {
t.Error(err)
return
}
if m == nil {
t.Error("expect not nil got nil")
return
}
if m, ok := m.(*msg.Chat); !ok {
t.Error("expect *msg.Chat got", reflect.TypeOf(m))
return
} else {
if m.Text != "hello wizard!" {
t.Error("expect hello wizard! got", m.Text)
return
}
}
}()
go func() {
defer wg.Done()
w.Send(&msg.Chat{Text: "hello wizard!"})
}()
wg.Wait()
} | explode_data.jsonl/67898 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
3564,
46267,
1155,
353,
8840,
836,
8,
341,
1903,
11,
272,
1669,
4534,
8787,
12443,
741,
16867,
274,
10421,
741,
16867,
272,
10421,
2822,
197,
33977,
1669,
1281,
35190,
4856,
340,
6692,
1669,
1532,
445,
58593,
497,
6376,
1554... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetIcon(t *testing.T) {
req, err := http.NewRequest("GET", "/icon?url=apple.com&size=120", nil)
if err != nil {
log.Fatal(err)
}
w := httptest.NewRecorder()
iconHandler(w, req)
assertStringEquals(t, "302", fmt.Sprintf("%d", w.Code))
assertStringEquals(t, "max-age=86400", w.Header().Get("Cache-Control"))
assertStringEquals(t, "https://www.apple.com/apple-touch-icon.png", w.Header().Get("Location"))
} | explode_data.jsonl/25590 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
1949,
4395,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
3521,
1924,
94399,
28,
22377,
905,
5,
2141,
28,
16,
17,
15,
497,
2092,
340,
743,
1848,
961,
2092,
341,
197,
6725,
26133,
3964,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewPeerServer(t *testing.T) {
server, err := NewPeerServer(":4050", comm.ServerConfig{})
assert.NoError(t, err, "NewPeerServer returned unexpected error")
assert.Equal(t, "[::]:4050", server.Address(), "NewPeerServer returned the wrong address")
server.Stop()
_, err = NewPeerServer("", comm.ServerConfig{})
assert.Error(t, err, "expected NewPeerServer to return error with missing address")
} | explode_data.jsonl/56825 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 133
} | [
2830,
3393,
3564,
30888,
5475,
1155,
353,
8840,
836,
8,
341,
41057,
11,
1848,
1669,
1532,
30888,
5475,
18893,
19,
15,
20,
15,
497,
1063,
22997,
2648,
37790,
6948,
35699,
1155,
11,
1848,
11,
330,
3564,
30888,
5475,
5927,
16500,
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... | 1 |
func TestGet(t *testing.T) {
dep, err := generateDeployment()
if err != nil {
t.Fatal(err)
}
req := api.GetMessageRequest{Mailbox: dep.Mailbox.Id}
req.Sign(dep.AccessKey.Name, dep.AccessKey.Secret)
var resp api.GetMessageResponse
doRequest(t, req, &resp, "get")
if resp.Body != dep.Message.Body {
t.Fatalf("Message body TEST!=%s", dep.Message.Body)
}
if resp.ReceiveCount != 1 {
t.Fatal("Message receiveCount is not 1")
}
doRequest(t, req, &resp, "get")
if resp.ReceiveCount != 2 {
t.Fatal("Message receiveCount did not increase to 2 on second call")
}
} | explode_data.jsonl/15709 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
1949,
1155,
353,
8840,
836,
8,
341,
197,
14891,
11,
1848,
1669,
6923,
75286,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
24395,
1669,
6330,
2234,
2052,
1900,
90,
16702,
2011,
25,
2170,
73103,
201... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRangeStatsInit(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
stopper := stop.NewStopper()
defer stopper.Stop(context.TODO())
tc.Start(t, stopper)
ms := enginepb.MVCCStats{
LiveBytes: 1,
KeyBytes: 2,
ValBytes: 3,
IntentBytes: 4,
LiveCount: 5,
KeyCount: 6,
ValCount: 7,
IntentCount: 8,
IntentAge: 9,
GCBytesAge: 10,
LastUpdateNanos: 11,
}
if err := engine.MVCCSetRangeStats(context.Background(), tc.engine, 1, &ms); err != nil {
t.Fatal(err)
}
loadMS, err := engine.MVCCGetRangeStats(context.Background(), tc.engine, tc.repl.RangeID)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(ms, loadMS) {
t.Errorf("mvcc stats mismatch %+v != %+v", ms, loadMS)
}
} | explode_data.jsonl/25279 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 383
} | [
2830,
3393,
6046,
16635,
3803,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
78255,
1669,
1273,
1972,
16094,
62644,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
2936,
712,
30213,
5378,
90988,
2398,
78255,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateLeaderIP(t *testing.T) {
le := &fakeLeaderEngine{}
h := &Handler{
leadershipChan: make(chan state, 1),
leaderStatusCallback: le.get,
}
// First run, become leader
le.set("", nil)
err := h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "", h.leaderIP)
h.assertLeadershipMessage(t, leader)
// Second run, still leader, no update
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "", h.leaderIP)
h.assertNoLeadershipMessage(t)
// Query error
queryError := errors.New("test query error")
le.set("1.2.3.4", queryError)
err = h.updateLeaderIP()
assert.Equal(t, queryError, err)
assert.Equal(t, "", h.leaderIP)
h.assertNoLeadershipMessage(t)
// Lose leadership
le.set("1.2.3.4", nil)
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "1.2.3.4", h.leaderIP)
h.assertLeadershipMessage(t, follower)
// New leader, still following
le.set("1.2.3.40", nil)
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "1.2.3.40", h.leaderIP)
h.assertNoLeadershipMessage(t)
// Back to leader
le.set("", nil)
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "", h.leaderIP)
h.assertLeadershipMessage(t, leader)
// Start fresh, test unknown -> follower
le = &fakeLeaderEngine{}
h = &Handler{
leadershipChan: make(chan state, 1),
leaderStatusCallback: le.get,
}
le.set("1.2.3.4", nil)
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "1.2.3.4", h.leaderIP)
h.assertLeadershipMessage(t, follower)
// Start fresh, test unknown -> unknown -> leader
le = &fakeLeaderEngine{}
h = &Handler{
leadershipChan: make(chan state, 1),
leaderStatusCallback: le.get,
}
le.set("", errors.New("failing"))
for i := 0; i < 4; i++ {
err = h.updateLeaderIP()
assert.Error(t, err)
assert.Equal(t, "", h.leaderIP)
assert.Equal(t, unknown, h.state)
h.assertNoLeadershipMessage(t)
}
le.set("", nil)
err = h.updateLeaderIP()
assert.NoError(t, err)
assert.Equal(t, "", h.leaderIP)
assert.Equal(t, leader, h.state)
h.assertLeadershipMessage(t, leader)
} | explode_data.jsonl/17097 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 873
} | [
2830,
3393,
4289,
52621,
3298,
1155,
353,
8840,
836,
8,
341,
197,
273,
1669,
609,
30570,
52621,
4571,
16094,
9598,
1669,
609,
3050,
515,
197,
197,
78386,
2151,
46019,
25,
981,
1281,
35190,
1584,
11,
220,
16,
1326,
197,
197,
37391,
252... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPareLineErrors(t *testing.T) {
for _, tc := range []struct {
id string
line string
expectedErr string
}{
{
id: "empty line okay",
line: " # gibberish range: ",
expectedErr: "",
},
{
id: "Not enough fields",
line: "blurg",
expectedErr: "Line 0: Missing values",
},
{
id: "Invalid prefix",
line: "blurg:",
expectedErr: "Line 0: Invalid prefix \"blurg\"",
},
{
id: "Missing path",
line: "PATHGLOB:",
expectedErr: "Line 0: Must specify path",
},
{
id: "Multiple paths",
line: "PaTHGLOB:a:b",
expectedErr: "Line 0: Using multiple path values is invalid",
},
{
id: "Incomplete range",
line: "rANgE:0",
expectedErr: "Line 0: Range lines must have two values",
},
{
id: "Overspecified range",
line: "rANgE:0:b:z",
expectedErr: "Line 0: Range lines must have two values",
},
} {
t.Logf("Testing case %q", tc.id)
p := parser{line: tc.line, fieldSep: ":"}
err := p.parseLine()
if err == nil {
if tc.expectedErr != "" {
t.Fatalf("Expected error %q, got nil", tc.expectedErr)
}
} else {
if err.Error() != tc.expectedErr {
t.Fatalf("Expected error %q, got %q", tc.expectedErr, err)
}
}
}
} | explode_data.jsonl/54251 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 688
} | [
2830,
3393,
47,
546,
2460,
13877,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
15710,
688,
914,
198,
197,
27109,
286,
914,
198,
197,
42400,
7747,
914,
198,
197,
59403,
197,
197,
515,
298,
15710,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReceiverExistsForDeepSubRoute(t *testing.T) {
in := `
route:
receiver: team-X
routes:
- match:
foo: bar
routes:
- match:
foo: bar
receiver: nonexistent
receivers:
- name: 'team-X'
`
_, err := Load(in)
expected := "undefined receiver \"nonexistent\" used in route"
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/72896 | {
"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,
25436,
15575,
2461,
33464,
3136,
4899,
1155,
353,
8840,
836,
8,
341,
17430,
1669,
22074,
8966,
510,
262,
13964,
25,
2083,
30550,
198,
262,
11291,
510,
414,
481,
2432,
510,
688,
15229,
25,
3619,
198,
286,
11291,
510,
286,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddNodeIDToDimensionReturnsOK(t *testing.T) {
t.Parallel()
Convey("Given a dataset API with a successful store mock and auth", t, func() {
mockedDataStore, isLocked := storeMockWithLock(true)
mockedDataStore.UpdateETagForOptionsFunc = func(ctx context.Context, currentInstance *models.Instance, upserts []*models.CachedDimensionOption, updates []*models.DimensionOption, eTagSelector string) (string, error) {
So(*isLocked, ShouldBeTrue)
return testETag, nil
}
mockedDataStore.UpdateDimensionsNodeIDAndOrderFunc = func(ctx context.Context, dimensions []*models.DimensionOption) error {
So(*isLocked, ShouldBeTrue)
return nil
}
datasetAPI := getAPIWithCMDMocks(testContext, mockedDataStore, &mocks.DownloadsGeneratorMock{})
Convey("When a PUT request to update the nodeID for an option is made, with a valid If-Match header", func() {
r, err := createRequestWithToken("PUT", "http://localhost:21800/instances/123/dimensions/age/options/55/node_id/11", nil)
r.Header.Add("If-Match", testIfMatch)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
datasetAPI.Router.ServeHTTP(w, r)
Convey("Then the response status is 200 OK, with the expected ETag header", func() {
So(w.Code, ShouldEqual, http.StatusOK)
So(w.Header().Get("ETag"), ShouldEqual, testETag)
})
Convey("Then the expected functions are called", func() {
validateDimensionUpdates(mockedDataStore, []*models.DimensionOption{
{
InstanceID: "123",
Name: "age",
NodeID: "11",
Option: "55",
Order: nil,
},
}, testIfMatch)
})
Convey("Then the db lock is acquired and released as expected", func() {
validateLock(mockedDataStore, "123")
So(*isLocked, ShouldBeFalse)
})
})
Convey("When a PUT request to update the nodeID for an option is made, without an If-Match header", func() {
r, err := createRequestWithToken("PUT", "http://localhost:21800/instances/123/dimensions/age/options/55/node_id/11", nil)
So(err, ShouldBeNil)
w := httptest.NewRecorder()
datasetAPI.Router.ServeHTTP(w, r)
Convey("Then the response status is 200 OK, with the expected ETag header", func() {
So(w.Code, ShouldEqual, http.StatusOK)
So(w.Header().Get("ETag"), ShouldEqual, testETag)
})
Convey("Then the expected functions are called, with the '*' wildchar when validting the provided If-Match value", func() {
validateDimensionUpdates(mockedDataStore, []*models.DimensionOption{
{
InstanceID: "123",
Name: "age",
NodeID: "11",
Option: "55",
Order: nil,
},
}, AnyETag)
})
Convey("Then the db lock is acquired and released as expected", func() {
validateLock(mockedDataStore, "123")
So(*isLocked, ShouldBeFalse)
})
})
})
} | explode_data.jsonl/20823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1117
} | [
2830,
3393,
2212,
1955,
915,
1249,
26121,
16446,
3925,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
93070,
5617,
445,
22043,
264,
10337,
5333,
448,
264,
6849,
3553,
7860,
323,
4166,
497,
259,
11,
2915,
368,
341,
197,
2109,
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,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNilStringMap(t *testing.T) {
assert.EqualValues(t, 0, NewStringMap().Len())
val, exist := NewStringMap().Get("test_key")
assert.False(t, exist)
assert.EqualValues(t, StringValue{nil}, val)
insertMap := NewStringMap()
insertMap.Insert("k", "v")
assert.EqualValues(t, generateTestStringMap(), insertMap)
updateMap := NewStringMap()
updateMap.Update("k", "v")
assert.EqualValues(t, NewStringMap(), updateMap)
upsertMap := NewStringMap()
upsertMap.Upsert("k", "v")
assert.EqualValues(t, generateTestStringMap(), upsertMap)
deleteMap := NewStringMap()
assert.False(t, deleteMap.Delete("k"))
assert.EqualValues(t, NewStringMap(), deleteMap)
// Test Sort
assert.EqualValues(t, NewStringMap(), NewStringMap().Sort())
} | explode_data.jsonl/38205 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
19064,
703,
2227,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
6227,
1155,
11,
220,
15,
11,
1532,
703,
2227,
1005,
11271,
12367,
19302,
11,
3000,
1669,
1532,
703,
2227,
1005,
1949,
445,
1944,
3097,
1138,
6948,
50757,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUpdateUserPassword(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()
Client := th.Client
password := "newpassword1"
pass, resp := Client.UpdateUserPassword(th.BasicUser.Id, th.BasicUser.Password, password)
CheckNoError(t, resp)
if !pass {
t.Fatal("should have returned true")
}
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, password, "")
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, password, "junk")
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword("junk", password, password)
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, "", password)
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, "junk", password)
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, password, th.BasicUser.Password)
CheckNoError(t, resp)
Client.Logout()
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, password, password)
CheckUnauthorizedStatus(t, resp)
th.LoginBasic2()
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, password, password)
CheckForbiddenStatus(t, resp)
th.LoginBasic()
// Test lockout
passwordAttempts := utils.Cfg.ServiceSettings.MaximumLoginAttempts
defer func() {
utils.Cfg.ServiceSettings.MaximumLoginAttempts = passwordAttempts
}()
utils.Cfg.ServiceSettings.MaximumLoginAttempts = 2
// Fail twice
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, "badpwd", "newpwd")
CheckBadRequestStatus(t, resp)
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, "badpwd", "newpwd")
CheckBadRequestStatus(t, resp)
// Should fail because account is locked out
_, resp = Client.UpdateUserPassword(th.BasicUser.Id, th.BasicUser.Password, "newpwd")
CheckErrorMessage(t, resp, "api.user.check_user_login_attempts.too_many.app_error")
CheckForbiddenStatus(t, resp)
// System admin can update another user's password
adminSetPassword := "pwdsetbyadmin"
pass, resp = th.SystemAdminClient.UpdateUserPassword(th.BasicUser.Id, "", adminSetPassword)
CheckNoError(t, resp)
if !pass {
t.Fatal("should have returned true")
}
_, resp = Client.Login(th.BasicUser.Email, adminSetPassword)
CheckNoError(t, resp)
} | explode_data.jsonl/49502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 763
} | [
2830,
3393,
4289,
1474,
4876,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
76982,
4454,
741,
71724,
1669,
270,
11716,
271,
58199,
1669,
330,
931,
3833,
16,
698,
41431,
11,
9039... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBeginEndMatcher_Match(t *testing.T) {
t.Helper()
var test = func(expect bool, value string, prefixes []string) {
t.Helper()
var matcher = NewBeginEndMatcher(prefixes)
var got = matcher.Match(value)
if expect != got {
t.Errorf("expect %t, got %t", expect, got)
}
}
test(false, "", nil)
test(false, "abc", nil)
test(false, "abc", []string{"abc1", "abc2"})
// * = 1+ chars
test(false, "abc", []string{"*abc", "abc1", "abc2"})
test(false, "abc", []string{"abc*", "abc1", "abc2"})
test(true, "abc", []string{"*bc", "nnn1", "nnn2"})
test(true, "abc", []string{"*c", "nnn1", "nnn2"})
test(true, "abc", []string{"a*", "nnn1", "nnn2"})
test(true, "abc", []string{"ab*", "nnn1", "nnn2"})
} | explode_data.jsonl/73257 | {
"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,
11135,
3727,
37554,
1245,
754,
1155,
353,
8840,
836,
8,
341,
3244,
69282,
2822,
2405,
1273,
284,
2915,
89443,
1807,
11,
897,
914,
11,
62576,
3056,
917,
8,
341,
197,
3244,
69282,
2822,
197,
2405,
36052,
284,
1532,
11135,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateMetricsReceiver(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.Brokers = []string{"invalid:9092"}
cfg.ProtocolVersion = "2.0.0"
f := kafkaReceiverFactory{metricsUnmarshalers: defaultMetricsUnmarshalers()}
r, err := f.createMetricsReceiver(context.Background(), componenttest.NewNopReceiverCreateSettings(), cfg, nil)
// no available broker
require.Error(t, err)
assert.Nil(t, r)
} | explode_data.jsonl/70856 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
4021,
27328,
25436,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
1855,
3675,
2648,
1005,
4071,
2648,
340,
50286,
1785,
299,
26177,
284,
3056,
917,
4913,
11808,
25,
24,
15,
24,
17,
16707,
50286,
54096,
5637,
284,
330,
17,
13,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUintJsonUnmarshalInvalid(t *testing.T) {
u := Uint{}
if err := u.UnmarshalJSON([]byte(`"0`)); err == nil {
t.Errorf("Expected error when json.Unmarshal, but not; %#v", u)
}
} | explode_data.jsonl/13389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
21570,
5014,
1806,
27121,
7928,
1155,
353,
8840,
836,
8,
341,
10676,
1669,
27883,
16094,
743,
1848,
1669,
575,
38097,
5370,
10556,
3782,
5809,
1,
15,
63,
5905,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
18896,
1465,
979,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func Test_LogLevel(t *testing.T) {
logLevel := "warn"
fixtureHandler := func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
var ll LogLevel
if err := json.NewDecoder(r.Body).Decode(&ll); err != nil {
t.Logf("could not decode json: %v\n", err)
t.FailNow()
}
logLevel = ll.Level
}
fmt.Fprintf(w, `{
"log-level": "%s"
}`, logLevel)
}
ts := httptest.NewServer(http.HandlerFunc(fixtureHandler))
defer ts.Close()
client := NewClient(ts.URL, http.DefaultClient)
curLvl, err := client.LogLevel()
if err != nil {
t.Logf("could not get current log level: %v", err)
t.FailNow()
}
if !strings.EqualFold(curLvl.Level, logLevel) {
t.Logf("log level is not correct\n\tExpected: %s\n\t Got: %s\n", logLevel, curLvl.Level)
t.FailNow()
}
newLvl, err := client.SetLogLevel(&LogLevel{Level: "trace"})
if err != nil {
t.Logf("could not set log level: %v", err)
t.FailNow()
}
if !strings.EqualFold(newLvl.Level, logLevel) {
t.Logf("log level is not correct\n\tExpected: %s\n\t Got: %s\n", logLevel, newLvl.Level)
t.FailNow()
}
} | explode_data.jsonl/66142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 489
} | [
2830,
3393,
44083,
4449,
1155,
353,
8840,
836,
8,
341,
6725,
4449,
1669,
330,
33481,
698,
1166,
12735,
3050,
1669,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
621,
1758,
20798,
4133,
341,
298,
2405... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTidbClusterControllerSync(t *testing.T) {
g := NewGomegaWithT(t)
type testcase struct {
name string
addTcToIndexer bool
errWhenUpdateTidbCluster bool
errExpectFn func(*GomegaWithT, error)
}
testFn := func(test *testcase, t *testing.T) {
t.Log(test.name)
tc := newTidbCluster()
tcc, tcIndexer, tcControl := newFakeTidbClusterController()
if test.addTcToIndexer {
err := tcIndexer.Add(tc)
g.Expect(err).NotTo(HaveOccurred())
}
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(tc)
g.Expect(err).NotTo(HaveOccurred())
if test.errWhenUpdateTidbCluster {
tcControl.SetUpdateTCError(fmt.Errorf("update tidb cluster failed"))
}
err = tcc.sync(key)
if test.errExpectFn != nil {
test.errExpectFn(g, err)
}
}
tests := []testcase{
{
name: "normal",
addTcToIndexer: true,
errWhenUpdateTidbCluster: false,
errExpectFn: func(g *GomegaWithT, err error) {
g.Expect(err).NotTo(HaveOccurred())
},
},
{
name: "can't found tidb cluster",
addTcToIndexer: false,
errWhenUpdateTidbCluster: false,
errExpectFn: func(g *GomegaWithT, err error) {
g.Expect(err).NotTo(HaveOccurred())
},
},
{
name: "update tidb cluster failed",
addTcToIndexer: true,
errWhenUpdateTidbCluster: true,
errExpectFn: func(g *GomegaWithT, err error) {
g.Expect(err).To(HaveOccurred())
g.Expect(strings.Contains(err.Error(), "update tidb cluster failed")).To(Equal(true))
},
},
}
for i := range tests {
testFn(&tests[i], t)
}
} | explode_data.jsonl/68176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 823
} | [
2830,
3393,
51,
307,
65,
28678,
2051,
12154,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
340,
13158,
70080,
2036,
341,
197,
11609,
3824,
914,
198,
197,
12718,
51,
66,
1249,
1552,
261,
1843,
1807,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDirectModeHandler(t *testing.T) {
privKey, pubkey, addr := testdata.KeyTestPubAddr()
interfaceRegistry := codectypes.NewInterfaceRegistry()
interfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), &testdata.TestMsg{})
marshaler := codec.NewProtoCodec(interfaceRegistry)
txConfig := NewTxConfig(marshaler, []signingtypes.SignMode{signingtypes.SignMode_SIGN_MODE_DIRECT})
txBuilder := txConfig.NewTxBuilder()
memo := "sometestmemo"
msgs := []sdk.Msg{testdata.NewTestMsg(addr)}
accSeq := uint64(2) // Arbitrary account sequence
any, err := codectypes.NewAnyWithValue(pubkey)
require.NoError(t, err)
var signerInfo []*txtypes.SignerInfo
signerInfo = append(signerInfo, &txtypes.SignerInfo{
PublicKey: any,
ModeInfo: &txtypes.ModeInfo{
Sum: &txtypes.ModeInfo_Single_{
Single: &txtypes.ModeInfo_Single{
Mode: signingtypes.SignMode_SIGN_MODE_DIRECT,
},
},
},
Sequence: accSeq,
})
sigData := &signingtypes.SingleSignatureData{
SignMode: signingtypes.SignMode_SIGN_MODE_DIRECT,
}
sig := signingtypes.SignatureV2{
PubKey: pubkey,
Data: sigData,
Sequence: accSeq,
}
fee := txtypes.Fee{Amount: sdk.NewCoins(sdk.NewInt64Coin("atom", 150)), GasLimit: 20000}
err = txBuilder.SetMsgs(msgs...)
require.NoError(t, err)
txBuilder.SetMemo(memo)
txBuilder.SetFeeAmount(fee.Amount)
txBuilder.SetGasLimit(fee.GasLimit)
err = txBuilder.SetSignatures(sig)
require.NoError(t, err)
t.Log("verify modes and default-mode")
modeHandler := txConfig.SignModeHandler()
require.Equal(t, modeHandler.DefaultMode(), signingtypes.SignMode_SIGN_MODE_DIRECT)
require.Len(t, modeHandler.Modes(), 1)
signingData := signing.SignerData{
ChainID: "test-chain",
AccountNumber: 1,
}
signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())
require.NoError(t, err)
require.NotNil(t, signBytes)
authInfo := &txtypes.AuthInfo{
Fee: &fee,
SignerInfos: signerInfo,
}
authInfoBytes := marshaler.MustMarshal(authInfo)
anys := make([]*codectypes.Any, len(msgs))
for i, msg := range msgs {
var err error
anys[i], err = codectypes.NewAnyWithValue(msg)
if err != nil {
panic(err)
}
}
txBody := &txtypes.TxBody{
Memo: memo,
Messages: anys,
}
bodyBytes := marshaler.MustMarshal(txBody)
t.Log("verify GetSignBytes with generating sign bytes by marshaling SignDoc")
signDoc := txtypes.SignDoc{
AccountNumber: 1,
AuthInfoBytes: authInfoBytes,
BodyBytes: bodyBytes,
ChainId: "test-chain",
}
expectedSignBytes, err := signDoc.Marshal()
require.NoError(t, err)
require.Equal(t, expectedSignBytes, signBytes)
t.Log("verify that setting signature doesn't change sign bytes")
sigData.Signature, err = privKey.Sign(signBytes)
require.NoError(t, err)
err = txBuilder.SetSignatures(sig)
require.NoError(t, err)
signBytes, err = modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx())
require.NoError(t, err)
require.Equal(t, expectedSignBytes, signBytes)
t.Log("verify GetSignBytes with false txBody data")
signDoc.BodyBytes = []byte("dfafdasfds")
expectedSignBytes, err = signDoc.Marshal()
require.NoError(t, err)
require.NotEqual(t, expectedSignBytes, signBytes)
} | explode_data.jsonl/38085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1270
} | [
2830,
3393,
16027,
3636,
3050,
1155,
353,
8840,
836,
8,
341,
71170,
1592,
11,
95116,
11,
10789,
1669,
1273,
691,
9610,
2271,
29162,
13986,
741,
58915,
1564,
15603,
1669,
20329,
439,
1804,
7121,
5051,
15603,
741,
58915,
1564,
15603,
19983,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMuxMatch(t *testing.T) {
r := NewRouter()
r.Get("/hi", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Test", "yes")
w.Write([]byte("bye"))
})
r.Route("/articles", func(r Router) {
r.Get("/{id}", func(w http.ResponseWriter, r *http.Request) {
id := URLParam(r, "id")
w.Header().Set("X-Article", id)
w.Write([]byte("article:" + id))
})
})
r.Route("/users", func(r Router) {
r.Head("/{id}", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-User", "-")
w.Write([]byte("user"))
})
r.Get("/{id}", func(w http.ResponseWriter, r *http.Request) {
id := URLParam(r, "id")
w.Header().Set("X-User", id)
w.Write([]byte("user:" + id))
})
})
tctx := NewRouteContext()
tctx.Reset()
if r.Match(tctx, "GET", "/users/1") == false {
t.Fatal("expecting to find match for route:", "GET", "/users/1")
}
tctx.Reset()
if r.Match(tctx, "HEAD", "/articles/10") == true {
t.Fatal("not expecting to find match for route:", "HEAD", "/articles/10")
}
} | explode_data.jsonl/42895 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 451
} | [
2830,
3393,
44,
2200,
8331,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
9523,
741,
7000,
2234,
4283,
6023,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
6692,
15753,
1005,
1649,
445,
55,
12,
2271,
497,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMSSQLIssue5(t *testing.T) {
testingIssue5 = true
defer func() {
testingIssue5 = false
}()
db, sc, err := mssqlConnect()
if err != nil {
t.Fatal(err)
}
const nworkers = 8
defer closeDB(t, db, sc, sc)
db.Exec("drop table dbo.temp")
exec(t, db, `
create table dbo.temp (
id int,
value int,
constraint [pk_id] primary key ([id])
)
`)
var count int32
runCycle := func(waitch <-chan struct{}, errch chan<- error) (reterr error) {
defer func() {
errch <- reterr
}()
stmt, err := db.Prepare("insert into dbo.temp (id, value) values (?, ?)")
if err != nil {
return fmt.Errorf("Prepare failed: %v", err)
}
defer stmt.Close()
errch <- nil
<-waitch
for {
i := (int)(atomic.AddInt32(&count, 1))
_, err := stmt.Exec(i, i)
if err != nil {
return fmt.Errorf("Exec failed i=%d: %v", i, err)
}
runtime.GC()
if i >= 100 {
break
}
}
return
}
waitch := make(chan struct{})
errch := make(chan error, nworkers)
for i := 0; i < nworkers; i++ {
go runCycle(waitch, errch)
}
for i := 0; i < nworkers; i++ {
if err := <-errch; err != nil {
t.Error(err)
}
}
if t.Failed() {
return
}
close(waitch)
for i := 0; i < nworkers; i++ {
if err := <-errch; err != nil {
t.Fatal(err)
}
}
// TODO: maybe I should verify dbo.temp records here
exec(t, db, "drop table dbo.temp")
} | explode_data.jsonl/33551 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 635
} | [
2830,
3393,
44,
1220,
3588,
42006,
20,
1155,
353,
8840,
836,
8,
341,
197,
8840,
42006,
20,
284,
830,
198,
16867,
2915,
368,
341,
197,
197,
8840,
42006,
20,
284,
895,
198,
197,
69826,
20939,
11,
1136,
11,
1848,
1669,
296,
79713,
1461... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerInitialization(t *testing.T) {
controller, r := newTestController("", "")
// Initialize should create the registration entry for the cluster nodes
require.NoError(t, controller.Initialize(context.Background()))
requireEntriesEqual(t, []*types.Entry{
{
Id: "00000001",
ParentId: mustIDFromString("spiffe://domain.test/spire/server"),
SpiffeId: mustIDFromString("spiffe://domain.test/k8s-workload-registrar/CLUSTER/node"),
Selectors: []*types.Selector{
{Type: "k8s_psat", Value: "cluster:CLUSTER"},
},
},
}, r.GetEntries())
} | explode_data.jsonl/32147 | {
"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,
2051,
61928,
1155,
353,
8840,
836,
8,
341,
61615,
11,
435,
1669,
501,
2271,
2051,
19814,
85617,
197,
322,
9008,
1265,
1855,
279,
12227,
4343,
369,
279,
10652,
7798,
198,
17957,
35699,
1155,
11,
6461,
45829,
5378,
19047,
1214... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadConfigFromUrl_Corrupted(t *testing.T) {
fileName, _, _ := toolbox.CallerInfo(2)
basePath := path.Dir(fileName)
url := toolbox.FileSchema + path.Join(basePath, "test", "corrupted_config.json")
config := &TestConfig{}
err := toolbox.LoadConfigFromUrl(url, config)
assert.NotNil(t, err)
} | explode_data.jsonl/72333 | {
"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,
5879,
2648,
3830,
2864,
920,
269,
85954,
1155,
353,
8840,
836,
8,
1476,
17661,
675,
11,
8358,
716,
1669,
67870,
727,
13956,
1731,
7,
17,
340,
24195,
1820,
1669,
1815,
83757,
23014,
340,
19320,
1669,
67870,
8576,
8632,
488,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllocateErrorAndRecovery(t *testing.T) {
defer leaktest.AfterTest(t)
store, _, stopper := createTestStore(t)
defer stopper.Stop()
allocd := make(chan int, 10)
// Firstly create a valid IDAllocator to get some ID.
idAlloc, err := newIDAllocator(keys.RaftIDGenerator, store.ctx.DB, 2, 10, stopper)
if err != nil {
t.Errorf("failed to create IDAllocator: %v", err)
}
firstID, err := idAlloc.Allocate()
if err != nil {
t.Fatal(err)
}
if firstID != 2 {
t.Errorf("expected ID is 2, but got: %d", firstID)
}
// Make Allocator invalid.
idAlloc.idKey.Store(proto.KeyMin)
// Should be able to get the allocated IDs, and there will be one
// background allocateBlock to get ID continuously.
for i := 0; i < 8; i++ {
id, err := idAlloc.Allocate()
if err != nil {
t.Fatal(err)
}
if int(id) != i+3 {
t.Errorf("expected ID is %d, but got: %d", i+3, id)
}
}
const routines = 10
var wg sync.WaitGroup
wg.Add(routines)
// Then the paralleled allocations should be blocked until Allocator
// is recovered.
for i := 0; i < routines; i++ {
go func() {
select {
case <-idAlloc.ids:
t.Errorf("Allocate() should be blocked until idKey is valid")
case <-time.After(10 * time.Millisecond):
}
wg.Done()
id, err := idAlloc.Allocate()
if err != nil {
t.Fatal(err)
}
allocd <- int(id)
}()
}
// Wait until all the allocations are blocked.
wg.Wait()
// Make the IDAllocator valid again.
idAlloc.idKey.Store(keys.RaftIDGenerator)
// Check if the blocked allocations return expected ID.
ids := make([]int, routines)
for i := 0; i < routines; i++ {
ids[i] = <-allocd
}
sort.Ints(ids)
for i := 0; i < routines; i++ {
if ids[i] != i+11 {
t.Errorf("expected \"%d\"th ID to be %d; got %d", i, i+11, ids[i])
}
}
// Check if the following allocations return expected ID.
for i := 0; i < routines; i++ {
id, err := idAlloc.Allocate()
if err != nil {
t.Fatal(err)
}
if int(id) != i+21 {
t.Errorf("expected ID is %d, but got: %d", i+21, id)
}
}
} | explode_data.jsonl/45460 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 857
} | [
2830,
3393,
75380,
1454,
3036,
693,
7449,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
340,
57279,
11,
8358,
2936,
712,
1669,
1855,
2271,
6093,
1155,
340,
16867,
2936,
712,
30213,
741,
197,
4742,
67,
1669,
1281,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshalNullWithJSONPBUnmarshaler(t *testing.T) {
rawJson := `{"stringField":null}`
var ptrFieldMsg ptrFieldMessage
if err := Unmarshal(strings.NewReader(rawJson), &ptrFieldMsg); err != nil {
t.Errorf("unmarshal error: %v", err)
}
want := ptrFieldMessage{StringField: &stringField{IsSet: true, StringValue: "null"}}
if !proto.Equal(&ptrFieldMsg, &want) {
t.Errorf("unmarshal result StringField: got %v, want %v", ptrFieldMsg, want)
}
} | explode_data.jsonl/63127 | {
"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,
1806,
27121,
3280,
2354,
5370,
40637,
1806,
27121,
261,
1155,
353,
8840,
836,
8,
341,
76559,
5014,
1669,
1565,
4913,
917,
1877,
788,
2921,
31257,
2405,
10087,
1877,
6611,
10087,
1877,
2052,
198,
743,
1848,
1669,
1230,
27121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUser_AddMember(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
org := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
// add a user that is not a member
AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
prevNumMembers := org.NumMembers
assert.NoError(t, org.AddMember(5))
AssertExistsAndLoadBean(t, &OrgUser{UID: 5, OrgID: 3})
org = AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers+1, org.NumMembers)
// add a user that is already a member
AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
prevNumMembers = org.NumMembers
assert.NoError(t, org.AddMember(4))
AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
org = AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers, org.NumMembers)
CheckConsistencyFor(t, &User{})
} | explode_data.jsonl/71051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
1474,
21346,
9366,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
2398,
87625,
1669,
5319,
15575,
3036,
5879,
10437,
1155,
11,
609,
1474,
90,
915,
25,
220,
18,
16630,
4071,
1474,
692,
197,
322,
912... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServicecheckExtraPassAns(t *testing.T) {
convey.Convey("checkExtraPassAns", t, func() {
ret, qs, err := s.checkExtraPassAns(context.Background(), 14771787, []int64{}, nil, "", 0)
convey.So(err, convey.ShouldBeNil)
convey.So(qs, convey.ShouldNotBeNil)
convey.So(ret, convey.ShouldNotBeNil)
})
} | explode_data.jsonl/21135 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
1860,
2028,
11612,
12187,
69599,
1155,
353,
8840,
836,
8,
341,
37203,
5617,
4801,
5617,
445,
2028,
11612,
12187,
69599,
497,
259,
11,
2915,
368,
341,
197,
11262,
11,
32421,
11,
1848,
1669,
274,
9093,
11612,
12187,
69599,
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... | 1 |
func TestTaintedNode(t *testing.T) {
forEachStrategy(t, func(t *testing.T, strategy *apps.DaemonSetUpdateStrategy) {
closeFn, dc, informers, clientset := setup(t)
defer closeFn()
ns := framework.CreateNamespaceOrDie(clientset, "tainted-node", t)
defer framework.DeleteNamespaceOrDie(clientset, ns, t)
dsClient := clientset.AppsV1().DaemonSets(ns.Name)
podClient := clientset.CoreV1().Pods(ns.Name)
podInformer := informers.Core().V1().Pods().Informer()
nodeClient := clientset.CoreV1().Nodes()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
informers.Start(ctx.Done())
go dc.Run(ctx, 2)
// Start Scheduler
setupScheduler(ctx, t, clientset, informers)
ds := newDaemonSet("foo", ns.Name)
ds.Spec.UpdateStrategy = *strategy
ds, err := dsClient.Create(context.TODO(), ds, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create DaemonSet: %v", err)
}
defer cleanupDaemonSets(t, clientset, ds)
nodeWithTaint := newNode("node-with-taint", nil)
nodeWithTaint.Spec.Taints = []v1.Taint{{Key: "key1", Value: "val1", Effect: "NoSchedule"}}
_, err = nodeClient.Create(context.TODO(), nodeWithTaint, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create nodeWithTaint: %v", err)
}
nodeWithoutTaint := newNode("node-without-taint", nil)
_, err = nodeClient.Create(context.TODO(), nodeWithoutTaint, metav1.CreateOptions{})
if err != nil {
t.Fatalf("Failed to create nodeWithoutTaint: %v", err)
}
validateDaemonSetPodsAndMarkReady(podClient, podInformer, 1, t)
validateDaemonSetStatus(dsClient, ds.Name, 1, t)
// remove taint from nodeWithTaint
nodeWithTaint, err = nodeClient.Get(context.TODO(), "node-with-taint", metav1.GetOptions{})
if err != nil {
t.Fatalf("Failed to retrieve nodeWithTaint: %v", err)
}
nodeWithTaintCopy := nodeWithTaint.DeepCopy()
nodeWithTaintCopy.Spec.Taints = []v1.Taint{}
_, err = nodeClient.Update(context.TODO(), nodeWithTaintCopy, metav1.UpdateOptions{})
if err != nil {
t.Fatalf("Failed to update nodeWithTaint: %v", err)
}
validateDaemonSetPodsAndMarkReady(podClient, podInformer, 2, t)
validateDaemonSetStatus(dsClient, ds.Name, 2, t)
})
} | explode_data.jsonl/70046 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 883
} | [
2830,
3393,
51,
30229,
1955,
1155,
353,
8840,
836,
8,
341,
2023,
4854,
19816,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
8282,
353,
27635,
909,
64,
7291,
1649,
4289,
19816,
8,
341,
197,
27873,
24911,
11,
19402,
11,
6051,
388,
11,
294... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSignerAddCommandNoTargetsKey(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "docker-sign-test-")
assert.NilError(t, err)
defer os.RemoveAll(tmpDir)
config.SetDir(tmpDir)
tmpfile, err := ioutil.TempFile("", "pemfile")
assert.NilError(t, err)
defer os.Remove(tmpfile.Name())
cli := test.NewFakeCli(&fakeClient{})
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
cmd := newSignerAddCommand(cli)
cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"})
cmd.SetOutput(ioutil.Discard)
assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name()))
} | explode_data.jsonl/23299 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
7264,
261,
2212,
4062,
2753,
49030,
1592,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
28648,
27953,
16839,
12,
1138,
6948,
59678,
1454,
1155,
11,
1848,
340,
16867,
2643,
84427,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenModel_Issue222(t *testing.T) {
specDoc, err := loads.Spec("../fixtures/codegen/tasklist.basic.yml")
require.NoError(t, err)
definitions := specDoc.Spec().Definitions
k := "Price"
opts := opts()
genModel, err := makeGenDefinition(k, "models", definitions[k], specDoc, opts)
require.NoError(t, err)
require.True(t, genModel.HasValidations)
buf := bytes.NewBuffer(nil)
require.NoError(t, opts.templates.MustGet("model").Execute(buf, genModel))
ct, err := opts.LanguageOpts.FormatContent("price.go", buf.Bytes())
require.NoError(t, err)
res := string(ct)
assertInCode(t, "Price) Validate(formats strfmt.Registry) error", res)
assertInCode(t, "Currency Currency `json:\"currency,omitempty\"`", res)
assertInCode(t, "m.Currency.Validate(formats); err != nil", res)
} | explode_data.jsonl/2538 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
9967,
1712,
7959,
83890,
17,
17,
17,
1155,
353,
8840,
836,
8,
341,
98100,
9550,
11,
1848,
1669,
20907,
36473,
17409,
45247,
46928,
4370,
58186,
1607,
33257,
33936,
1138,
17957,
35699,
1155,
11,
1848,
692,
7452,
4054,
82,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegralPalindromesArePalindromes(t *testing.T) {
palindromes := [...]int{11, 101, 111, 1221, 12321, 1234321}
for _, n := range palindromes {
assert.True(t, IsPalindrome(n),
"%d should be a palindrome", n)
}
notPalindromes := [...]int{10, 12, 13, 113, 201, 311, 301, 1011, 17221, 3141, 12345678}
for _, n := range notPalindromes {
assert.False(t, IsPalindrome(n), "%d should not be a palindrome", n)
}
} | explode_data.jsonl/10876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
66164,
19980,
484,
441,
288,
11526,
19980,
484,
441,
288,
1155,
353,
8840,
836,
8,
341,
3223,
278,
484,
441,
288,
1669,
48179,
396,
90,
16,
16,
11,
220,
16,
15,
16,
11,
220,
16,
16,
16,
11,
220,
16,
17,
17,
16,
11,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestEnsureBytes(t *testing.T) {
// the content here doesn't matter
r := strings.NewReader("0123456789")
lcd := largeChunkDecoder{
r, 0, 0,
3, 8189,
make([]byte, 8192),
bytes.NewBuffer(make([]byte, defaultStringBufferSize)),
nil,
}
lcd.ensureBytes(4)
// we expect the new remainder to be 3 + 10 (length of r)
if lcd.rem != 13 {
t.Fatalf("buffer was not refilled correctly")
}
} | explode_data.jsonl/23252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
64439,
7078,
1155,
353,
8840,
836,
8,
341,
197,
322,
279,
2213,
1588,
3171,
944,
4925,
198,
7000,
1669,
9069,
68587,
445,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
5130,
90596,
1669,
3460,
28304,
20732,
515,
197,
7000,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProcessDNSRace(t *testing.T) {
p := new(process)
var wg sync.WaitGroup
wg.Add(2)
address := func(i byte) net.IP { return net.IPv4(172, 16, 0, i) }
go func() {
for i := byte(255); i > 0; i-- {
p.addTransaction(dns.Transaction{
Client: net.UDPAddr{IP: net.IPv4(10, 20, 30, 40)},
Server: net.UDPAddr{IP: net.IPv4(10, 20, 30, 41)},
Domain: "example.net",
Addresses: []net.IP{address(i)},
})
}
wg.Done()
}()
go func() {
for i := byte(255); i > 0; i-- {
p.ResolveIP(address(i))
}
wg.Done()
}()
wg.Wait()
} | explode_data.jsonl/70819 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 290
} | [
2830,
3393,
7423,
61088,
55991,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
501,
21929,
340,
2405,
63581,
12811,
28384,
2808,
198,
72079,
1904,
7,
17,
340,
63202,
1669,
2915,
1956,
4922,
8,
4179,
46917,
314,
470,
4179,
46917,
85,
19,
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 TestMakeHTTPWatchHandler(t *testing.T) {
t.Parallel()
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
idx := r.Header.Get("X-Consul-Index")
if idx != "100" {
t.Fatalf("bad: %s", idx)
}
// Get the first one
customHeader := r.Header.Get("X-Custom")
if customHeader != "abc" {
t.Fatalf("bad: %s", idx)
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("err: %v", err)
}
if string(body) != "[\"foo\",\"bar\",\"baz\"]\n" {
t.Fatalf("bad: %s", body)
}
w.Write([]byte("Ok, i see"))
}))
defer server.Close()
config := watch.HttpHandlerConfig{
Path: server.URL,
Header: map[string][]string{"X-Custom": {"abc", "def"}},
Timeout: time.Minute,
}
handler := makeHTTPWatchHandler(os.Stderr, &config)
handler(100, []string{"foo", "bar", "baz"})
} | explode_data.jsonl/26657 | {
"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,
8078,
9230,
14247,
3050,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
62077,
1669,
435,
15753,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestAssignFieldErrors(t *testing.T) {
t.Parallel()
tests := []struct {
name string
dest interface{}
src interface{}
err btcjson.Error
}{
{
name: "general incompatible int -> string",
dest: string(rune(0)),
src: int(0),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow source int -> dest int",
dest: int8(0),
src: int(128),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow source int -> dest uint",
dest: uint8(0),
src: int(256),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "int -> float",
dest: float32(0),
src: int(256),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow source uint64 -> dest int64",
dest: int64(0),
src: uint64(1 << 63),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow source uint -> dest int",
dest: int8(0),
src: uint(128),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow source uint -> dest uint",
dest: uint8(0),
src: uint(256),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "uint -> float",
dest: float32(0),
src: uint(256),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "float -> int",
dest: int(0),
src: float32(1.0),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow float64 -> float32",
dest: float32(0),
src: float64(math.MaxFloat64),
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> bool",
dest: true,
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> int",
dest: int8(0),
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow string -> int",
dest: int8(0),
src: "128",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> uint",
dest: uint8(0),
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow string -> uint",
dest: uint8(0),
src: "256",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> float",
dest: float32(0),
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "overflow string -> float",
dest: float32(0),
src: "1.7976931348623157e+308",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> array",
dest: [3]int{},
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> slice",
dest: []int{},
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> struct",
dest: struct{ A int }{},
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
{
name: "invalid string -> map",
dest: map[string]int{},
src: "foo",
err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType},
},
}
t.Logf("Running %d tests", len(tests))
for i, test := range tests {
dst := reflect.New(reflect.TypeOf(test.dest)).Elem()
src := reflect.ValueOf(test.src)
err := btcjson.TstAssignField(1, "testField", dst, src)
if reflect.TypeOf(err) != reflect.TypeOf(test.err) {
t.Errorf("Test #%d (%s) wrong error - got %T (%[3]v), "+
"want %T", i, test.name, err, test.err)
continue
}
gotErrorCode := err.(btcjson.Error).ErrorCode
if gotErrorCode != test.err.ErrorCode {
t.Errorf("Test #%d (%s) mismatched error code - got "+
"%v (%v), want %v", i, test.name, gotErrorCode,
err, test.err.ErrorCode)
continue
}
}
} | explode_data.jsonl/5031 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1790
} | [
2830,
3393,
28933,
1877,
13877,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
49616,
3749,
16094,
197,
41144,
220,
3749,
16094,
197,
9859,
220,
86037,
2236,
6141,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestWordCountAndSimilarVsSummary(t *testing.T) {
t.Parallel()
assert := require.New(t)
single := []string{"_default/single.html", `
WordCount: {{ .WordCount }}
FuzzyWordCount: {{ .FuzzyWordCount }}
ReadingTime: {{ .ReadingTime }}
Len Plain: {{ len .Plain }}
Len PlainWords: {{ len .PlainWords }}
Truncated: {{ .Truncated }}
Len Summary: {{ len .Summary }}
Len Content: {{ len .Content }}
SUMMARY:{{ .Summary }}:{{ len .Summary }}:END
`}
b := newTestSitesBuilder(t)
b.WithSimpleConfigFile().WithTemplatesAdded(single...).WithContent("p1.md", fmt.Sprintf(`---
title: p1
---
%s
`, strings.Repeat("word ", 510)),
"p2.md", fmt.Sprintf(`---
title: p2
---
This is a summary.
<!--more-->
%s
`, strings.Repeat("word ", 310)),
"p3.md", fmt.Sprintf(`---
title: p3
isCJKLanguage: true
---
Summary: In Chinese, ε₯½ means good.
<!--more-->
%s
`, strings.Repeat("ε₯½", 200)),
"p4.md", fmt.Sprintf(`---
title: p4
isCJKLanguage: false
---
Summary: In Chinese, ε₯½ means good.
<!--more-->
%s
`, strings.Repeat("ε₯½", 200)),
"p5.md", fmt.Sprintf(`---
title: p4
isCJKLanguage: true
---
Summary: In Chinese, ε₯½ means good.
%s
`, strings.Repeat("ε₯½", 200)),
"p6.md", fmt.Sprintf(`---
title: p4
isCJKLanguage: false
---
Summary: In Chinese, ε₯½ means good.
%s
`, strings.Repeat("ε₯½", 200)),
)
b.CreateSites().Build(BuildCfg{})
assert.Equal(1, len(b.H.Sites))
require.Len(t, b.H.Sites[0].RegularPages(), 6)
b.AssertFileContent("public/p1/index.html", "WordCount: 510\nFuzzyWordCount: 600\nReadingTime: 3\nLen Plain: 2550\nLen PlainWords: 510\nTruncated: false\nLen Summary: 2549\nLen Content: 2557")
b.AssertFileContent("public/p2/index.html", "WordCount: 314\nFuzzyWordCount: 400\nReadingTime: 2\nLen Plain: 1569\nLen PlainWords: 314\nTruncated: true\nLen Summary: 25\nLen Content: 1583")
b.AssertFileContent("public/p3/index.html", "WordCount: 206\nFuzzyWordCount: 300\nReadingTime: 1\nLen Plain: 638\nLen PlainWords: 7\nTruncated: true\nLen Summary: 43\nLen Content: 652")
b.AssertFileContent("public/p4/index.html", "WordCount: 7\nFuzzyWordCount: 100\nReadingTime: 1\nLen Plain: 638\nLen PlainWords: 7\nTruncated: true\nLen Summary: 43\nLen Content: 652")
b.AssertFileContent("public/p5/index.html", "WordCount: 206\nFuzzyWordCount: 300\nReadingTime: 1\nLen Plain: 638\nLen PlainWords: 7\nTruncated: true\nLen Summary: 229\nLen Content: 653")
b.AssertFileContent("public/p6/index.html", "WordCount: 7\nFuzzyWordCount: 100\nReadingTime: 1\nLen Plain: 638\nLen PlainWords: 7\nTruncated: false\nLen Summary: 637\nLen Content: 653")
} | explode_data.jsonl/60638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1020
} | [
2830,
3393,
10879,
2507,
3036,
34402,
51737,
19237,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
741,
6948,
1669,
1373,
7121,
1155,
692,
1903,
2173,
1669,
3056,
917,
4913,
62,
2258,
96562,
2564,
497,
22074,
10879,
2507,
25,
5867,
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,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTLSCodec_9(t *testing.T) {
t.Parallel()
l, p, _ := RandomListen("")
l0 := NewEventListener(l)
l0.AddCodecFactory(func(ctx Context) Codec {
c0 := NewTLSServerCodec()
c0.AddCertificate(testCert, testKEY)
c0.AddClientCa([]byte("aaa"))
return c0
})
var hasErr error
l0.OnAccept(func(ctx Context, c net.Conn) {
_, hasErr = Read(c, 5)
c.Close()
})
l0.Start()
time.Sleep(time.Second)
conn, _ := net.Dial("tcp", "127.0.0.1:"+p)
conn0 := NewConn(conn)
c1 := NewTLSClientCodec()
c1.AddCertificate(helloCert, helloKEY)
c1.SetServerName("demo.com")
c1.AddServerCa(demoCert)
c1.SkipVerify(true)
conn0.AddCodec(c1)
assert.Error(t, c1.AddCertificate([]byte("aaa"), []byte("aaa")))
_, err := Read(conn0, 5)
time.Sleep(time.Second)
assert.Error(t, err)
assert.Error(t, hasErr)
} | explode_data.jsonl/34697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 369
} | [
2830,
3393,
45439,
36913,
62,
24,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
8810,
11,
281,
11,
716,
1669,
10612,
38714,
31764,
8810,
15,
1669,
1532,
7765,
2333,
340,
8810,
15,
1904,
36913,
4153,
18552,
7502,
9608,
8,
67077... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSprintfln(t *testing.T) {
for _, randomString := range internal.RandomStrings {
testza.AssertEqual(t, randomString+"\n", pterm.Sprintfln(randomString))
}
testza.AssertEqual(t, "Hello, World!\n", pterm.Sprintfln("Hello, %s!", "World"))
} | explode_data.jsonl/49130 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
50,
1350,
1489,
77,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
4194,
703,
1669,
2088,
5306,
26709,
20859,
341,
197,
18185,
4360,
11711,
2993,
1155,
11,
4194,
703,
36269,
77,
497,
281,
4991,
808,
1350,
1489,
77,
25110,
703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestArtifact_GetArchive(t *testing.T) {
assert.NotNil(t, (&Artifact{}).GetArchive())
assert.Equal(t, &ArchiveStrategy{None: &NoneStrategy{}}, (&Artifact{Archive: &ArchiveStrategy{None: &NoneStrategy{}}}).GetArchive())
} | explode_data.jsonl/26034 | {
"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,
85578,
13614,
42502,
1155,
353,
8840,
836,
8,
341,
6948,
93882,
1155,
11,
15899,
85578,
6257,
568,
1949,
42502,
2398,
6948,
12808,
1155,
11,
609,
42502,
19816,
90,
4064,
25,
609,
4064,
19816,
6257,
2137,
15899,
85578,
90,
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 |
func TestJobsSort(t *testing.T) {
assert := assert.New(t)
jobs := Jobs{
{Name: "aaa"},
{Name: "bbb"},
}
sort.Sort(jobs)
assert.Equal(jobs[0].Name, "aaa")
assert.Equal(jobs[1].Name, "bbb")
jobs = Jobs{
{Name: "ddd"},
{Name: "ccc"},
}
sort.Sort(jobs)
assert.Equal(jobs[0].Name, "ccc")
assert.Equal(jobs[1].Name, "ddd")
} | explode_data.jsonl/80862 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
40667,
10231,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
12428,
5481,
1669,
23076,
515,
197,
197,
63121,
25,
330,
32646,
7115,
197,
197,
63121,
25,
330,
53151,
7115,
197,
532,
39487,
35976,
3325,
5481,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGitCommandDiscardAnyUnstagedFileChanges(t *testing.T) {
type scenario struct {
testName string
command func(string, ...string) *exec.Cmd
test func(error)
}
scenarios := []scenario{
{
"valid case",
test.CreateMockCommand(t, []*test.CommandSwapper{
{
Expect: `git checkout -- .`,
Replace: "echo",
},
}),
func(err error) {
assert.NoError(t, err)
},
},
}
gitCmd := NewDummyGitCommand()
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
gitCmd.OSCommand.Command = s.command
s.test(gitCmd.DiscardAnyUnstagedFileChanges())
})
}
} | explode_data.jsonl/6324 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
46562,
4062,
23477,
567,
8610,
1806,
267,
3279,
1703,
11317,
1155,
353,
8840,
836,
8,
341,
13158,
15048,
2036,
341,
197,
18185,
675,
914,
198,
197,
45566,
220,
2915,
3609,
11,
2503,
917,
8,
353,
11748,
64512,
198,
197,
181... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStrArray_Clone(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []string{"0", "1", "2", "3", "4", "5", "6"}
array1 := garray.NewStrArrayFrom(a1)
array2 := array1.Clone()
t.Assert(array2, array1)
t.Assert(array2.Len(), 7)
})
} | explode_data.jsonl/53107 | {
"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,
2580,
1857,
85110,
603,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
917,
4913,
15,
497,
330,
16,
497,
330,
17,
497,
330,
18,
497,
330,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTiDBDecodePlanFunc(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustQuery("select tidb_decode_plan('')").Check(testkit.Rows(""))
tk.MustQuery("select tidb_decode_plan('7APIMAk1XzEzCTAJMQlmdW5jczpjb3VudCgxKQoxCTE3XzE0CTAJMAlpbm5lciBqb2luLCBp" +
"AQyQOlRhYmxlUmVhZGVyXzIxLCBlcXVhbDpbZXEoQ29sdW1uIzEsIA0KCDkpIBkXADIVFywxMCldCjIJMzFfMTgFZXhkYXRhOlNlbGVjdGlvbl" +
"8xNwozCTFfMTcJMQkwCWx0HVlATlVMTCksIG5vdChpc251bGwVHAApUhcAUDIpKQo0CTEwXzE2CTEJMTAwMDAJdAHB2Dp0MSwgcmFuZ2U6Wy1p" +
"bmYsK2luZl0sIGtlZXAgb3JkZXI6ZmFsc2UsIHN0YXRzOnBzZXVkbwoFtgAyAZcEMAk6tgAEMjAFtgQyMDq2AAg5LCBmtgAAMFa3AAA5FbcAO" +
"T63AAAyzrcA')").Check(testkit.Rows("" +
"\tid \ttask\testRows\toperator info\n" +
"\tStreamAgg_13 \troot\t1 \tfuncs:count(1)\n" +
"\tββHashJoin_14 \troot\t0 \tinner join, inner:TableReader_21, equal:[eq(Column#1, Column#9) eq(Column#2, Column#10)]\n" +
"\t ββTableReader_18 \troot\t0 \tdata:Selection_17\n" +
"\t β ββSelection_17 \tcop \t0 \tlt(Column#1, NULL), not(isnull(Column#1)), not(isnull(Column#2))\n" +
"\t β ββTableScan_16\tcop \t10000 \ttable:t1, range:[-inf,+inf], keep order:false, stats:pseudo\n" +
"\t ββTableReader_21 \troot\t0 \tdata:Selection_20\n" +
"\t ββSelection_20 \tcop \t0 \tlt(Column#9, NULL), not(isnull(Column#10)), not(isnull(Column#9))\n" +
"\t ββTableScan_19\tcop \t10000 \ttable:t2, range:[-inf,+inf], keep order:false, stats:pseudo"))
tk.MustQuery("select tidb_decode_plan('rwPwcTAJNV8xNAkwCTEJZnVuY3M6bWF4KHRlc3QudC5hKS0+Q29sdW1uIzQJMQl0aW1lOj" +
"IyMy45MzXCtXMsIGxvb3BzOjIJMTI4IEJ5dGVzCU4vQQoxCTE2XzE4CTAJMQlvZmZzZXQ6MCwgY291bnQ6MQkxCQlHFDE4LjQyMjJHAAhOL0" +
"EBBCAKMgkzMl8yOAkBlEBpbmRleDpMaW1pdF8yNwkxCQ0+DDYuODUdPSwxLCBycGMgbnVtOiANDAUpGDE1MC44MjQFKjhwcm9jIGtleXM6MA" +
"kxOTgdsgAzAbIAMgFearIAFDU3LjM5NgVKAGwN+BGxIDQJMTNfMjYJMQGgHGFibGU6dCwgCbqwaWR4KGEpLCByYW5nZTooMCwraW5mXSwga2" +
"VlcCBvcmRlcjp0cnVlLCBkZXNjAT8kaW1lOjU2LjY2MR1rJDEJTi9BCU4vQQo=')").Check(testkit.Rows("" +
"\tid \ttask\testRows\toperator info \tactRows\texecution info \tmemory \tdisk\n" +
"\tStreamAgg_14 \troot\t1 \tfuncs:max(test.t.a)->Column#4 \t1 \ttime:223.935Β΅s, loops:2 \t128 Bytes\tN/A\n" +
"\tββLimit_18 \troot\t1 \toffset:0, count:1 \t1 \ttime:218.422Β΅s, loops:2 \tN/A \tN/A\n" +
"\t ββIndexReader_28 \troot\t1 \tindex:Limit_27 \t1 \ttime:216.85Β΅s, loops:1, rpc num: 1, rpc time:150.824Β΅s, proc keys:0\t198 Bytes\tN/A\n" +
"\t ββLimit_27 \tcop \t1 \toffset:0, count:1 \t1 \ttime:57.396Β΅s, loops:2 \tN/A \tN/A\n" +
"\t ββIndexScan_26\tcop \t1 \ttable:t, index:idx(a), range:(0,+inf], keep order:true, desc\t1 \ttime:56.661Β΅s, loops:1 \tN/A \tN/A"))
// Test issue16939
tk.MustQuery("select tidb_decode_plan(query), time from information_schema.slow_query order by time desc limit 1;")
tk.MustQuery("select tidb_decode_plan('xxx')").Check(testkit.Rows("xxx"))
} | explode_data.jsonl/65464 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2268
} | [
2830,
3393,
45351,
3506,
32564,
20485,
9626,
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 TestCalculateNextReconcileTimeNoInterval(t *testing.T) {
now := metav1.Now()
count := intstr.FromInt(1)
run := &v1alpha1.AnalysisRun{
Spec: v1alpha1.AnalysisRunSpec{
Metrics: []v1alpha1.Metric{{
Name: "success-rate",
Count: &count,
}},
},
Status: v1alpha1.AnalysisRunStatus{
Phase: v1alpha1.AnalysisPhaseRunning,
MetricResults: []v1alpha1.MetricResult{{
Name: "success-rate",
Phase: v1alpha1.AnalysisPhaseSuccessful,
Measurements: []v1alpha1.Measurement{{
Value: "99",
Phase: v1alpha1.AnalysisPhaseSuccessful,
StartedAt: &now,
FinishedAt: &now,
}},
}},
},
}
assert.Nil(t, calculateNextReconcileTime(run, run.Spec.Metrics))
} | explode_data.jsonl/75824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
47866,
5847,
693,
40446,
457,
1462,
2753,
10256,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
77520,
16,
13244,
741,
18032,
1669,
526,
495,
11439,
1072,
7,
16,
340,
56742,
1669,
609,
85,
16,
7141,
16,
8624,
9092,
6727,
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... | 1 |
func TestGenManSeeAlso(t *testing.T) {
rootCmd := &cobra.Command{Use: "root", Run: emptyRun}
aCmd := &cobra.Command{Use: "aaa", Run: emptyRun, Hidden: true} // #229
bCmd := &cobra.Command{Use: "bbb", Run: emptyRun}
cCmd := &cobra.Command{Use: "ccc", Run: emptyRun}
rootCmd.AddCommand(aCmd, bCmd, cCmd)
buf := new(bytes.Buffer)
header := &GenManHeader{}
if err := GenMan(rootCmd, header, buf); err != nil {
t.Fatal(err)
}
scanner := bufio.NewScanner(buf)
if err := assertLineFound(scanner, ".SH SEE ALSO"); err != nil {
t.Fatalf("Couldn't find SEE ALSO section header: %v", err)
}
if err := assertNextLineEquals(scanner, ".PP"); err != nil {
t.Fatalf("First line after SEE ALSO wasn't break-indent: %v", err)
}
if err := assertNextLineEquals(scanner, `\fBroot-bbb(1)\fP, \fBroot-ccc(1)\fP`); err != nil {
t.Fatalf("Second line after SEE ALSO wasn't correct: %v", err)
}
} | explode_data.jsonl/21958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 362
} | [
2830,
3393,
9967,
1658,
9830,
13394,
1155,
353,
8840,
836,
8,
341,
33698,
15613,
1669,
609,
59410,
12714,
90,
10253,
25,
330,
2888,
497,
6452,
25,
4287,
6727,
532,
11323,
15613,
1669,
609,
59410,
12714,
90,
10253,
25,
330,
32646,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestJob(t *testing.T) {
eng := newTestEngine(t)
job1 := eng.Job("dummy1", "--level=awesome")
if job1.handler != nil {
t.Fatalf("job1.handler should be empty")
}
h := func(j *Job) Status {
j.Printf("%s\n", j.Name)
return 42
}
eng.Register("dummy2", h)
job2 := eng.Job("dummy2", "--level=awesome")
if job2.handler == nil {
t.Fatalf("job2.handler shouldn't be nil")
}
if job2.handler(job2) != 42 {
t.Fatalf("handler dummy2 was not found in job2")
}
} | explode_data.jsonl/45349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
12245,
1155,
353,
8840,
836,
8,
341,
197,
826,
1669,
501,
2271,
4571,
1155,
340,
68577,
16,
1669,
2922,
45293,
445,
31390,
16,
497,
14482,
3294,
28,
16875,
5130,
743,
2618,
16,
31171,
961,
2092,
341,
197,
3244,
30762,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDomain_Transfer(t *testing.T) {
// defines test prereqs
init := func() (k keeper.Keeper, ctx sdk.Context, ex *Domain) {
k, ctx, _ = keeper.NewTestKeeper(t, false)
domain := types.Domain{
Name: "test",
Admin: keeper.BobKey,
ValidUntil: 1,
Type: types.OpenDomain,
Broker: nil,
}
acc1 := types.Account{
Domain: "test",
Name: utils.StrPtr("1"),
Owner: keeper.BobKey,
ValidUntil: 1,
Resources: nil,
Certificates: nil,
Broker: nil,
MetadataURI: "",
}
acc2 := types.Account{
Domain: "test",
Name: utils.StrPtr("2"),
Owner: keeper.BobKey,
ValidUntil: 1,
Resources: nil,
Certificates: nil,
Broker: nil,
MetadataURI: "",
}
// add account not owned
acc3 := types.Account{
Domain: "test",
Name: utils.StrPtr("not-owned"),
Owner: keeper.CharlieKey,
}
NewDomain(ctx, k, domain).Create()
NewAccount(ctx, k, acc1).Create()
NewAccount(ctx, k, acc2).Create()
NewAccount(ctx, k, acc3).Create()
ex = NewDomain(ctx, k, domain)
return
}
t.Run("transfer owned", func(t *testing.T) {
k, ctx, ex := init()
ex.Transfer(types.TransferOwned, keeper.AliceKey)
filter := k.AccountStore(ctx).Filter(&types.Account{
Domain: "test",
})
for ; filter.Valid(); filter.Next() {
acc := new(types.Account)
filter.Read(acc)
if !acc.Owner.Equals(keeper.AliceKey) && *acc.Name != "not-owned" {
t.Fatal("owner mismatch")
}
if *acc.Name == "not-owned" && !acc.Owner.Equals(keeper.CharlieKey) {
t.Fatal("a not owned account was transferred")
}
}
})
t.Run("transfer-flush", func(t *testing.T) {
k, ctx, ex := init()
ex.Transfer(types.TransferFlush, keeper.AliceKey)
filter := k.AccountStore(ctx).Filter(&types.Account{
Domain: "test",
})
emptyAccountExists := false
for ; filter.Valid(); filter.Next() {
acc := new(types.Account)
filter.Read(acc)
// only empty account is expected
if *acc.Name != types.EmptyAccountName {
t.Fatalf("only empty account is expected to exist, got: %s", *acc.Name)
}
if *acc.Name == types.EmptyAccountName {
emptyAccountExists = true
}
}
if !emptyAccountExists {
t.Fatal("empty account not found")
}
})
t.Run("transfer-reset-none", func(t *testing.T) {
k, ctx, ex := init()
ex.Transfer(types.TransferResetNone, keeper.AliceKey)
filter := k.AccountStore(ctx).Filter(&types.Account{
Domain: "test",
})
for ; filter.Valid(); filter.Next() {
acc := new(types.Account)
filter.Read(acc)
switch *acc.Name {
case types.EmptyAccountName:
if !acc.Owner.Equals(keeper.AliceKey) {
t.Fatal("owner mismatch")
}
case "1":
if !acc.Owner.Equals(keeper.BobKey) {
t.Fatal("owner mismatch")
}
case "2":
if !acc.Owner.Equals(keeper.BobKey) {
t.Fatal("owner mismatch")
}
case "not-owned":
if !acc.Owner.Equals(keeper.CharlieKey) {
t.Fatal("owner mismatch")
}
default:
t.Fatalf("unexpected account found: %s", *acc.Name)
}
}
})
} | explode_data.jsonl/16619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1387
} | [
2830,
3393,
13636,
34932,
802,
1155,
353,
8840,
836,
8,
341,
197,
322,
18653,
1273,
43901,
26358,
198,
28248,
1669,
2915,
368,
320,
74,
53416,
11352,
43031,
11,
5635,
45402,
9328,
11,
505,
353,
13636,
8,
341,
197,
16463,
11,
5635,
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 TestJob_Split(t *testing.T) {
type args struct {
ctx context.Context
number int
}
tests := []struct {
name string
jobConf *config.JSON
args args
wantConfigs []*config.JSON
wantErr bool
}{
{
name: "1",
jobConf: testJSONFromString(`{"path":["file1"],"column":[],"delimiter":";","encoding":""}`),
args: args{
ctx: context.TODO(),
},
wantConfigs: []*config.JSON{
testJSONFromString(`{"path":"file1","content":[{"column":[],"encoding":"","delimiter":";","nullFormat":"","startRow":0,"comment":""}]}`),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
j := NewJob()
defer j.Destroy(tt.args.ctx)
j.SetPluginJobConf(tt.jobConf)
if err := j.Init(tt.args.ctx); err != nil {
t.Errorf("init fail. err: %v", err)
}
gotConfigs, err := j.Split(tt.args.ctx, tt.args.number)
if (err != nil) != tt.wantErr {
t.Errorf("Job.Split() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotConfigs, tt.wantConfigs) {
t.Errorf("Job.Split() = %v, want %v", gotConfigs, tt.wantConfigs)
}
})
}
} | explode_data.jsonl/73235 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 532
} | [
2830,
3393,
12245,
1098,
2292,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
20985,
262,
2266,
9328,
198,
197,
57135,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
68577,
15578,
257,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestValidateCognitoIdentityProvidersClientId(t *testing.T) {
validValues := []string{
"7lhlkkfbfb4q5kpp90urffao",
"12345678",
"foo_123",
strings.Repeat("W", 128),
}
for _, s := range validValues {
_, errors := validateCognitoIdentityProvidersClientId(s, "client_id")
if len(errors) > 0 {
t.Fatalf("%q should be a valid Cognito Identity Provider Client ID: %v", s, errors)
}
}
invalidValues := []string{
"",
strings.Repeat("W", 129), // > 128
"foo-bar",
"foo:bar",
"foo;bar",
}
for _, s := range invalidValues {
_, errors := validateCognitoIdentityProvidersClientId(s, "client_id")
if len(errors) == 0 {
t.Fatalf("%q should not be a valid Cognito Identity Provider Client ID: %v", s, errors)
}
}
} | explode_data.jsonl/78624 | {
"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,
17926,
34,
63441,
18558,
37351,
94116,
1155,
353,
8840,
836,
8,
341,
56322,
6227,
1669,
3056,
917,
515,
197,
197,
1,
22,
75,
17958,
19196,
10798,
10798,
19,
80,
20,
74,
602,
24,
15,
324,
542,
3441,
756,
197,
197,
1,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestGroupStatsAlignment(t *testing.T) {
var g Group
off := unsafe.Offsetof(g.Stats)
if off%8 != 0 {
t.Fatal("Stats structure is not 8-byte aligned.")
}
} | explode_data.jsonl/62851 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
2808,
16635,
7033,
1155,
353,
8840,
836,
8,
341,
2405,
342,
5737,
198,
197,
1847,
1669,
19860,
61958,
1055,
3268,
7758,
1862,
340,
743,
1007,
4,
23,
961,
220,
15,
341,
197,
3244,
26133,
445,
16635,
5944,
374,
537,
220,
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
] | 2 |
func TestPluginReconfigure(t *testing.T) {
ctx := context.Background()
fixture := newTestFixture(t)
defer fixture.server.stop()
if err := fixture.plugin.Start(ctx); err != nil {
t.Fatal(err)
}
minDelay := 2
maxDelay := 3
pluginConfig := []byte(fmt.Sprintf(`{
"service": "example",
"reporting": {
"min_delay_seconds": %v,
"max_delay_seconds": %v
}
}`, minDelay, maxDelay))
config, _ := ParseConfig(pluginConfig, fixture.manager.Services(), nil)
fixture.plugin.Reconfigure(ctx, config)
fixture.plugin.Stop(ctx)
actualMin := time.Duration(*fixture.plugin.config.Reporting.MinDelaySeconds) / time.Nanosecond
expectedMin := time.Duration(minDelay) * time.Second
if actualMin != expectedMin {
t.Fatalf("Expected minimum polling interval: %v but got %v", expectedMin, actualMin)
}
actualMax := time.Duration(*fixture.plugin.config.Reporting.MaxDelaySeconds) / time.Nanosecond
expectedMax := time.Duration(maxDelay) * time.Second
if actualMax != expectedMax {
t.Fatalf("Expected maximum polling interval: %v but got %v", expectedMax, actualMax)
}
} | explode_data.jsonl/2175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 392
} | [
2830,
3393,
11546,
693,
21002,
1155,
353,
8840,
836,
8,
1476,
20985,
1669,
2266,
19047,
741,
1166,
12735,
1669,
501,
69356,
1155,
340,
16867,
12507,
12638,
13227,
2822,
743,
1848,
1669,
12507,
26969,
12101,
7502,
1215,
1848,
961,
2092,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestCandidateVoteFail(t *testing.T) {
ctx := startup_candidate_test(t)
defer teardown_candidate_test(t, ctx)
for _, o := range ctx.svr.cluster_info {
oo, _ := o.client.(*MockClient)
oo.ReplaceVoteFunctor(func(ctx context.Context, req *pb.RequestVoteReq) (*pb.RequestVoteRes, error) {
rsp := new(pb.RequestVoteRes)
rsp.Header = new(pb.ResHeader)
rsp.Term = int64(1)
rsp.VoteGranted = "id1"
return rsp, nil
})
}
go ctx.svr.Elect()
time.Sleep(1 * time.Second)
if ctx.svr.state != pb.PeerState_Follower {
t.Errorf("peer should become follower after elect fail:%v", ctx.svr.state)
}
} | explode_data.jsonl/59087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
63901,
41412,
19524,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
20567,
62360,
4452,
1155,
340,
16867,
49304,
62360,
4452,
1155,
11,
5635,
340,
2023,
8358,
297,
1669,
2088,
5635,
514,
18920,
40501,
3109,
341,
197,
197,
2624,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExistConfig(t *testing.T) {
tests := []struct {
name string
setupFunc func(t *testing.T) func(t *testing.T)
want bool
}{
{"True", setupTestExistConfig, true},
{"False", setupTestExistConfigFail, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt := tt
defer tt.setupFunc(t)(t)
got := internal.ExistConfig()
if got != tt.want {
t.Errorf("ExistConfig() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/17824 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
25613,
2648,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
84571,
9626,
2915,
1155,
353,
8840,
836,
8,
2915,
1155,
353,
8840,
836,
340,
197,
50780,
414,
1807,
198,
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... | 1 |
func TestPubKeys(t *testing.T) {
for _, test := range pubKeyTests {
pk, err := ParsePubKey(test.key, S256())
if err != nil {
if test.isValid {
t.Errorf("%s pubkey failed when shouldn't %v",
test.name, err)
}
continue
}
if !test.isValid {
t.Errorf("%s counted as valid when it should fail",
test.name)
continue
}
var pkStr []byte
switch test.format {
case pubkeyUncompressed:
pkStr = (*PublicKey)(pk).SerializeUncompressed()
case pubkeyCompressed:
pkStr = (*PublicKey)(pk).SerializeCompressed()
case pubkeyHybrid:
pkStr = (*PublicKey)(pk).SerializeHybrid()
}
if !bytes.Equal(test.key, pkStr) {
t.Errorf("%s pubkey: serialized keys do not match.",
test.name)
spew.Dump(test.key)
spew.Dump(pkStr)
}
}
} | explode_data.jsonl/71131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
29162,
8850,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
6675,
1592,
18200,
341,
197,
3223,
74,
11,
1848,
1669,
14775,
29162,
1592,
8623,
4735,
11,
328,
17,
20,
21,
2398,
197,
743,
1848,
961,
2092,
341,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func Test_Get_Succ(t *testing.T) {
cache := mem.NewRotateCache(time.Second, func(key string) (string, error) {
return time.Now().Format(time.StampMilli), nil
})
v1, _ := cache.Get("now")
time.Sleep(600 * time.Millisecond)
v2, _ := cache.Get("now")
time.Sleep(600 * time.Millisecond)
v3, _ := cache.Get("now")
if v1 != v2 || v2 == v3 {
t.Error("failed", v1, v2, v3)
}
} | explode_data.jsonl/46753 | {
"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,
13614,
1098,
14570,
1155,
353,
8840,
836,
8,
341,
52680,
1669,
1833,
7121,
34540,
8233,
9730,
32435,
11,
2915,
4857,
914,
8,
320,
917,
11,
1465,
8,
341,
197,
853,
882,
13244,
1005,
4061,
9730,
7758,
1121,
12328,
72,
701,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestList_IteratorAsc(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
l := New()
a1 := []interface{}{1, 2, 5, 6, 3, 4}
l.PushFronts(a1)
e1 := l.Back()
fun1 := func(e *Element) bool {
if gconv.Int(e1.Value) > 2 {
return true
}
return false
}
checkList(t, l, []interface{}{4, 3, 6, 5, 2, 1})
l.IteratorAsc(fun1)
checkList(t, l, []interface{}{4, 3, 6, 5, 2, 1})
})
} | explode_data.jsonl/30912 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
852,
7959,
465,
850,
40103,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
8810,
1669,
1532,
741,
197,
11323,
16,
1669,
3056,
4970,
6257,
90,
16,
11,
220,
17,
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... | 2 |
func TestAddSummaryEmpty(t *testing.T) {
t.Parallel()
// arrange
p := podcast.New("title", "desc", "Link", nil, nil)
// act
p.AddSummary("")
// assert
assert.Nil(t, p.ISummary)
} | explode_data.jsonl/73088 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
2212,
19237,
3522,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
30893,
198,
3223,
1669,
17711,
7121,
445,
2102,
497,
330,
8614,
497,
330,
3939,
497,
2092,
11,
2092,
692,
197,
322,
1160,
198,
3223,
1904,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommitsOnBranch(t *testing.T) {
repo := setupRepo()
createTestHistory(repo)
head, _ := repo.Head()
testGit := &Git{repo: repo}
commits, err := testGit.CommitsOnBranch(head.Hash())
assert.Equal(t, 4, len(commits))
commit, commitErr := repo.CommitObject(commits[0])
assert.NoError(t, commitErr)
assert.Equal(t, "third commit on new branch", commit.Message)
assert.Equal(t, err, nil)
lastCommit, _ := repo.CommitObject(commits[3])
assert.Equal(t, "test commit on master", lastCommit.Message)
} | explode_data.jsonl/73761 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
17977,
1199,
1925,
18197,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
1669,
6505,
25243,
741,
39263,
2271,
13424,
50608,
692,
46081,
11,
716,
1669,
15867,
90478,
2822,
18185,
46562,
1669,
609,
46562,
90,
23476,
25,
15867,
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... | 1 |
func TestIsValidDomain(t *testing.T) {
testCases := []struct {
// Input.
host string
// Expected result.
result bool
}{
{"s3.amazonaws.com", true},
{"s3.cn-north-1.amazonaws.com.cn", true},
{"s3.amazonaws.com_", false},
{"%$$$", false},
{"s3.amz.test.com", true},
{"s3.%%", false},
{"localhost", true},
{"-localhost", false},
{"", false},
{"\n \t", false},
{" ", false},
}
for i, testCase := range testCases {
result := IsValidDomain(testCase.host)
if testCase.result != result {
t.Errorf("Test %d: Expected isValidDomain test to be '%v', but found '%v' instead", i+1, testCase.result, result)
}
}
} | explode_data.jsonl/20466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
55470,
13636,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
197,
322,
5571,
624,
197,
63104,
914,
198,
197,
197,
322,
31021,
1102,
624,
197,
9559,
1807,
198,
197,
59403,
197,
197,
4913,
82,
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... | 3 |
func TestLoggingSetup(t *testing.T) {
origLogLevel, exists := os.LookupEnv("JX_LOG_LEVEL")
if exists {
defer func() {
_ = os.Setenv("JX_LOG_LEVEL", origLogLevel)
}()
}
var logTests = []struct {
envLogLevel string
verbose bool
expectedOutput string
}{
{"trace", false, "TRACE: trace\nDEBUG: debug\ninfo\nWARNING: warn\nERROR: error\n"},
{"trace", true, "TRACE: trace\nDEBUG: debug\ninfo\nWARNING: warn\nERROR: error\n"},
{"debug", false, "DEBUG: debug\ninfo\nWARNING: warn\nERROR: error\n"},
{"debug", true, "DEBUG: debug\ninfo\nWARNING: warn\nERROR: error\n"},
{"info", false, "info\nWARNING: warn\nERROR: error\n"},
{"info", true, "info\nWARNING: warn\nERROR: error\n"},
{"warn", false, "WARNING: warn\nERROR: error\n"},
{"warn", true, "WARNING: warn\nERROR: error\n"},
{"error", false, "ERROR: error\n"},
{"error", true, "ERROR: error\n"},
{"", true, "DEBUG: debug\ninfo\nWARNING: warn\nERROR: error\n"},
{"", false, "info\nWARNING: warn\nERROR: error\n"},
{"foo", false, "info\nWARNING: warn\nERROR: error\n"},
{"foo", true, "info\nWARNING: warn\nERROR: error\n"},
}
testCommandName := "logtest"
for _, logTest := range logTests {
t.Run(fmt.Sprintf("JX_LOG_LEVEL=%s verbose=%t", logTest.envLogLevel, logTest.verbose), func(t *testing.T) {
if logTest.envLogLevel == "" {
err := os.Unsetenv("JX_LOG_LEVEL")
assert.NoError(t, err)
} else {
err := os.Setenv("JX_LOG_LEVEL", logTest.envLogLevel)
assert.NoError(t, err)
}
logCommand := &cobra.Command{
Use: testCommandName,
Short: "dummy test command",
Run: func(cmd *cobra.Command, args []string) {
out := log.CaptureOutput(func() {
log.Logger().Trace("trace")
log.Logger().Debug("debug")
log.Logger().Info("info")
log.Logger().Warn("warn")
log.Logger().Error("error")
})
assert.Equal(t, logTest.expectedOutput, out)
},
}
rootCmd := NewJXCommand(fake.NewFakeFactory(), os.Stdin, os.Stdout, os.Stderr, nil)
rootCmd.AddCommand(logCommand)
args := []string{testCommandName}
if logTest.verbose {
args = append(args, "--verbose")
}
rootCmd.SetArgs(args)
_ = log.CaptureOutput(func() {
err := rootCmd.Execute()
assert.NoError(t, err)
})
})
}
} | explode_data.jsonl/60769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 997
} | [
2830,
3393,
34575,
21821,
1155,
353,
8840,
836,
8,
341,
197,
4670,
72676,
11,
6724,
1669,
2643,
79261,
14359,
445,
41,
55,
8419,
17415,
1138,
743,
6724,
341,
197,
16867,
2915,
368,
341,
298,
197,
62,
284,
2643,
4202,
3160,
445,
41,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetIQN(t *testing.T) {
tests := map[string]struct {
expectedOutput string
Volume VolumeInfo
}{
"Fetching IQN": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
Spec: v1alpha1.CASVolumeSpec{
Iqn: "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
},
},
expectedOutput: "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
"Fetching Controller when iqn is present in openebs.io annotations": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"openebs.io/iqn": "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
},
},
},
expectedOutput: "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
"Fetching Controller when iqn is present in vsm.openebs.io annotations": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"vsm.openebs.io/iqn": "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
},
},
},
expectedOutput: "iqn.2016-09.com.openebs.cstor:default-testclaim7",
},
"Fetching Controller when iqn is not present": {
Volume: VolumeInfo{
Volume: v1alpha1.CASVolume{
ObjectMeta: metav1.ObjectMeta{},
},
},
expectedOutput: "",
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
got := tt.Volume.GetIQN()
if got != tt.expectedOutput {
t.Fatalf("Test: %v Expected: %v but got: %v", name, tt.expectedOutput, got)
}
})
}
} | explode_data.jsonl/78048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 792
} | [
2830,
3393,
1949,
61950,
45,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
42400,
5097,
914,
198,
197,
17446,
4661,
260,
20265,
1731,
198,
197,
59403,
197,
197,
1,
52416,
36711,
45,
788,
341,
298,
17446,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeTopic(t *testing.T) {
seedBroker := NewMockBroker(t, 1)
defer seedBroker.Close()
seedBroker.SetHandlerByMap(map[string]MockResponse{
"MetadataRequest": NewMockMetadataResponse(t).
SetController(seedBroker.BrokerID()).
SetLeader("my_topic", 0, seedBroker.BrokerID()).
SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
})
config := NewTestConfig()
config.Version = V1_0_0_0
admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
if err != nil {
t.Fatal(err)
}
topics, err := admin.DescribeTopics([]string{"my_topic"})
if err != nil {
t.Fatal(err)
}
if len(topics) != 1 {
t.Fatalf("Expected 1 result, got %v", len(topics))
}
if topics[0].Name != "my_topic" {
t.Fatalf("Incorrect topic name: %v", topics[0].Name)
}
err = admin.Close()
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/40802 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
74785,
26406,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
1669,
1532,
11571,
65545,
1155,
11,
220,
16,
340,
16867,
10320,
65545,
10421,
2822,
197,
22602,
65545,
4202,
3050,
1359,
2227,
9147,
14032,
60,
11571,
2582,
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... | 6 |
func TestSortByName(t *testing.T) {
SortByName(releases)
check(t, "ByName", func(i, j int) bool {
ni := releases[i].Name
nj := releases[j].Name
return ni < nj
})
} | explode_data.jsonl/4969 | {
"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,
10231,
16898,
1155,
353,
8840,
836,
8,
341,
7568,
371,
16898,
5801,
28299,
692,
25157,
1155,
11,
330,
16898,
497,
2915,
1956,
11,
502,
526,
8,
1807,
341,
197,
197,
7751,
1669,
19232,
989,
936,
675,
198,
197,
9038,
73,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestString_ToInt8(t *testing.T) {
tests := []struct {
name string
e String
want Int8
}{
{name: "", e: String{"123"}, want: Int8{123}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.ToInt8(); !got.Equal(tt.want) {
t.Errorf("String.ToInt8() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34777 | {
"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,
703,
38346,
1072,
23,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
923,
198,
197,
50780,
1333,
23,
198,
197,
59403,
197,
197,
47006,
25,
7342,
384,
25,
923,
4913,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetFiles(t *testing.T) {
dir, err := ioutil.TempDir("", t.Name())
if err != nil {
t.Fatal(err)
}
defer func() {
os.RemoveAll(dir)
os.Unsetenv("OKTETO_FOLDER")
}()
os.Setenv("OKTETO_FOLDER", dir)
log := GetLogFile("test", "application")
expected := filepath.Join(dir, "test", "application", "syncthing.log")
if log != expected {
t.Errorf("got %s, expected %s", log, expected)
}
info := getInfoFile("test", "application")
expected = filepath.Join(dir, "test", "application", "syncthing.info")
if info != expected {
t.Errorf("got %s, expected %s", info, expected)
}
} | explode_data.jsonl/77145 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
1949,
10809,
1155,
353,
8840,
836,
8,
1476,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
259,
2967,
2398,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
2915,
368,
341,
197,
25078,
84427,
14161... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMinInt64(t *testing.T) {
h := new(MinInt64)
h.verify(t, 0)
for i := 20; i > 10; i-- {
h.push(int64(i))
}
h.Init()
h.verify(t, 0)
for i := 10; i > 0; i-- {
h.Push(int64(i))
h.verify(t, 0)
}
for i := 1; h.length() > 0; i++ {
x := h.Pop()
if i < 20 {
h.Push(int64(20 + i))
}
h.verify(t, 0)
if x != int64(i) {
t.Errorf("%d.th pop got %d; want %d", i, x, int64(i))
}
}
} | explode_data.jsonl/57432 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
6217,
1072,
21,
19,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
3189,
258,
1072,
21,
19,
340,
9598,
27520,
1155,
11,
220,
15,
692,
2023,
600,
1669,
220,
17,
15,
26,
600,
861,
220,
16,
15,
26,
600,
313,
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... | 6 |
func TestDotImport(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
import {x} from '.'
console.log(x)
`,
"/index.js": `
exports.x = 123
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38467 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
34207,
11511,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
21918,
314,
87,
92,
504,
6256,
124... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDFS(t *testing.T) {
g4 := gs.FromJSON("../../files/testgraph.json", "testgraph.004")
_ = DFS(g4)
/*
g4c1 := "S β B β A β D β E β T β F β C"
g4c2 := "S β B β D β E β A β T β F β C"
g4c3 := "S β B β E β A β D β C β F β T"
if g4s != g4c1 && g4s != g4c2 && g4s != g4c3 {
t.Errorf("Should be same but\n%v\n%v\n%v", g4s, g4c1, g4c2)
}
*/
allvisited4 := true
g4vts := g4.GetVertices()
for _, vtx := range *g4vts {
if "black" != fmt.Sprintf("%v", vtx.(*gs.Vertex).Color) {
allvisited4 = false
}
}
if !allvisited4 {
t.Errorf("All vertices should be marked black")
}
g5 := gs.FromJSON("../../files/testgraph.json", "testgraph.005")
_ = DFS(g5)
/*
g5c1 := "A β C β F β B β D β E"
g5c2 := "A β B β C β F β D β E"
if g5s != g5c1 && g5s != g5c2 {
t.Errorf("Should be same but\n%v\n%v\n%v", g5s, g5c1, g5c2)
}
*/
allvisited5 := true
g5vts := g5.GetVertices()
for _, vtx := range *g5vts {
if "black" != fmt.Sprintf("%v", vtx.(*gs.Vertex).Color) {
allvisited5 = false
}
}
if !allvisited5 {
t.Errorf("All vertices should be marked black")
}
} | explode_data.jsonl/51287 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 576
} | [
2830,
3393,
62266,
1155,
353,
8840,
836,
8,
341,
3174,
19,
1669,
28081,
11439,
5370,
36800,
7198,
12697,
4439,
4323,
497,
330,
1944,
4439,
13,
15,
15,
19,
1138,
197,
62,
284,
56383,
3268,
19,
340,
197,
3284,
197,
3174,
19,
66,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestCreateTenant(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
mockCreateTenantResponse(t)
opts := tenants.CreateOpts{
Name: "new_tenant",
Description: "This is new tenant",
Enabled: golangsdk.Enabled,
}
tenant, err := tenants.Create(client.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
expected := &tenants.Tenant{
Name: "new_tenant",
Description: "This is new tenant",
Enabled: true,
ID: "5c62ef576dc7444cbb73b1fe84b97648",
}
th.AssertDeepEquals(t, expected, tenant)
} | explode_data.jsonl/82167 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 243
} | [
2830,
3393,
4021,
71252,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
77333,
4021,
71252,
2582,
1155,
692,
64734,
1669,
39916,
7251,
43451,
515,
197,
21297,
25,
286,
330,
931,
528,
25121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAzureBlobNoContainerFails(t *testing.T) {
g := gomega.NewGomegaWithT(t)
isvc := makeTestInferenceService()
isvc.Spec.Default.Predictor.Tensorflow.StorageURI = "https://foo.blob.core.windows.net/"
g.Expect(isvc.validate(c)).ShouldNot(gomega.Succeed())
} | explode_data.jsonl/1484 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
78107,
37985,
2753,
4502,
37,
6209,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
340,
19907,
7362,
1669,
1281,
2271,
641,
2202,
1860,
741,
19907,
7362,
36473,
13275,
1069,
8861,
269,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetWithEtag(t *testing.T) {
resetTest()
req, err := http.NewRequest("GET", s.server.URL+"/etag", nil)
if err != nil {
t.Fatal(err)
}
{
resp, err := s.client.Do(req)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.Header.Get(XFromCache) != "" {
t.Fatal("XFromCache header isn't blank")
}
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
}
{
resp, err := s.client.Do(req)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.Header.Get(XFromCache) != "1" {
t.Fatalf(`XFromCache header isn't "1": %v`, resp.Header.Get(XFromCache))
}
// additional assertions to verify that 304 response is converted properly
if resp.StatusCode != http.StatusOK {
t.Fatalf("response status code isn't 200 OK: %v", resp.StatusCode)
}
if _, ok := resp.Header["Connection"]; ok {
t.Fatalf("Connection header isn't absent")
}
}
} | explode_data.jsonl/77619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 404
} | [
2830,
3393,
1949,
2354,
36,
4578,
1155,
353,
8840,
836,
8,
341,
70343,
2271,
741,
24395,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
274,
12638,
20893,
27569,
80465,
497,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestModel_Forward(t *testing.T) {
model := New()
g := ag.NewGraph()
ctx := nn.Context{Graph: g, Mode: nn.Training}
// == Forward
x1 := g.NewVariable(mat.NewVecDense([]mat.Float{1.0, 2.0, 0.0, 4.0}), true)
x2 := g.NewVariable(mat.NewVecDense([]mat.Float{3.0, 2.0, 1.0, 6.0}), true)
x3 := g.NewVariable(mat.NewVecDense([]mat.Float{6.0, 2.0, 5.0, 1.0}), true)
y := nn.Reify(ctx, model).(*Model).Forward(x1, x2, x3)
assert.InDeltaSlice(t, []mat.Float{-0.5070925528, 0.1690308509, -1.1832159566, 1.5212776585}, y[0].Value().Data(), 1.0e-06)
assert.InDeltaSlice(t, []mat.Float{0.0, -0.5345224838, -1.0690449676, 1.6035674515}, y[1].Value().Data(), 1.0e-06)
assert.InDeltaSlice(t, []mat.Float{1.2126781252, -0.7276068751, 0.7276068751, -1.2126781252}, y[2].Value().Data(), 1.0e-06)
// == Backward
y[0].PropagateGrad(mat.NewVecDense([]mat.Float{-1.0, -0.2, 0.4, 0.6}))
y[1].PropagateGrad(mat.NewVecDense([]mat.Float{-0.3, 0.1, 0.7, 0.9}))
y[2].PropagateGrad(mat.NewVecDense([]mat.Float{0.3, -0.4, 0.7, -0.8}))
g.BackwardAll()
assert.InDeltaSlice(t, []mat.Float{-0.5640800969, -0.1274975561, 0.4868088507, 0.2047688023}, x1.Grad().Data(), 1.0e-06)
assert.InDeltaSlice(t, []mat.Float{-0.3474396144, -0.0878144080, 0.2787152951, 0.1565387274}, x2.Grad().Data(), 1.0e-06)
assert.InDeltaSlice(t, []mat.Float{-0.1440946948, 0.0185468419, 0.1754816581, -0.0499338051}, x3.Grad().Data(), 1.0e-06)
} | explode_data.jsonl/15146 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 716
} | [
2830,
3393,
1712,
84368,
1606,
1155,
353,
8840,
836,
8,
341,
19727,
1669,
1532,
741,
3174,
1669,
933,
7121,
11212,
741,
20985,
1669,
10883,
9328,
90,
11212,
25,
342,
11,
14562,
25,
10883,
8240,
2056,
630,
197,
322,
621,
22164,
198,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBaseIdentity_ExhaustGettersSetters(t *testing.T) {
i := getTestBaseIdentity()
if i.IsExhausted() {
t.Error("IsExhausted should have returned false, but retunned true")
}
r := i.Exhaust()
if !i.IsExhausted() {
t.Error("Exhaust should have set exhausted to true, but it was false")
}
if !r {
t.Error("Calling Exhaust when exhaust was set to false should have returned true, it returned false")
}
sr := i.Exhaust()
if sr {
t.Error("Calling exhaust when exhaust was set to true should have returned false, it returned true")
}
i.Ready()
if i.IsExhausted() {
t.Errorf("Ready should have set exhausted to false, it was true")
}
} | explode_data.jsonl/55783 | {
"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,
3978,
18558,
62531,
15074,
1949,
5045,
1649,
5045,
1155,
353,
8840,
836,
8,
341,
8230,
1669,
633,
2271,
3978,
18558,
741,
743,
600,
4506,
840,
15074,
291,
368,
341,
197,
3244,
6141,
445,
3872,
840,
15074,
291,
1265,
614,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.