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 TestAsOfSystemTimeOnRestoredData(t *testing.T) {
defer leaktest.AfterTest(t)()
const numAccounts = 10
_, _, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, singleNode, numAccounts, InitNone)
defer cleanupFn()
sqlDB.Exec(t, `BACKUP data.* To $1`, LocalFoo)
sqlDB.Exec(t, `DROP TABLE data.bank`)
var beforeTs string
sqlDB.QueryRow(t, `SELECT cluster_logical_timestamp()`).Scan(&beforeTs)
sqlDB.Exec(t, `RESTORE data.* FROM $1`, LocalFoo)
var afterTs string
sqlDB.QueryRow(t, `SELECT cluster_logical_timestamp()`).Scan(&afterTs)
var rowCount int
const q = `SELECT count(*) FROM data.bank AS OF SYSTEM TIME '%s'`
// Before the RESTORE, the table doesn't exist, so an AS OF query should fail.
sqlDB.ExpectErr(
t, `relation "data.bank" does not exist`,
fmt.Sprintf(q, beforeTs),
)
// After the RESTORE, an AS OF query should work.
sqlDB.QueryRow(t, fmt.Sprintf(q, afterTs)).Scan(&rowCount)
if expected := numAccounts; rowCount != expected {
t.Fatalf("expected %d rows but found %d", expected, rowCount)
}
} | explode_data.jsonl/57597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 384
} | [
2830,
3393,
2121,
2124,
2320,
1462,
1925,
12416,
3018,
1043,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
1629,
41369,
284,
220,
16,
15,
198,
197,
6878,
8358,
5704,
3506,
11,
8358,
21290,
24911,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractTopics(t *testing.T) {
testCases := map[string]struct {
Members []GroupMember
Topics []string
}{
"nil": {},
"single member, single topic": {
Members: []GroupMember{
{
ID: "a",
Topics: []string{"topic"},
},
},
Topics: []string{"topic"},
},
"two members, single topic": {
Members: []GroupMember{
{
ID: "a",
Topics: []string{"topic"},
},
{
ID: "b",
Topics: []string{"topic"},
},
},
Topics: []string{"topic"},
},
"two members, two topics": {
Members: []GroupMember{
{
ID: "a",
Topics: []string{"topic-1"},
},
{
ID: "b",
Topics: []string{"topic-2"},
},
},
Topics: []string{"topic-1", "topic-2"},
},
"three members, three shared topics": {
Members: []GroupMember{
{
ID: "a",
Topics: []string{"topic-1", "topic-2"},
},
{
ID: "b",
Topics: []string{"topic-2", "topic-3"},
},
{
ID: "c",
Topics: []string{"topic-3", "topic-1"},
},
},
Topics: []string{"topic-1", "topic-2", "topic-3"},
},
}
for label, tc := range testCases {
t.Run(label, func(t *testing.T) {
topics := extractTopics(tc.Members)
if !reflect.DeepEqual(tc.Topics, topics) {
t.Errorf("expected %v; got %v", tc.Topics, topics)
}
})
}
} | explode_data.jsonl/80373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 683
} | [
2830,
3393,
28959,
45003,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
9209,
7062,
3056,
2808,
9366,
198,
197,
197,
45003,
220,
3056,
917,
198,
197,
59403,
197,
197,
79925,
788,
14573,
197,
197,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAlertProvider_ToCustomAlertProviderWithResolvedAlert(t *testing.T) {
provider := AlertProvider{WebhookURL: "http://example.com"}
customAlertProvider := provider.ToCustomAlertProvider(&core.Service{}, &alert.Alert{}, &core.Result{ConditionResults: []*core.ConditionResult{{Condition: "SUCCESSFUL_CONDITION", Success: true}}}, true)
if customAlertProvider == nil {
t.Fatal("customAlertProvider shouldn't have been nil")
}
if !strings.Contains(customAlertProvider.Body, "resolved") {
t.Error("customAlertProvider.Body should've contained the substring resolved")
}
if customAlertProvider.URL != "http://example.com" {
t.Errorf("expected URL to be %s, got %s", "http://example.com", customAlertProvider.URL)
}
if customAlertProvider.Method != http.MethodPost {
t.Errorf("expected method to be %s, got %s", http.MethodPost, customAlertProvider.Method)
}
body := make(map[string]interface{})
err := json.Unmarshal([]byte(customAlertProvider.Body), &body)
if err != nil {
t.Error("expected body to be valid JSON, got error:", err.Error())
}
} | explode_data.jsonl/56727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 339
} | [
2830,
3393,
9676,
5179,
38346,
10268,
9676,
5179,
2354,
65394,
9676,
1155,
353,
8840,
836,
8,
341,
197,
19979,
1669,
13975,
5179,
90,
5981,
20873,
3144,
25,
330,
1254,
1110,
8687,
905,
16707,
1444,
1450,
9676,
5179,
1669,
9109,
3274,
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... | 6 |
func TestDeleteExperiment(t *testing.T) {
store, manager, experiment := initWithExperiment(t)
defer store.Close()
err := manager.DeleteExperiment(experiment.UUID)
assert.Nil(t, err)
_, err = manager.GetExperiment(experiment.UUID)
assert.Equal(t, codes.NotFound, err.(*util.UserError).ExternalStatusCode())
assert.Contains(t, err.Error(), "not found")
} | explode_data.jsonl/28367 | {
"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,
6435,
77780,
1155,
353,
8840,
836,
8,
341,
57279,
11,
6645,
11,
9342,
1669,
13864,
77780,
1155,
340,
16867,
3553,
10421,
741,
9859,
1669,
6645,
18872,
77780,
5463,
14329,
39636,
340,
6948,
59678,
1155,
11,
1848,
692,
197,
68... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJWTIsRequired(t *testing.T) {
MiddlewareStack = []negroni.Handler{}
app = nil
os.Setenv("PREST_JWT_DEFAULT", "true")
os.Setenv("PREST_DEBUG", "false")
config.Load()
nd := appTestWithJwt()
serverd := httptest.NewServer(nd)
defer serverd.Close()
respd, err := http.Get(serverd.URL)
if err != nil {
t.Errorf("expected no errors, but got %v", err)
}
if respd.StatusCode != http.StatusUnauthorized {
t.Errorf("expected status code 401, but got %d", respd.StatusCode)
}
} | explode_data.jsonl/51062 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
55172,
58541,
1155,
353,
8840,
836,
8,
341,
9209,
11603,
4336,
284,
3056,
28775,
2248,
72,
31010,
16094,
28236,
284,
2092,
198,
25078,
4202,
3160,
445,
17357,
784,
10598,
18454,
13811,
497,
330,
1866,
1138,
25078,
4202,
3160,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadTimeout(t *testing.T) {
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
}
handler := func(ls *localServer, ln Listener) {
c, err := ln.Accept()
if err != nil {
t.Error(err)
return
}
c.Write([]byte("READ TIMEOUT TEST"))
defer c.Close()
}
ls, err := newLocalServer("tcp")
if err != nil {
t.Fatal(err)
}
defer ls.teardown()
if err := ls.buildup(handler); err != nil {
t.Fatal(err)
}
c, err := Dial(ls.Listener.Addr().Network(), ls.Listener.Addr().String())
if err != nil {
t.Fatal(err)
}
defer c.Close()
for i, tt := range readTimeoutTests {
if err := c.SetReadDeadline(time.Now().Add(tt.timeout)); err != nil {
t.Fatalf("#%d: %v", i, err)
}
var b [1]byte
for j, xerr := range tt.xerrs {
for {
n, err := c.Read(b[:])
if xerr != nil {
if perr := parseReadError(err); perr != nil {
t.Errorf("#%d/%d: %v", i, j, perr)
}
if nerr, ok := err.(Error); !ok || !nerr.Timeout() {
t.Fatalf("#%d/%d: %v", i, j, err)
}
}
if err == nil {
time.Sleep(tt.timeout / 3)
continue
}
if n != 0 {
t.Fatalf("#%d/%d: read %d; want 0", i, j, n)
}
break
}
}
}
} | explode_data.jsonl/57677 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 613
} | [
2830,
3393,
4418,
7636,
1155,
353,
8840,
836,
8,
341,
8961,
15592,
97574,
3126,
341,
2722,
330,
10393,
24,
4660,
197,
3244,
57776,
69,
445,
1921,
7248,
389,
1018,
82,
497,
15592,
97574,
3126,
340,
197,
630,
53326,
1669,
2915,
62991,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_Pagination_PrevNext_HeldBackLinks(t *testing.T) {
doc := testutil.CreateHTML()
body := dom.QuerySelector(doc, "body")
root := testutil.CreateDiv(0)
dom.AppendChild(body, root)
nextAnchor := testutil.CreateAnchor("page2", "next page")
dom.AppendChild(root, nextAnchor)
// If "page2" gets bad scores from other links, it would be missed.
bad := testutil.CreateAnchor("page2", "prev or next")
dom.AppendChild(root, bad)
assertDefaultDocumenOutlink(t, doc, nil, nextAnchor)
} | explode_data.jsonl/10831 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
1088,
10353,
1088,
7282,
5847,
2039,
783,
3707,
24089,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
1273,
1314,
7251,
5835,
741,
35402,
1669,
4719,
15685,
5877,
19153,
11,
330,
2599,
5130,
33698,
1669,
1273,
1314,
7251,
12509,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfirmUsableMissingConfig(t *testing.T) {
config := clientcmdapi.NewConfig()
test := configValidationTest{
config: config,
expectedErrorSubstring: []string{"invalid configuration: no configuration has been provided"},
}
test.testConfirmUsable("not-here", t)
} | explode_data.jsonl/13482 | {
"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,
16728,
3558,
480,
25080,
2648,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
2943,
8710,
2068,
7121,
2648,
741,
18185,
1669,
2193,
13799,
2271,
515,
197,
25873,
25,
338,
2193,
345,
197,
42400,
1454,
59075,
25,
3056,
917,
4913,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoProjectID(t *testing.T) {
client, err := NewClient(context.Background(), &internal.InstanceIDConfig{})
if client != nil || err == nil {
t.Errorf("NewClient() = (%v, %v); want = (nil, error)", client, err)
}
} | explode_data.jsonl/54621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
2753,
7849,
915,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
1532,
2959,
5378,
19047,
1507,
609,
10481,
12688,
915,
2648,
37790,
743,
2943,
961,
2092,
1369,
1848,
621,
2092,
341,
197,
3244,
13080,
445,
3564,
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
] | 3 |
func Test_IntStrMap_Batch(t *testing.T) {
m := gmap.NewIntStrMap()
m.Sets(map[int]string{1: "a", 2: "b", 3: "c"})
gtest.Assert(m.Map(), map[int]string{1: "a", 2: "b", 3: "c"})
m.Removes([]int{1, 2})
gtest.Assert(m.Map(), map[int]interface{}{3: "c"})
} | explode_data.jsonl/7641 | {
"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,
32054,
2580,
2227,
1668,
754,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
342,
2186,
7121,
1072,
2580,
2227,
2822,
2109,
808,
1415,
9147,
18640,
30953,
90,
16,
25,
330,
64,
497,
220,
17,
25,
330,
65,
497,
220,
18,
25,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHello(t *testing.T) {
want := "Hello, world."
if got := Hello(); got != want {
t.Errorf("Hello() = %q, want %q", got, want)
}
} | explode_data.jsonl/16569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
9707,
1155,
353,
8840,
836,
8,
341,
262,
1366,
1669,
330,
9707,
11,
1879,
10040,
262,
421,
2684,
1669,
21927,
2129,
2684,
961,
1366,
341,
286,
259,
13080,
445,
9707,
368,
284,
1018,
80,
11,
1366,
1018,
80,
497,
2684,
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
] | 2 |
func TestRollupBigNumberOfValues(t *testing.T) {
const srcValuesCount = 1e4
rc := rollupConfig{
Func: rollupDefault,
End: srcValuesCount,
Step: srcValuesCount / 5,
Window: srcValuesCount / 4,
}
rc.Timestamps = getTimestamps(rc.Start, rc.End, rc.Step)
srcValues := make([]float64, srcValuesCount)
srcTimestamps := make([]int64, srcValuesCount)
for i := 0; i < srcValuesCount; i++ {
srcValues[i] = float64(i)
srcTimestamps[i] = int64(i / 2)
}
values := rc.Do(nil, srcValues, srcTimestamps)
valuesExpected := []float64{1, 4001, 8001, 9999, nan, nan}
timestampsExpected := []int64{0, 2000, 4000, 6000, 8000, 10000}
testRowsEqual(t, values, rc.Timestamps, valuesExpected, timestampsExpected)
} | explode_data.jsonl/23125 | {
"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,
32355,
454,
15636,
40619,
6227,
1155,
353,
8840,
836,
8,
341,
4777,
2286,
6227,
2507,
284,
220,
16,
68,
19,
198,
30295,
1669,
6502,
454,
2648,
515,
197,
197,
9626,
25,
256,
6502,
454,
3675,
345,
197,
38407,
25,
262,
2286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckAuthorization(t *testing.T) {
auth := setupAuthorizationTest(t)
err := checkAuthorization(auth.ctx, auth.id, auth.ttl, auth.resource, auth.view, auth.role, auth.cfg, test.TestClientID, auth.dam.ValidateCfgOpts(storage.DefaultRealm, nil))
if err != nil {
t.Errorf("checkAuthorization(ctx, id, %v, %q, %q, %q, cfg, %q) failed, expected %d, got: %v", auth.ttl, auth.resource, auth.view, auth.role, test.TestClientID, http.StatusOK, err)
}
// TODO: we need more tests for other condition in checkAuthorization()
} | explode_data.jsonl/18481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
3973,
18124,
1155,
353,
8840,
836,
8,
341,
78011,
1669,
6505,
18124,
2271,
1155,
340,
9859,
1669,
1779,
18124,
27435,
30608,
11,
4166,
1764,
11,
4166,
734,
11544,
11,
4166,
24013,
11,
4166,
3792,
11,
4166,
26006,
11,
4166,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnnotatingExecuteKeyspaceIdsMultipleIds(t *testing.T) {
keyspace, shards := setUpSandboxWithTwoShards("TestAnnotatingExecuteKeyspaceIdsMultipleIds")
_, err := rpcVTGate.ExecuteKeyspaceIds(
context.Background(),
"INSERT INTO table () VALUES();",
nil,
keyspace,
[][]byte{{0x10}, {0x15}},
topodatapb.TabletType_MASTER,
nil,
false,
nil)
if err == nil || !strings.Contains(err.Error(), "DML should not span multiple keyspace_ids") {
t.Fatalf("want specific error, got %v", err)
}
// Currently, there's logic in resolver.go for rejecting
// multiple-ids DML's so we expect 0 queries here.
verifyNumQueries(t, 0, shards[0].Queries)
} | explode_data.jsonl/7845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
2082,
1921,
1095,
17174,
8850,
1306,
12701,
32089,
12701,
1155,
353,
8840,
836,
8,
341,
23634,
8746,
11,
74110,
1669,
18620,
50,
31536,
2354,
11613,
2016,
2347,
445,
2271,
2082,
1921,
1095,
17174,
8850,
1306,
12701,
32089,
127... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_StringIsIntDive(t *testing.T) {
r := require.New(t)
field := []string{"1", "+1", "0", "-12"}
v := StringSliceDive{
Validator: &StringIsInt{
Name: "MySlice",
},
Field: field,
}
e := validator.NewErrors()
v.Validate(e)
r.Equal(0, e.Count())
field = []string{"11", "12.5", "a", " 11", "1 1", " ", ""}
v = StringSliceDive{
Validator: &StringIsInt{
Name: "MySlice",
},
Field: field,
}
e = validator.NewErrors()
v.Validate(e)
r.Equal(5, e.Count())
} | explode_data.jsonl/35839 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
31777,
3872,
1072,
35,
533,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
692,
39250,
1669,
3056,
917,
4913,
16,
497,
6630,
16,
497,
330,
15,
497,
6523,
16,
17,
63159,
5195,
1669,
923,
33236,
35,
533,
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 TestLicenseFile(t *testing.T) {
testCases := []struct {
path string
result string
}{
// 0 - no license
{
path: "",
result: filepath.Join(defaults.DataDir, defaults.LicenseFile),
},
// 1 - relative path
{
path: "lic.pem",
result: filepath.Join(defaults.DataDir, "lic.pem"),
},
// 2 - absolute path
{
path: "/etc/teleport/license",
result: "/etc/teleport/license",
},
}
cfg := service.MakeDefaultConfig()
require.Equal(t, filepath.Join(defaults.DataDir, defaults.LicenseFile), cfg.Auth.LicenseFile)
for _, tc := range testCases {
fc := new(FileConfig)
require.NoError(t, fc.CheckAndSetDefaults())
fc.Auth.LicenseFile = tc.path
err := ApplyFileConfig(fc, cfg)
require.NoError(t, err)
require.Equal(t, tc.result, cfg.Auth.LicenseFile)
}
} | explode_data.jsonl/47172 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
9827,
1703,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
26781,
256,
914,
198,
197,
9559,
914,
198,
197,
59403,
197,
197,
322,
220,
15,
481,
902,
5723,
198,
197,
197,
515,
298,
26781,
25,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewMarketName(t *testing.T) {
mkt, err := MarketName(AssetDCR, AssetBTC)
if err != nil {
t.Fatalf("MarketName(%d,%d) failed: %v", AssetDCR, AssetBTC, err)
}
if mkt != "dcr_btc" {
t.Errorf("Incorrect market name. Got %s, expected %s", mkt, "dcr_btc")
}
} | explode_data.jsonl/15942 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
3564,
38822,
675,
1155,
353,
8840,
836,
8,
341,
2109,
5840,
11,
1848,
1669,
7993,
675,
7,
16604,
5626,
49,
11,
22605,
59118,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
38822,
675,
15238,
67,
18191,
67,
8,
464... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseImportWithString(t *testing.T) {
t.Parallel()
result, errs := ParseProgram(`
import "test.cdc"
`)
require.Empty(t, errs)
utils.AssertEqualWithDiff(t,
[]ast.Declaration{
&ast.ImportDeclaration{
Identifiers: nil,
Location: common.StringLocation("test.cdc"),
Range: ast.Range{
StartPos: ast.Position{Offset: 9, Line: 2, Column: 8},
EndPos: ast.Position{Offset: 25, Line: 2, Column: 24},
},
LocationPos: ast.Position{Offset: 16, Line: 2, Column: 15},
},
},
result.Declarations(),
)
} | explode_data.jsonl/35981 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
14463,
11511,
52342,
1155,
353,
8840,
836,
8,
1476,
3244,
41288,
7957,
2822,
9559,
11,
70817,
1669,
14775,
10690,
61528,
286,
1159,
330,
1944,
520,
7628,
698,
197,
24183,
17957,
11180,
1155,
11,
70817,
692,
80206,
11711,
2993,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSalesforceAPI_UpdatedRecords(t *testing.T) {
type fields struct {
metadata *metadata
describe *describe
dml *dml
query *query
}
type args struct {
sobject string
startDate time.Time
endDate time.Time
}
tests := []struct {
name string
fields fields
args args
want UpdatedRecords
wantErr bool
}{
{
name: "No Query field",
want: UpdatedRecords{},
wantErr: true,
},
{
name: "Invalid Args",
fields: fields{
query: &query{
session: &session.Mock{
URL: "http://wwww.google.com",
},
},
},
want: UpdatedRecords{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := &Resources{
metadata: tt.fields.metadata,
describe: tt.fields.describe,
dml: tt.fields.dml,
query: tt.fields.query,
}
got, err := a.UpdatedRecords(tt.args.sobject, tt.args.startDate, tt.args.endDate)
if (err != nil) != tt.wantErr {
t.Errorf("SalesforceAPI.UpdatedRecords() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("SalesforceAPI.UpdatedRecords() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/45147 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 593
} | [
2830,
3393,
35418,
8833,
7082,
62,
16196,
25876,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
2109,
7603,
353,
17637,
198,
197,
82860,
353,
12332,
198,
197,
2698,
1014,
414,
353,
67,
1014,
198,
197,
27274,
262,
353,
1631... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestButton_ToUSI(t *testing.T) {
b := &Button{Name: "test"}
res := b.ToUSI()
usi := "setoption name test"
if res != usi {
t.Errorf(`
[app > domain > entity > engine > Button.ToUSI]
Expected: %s
Actual: %s
`, usi, res)
}
} | explode_data.jsonl/57623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
1567,
38346,
2034,
40,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
609,
1567,
63121,
25,
330,
1944,
16707,
10202,
1669,
293,
3274,
2034,
40,
741,
197,
52813,
1669,
330,
746,
2047,
829,
1273,
1837,
743,
592,
961,
601,
72,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGenerateTagList(t *testing.T) {
tests := []struct {
name string
ASGName string
ASGLCName string
instanceTags []*ec2.Tag
expectedTagSpecification []*ec2.TagSpecification
}{
{name: "no tags on original instance",
ASGLCName: "testLC0",
ASGName: "myASG",
instanceTags: []*ec2.Tag{},
expectedTagSpecification: []*ec2.TagSpecification{
{
ResourceType: aws.String("instance"),
Tags: []*ec2.Tag{
{
Key: aws.String("LaunchConfigurationName"),
Value: aws.String("testLC0"),
},
{
Key: aws.String("launched-by-autospotting"),
Value: aws.String("true"),
},
{
Key: aws.String("launched-for-asg"),
Value: aws.String("myASG"),
},
},
},
},
},
{name: "Multiple tags on original instance",
ASGLCName: "testLC0",
ASGName: "myASG",
instanceTags: []*ec2.Tag{
{
Key: aws.String("foo"),
Value: aws.String("bar"),
},
{
Key: aws.String("baz"),
Value: aws.String("bazinga"),
},
},
expectedTagSpecification: []*ec2.TagSpecification{
{
ResourceType: aws.String("instance"),
Tags: []*ec2.Tag{
{
Key: aws.String("LaunchConfigurationName"),
Value: aws.String("testLC0"),
},
{
Key: aws.String("launched-by-autospotting"),
Value: aws.String("true"),
},
{
Key: aws.String("launched-for-asg"),
Value: aws.String("myASG"),
},
{
Key: aws.String("foo"),
Value: aws.String("bar"),
},
{
Key: aws.String("baz"),
Value: aws.String("bazinga"),
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
i := instance{
Instance: &ec2.Instance{
Tags: tt.instanceTags,
},
asg: &autoScalingGroup{
name: tt.ASGName,
Group: &autoscaling.Group{
LaunchConfigurationName: aws.String(tt.ASGLCName),
},
},
}
tags := i.generateTagsList()
if !reflect.DeepEqual(tags, tt.expectedTagSpecification) {
t.Errorf("propagatedInstanceTags received: %+v, expected: %+v",
tags, tt.expectedTagSpecification)
}
})
}
} | explode_data.jsonl/55204 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1215
} | [
2830,
3393,
31115,
5668,
852,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
3824,
914,
198,
197,
197,
1911,
38,
675,
1698,
914,
198,
197,
197,
1911,
3825,
34,
675,
394,
914,
198,
197,
56256,
15930,
1797,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestParseSPBlock(t *testing.T) {
data, err := network.ReadBlobData(path.Join("..", "testdata"), 16)
require.NoError(t, err)
rw := network.NewBlobReader(data)
reader := network.NewMultiReader(rw)
err = reader.Seek(36870)
require.NoError(t, err)
err = parseSPBlock(reader)
require.NoError(t, err)
} | explode_data.jsonl/35188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
14463,
4592,
4713,
1155,
353,
8840,
836,
8,
341,
8924,
11,
1848,
1669,
3922,
6503,
37985,
1043,
5581,
22363,
95032,
497,
330,
92425,
3975,
220,
16,
21,
340,
17957,
35699,
1155,
11,
1848,
340,
7000,
86,
1669,
3922,
7121,
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... | 1 |
func TestPeerWithSubstitutedConfig_WithSubstituteUrlExpression(t *testing.T) {
_, fetchedConfig := testCommonConfigPeer(t, "peer0.org1.example.com", "peer5.example4.com:1234")
if fetchedConfig.URL != "peer5.org1.example.com:1234" {
t.Fatal("fetched Config url should change to include org1 as given in the substituteexp in yaml file")
}
if fetchedConfig.GRPCOptions["ssl-target-name-override"] != "peer5.org1.example.com" {
t.Fatal("Fetched config should have the ssl-target-name-override as per sslTargetOverrideUrlSubstitutionExp in yaml file")
}
} | explode_data.jsonl/34083 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
30888,
2354,
3136,
3696,
2774,
2648,
62,
2354,
3136,
7660,
2864,
9595,
1155,
353,
8840,
836,
8,
341,
197,
6878,
41442,
2648,
1669,
1273,
10839,
2648,
30888,
1155,
11,
330,
16537,
15,
2659,
16,
7724,
905,
497,
330,
16537,
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... | 3 |
func TestAddProwPlugin(t *testing.T) {
t.Parallel()
o := TestOptions{}
o.Setup()
o.Kind = prowconfig.Environment
o.EnvironmentNamespace = "jx-staging"
o.Repos = append(o.Repos, "test/repo2")
data := make(map[string]string)
data["domain"] = "dummy.domain.nip.io"
data["tls"] = "false"
cm := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: kube.IngressConfigConfigmap,
},
Data: data,
}
_, err := o.KubeClient.CoreV1().ConfigMaps(o.NS).Create(cm)
assert.NoError(t, err)
err = o.AddProwPlugins()
assert.NoError(t, err)
cm, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Get(prow.ProwPluginsConfigMapName, metav1.GetOptions{})
assert.NoError(t, err)
pluginConfig := &plugins.Configuration{}
assert.NoError(t, yaml.Unmarshal([]byte(cm.Data[prow.ProwPluginsFilename]), &pluginConfig))
assert.Equal(t, "test/repo", pluginConfig.Approve[0].Repos[0])
assert.Equal(t, "test/repo2", pluginConfig.Approve[1].Repos[0])
assert.Contains(t, pluginConfig.Plugins, "test/repo2")
assert.NotEmpty(t, pluginConfig.Plugins["test/repo2"])
} | explode_data.jsonl/220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 444
} | [
2830,
3393,
2212,
47,
651,
11546,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22229,
1669,
3393,
3798,
16094,
22229,
39820,
741,
22229,
54199,
284,
47558,
1676,
45651,
198,
22229,
45651,
22699,
284,
330,
73,
87,
5477,
4118,
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 TestDesEncrypt(t *testing.T) {
key := []byte(RandString(8))
origtext := []byte("hello world123563332")
t.Run("success", func(t *testing.T) {
erytext, err := DesEncrypt(origtext, key)
if !assert.NoError(t, err) {
t.FailNow()
}
destext, err := DesDecrypt(erytext, key)
if !assert.NoError(t, err) {
t.FailNow()
}
assert.Equal(t, string(origtext), string(destext))
})
t.Run("error empty key", func(t *testing.T) {
_, err := DesEncrypt(origtext, nil)
if !assert.Error(t, err) {
t.FailNow()
}
})
t.Run("error orig key", func(t *testing.T) {
_, err := DesEncrypt(nil, key)
if !assert.Error(t, err) {
t.FailNow()
}
})
} | explode_data.jsonl/40096 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 301
} | [
2830,
3393,
4896,
61520,
1155,
353,
8840,
836,
8,
341,
23634,
1669,
3056,
3782,
2785,
437,
703,
7,
23,
1171,
197,
4670,
1318,
1669,
3056,
3782,
445,
14990,
1879,
16,
17,
18,
20,
21,
18,
18,
18,
17,
1138,
3244,
16708,
445,
5630,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMakeOCIBundle(t *testing.T) {
assert := assert.New(t)
tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)
bundleDir := filepath.Join(tmpdir, "bundle")
err = makeOCIBundle(bundleDir)
assert.NoError(err)
specFile := filepath.Join(bundleDir, specConfig)
assert.True(katautils.FileExists(specFile))
} | explode_data.jsonl/52188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
8078,
7612,
3256,
4206,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
8623,
6184,
11,
14676,
6948,
35699,
3964,
340,
16867,
2643,
84427,
10368,
3741,
692,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_initFailedLoginCount(t *testing.T) {
var username string
var object, schema types.M
var accountLockout *AccountLockout
var err error
var results, expect []types.M
/*****************************************************************/
initEnv()
username = "joe"
schema = types.M{
"fields": types.M{
"username": types.M{"type": "String"},
"password": types.M{"type": "String"},
},
}
orm.Adapter.CreateClass("_User", schema)
object = types.M{
"objectId": "01",
"username": username,
}
orm.Adapter.CreateObject("_User", schema, object)
accountLockout = NewAccountLockout(username)
err = accountLockout.initFailedLoginCount()
if err != nil {
t.Error("expect:", nil, "result:", err)
}
results, err = orm.Adapter.Find("_User", schema, types.M{}, types.M{})
expect = []types.M{
types.M{
"objectId": "01",
"username": username,
"_failed_login_count": 0,
},
}
if reflect.DeepEqual(expect, results) == false {
t.Error("expect:", expect, "result:", results)
}
orm.TomatoDBController.DeleteEverything()
} | explode_data.jsonl/73718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
6137,
9408,
6231,
2507,
1155,
353,
8840,
836,
8,
341,
2405,
5934,
914,
198,
2405,
1633,
11,
10802,
4494,
1321,
198,
2405,
2692,
11989,
411,
353,
7365,
11989,
411,
198,
2405,
1848,
1465,
198,
2405,
3059,
11,
1720,
3056,
924... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConfigCommaSeparatedList(t *testing.T) {
assert := assert.New(t)
list := CommaSeparatedList{}
err := list.UnmarshalFlag("one,two")
assert.Nil(err)
assert.Equal(CommaSeparatedList{"one", "two"}, list, "should parse comma sepearated list")
marshal, err := list.MarshalFlag()
assert.Nil(err)
assert.Equal("one,two", marshal, "should marshal back to comma sepearated list")
} | explode_data.jsonl/33764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
2648,
1092,
1728,
91925,
852,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
14440,
1669,
1198,
1728,
91925,
852,
31483,
9859,
1669,
1140,
38097,
12135,
445,
603,
13960,
1126,
1138,
6948,
59678,
3964,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFindAppBySlug(t *testing.T) {
// clear the envs table when we're finished
defer truncate("123")
app := App{
EnvID: "123",
ID: "123_dev",
Name: "dev",
}
if err := app.Save(); err != nil {
t.Error(err)
}
app2, err := FindAppBySlug("123", "dev")
if err != nil {
t.Error(err)
}
if app2.EnvID != "123" || app2.Name != "dev" {
t.Errorf("did not load the correct env")
}
} | explode_data.jsonl/32900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
9885,
2164,
1359,
54968,
1155,
353,
8840,
836,
8,
341,
197,
322,
2797,
279,
6105,
82,
1965,
979,
582,
2299,
8060,
198,
16867,
56772,
445,
16,
17,
18,
5130,
28236,
1669,
1845,
515,
197,
197,
14359,
915,
25,
330,
16,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestOpenIdAuthControllerAuthenticatesCorrectlyWithAuthorizationCodeFlow(t *testing.T) {
cachedOpenIdMetadata = nil
var oidcMetadata []byte
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/.well-known/openid-configuration" {
w.WriteHeader(200)
_, _ = w.Write(oidcMetadata)
}
if r.URL.Path == "/token" {
_ = r.ParseForm()
assert.Equal(t, "f0code", r.Form.Get("code"))
assert.Equal(t, "authorization_code", r.Form.Get("grant_type"))
assert.Equal(t, "kiali-client", r.Form.Get("client_id"))
assert.Equal(t, "https://kiali.io:44/kiali-test", r.Form.Get("redirect_uri"))
w.WriteHeader(200)
_, _ = w.Write([]byte("{ \"id_token\": \"" + openIdTestToken + "\" }"))
}
}))
defer testServer.Close()
oidcMeta := openIdMetadata{
Issuer: testServer.URL,
AuthURL: testServer.URL + "/auth",
TokenURL: testServer.URL + "/token",
JWKSURL: testServer.URL + "/jwks",
UserInfoURL: "",
Algorithms: nil,
ScopesSupported: []string{"openid"},
ResponseTypesSupported: []string{"code"},
}
oidcMetadata, err := json.Marshal(oidcMeta)
assert.Nil(t, err)
clockTime := time.Date(2021, 12, 1, 0, 0, 0, 0, time.UTC)
util.Clock = util.ClockMock{Time: clockTime}
cfg := config.NewConfig()
cfg.Server.WebRoot = "/kiali-test"
cfg.LoginToken.SigningKey = "kiali67890123456"
cfg.LoginToken.ExpirationSeconds = 1
cfg.Auth.OpenId.IssuerUri = testServer.URL
cfg.Auth.OpenId.ClientId = "kiali-client"
config.Set(cfg)
// Returning some namespace when a cluster API call is made should have the result of
// a successful authentication.
k8s := kubetest.NewK8SClientMock()
k8s.On("GetProjects", "").Return([]osproject_v1.Project{
{ObjectMeta: meta_v1.ObjectMeta{Name: "Foo"}},
}, nil)
stateHash := sha256.Sum224([]byte(fmt.Sprintf("%s+%s+%s", "nonceString", clockTime.UTC().Format("060102150405"), config.GetSigningKey())))
uri := fmt.Sprintf("https://kiali.io:44/api/authenticate?code=f0code&state=%x-%s", stateHash, clockTime.UTC().Format("060102150405"))
request := httptest.NewRequest(http.MethodGet, uri, nil)
request.AddCookie(&http.Cookie{
Name: OpenIdNonceCookieName,
Value: "nonceString",
})
controller := NewOpenIdAuthController(CookieSessionPersistor{}, func(authInfo *api.AuthInfo) (*business.Layer, error) {
if authInfo.Token != openIdTestToken {
return nil, errors.New("unexpected token")
}
return business.NewWithBackends(k8s, nil, nil), nil
})
rr := httptest.NewRecorder()
controller.GetAuthCallbackHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Failf(t, "Callback function shouldn't have been called.", "")
})).ServeHTTP(rr, request)
expectedExpiration := time.Date(2021, 12, 1, 0, 0, 1, 0, time.UTC)
// Check that cookies are set and have the right expiration.
response := rr.Result()
assert.Len(t, response.Cookies(), 2)
// nonce cookie cleanup
assert.Equal(t, OpenIdNonceCookieName, response.Cookies()[0].Name)
assert.True(t, clockTime.After(response.Cookies()[0].Expires))
// Session cookie
assert.Equal(t, config.TokenCookieName+"-aes", response.Cookies()[1].Name)
assert.Equal(t, expectedExpiration, response.Cookies()[1].Expires)
assert.Equal(t, http.StatusFound, response.StatusCode)
// Redirection to boot the UI
assert.Equal(t, "/kiali-test/", response.Header.Get("Location"))
} | explode_data.jsonl/72705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1391
} | [
2830,
3393,
5002,
764,
5087,
2051,
5087,
4256,
973,
33092,
398,
2354,
18124,
2078,
18878,
1155,
353,
8840,
836,
8,
341,
1444,
3854,
5002,
764,
14610,
284,
2092,
198,
2405,
48766,
66,
14610,
3056,
3782,
198,
18185,
5475,
1669,
54320,
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... | 3 |
func TestSuccessDry(t *testing.T) {
testRepo := newTestRepo(t)
defer testRepo.cleanup(t)
testRepo.sut.SetDry()
err := testRepo.sut.Push(git.DefaultBranch)
require.Nil(t, err)
} | explode_data.jsonl/14005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
7188,
85215,
1155,
353,
8840,
836,
8,
341,
18185,
25243,
1669,
501,
2271,
25243,
1155,
340,
16867,
1273,
25243,
87689,
1155,
692,
18185,
25243,
514,
332,
4202,
85215,
2822,
9859,
1669,
1273,
25243,
514,
332,
34981,
3268,
275,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestChannelArbitratorBreachClose(t *testing.T) {
log := &mockArbitratorLog{
state: StateDefault,
newStates: make(chan ArbitratorState, 5),
}
chanArbCtx, err := createTestChannelArbitrator(t, log)
if err != nil {
t.Fatalf("unable to create ChannelArbitrator: %v", err)
}
chanArb := chanArbCtx.chanArb
if err := chanArb.Start(); err != nil {
t.Fatalf("unable to start ChannelArbitrator: %v", err)
}
defer func() {
if err := chanArb.Stop(); err != nil {
t.Fatal(err)
}
}()
// It should start out in the default state.
chanArbCtx.AssertState(StateDefault)
// Send a breach close event.
chanArb.cfg.ChainEvents.ContractBreach <- &lnwallet.BreachRetribution{}
// It should transition StateDefault -> StateFullyResolved.
chanArbCtx.AssertStateTransitions(
StateFullyResolved,
)
// It should also mark the channel as resolved.
select {
case <-chanArbCtx.resolvedChan:
// Expected.
case <-time.After(defaultTimeout):
t.Fatalf("contract was not resolved")
}
} | explode_data.jsonl/3693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
9629,
6953,
4489,
81,
850,
33,
22606,
7925,
1155,
353,
8840,
836,
8,
341,
6725,
1669,
609,
16712,
6953,
4489,
81,
850,
2201,
515,
197,
24291,
25,
257,
3234,
3675,
345,
197,
8638,
23256,
25,
1281,
35190,
58795,
81,
850,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeleteAppliedResourceFunc(t *testing.T) {
h := AppHandler{appliedResources: []common.ClusterObjectReference{
{
ObjectReference: corev1.ObjectReference{
Name: "wl-1",
Kind: "Deployment",
},
},
{
ObjectReference: corev1.ObjectReference{
Name: "wl-2",
Kind: "Deployment",
},
},
{
ObjectReference: corev1.ObjectReference{
Name: "wl-1",
Kind: "StatefulSet",
},
},
{
Cluster: "runtime-cluster",
ObjectReference: corev1.ObjectReference{
Name: "wl-1",
Kind: "StatefulSet",
},
},
}}
deleteResc_1 := common.ClusterObjectReference{ObjectReference: corev1.ObjectReference{Name: "wl-1", Kind: "StatefulSet"}, Cluster: "runtime-cluster"}
deleteResc_2 := common.ClusterObjectReference{ObjectReference: corev1.ObjectReference{Name: "wl-2", Kind: "Deployment"}}
h.deleteAppliedResource(deleteResc_1)
h.deleteAppliedResource(deleteResc_2)
if len(h.appliedResources) != 2 {
t.Errorf("applied length error acctually %d", len(h.appliedResources))
}
if h.appliedResources[0].Name != "wl-1" || h.appliedResources[0].Kind != "Deployment" {
t.Errorf("resource missmatch")
}
if h.appliedResources[1].Name != "wl-1" || h.appliedResources[1].Kind != "StatefulSet" {
t.Errorf("resource missmatch")
}
} | explode_data.jsonl/47029 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 513
} | [
2830,
3393,
6435,
75856,
4783,
9626,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
1845,
3050,
90,
391,
3440,
11277,
25,
3056,
5464,
72883,
1190,
8856,
515,
197,
197,
515,
298,
23816,
8856,
25,
6200,
85,
16,
8348,
8856,
515,
571,
21297,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunSpaceAreaREST(t *testing.T) {
resource.Require(t, resource.Database)
pwd, err := os.Getwd()
if err != nil {
require.NoError(t, err)
}
suite.Run(t, &TestSpaceAreaREST{DBTestSuite: gormtestsupport.NewDBTestSuite(pwd + "/../config.yaml")})
} | explode_data.jsonl/22621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
6727,
9914,
8726,
38307,
1155,
353,
8840,
836,
8,
341,
50346,
81288,
1155,
11,
5101,
25008,
340,
3223,
6377,
11,
1848,
1669,
2643,
2234,
6377,
741,
743,
1848,
961,
2092,
341,
197,
17957,
35699,
1155,
11,
1848,
340,
197,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPopulateCluster_TopologyInvalidNil_Required(t *testing.T) {
c := buildMinimalCluster()
c.Spec.Topology.Masters = ""
c.Spec.Topology.Nodes = ""
expectErrorFromPopulateCluster(t, c, "topology")
} | explode_data.jsonl/75043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
11598,
6334,
28678,
94819,
2449,
7928,
19064,
62,
8164,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
88328,
28678,
741,
1444,
36473,
17557,
2449,
1321,
14199,
284,
8389,
1444,
36473,
17557,
2449,
52184,
284,
8389,
24952,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInfo_expired(t *testing.T) {
assert := assert.New(t)
_, log, cleanup := setup(t)
defer cleanup()
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := log.Info(ctx)
assert.Equal(ctx.Err(), err)
} | explode_data.jsonl/60 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
1731,
80221,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
197,
6878,
1487,
11,
21290,
1669,
6505,
1155,
340,
16867,
21290,
741,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
84441,
741,
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 |
func Test_RpmSpecFile(t *testing.T) {
rpmspecfile := NewRpmSpecFile("testdata/rpm/vlc.spec")
if err := rpmspecfile.Process(); err != nil {
t.Errorf("Test_RpmSpecFile: %s", err)
return
}
name := rpmspecfile.Name()
dependencies := rpmspecfile.Dependencies()
sort.Strings(dependencies)
expectequalstrings(t,
"Test_RpmSpecFile",
name,
"vlc")
expectequalarraystrings(t,
"Test_RpmSpecFile",
dependencies,
[]string{ "alsa-lib-devel",
"ffmpeg",
"libgcrypt-devel",
"libva-devel",
"lua-devel",
"qt-devel",
"xcb-util-keysyms-devel" })
} | explode_data.jsonl/20245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 625
} | [
2830,
3393,
2568,
5187,
8327,
1703,
1155,
353,
8840,
836,
8,
341,
262,
33109,
1011,
992,
1192,
1669,
1532,
49,
5187,
8327,
1703,
445,
92425,
7382,
5187,
5457,
17257,
28326,
1138,
262,
421,
1848,
1669,
33109,
1011,
992,
1192,
29012,
2129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTxNil(t *testing.T) {
ctx := NewContext(t)
c := linearcodec.NewDefault()
m := codec.NewDefaultManager()
if err := m.RegisterCodec(codecVersion, c); err != nil {
t.Fatal(err)
}
tx := (*Tx)(nil)
if err := tx.SyntacticVerify(ctx, m, ids.Empty, 0, 0, 1); err == nil {
t.Fatalf("Should have errored due to nil tx")
}
if err := tx.SemanticVerify(nil, nil); err == nil {
t.Fatalf("Should have errored due to nil tx")
}
} | explode_data.jsonl/48911 | {
"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,
31584,
19064,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1532,
1972,
1155,
340,
1444,
1669,
13482,
34607,
7121,
3675,
741,
2109,
1669,
34647,
7121,
3675,
2043,
741,
743,
1848,
1669,
296,
19983,
36913,
67922,
5637,
11,
272,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestPublishInvalidEventTime(t *testing.T) {
payload := buildTestPayload(testSourceID, testEventType, testEventTypeVersion, testEventID,
testEventTimeInvalid, testData)
body, statusCode := performPublishRequest(t, publishServer.URL, payload)
assertExpectedError(t, body, statusCode, http.StatusBadRequest, api.FieldEventTime, api.ErrorTypeValidationViolation)
} | explode_data.jsonl/74418 | {
"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,
50145,
7928,
1556,
1462,
1155,
353,
8840,
836,
8,
341,
76272,
1669,
1936,
2271,
29683,
8623,
3608,
915,
11,
1273,
47906,
11,
1273,
47906,
5637,
11,
1273,
1556,
915,
345,
197,
18185,
1556,
1462,
7928,
11,
67348,
340,
35402,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQpsMissingMetrics(t *testing.T) {
tc := testCase{
replicas: 3,
desiredError: fmt.Errorf("requested metrics for 3 pods, got metrics for 1"),
metricName: "qps",
targetTimestamp: 1,
reportedMetricsPoints: [][]metricPoint{{{4000, 4}}},
}
tc.runTest(t)
} | explode_data.jsonl/66350 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
48,
1690,
25080,
27328,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
54452,
515,
197,
73731,
52210,
25,
1060,
220,
18,
345,
197,
52912,
2690,
1454,
25,
688,
8879,
13080,
445,
67105,
16734,
369,
220,
18,
54587,
11,
2684,
1673... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestV1EnvsnapResult_Results(t *testing.T) {
v1 := NewV1EnvsnapResult()
v1.System = NewSystemResult()
v1.Environment = NewEnvResult()
v1.Exec = NewExecResult()
v1.Python = NewPythonResult()
v1.Golang = NewGolangResult()
res := v1.Results()
assert.Len(t, res, 5)
assert.IsType(t, SystemResult{}, res[0])
assert.IsType(t, EnvResult{}, res[1])
assert.IsType(t, ExecResult{}, res[2])
assert.IsType(t, PythonResult{}, res[3])
assert.IsType(t, GolangResult{}, res[4])
} | explode_data.jsonl/62954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
53,
16,
1702,
11562,
6861,
2077,
62,
9801,
1155,
353,
8840,
836,
8,
341,
5195,
16,
1669,
1532,
53,
16,
1702,
11562,
6861,
2077,
741,
5195,
16,
16620,
284,
1532,
2320,
2077,
741,
5195,
16,
45651,
284,
1532,
14359,
2077,
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 TestConnectionMux(t *testing.T) {
var muxTests = []struct {
smux, slmux bool
cmux, clmux bool
count int
}{
{false, false, false, false, 3},
{true, false, false, false, 3},
{false, true, false, false, 3},
{true, true, false, false, 3},
{false, false, true, false, 3},
{true, false, true, false, 1},
{false, true, true, false, 1},
{true, true, true, false, 1},
{false, false, false, true, 2},
{true, false, false, true, 2},
{false, true, false, true, 1},
{true, true, false, true, 1},
{false, false, true, true, 2},
{true, false, true, true, 2},
{false, true, true, true, 1},
{true, true, true, true, 1},
}
for _, test := range muxTests {
testMux(t, test.cmux, test.clmux, test.smux, test.slmux, test.count)
}
} | explode_data.jsonl/53847 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
4526,
44,
2200,
1155,
353,
8840,
836,
8,
341,
2405,
59807,
18200,
284,
3056,
1235,
341,
197,
72023,
2200,
11,
1739,
75066,
1807,
198,
197,
1444,
75066,
11,
1185,
75066,
1807,
198,
197,
18032,
981,
526,
198,
197,
59403,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRejectExpiredUnexpired(t *testing.T) {
fakeCARoots := NewPEMCertPool()
// Validity period: Jul 11, 2016 - Jul 11, 2017.
if !fakeCARoots.AppendCertsFromPEM([]byte(testonly.FakeCACertPEM)) {
t.Fatal("failed to load fake root")
}
// Validity period: May 13, 2016 - Jul 12, 2019.
chain := pemsToDERChain(t, []string{testonly.LeafSignedByFakeIntermediateCertPEM, testonly.FakeIntermediateCertPEM})
validateOpts := CertValidationOpts{
trustedRoots: fakeCARoots,
extKeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageAny},
}
beforeValidPeriod := time.Date(1999, 1, 1, 0, 0, 0, 0, time.UTC)
currentValidPeriod := time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)
afterValidPeriod := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
for _, tc := range []struct {
desc string
rejectExpired bool
rejectUnexpired bool
now time.Time
wantErr string
}{
// No flags: accept anything.
{
desc: "no-reject-current",
now: currentValidPeriod,
},
{
desc: "no-reject-after",
now: afterValidPeriod,
},
{
desc: "no-reject-before",
now: beforeValidPeriod,
},
// Reject-Expired: only allow currently-valid and not yet valid
{
desc: "reject-expired-current",
rejectExpired: true,
now: currentValidPeriod,
},
{
desc: "reject-expired-after",
rejectExpired: true,
now: afterValidPeriod,
wantErr: "rejecting expired certificate",
},
{
desc: "reject-expired-before",
rejectExpired: true,
now: beforeValidPeriod,
},
// Reject-Unexpired: only allow expired
{
desc: "reject-non-expired-after",
rejectUnexpired: true,
now: afterValidPeriod,
},
{
desc: "reject-non-expired-before",
rejectUnexpired: true,
now: beforeValidPeriod,
wantErr: "rejecting unexpired certificate",
},
{
desc: "reject-non-expired-current",
rejectUnexpired: true,
now: currentValidPeriod,
wantErr: "rejecting unexpired certificate",
},
// Reject-Expired AND Reject-Unexpired: nothing allowed
{
desc: "reject-all-after",
rejectExpired: true,
rejectUnexpired: true,
now: afterValidPeriod,
wantErr: "rejecting expired certificate",
},
{
desc: "reject-all-before",
rejectExpired: true,
rejectUnexpired: true,
now: beforeValidPeriod,
wantErr: "rejecting unexpired certificate",
},
{
desc: "reject-all-current",
rejectExpired: true,
rejectUnexpired: true,
now: currentValidPeriod,
wantErr: "rejecting unexpired certificate",
},
} {
t.Run(tc.desc, func(t *testing.T) {
validateOpts.currentTime = tc.now
validateOpts.rejectExpired = tc.rejectExpired
validateOpts.rejectUnexpired = tc.rejectUnexpired
_, err := ValidateChain(chain, validateOpts)
if err != nil {
if len(tc.wantErr) == 0 {
t.Errorf("ValidateChain()=_,%v; want _,nil", err)
} else if !strings.Contains(err.Error(), tc.wantErr) {
t.Errorf("ValidateChain()=_,%v; want err containing %q", err, tc.wantErr)
}
} else if len(tc.wantErr) != 0 {
t.Errorf("ValidateChain()=_,nil; want err containing %q", tc.wantErr)
}
})
}
} | explode_data.jsonl/13642 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1606
} | [
2830,
3393,
78413,
54349,
1806,
75532,
1155,
353,
8840,
836,
8,
341,
1166,
726,
36390,
1905,
82,
1669,
1532,
1740,
11604,
529,
10551,
741,
197,
322,
7818,
487,
4168,
25,
10057,
220,
16,
16,
11,
220,
17,
15,
16,
21,
481,
10057,
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... | 5 |
func TestAccDataSourceLookup_basic(t *testing.T) {
expectedPayload := map[string]interface{}{"argentina": "buenos aires", "france": "paris", "spain": "malaga"}
expectedJSON, err := json.Marshal(expectedPayload)
if err != nil {
t.Fatalf("Unable to marshal JSON: %s", err)
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccDataSourceLookup_basic,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.jerakia_lookup.lookup_1", "result_json", string(expectedJSON)),
),
},
},
})
} | explode_data.jsonl/43727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 263
} | [
2830,
3393,
14603,
17173,
34247,
34729,
1155,
353,
8840,
836,
8,
341,
42400,
29683,
1669,
2415,
14032,
31344,
6257,
4913,
858,
23909,
788,
330,
65,
10316,
436,
264,
3861,
497,
330,
1626,
681,
788,
330,
1732,
285,
497,
330,
2154,
466,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPausePlayStopBuffered(t *testing.T) {
channel := make(chan Action, 1)
defer close(channel)
jobs := make(map[string]JobFunc)
jobs["dumb"] = func(id int, value interface{}) {}
handler := RunWorkers(channel, jobs, 0)
for i := 0; i < 10; i++ {
channel <- Action{"dumb", 0}
}
sleep()
length := len(channel)
if length != 0 {
t.Errorf("start: len(channel) = %v, want %v", length, 0)
}
handler.Pause()
sleep()
channel <- Action{"dumb", 0}
length = len(channel)
if length != 1 {
t.Errorf("pause: len(channel) = %v, want %v", length, 1)
}
handler.Play()
sleep()
length = len(channel)
if length != 0 {
t.Errorf("play: len(channel) = %v, want %v", length, 0)
}
handler.Quit()
sleep()
channel <- Action{"dumb", 0}
length = len(channel)
if length != 1 {
t.Errorf("stop: len(channel) = %v, want %v", length, 1)
}
} | explode_data.jsonl/12818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
28391,
9137,
10674,
4095,
291,
1155,
353,
8840,
836,
8,
341,
71550,
1669,
1281,
35190,
5586,
11,
220,
16,
340,
16867,
3265,
25923,
340,
12428,
5481,
1669,
1281,
9147,
14032,
60,
12245,
9626,
340,
12428,
5481,
1183,
67,
3551,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLrg_IsAllowed_Complex_bug214(t *testing.T) {
URI_IS_ALLOWD := svcs.PolicyAtzPath + "is-allowed"
data := &[]testutil.TestCase{
//"role-policies:",
//"grant user user_complex1, user user_complex1A,user user_complex1B role_complex1",
//"policies:",
//"grant role role_complex1 get,del res_complex1 if request_user != 'user_complex1'",
//"deny user user_complex1A del res_complex1",
{
Name: "user_complex1_denied_in_condition",
Executer: testutil.NewRestTestExecuter,
Method: testutil.METHOD_IS_ALLOWED,
Data: &testutil.RestTestData{
URI: URI_IS_ALLOWD,
InputBody: &JsonContext{
Subject: &JsonSubject{Principals: []*JsonPrincipal{{Type: adsapi.PRINCIPAL_TYPE_USER, Name: "user_complex1"}}},
ServiceName: SERVICE_COMPLEX,
Resource: "res_complex1",
Action: "get",
},
ExpectedStatus: 200,
OutputBody: &IsAllowedResponse{},
ExpectedBody: &IsAllowedResponse{Allowed: false, Reason: int32(adsapi.NO_APPLICABLE_POLICIES)},
},
},
{
Name: "user_complex1B_allowed",
Executer: testutil.NewRestTestExecuter,
Method: testutil.METHOD_IS_ALLOWED,
Data: &testutil.RestTestData{
URI: URI_IS_ALLOWD,
InputBody: &JsonContext{
Subject: &JsonSubject{Principals: []*JsonPrincipal{{Type: adsapi.PRINCIPAL_TYPE_USER, Name: "user_complex1B"}}},
ServiceName: SERVICE_COMPLEX,
Resource: "res_complex1",
Action: "get",
},
ExpectedStatus: 200,
OutputBody: &IsAllowedResponse{},
ExpectedBody: &IsAllowedResponse{Allowed: true, Reason: int32(adsapi.GRANT_POLICY_FOUND)},
},
},
{
Name: "user_complex1A_get_allowed",
Executer: testutil.NewRestTestExecuter,
Method: testutil.METHOD_IS_ALLOWED,
Data: &testutil.RestTestData{
URI: URI_IS_ALLOWD,
InputBody: &JsonContext{
Subject: &JsonSubject{Principals: []*JsonPrincipal{{Type: adsapi.PRINCIPAL_TYPE_USER, Name: "user_complex1A"}}},
ServiceName: SERVICE_COMPLEX,
Resource: "res_complex1",
Action: "get",
},
ExpectedStatus: 200,
OutputBody: &IsAllowedResponse{},
ExpectedBody: &IsAllowedResponse{Allowed: true, Reason: int32(adsapi.GRANT_POLICY_FOUND)},
},
},
{
Name: "user_complex1A_del_denied_res_complex1",
Executer: testutil.NewRestTestExecuter,
Method: testutil.METHOD_IS_ALLOWED,
Data: &testutil.RestTestData{
URI: URI_IS_ALLOWD,
InputBody: &JsonContext{
Subject: &JsonSubject{Principals: []*JsonPrincipal{{Type: adsapi.PRINCIPAL_TYPE_USER, Name: "user_complex1A"}}},
ServiceName: SERVICE_COMPLEX,
Resource: "res_complex1",
Action: "del",
},
ExpectedStatus: 200,
OutputBody: &IsAllowedResponse{},
ExpectedBody: &IsAllowedResponse{Allowed: false, Reason: int32(adsapi.NO_APPLICABLE_POLICIES)},
},
},
{
Name: "user_complex1A_get_allowed_res_complexAny",
Executer: testutil.NewRestTestExecuter,
Method: testutil.METHOD_IS_ALLOWED,
Data: &testutil.RestTestData{
URI: URI_IS_ALLOWD,
InputBody: &JsonContext{
Subject: &JsonSubject{Principals: []*JsonPrincipal{{Type: adsapi.PRINCIPAL_TYPE_USER, Name: "user_complex1A"}}},
ServiceName: SERVICE_COMPLEX,
Resource: "res_complex1",
Action: "get",
},
ExpectedStatus: 200,
OutputBody: &IsAllowedResponse{},
ExpectedBody: &IsAllowedResponse{Allowed: true, Reason: int32(adsapi.GRANT_POLICY_FOUND)},
},
},
}
testutil.RunTestCases(t, data, nil)
} | explode_data.jsonl/16525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1631
} | [
2830,
3393,
43,
1984,
31879,
35382,
16946,
9111,
73232,
17,
16,
19,
1155,
353,
8840,
836,
8,
341,
197,
10301,
12766,
44324,
35,
1669,
13559,
4837,
1069,
8018,
1655,
89,
1820,
488,
330,
285,
12,
20967,
698,
8924,
1669,
609,
1294,
1944,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLexerTokens(t *testing.T) {
tests := []struct {
data string
tokens []tokenType
}{
{data: "", tokens: []tokenType{tokenEOF}},
{data: " \t ", tokens: []tokenType{tokenSpace, tokenEOF}},
{data: "\n\r\n\r\n\r", tokens: []tokenType{tokenEOL, tokenEOL, tokenEOL, tokenEOF}},
{data: "\n\n\n", tokens: []tokenType{tokenEOL, tokenEOL, tokenEOL, tokenEOF}},
{data: "0", tokens: []tokenType{tokenNumber, tokenEOF}},
{data: "0\n", tokens: []tokenType{tokenNumber, tokenEOL, tokenEOF}},
{data: "0\nkey1 1234\n", tokens: []tokenType{tokenNumber, tokenEOL, tokenString, tokenSpace, tokenNumber, tokenEOL, tokenEOF}},
{data: "0\nkey1\t1234\n", tokens: []tokenType{tokenNumber, tokenEOL, tokenString, tokenSpace, tokenNumber, tokenEOL, tokenEOF}},
{data: `2
key1 1
key2 2
CREATE key1 1
CREATE key2 3
MODIFY key2 + 4
`, tokens: []tokenType{
tokenNumber, tokenEOL,
tokenString, tokenSpace, tokenNumber, tokenEOL,
tokenString, tokenSpace, tokenNumber, tokenEOL,
tokenString, tokenSpace, tokenString, tokenSpace, tokenNumber, tokenEOL,
tokenString, tokenSpace, tokenString, tokenSpace, tokenNumber, tokenEOL,
tokenString, tokenSpace, tokenString, tokenSpace, tokenString, tokenSpace, tokenNumber, tokenEOL,
tokenSpace, tokenEOF}},
}
for i, test := range tests {
func() {
quit := make(chan struct{})
defer close(quit)
l := newLexer(quit, strings.NewReader(test.data))
go l.run()
tokens := []tokenType{}
for {
token := l.nextToken()
tokens = append(tokens, token.typ)
if token.typ == tokenError || token.typ == tokenEOF {
break
}
}
if !reflect.DeepEqual(test.tokens, tokens) {
assert.Fail(t, fmt.Sprintf("%d) Expected %v != Actual %v", i, test.tokens, tokens))
}
}()
}
} | explode_data.jsonl/52121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
92847,
29300,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
8924,
256,
914,
198,
197,
3244,
9713,
3056,
5839,
929,
198,
197,
59403,
197,
197,
90,
691,
25,
7342,
11211,
25,
3056,
5839,
929,
90,
5839,
23... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestParseURL(t *testing.T) {
type config struct {
ExampleURL url.URL `env:"EXAMPLE_URL" envDefault:"https://google.com"`
}
var cfg config
assert.NoError(t, Parse(&cfg))
assert.Equal(t, "https://google.com", cfg.ExampleURL.String())
} | explode_data.jsonl/78798 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 95
} | [
2830,
3393,
14463,
3144,
1155,
353,
8840,
836,
8,
341,
13158,
2193,
2036,
341,
197,
197,
13314,
3144,
2515,
20893,
1565,
3160,
2974,
95875,
8000,
1,
6105,
3675,
2974,
2428,
1110,
17485,
905,
8805,
197,
532,
2405,
13286,
2193,
198,
6948,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSQLQueryFactoryExtraOps(t *testing.T) {
s, _ := newMockProvider().init()
fb := database.MessageQueryFactory.NewFilter(context.Background())
u := fftypes.MustParseUUID("4066ABDC-8BBD-4472-9D29-1A55B467F9B9")
f := fb.And(
fb.In("created", []driver.Value{1, 2, 3}),
fb.NotIn("created", []driver.Value{1, 2, 3}),
fb.Eq("id", u),
fb.In("id", []driver.Value{*u}),
fb.Neq("id", nil),
fb.Lt("created", "0"),
fb.Lte("created", "0"),
fb.Gte("created", "0"),
fb.Neq("created", "0"),
fb.Gt("sequence", 12345),
fb.Contains("topics", "abc"),
fb.NotContains("topics", "def"),
fb.IContains("topics", "ghi"),
fb.NotIContains("topics", "jkl"),
).
Descending()
sel := squirrel.Select("*").From("mytable AS mt")
sel, _, _, err := s.filterSelect(context.Background(), "mt", sel, f, nil, []interface{}{"sequence"})
assert.NoError(t, err)
sqlFilter, _, err := sel.ToSql()
assert.NoError(t, err)
assert.Equal(t, "SELECT * FROM mytable AS mt WHERE (mt.created IN (?,?,?) AND mt.created NOT IN (?,?,?) AND mt.id = ? AND mt.id IN (?) AND mt.id IS NOT NULL AND mt.created < ? AND mt.created <= ? AND mt.created >= ? AND mt.created <> ? AND mt.seq > ? AND mt.topics LIKE ? AND mt.topics NOT LIKE ? AND mt.topics ILIKE ? AND mt.topics NOT ILIKE ?) ORDER BY mt.seq DESC", sqlFilter)
} | explode_data.jsonl/34917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
6688,
2859,
4153,
11612,
38904,
1155,
353,
8840,
836,
8,
1476,
1903,
11,
716,
1669,
501,
11571,
5179,
1005,
2327,
741,
1166,
65,
1669,
4625,
8472,
2859,
4153,
7121,
5632,
5378,
19047,
2398,
10676,
1669,
43700,
1804,
50463,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAuthorization_Deny(t *testing.T) {
framework.NewTest(t).
Run(func(ctx framework.TestContext) {
ns := namespace.NewOrFail(t, ctx, namespace.Config{
Prefix: "v1beta1-deny",
Inject: true,
})
var a, b, c echo.Instance
echoboot.NewBuilder(ctx).
With(&a, util.EchoConfig("a", ns, false, nil)).
With(&b, util.EchoConfig("b", ns, false, nil)).
With(&c, util.EchoConfig("c", ns, false, nil)).
BuildOrFail(t)
newTestCase := func(target echo.Instance, path string, expectAllowed bool) rbacUtil.TestCase {
return rbacUtil.TestCase{
Request: connection.Checker{
From: a,
Options: echo.CallOptions{
Target: target,
PortName: "http",
Scheme: scheme.HTTP,
Path: path,
},
},
ExpectAllowed: expectAllowed,
}
}
cases := []rbacUtil.TestCase{
newTestCase(b, "/deny", false),
newTestCase(b, "/deny?param=value", false),
newTestCase(b, "/global-deny", false),
newTestCase(b, "/global-deny?param=value", false),
newTestCase(b, "/other", true),
newTestCase(b, "/other?param=value", true),
newTestCase(b, "/allow", true),
newTestCase(b, "/allow?param=value", true),
newTestCase(c, "/allow/admin", false),
newTestCase(c, "/allow/admin?param=value", false),
newTestCase(c, "/global-deny", false),
newTestCase(c, "/global-deny?param=value", false),
newTestCase(c, "/other", false),
newTestCase(c, "/other?param=value", false),
newTestCase(c, "/allow", true),
newTestCase(c, "/allow?param=value", true),
}
args := map[string]string{
"Namespace": ns.Name(),
"RootNamespace": rootNamespace,
}
applyPolicy := func(filename string, ns namespace.Instance) []string {
policy := tmpl.EvaluateAllOrFail(t, args, file.AsStringOrFail(t, filename))
ctx.Config().ApplyYAMLOrFail(t, ns.Name(), policy...)
return policy
}
policy := applyPolicy("testdata/authz/v1beta1-deny.yaml.tmpl", ns)
defer ctx.Config().DeleteYAMLOrFail(t, ns.Name(), policy...)
policyNSRoot := applyPolicy("testdata/authz/v1beta1-deny-ns-root.yaml.tmpl", rootNS{})
defer ctx.Config().DeleteYAMLOrFail(t, rootNS{}.Name(), policyNSRoot...)
rbacUtil.RunRBACTest(t, cases)
})
} | explode_data.jsonl/41494 | {
"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,
18124,
1557,
32395,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
7121,
2271,
1155,
4292,
197,
85952,
18552,
7502,
12626,
8787,
1972,
8,
341,
298,
84041,
1669,
4473,
7121,
46059,
1155,
11,
5635,
11,
4473,
10753,
515,
571,
10025,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerDeleteEventWithNoController(t *testing.T) {
c, tc := makeController("v1", "Pod")
c.Delete(simplePod("unit", "test"))
validateNotSent(t, tc, sourcesv1beta1.ApiServerSourceDeleteRefEventType)
} | explode_data.jsonl/39269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
2051,
6435,
1556,
2354,
2753,
2051,
1155,
353,
8840,
836,
8,
341,
1444,
11,
17130,
1669,
1281,
2051,
445,
85,
16,
497,
330,
23527,
1138,
1444,
18872,
1141,
6456,
23527,
445,
3843,
497,
330,
1944,
5455,
197,
7067,
2623,
313... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCT_PageMarConstructor(t *testing.T) {
v := wml.NewCT_PageMar()
if v == nil {
t.Errorf("wml.NewCT_PageMar must return a non-nil value")
}
if err := v.Validate(); err != nil {
t.Errorf("newly constructed wml.CT_PageMar should validate: %s", err)
}
} | explode_data.jsonl/30587 | {
"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,
1162,
51540,
12061,
13288,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
289,
1014,
7121,
1162,
51540,
12061,
741,
743,
348,
621,
2092,
341,
197,
3244,
13080,
445,
86,
1014,
7121,
1162,
51540,
12061,
1969,
470,
264,
2477,
83248,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSinglePickup(t *testing.T) {
require := require.New(t)
from, err := TestClient.CreateAddress(
&easypost.Address{
Name: "Homer Simpson",
Company: "EasyPost",
Street1: "1 MONTGOMERY ST STE 400",
City: "San Francisco",
State: "CA",
Zip: "94104",
Phone: "415-456-7890",
},
&easypost.CreateAddressOptions{Verify: []string{"delivery"}},
)
require.NoError(err)
shipment, err := TestClient.CreateShipment(
&easypost.Shipment{
ToAddress: &easypost.Address{
Name: "Bugs Bunny",
Street1: "4000 Warner Blvd",
City: "Burbank",
State: "CA",
Zip: "91522",
Phone: "818-555-1212",
},
FromAddress: from,
Parcel: &easypost.Parcel{Weight: 21.2},
},
)
require.NoError(err)
require.NotEmpty(shipment.Rates)
shipment, err = TestClient.BuyShipment(
shipment.ID, shipment.Rates[0], "100.00",
)
require.NoError(err)
minDatetime := noonOnNextMonday()
maxDatetime := minDatetime.AddDate(0, 0, 1)
pickup, err := TestClient.CreatePickup(
&easypost.Pickup{
Address: from,
Shipment: shipment,
Reference: "internal_id_1234",
MinDatetime: &minDatetime,
MaxDatetime: &maxDatetime,
IsAccountAddress: true,
Instructions: "Special pickup instructions",
},
)
require.NotEmpty(pickup.PickupRates)
// This is probably a bug in the API. It always returns a rate, but isn't
// always a valid one.
pickup, err = TestClient.BuyPickup(pickup.ID, pickup.PickupRates[0])
if err != nil {
require.Contains(
err.Error(), "schedule and change requests must contain",
)
}
} | explode_data.jsonl/11528 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 706
} | [
2830,
3393,
10888,
36953,
454,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
42727,
11,
1848,
1669,
3393,
2959,
7251,
4286,
1006,
197,
197,
68070,
300,
1082,
535,
26979,
515,
298,
21297,
25,
262,
330,
39,
25359,
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... | 2 |
func Test_PrintObjectJsonWithStack(t *testing.T) {
u := User{2, "name2", 32}
PrintObjectJsonWithStack("", u)
PrintObjectJsonWithStack("u", u)
} | explode_data.jsonl/67095 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 58
} | [
2830,
3393,
45788,
1190,
5014,
2354,
4336,
1155,
353,
8840,
836,
8,
341,
10676,
1669,
2657,
90,
17,
11,
330,
606,
17,
497,
220,
18,
17,
532,
58702,
1190,
5014,
2354,
4336,
19814,
575,
340,
58702,
1190,
5014,
2354,
4336,
445,
84,
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 |
func TestErrorWithNonBoolReturn(t *testing.T) {
b, err := EvalCondition(true, "1")
assert.Equal(t, fmt.Errorf("expected bool, but got int"), err)
assert.False(t, b)
} | explode_data.jsonl/51793 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
1454,
2354,
8121,
11233,
5598,
1155,
353,
8840,
836,
8,
341,
2233,
11,
1848,
1669,
58239,
10547,
3715,
11,
330,
16,
1138,
6948,
12808,
1155,
11,
8879,
13080,
445,
7325,
1807,
11,
714,
2684,
526,
3975,
1848,
340,
6948,
5075... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBool(t *testing.T) {
{
var v, r bool
v = true
if err := encdec(v, &r, func(code byte) bool {
return code == def.True
}); err != nil {
t.Error(err)
}
}
{
var v, r bool
v = false
if err := encdec(v, &r, func(code byte) bool {
return code == def.False
}); err != nil {
t.Error(err)
}
}
// error
{
var v bool
var r uint8
v = true
if err := encdec(v, &r, func(code byte) bool {
return code == def.True
}); err == nil || !strings.Contains(err.Error(), "invalid code c3 decoding") {
t.Error("error")
}
}
} | explode_data.jsonl/64210 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
11233,
1155,
353,
8840,
836,
8,
341,
197,
515,
197,
2405,
348,
11,
435,
1807,
198,
197,
5195,
284,
830,
198,
197,
743,
1848,
1669,
3209,
8169,
3747,
11,
609,
81,
11,
2915,
15842,
4922,
8,
1807,
341,
298,
853,
2038,
621... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRefs(t *testing.T) {
is := is.New(t)
s := NewShell(shellUrl)
cid, err := s.AddDir("./testdata")
is.Nil(err)
is.Equal(cid, "QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")
refs, err := s.Refs(cid, false)
is.Nil(err)
expected := []string{
"QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V",
"QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y",
"QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7",
"QmejvEPop4D7YUadeGqYWmZxHhLc4JBUCzJJHWMzdcMe2y",
"QmXgqKTbzdh83pQtKFb19SpMCpDDcKR2ujqk3pKph9aCNF",
"QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB",
"QmQ5vhrL7uv6tuoN9KeVBwd4PwfQkXdVVmDLUZuTNxqgvm",
}
var actual []string
for r := range refs {
actual = append(actual, r)
}
sort.Strings(expected)
sort.Strings(actual)
is.Equal(expected, actual)
} | explode_data.jsonl/61094 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
82807,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
340,
1903,
1669,
1532,
25287,
93558,
2864,
692,
1444,
307,
11,
1848,
1669,
274,
1904,
6184,
13988,
92425,
1138,
19907,
59678,
3964,
340,
19907,
12808,
57350,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTemplatesRequest_Offset(t *testing.T) {
expectedOffset := test.RandomInt(9999, 999999)
var givenOffset int
expectedResult := randomGetTemplatesResult()
req := test.NewRequest(func(req *http.Request) (res *http.Response, err error) {
givenOffset, _ = strconv.Atoi(req.FormValue("offset"))
result := api.Response{
Result: expectedResult,
}
response, _ := json.Marshal(&result)
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewBuffer(response)),
}, nil
})
_, err := messages.GetTemplates(req).
Offset(expectedOffset).
Execute()
if err != nil {
t.Fatalf(`Error should be nil, "%s" given`, err.Error())
}
if expectedOffset != givenOffset {
t.Fatalf(`Offset should be %d, %d given`, expectedOffset, givenOffset)
}
} | explode_data.jsonl/54168 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 291
} | [
2830,
3393,
1949,
51195,
1900,
85697,
1155,
353,
8840,
836,
8,
341,
42400,
6446,
1669,
1273,
26709,
1072,
7,
24,
24,
24,
24,
11,
220,
24,
24,
24,
24,
24,
24,
340,
2405,
2661,
6446,
526,
271,
42400,
2077,
1669,
4194,
1949,
51195,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSignatureCorrupted(t *testing.T) {
tf.UnitTest(t)
fs, addr := requireSignerAddr(t)
data := []byte("THESE BYTES ARE SIGNED")
sig, err := fs.SignBytes(context.Background(), data, addr)
require.NoError(t, err)
sig.Data[0] = sig.Data[0] ^ 0xFF // This operation ensures sig is modified
assert.Error(t, crypto.Verify(sig, addr, data))
} | explode_data.jsonl/15402 | {
"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,
25088,
10580,
85954,
1155,
353,
8840,
836,
8,
341,
3244,
69,
25159,
2271,
1155,
692,
53584,
11,
10789,
1669,
1373,
7264,
261,
13986,
1155,
692,
8924,
1669,
3056,
3782,
445,
17229,
925,
7710,
28484,
15824,
328,
25015,
1138,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSchemaReadDeleteAndFailWrite(t *testing.T) {
conn, cleanup, _ := testserver.NewTestServer(require.New(t), 0, memdb.DisableGC, 0, false, testfixtures.EmptyDatastore)
t.Cleanup(cleanup)
client := v1alpha1.NewSchemaServiceClient(conn)
v0client := v0.NewNamespaceServiceClient(conn)
requestedObjectDefNames := []string{"example/user"}
// Issue a write to create the schema's namespaces.
writeResp, err := client.WriteSchema(context.Background(), &v1alpha1.WriteSchemaRequest{
Schema: `definition example/user {
relation foo1: example/user
}`,
})
require.NoError(t, err)
require.Equal(t, requestedObjectDefNames, writeResp.GetObjectDefinitionsNames())
// Read the schema.
resp, err := client.ReadSchema(context.Background(), &v1alpha1.ReadSchemaRequest{
ObjectDefinitionsNames: requestedObjectDefNames,
})
require.NoError(t, err)
// Issue a delete out of band for the namespace.
_, err = v0client.DeleteConfigs(context.Background(), &v0.DeleteConfigsRequest{
Namespaces: requestedObjectDefNames,
})
require.NoError(t, err)
// Try to write using the previous revision and ensure it fails.
_, err = client.WriteSchema(context.Background(), &v1alpha1.WriteSchemaRequest{
Schema: `definition example/user {
relation foo3: example/user
}`,
OptionalDefinitionsRevisionPrecondition: resp.ComputedDefinitionsRevision,
})
grpcutil.RequireStatus(t, codes.FailedPrecondition, err)
// Read the schema and ensure it was not written.
_, err = client.ReadSchema(context.Background(), &v1alpha1.ReadSchemaRequest{
ObjectDefinitionsNames: requestedObjectDefNames,
})
grpcutil.RequireStatus(t, codes.NotFound, err)
} | explode_data.jsonl/54550 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 544
} | [
2830,
3393,
8632,
4418,
6435,
3036,
19524,
7985,
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,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFormatEndpointIngressPath(t *testing.T) {
j := &v1alpha1.Jira{
ObjectMeta: metav1.ObjectMeta{
Name: "test-jira",
Namespace: "test-jira-namespace",
},
Spec: v1alpha1.JiraSpec{
Ingress: &v1alpha1.JiraIngressPolicy{
Host: "test-ingress-host",
Path: "/test-path",
},
},
}
e := formatEndpoint(j)
assert.NotNil(t, e)
assert.Equal(t, "http://test-ingress-host/test-path", e)
} | explode_data.jsonl/29200 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
4061,
27380,
641,
2483,
1820,
1155,
353,
8840,
836,
8,
341,
12428,
1669,
609,
85,
16,
7141,
16,
3503,
8832,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
1944,
13333,
8832,
756,
298,
90823,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractInfoMetricsSentinel(t *testing.T) {
if os.Getenv("TEST_REDIS_SENTINEL_URI") == "" {
t.Skipf("TEST_REDIS_SENTINEL_URI not set - skipping")
}
addr := os.Getenv("TEST_REDIS_SENTINEL_URI")
e, _ := NewRedisExporter(
addr,
Options{Namespace: "test"},
)
c, err := redis.DialURL(addr)
if err != nil {
t.Fatalf("Couldn't connect to %#v: %#v", addr, err)
}
infoAll, err := redis.String(doRedisCmd(c, "INFO", "ALL"))
if err != nil {
t.Logf("Redis INFO ALL err: %s", err)
infoAll, err = redis.String(doRedisCmd(c, "INFO"))
if err != nil {
t.Fatalf("Redis INFO err: %s", err)
}
}
chM := make(chan prometheus.Metric)
go func() {
e.extractInfoMetrics(chM, infoAll, 0)
close(chM)
}()
want := map[string]bool{
"sentinel_tilt": false,
"sentinel_running_scripts": false,
"sentinel_scripts_queue_length": false,
"sentinel_simulate_failure_flags": false,
"sentinel_masters": false,
"sentinel_master_status": false,
"sentinel_master_slaves": false,
"sentinel_master_sentinels": false,
}
for m := range chM {
for k := range want {
if strings.Contains(m.Desc().String(), k) {
want[k] = true
}
}
}
for k, found := range want {
if !found {
t.Errorf("didn't find %s", k)
}
}
} | explode_data.jsonl/47014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 622
} | [
2830,
3393,
28959,
1731,
27328,
31358,
29708,
1155,
353,
8840,
836,
8,
341,
743,
2643,
64883,
445,
10033,
2192,
21202,
72663,
687,
2749,
23116,
899,
621,
1591,
341,
197,
3244,
57776,
69,
445,
10033,
2192,
21202,
72663,
687,
2749,
23116,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Min(t *testing.T) {
expected := 1
input := []int{1, 2, 3, 4, 5}
actual := slices.Min(input)
assert.Equal(t, expected, actual)
} | explode_data.jsonl/23108 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 59
} | [
2830,
3393,
62122,
1155,
353,
8840,
836,
8,
341,
42400,
1669,
220,
16,
271,
22427,
1669,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
532,
88814,
1669,
34254,
17070,
5384,
692,
6948,
12808,
1155,
11,
3601... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestType(t *testing.T) {
s, err := Run()
ok(t, err)
defer s.Close()
c, err := proto.Dial(s.Addr())
ok(t, err)
defer c.Close()
s.Set("foo", "bar!")
t.Run("string", func(t *testing.T) {
mustDo(t, c,
"TYPE", "foo",
proto.Inline("string"),
)
})
s.HSet("aap", "noot", "mies")
t.Run("hash", func(t *testing.T) {
mustDo(t, c,
"TYPE", "aap",
proto.Inline("hash"),
)
})
t.Run("no such key", func(t *testing.T) {
mustDo(t, c,
"TYPE", "nosuch",
proto.Inline("none"),
)
})
t.Run("errors", func(t *testing.T) {
mustDo(t, c,
"TYPE",
proto.Error("usage error"),
)
mustDo(t, c,
"TYPE", "spurious", "arguments",
proto.Error("usage error"),
)
})
t.Run("direct", func(t *testing.T) {
equals(t, "hash", s.Type("aap"))
equals(t, "", s.Type("nokey"))
})
} | explode_data.jsonl/44816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 420
} | [
2830,
3393,
929,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
6452,
741,
59268,
1155,
11,
1848,
340,
16867,
274,
10421,
741,
1444,
11,
1848,
1669,
18433,
98462,
1141,
93626,
2398,
59268,
1155,
11,
1848,
340,
16867,
272,
10421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateMetrics(t *testing.T) {
testcases := map[string]struct {
setup func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func())
}{
"ping": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
check := sm.Check{
Target: "127.0.0.1",
Timeout: 2000,
Settings: sm.CheckSettings{
Ping: &sm.PingSettings{
IpVersion: sm.IpVersion_V4,
},
},
}
prober, err := icmp.NewProber(check)
if err != nil {
t.Fatalf("cannot create ICMP prober: %s", err)
}
return prober, check, func() {}
},
},
"http": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
httpSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
}))
httpSrv.Start()
check := sm.Check{
Target: httpSrv.URL,
Timeout: 2000,
Settings: sm.CheckSettings{
Http: &sm.HttpSettings{
IpVersion: sm.IpVersion_V4,
},
},
}
prober, err := httpProber.NewProber(
ctx,
check,
zerolog.New(io.Discard),
)
if err != nil {
t.Fatalf("cannot create HTTP prober: %s", err)
}
return prober, check, httpSrv.Close
},
},
"http_ssl": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
httpSrv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusOK)
}))
httpSrv.StartTLS()
check := sm.Check{
Target: httpSrv.URL,
Timeout: 2000,
Settings: sm.CheckSettings{
Http: &sm.HttpSettings{
IpVersion: sm.IpVersion_V4,
TlsConfig: &sm.TLSConfig{
InsecureSkipVerify: true,
},
},
},
}
prober, err := httpProber.NewProber(
ctx,
check,
zerolog.New(io.Discard),
)
if err != nil {
t.Fatalf("cannot create HTTP prober: %s", err)
}
return prober, check, httpSrv.Close
},
},
"dns": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
srv, clean := setupDNSServer(t)
check := sm.Check{
Target: "example.org",
Timeout: 2000,
Settings: sm.CheckSettings{
// target is "example.com"
Dns: &sm.DnsSettings{
Server: srv,
IpVersion: sm.IpVersion_V4,
Protocol: sm.DnsProtocol_UDP,
},
},
}
prober, err := dnsProber.NewProber(check)
if err != nil {
clean()
t.Fatalf("cannot create DNS prober: %s", err)
}
return prober, check, clean
},
},
"tcp": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
srv, clean := setupTCPServer(t)
check := sm.Check{
Target: srv,
Timeout: 2000,
Settings: sm.CheckSettings{
Tcp: &sm.TcpSettings{
IpVersion: sm.IpVersion_V4,
},
},
}
prober, err := tcp.NewProber(
ctx,
check,
zerolog.New(io.Discard))
if err != nil {
clean()
t.Fatalf("cannot create TCP prober: %s", err)
}
return prober, check, clean
},
},
"tcp_ssl": {
setup: func(ctx context.Context, t *testing.T) (prober.Prober, sm.Check, func()) {
srv, clean := setupTCPServerWithSSL(t)
check := sm.Check{
Target: srv,
Timeout: 2000,
Settings: sm.CheckSettings{
Tcp: &sm.TcpSettings{
IpVersion: sm.IpVersion_V4,
Tls: true,
TlsConfig: &sm.TLSConfig{
InsecureSkipVerify: true,
},
},
},
}
prober, err := tcp.NewProber(
ctx,
check,
zerolog.New(io.Discard))
if err != nil {
clean()
t.Fatalf("cannot create TCP prober: %s", err)
}
return prober, check, clean
},
},
}
for name, testcase := range testcases {
t.Run(name, func(t *testing.T) {
verifyProberMetrics(t, name, testcase.setup, false)
})
t.Run(name+"_basic", func(t *testing.T) {
verifyProberMetrics(t, name+"_basic", testcase.setup, true)
})
}
} | explode_data.jsonl/75482 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2073
} | [
2830,
3393,
17926,
27328,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
2415,
14032,
60,
1235,
341,
197,
84571,
2915,
7502,
2266,
9328,
11,
259,
353,
8840,
836,
8,
320,
776,
652,
7763,
652,
11,
1525,
10600,
11,
2915,
2398,
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 TestSyncReplicaSetDormancy(t *testing.T) {
// Setup a test server so we can lie about the current state of pods
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: "{}",
}
testServer := httptest.NewServer(&fakeHandler)
defer testServer.Close()
client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
fakePodControl := controller.FakePodControl{}
manager := NewReplicaSetController(client, controller.NoResyncPeriodFunc, BurstReplicas, 0)
manager.podStoreSynced = alwaysReady
manager.podControl = &fakePodControl
labelMap := map[string]string{"foo": "bar"}
rsSpec := newReplicaSet(2, labelMap)
manager.rsStore.Store.Add(rsSpec)
newPodList(manager.podStore.Indexer, 1, api.PodRunning, labelMap, rsSpec, "pod")
// Creates a replica and sets expectations
rsSpec.Status.Replicas = 1
manager.syncReplicaSet(getKey(rsSpec, t))
validateSyncReplicaSet(t, &fakePodControl, 1, 0)
// Expectations prevents replicas but not an update on status
rsSpec.Status.Replicas = 0
fakePodControl.Clear()
manager.syncReplicaSet(getKey(rsSpec, t))
validateSyncReplicaSet(t, &fakePodControl, 0, 0)
// Get the key for the controller
rsKey, err := controller.KeyFunc(rsSpec)
if err != nil {
t.Errorf("Couldn't get key for object %+v: %v", rsSpec, err)
}
// Lowering expectations should lead to a sync that creates a replica, however the
// fakePodControl error will prevent this, leaving expectations at 0, 0
manager.expectations.CreationObserved(rsKey)
rsSpec.Status.Replicas = 1
fakePodControl.Clear()
fakePodControl.Err = fmt.Errorf("Fake Error")
manager.syncReplicaSet(getKey(rsSpec, t))
validateSyncReplicaSet(t, &fakePodControl, 0, 0)
// This replica should not need a Lowering of expectations, since the previous create failed
fakePodControl.Err = nil
manager.syncReplicaSet(getKey(rsSpec, t))
validateSyncReplicaSet(t, &fakePodControl, 1, 0)
// 1 PUT for the ReplicaSet status during dormancy window.
// Note that the pod creates go through pod control so they're not recorded.
fakeHandler.ValidateRequestCount(t, 1)
} | explode_data.jsonl/10045 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 708
} | [
2830,
3393,
12154,
18327,
15317,
1649,
35,
493,
6572,
1155,
353,
8840,
836,
8,
341,
197,
322,
18626,
264,
1273,
3538,
773,
582,
646,
10246,
911,
279,
1482,
1584,
315,
54587,
198,
1166,
726,
3050,
1669,
4094,
8840,
991,
726,
3050,
515,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestInsertParam_TxOptions(t *testing.T) {
tests := []struct {
name string
i *InsertParam
want *sql.TxOptions
}{
{
name: "1",
i: NewInsertParam(nil, &sql.TxOptions{
Isolation: sql.LevelRepeatableRead,
ReadOnly: true,
}),
want: &sql.TxOptions{
Isolation: sql.LevelRepeatableRead,
ReadOnly: true,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.i.TxOptions(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("InsertParam.TxOptions() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/20044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 268
} | [
2830,
3393,
13780,
2001,
1139,
87,
3798,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
8230,
262,
353,
13780,
2001,
198,
197,
50780,
353,
3544,
81362,
3798,
198,
197,
59403,
197,
197,
515,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCancelInvalidLeaseIns(t *testing.T) {
to, path, err := createBalances()
assert.NoError(t, err, "createBalances() failed")
defer func() {
to.stor.close(t)
err = common.CleanTemporaryDirs(path)
assert.NoError(t, err, "failed to clean test data dirs")
}()
to.stor.addBlock(t, blockID0)
to.stor.addBlock(t, blockID1)
tests := []struct {
addr string
profile balanceProfile
blockID proto.BlockID
validLeaseIn int64
}{
{addr0, balanceProfile{100, 0, 0}, blockID0, 1},
{addr1, balanceProfile{2500, 2, 0}, blockID0, 3},
{addr2, balanceProfile{10, 1, 0}, blockID1, 1},
{addr3, balanceProfile{10, 5, 0}, blockID1, 0},
}
leaseIns := make(map[proto.WavesAddress]int64)
for _, tc := range tests {
addr, err := proto.NewAddressFromString(tc.addr)
assert.NoError(t, err, "NewAddressFromString() failed")
err = to.balances.setWavesBalance(addr.ID(), newWavesValueFromProfile(tc.profile), tc.blockID)
assert.NoError(t, err, "setWavesBalance() failed")
leaseIns[addr] = tc.validLeaseIn
}
err = to.balances.cancelInvalidLeaseIns(leaseIns, blockID1)
assert.NoError(t, err, "cancelInvalidLeaseIns() failed")
to.stor.flush(t)
for _, tc := range tests {
addr, err := proto.NewAddressFromString(tc.addr)
assert.NoError(t, err, "NewAddressFromString() failed")
profile, err := to.balances.wavesBalance(addr.ID(), true)
assert.NoError(t, err, "wavesBalance() failed")
assert.Equal(t, profile.balance, tc.profile.balance)
assert.Equal(t, profile.leaseIn, tc.validLeaseIn)
assert.Equal(t, profile.leaseOut, tc.profile.leaseOut)
}
} | explode_data.jsonl/37803 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 636
} | [
2830,
3393,
9269,
7928,
2304,
519,
15474,
1155,
353,
8840,
836,
8,
341,
31709,
11,
1815,
11,
1848,
1669,
1855,
37889,
3020,
741,
6948,
35699,
1155,
11,
1848,
11,
330,
3182,
37889,
3020,
368,
4641,
5130,
16867,
2915,
368,
341,
197,
317... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestResourceWithSecretSerialization(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: "secret_outputs",
Dependencies: []string{"@pulumi/pulumi"},
Quick: true,
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
// The program exports two resources, one named `withSecret` who's prefix property should be secret
// and one named `withoutSecret` which should not. We serialize both of the these as POJO objects, so
// they appear as maps in the output.
withSecretProps, ok := stackInfo.Outputs["withSecret"].(map[string]interface{})
assert.Truef(t, ok, "POJO output was not serialized as a map")
withoutSecretProps, ok := stackInfo.Outputs["withoutSecret"].(map[string]interface{})
assert.Truef(t, ok, "POJO output was not serialized as a map")
// The secret prop should have been serialized as a secret
secretPropValue, ok := withSecretProps["prefix"].(map[string]interface{})
assert.Truef(t, ok, "secret output was not serialized as a secret")
assert.Equal(t, resource.SecretSig, secretPropValue[resource.SigKey].(string))
// And here, the prop was not set, it should just be a string value
_, isString := withoutSecretProps["prefix"].(string)
assert.Truef(t, isString, "non-secret output was not a string")
},
})
} | explode_data.jsonl/76372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 457
} | [
2830,
3393,
4783,
2354,
19773,
35865,
1155,
353,
8840,
836,
8,
341,
2084,
17376,
80254,
2271,
1155,
11,
609,
60168,
80254,
2271,
3798,
515,
197,
197,
6184,
25,
688,
330,
20474,
35189,
756,
197,
197,
48303,
25,
3056,
917,
4913,
31,
79,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCmdAddTwoContainersWithEmptyInboundPort(t *testing.T) {
defer resetGlobalTestVariables()
delete(testAnnotations, includePortsKey)
testContainers = []string{"mockContainer", "mockContainer2"}
testAnnotations[includePortsKey] = ""
testCmdAdd(t)
if !nsenterFuncCalled {
t.Fatalf("expected nsenterFunc to be called")
}
mockIntercept, ok := GetInterceptRuleMgrCtor("mock")().(*mockInterceptRuleMgr)
if !ok {
t.Fatalf("expect using mockInterceptRuleMgr, actual %v", InterceptRuleMgrTypes["mock"])
}
r := mockIntercept.lastRedirect[len(mockIntercept.lastRedirect)-1]
if r.includePorts != "" {
t.Fatalf("expect includePorts is \"\", actual %v", r.includePorts)
}
} | explode_data.jsonl/17792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 253
} | [
2830,
3393,
15613,
2212,
11613,
74632,
2354,
3522,
641,
10891,
7084,
1155,
353,
8840,
836,
8,
341,
16867,
7585,
11646,
2271,
22678,
741,
15618,
8623,
21418,
11,
2924,
68273,
1592,
340,
18185,
74632,
284,
3056,
917,
4913,
16712,
4502,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestUGetOrderData(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip("skipping test: api keys not set")
}
_, err := b.UGetOrderData(context.Background(), currency.NewPair(currency.BTC, currency.USDT), "123", "")
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76572 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
52,
1949,
4431,
1043,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
445,
4886,
5654,
1273,
25,
6330,
6894,
537,
738,
1138,
197,
532,
197,
6878,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommandOverride_UnmarshalYAML(t *testing.T) {
testCases := map[string]struct {
inContent []byte
wantedStruct CommandOverride
wantedError error
}{
"Entrypoint specified in string": {
inContent: []byte(`command: echo hello`),
wantedStruct: CommandOverride{
String: aws.String("echo hello"),
StringSlice: nil,
},
},
"Entrypoint specified in slice of strings": {
inContent: []byte(`command: ["--version"]`),
wantedStruct: CommandOverride{
String: nil,
StringSlice: []string{"--version"},
},
},
"Error if unmarshalable": {
inContent: []byte(`command: {-c}`),
wantedStruct: CommandOverride{
String: nil,
StringSlice: nil,
},
wantedError: errUnmarshalCommand,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
e := ImageOverride{
Command: &CommandOverride{
String: aws.String("wrong"),
},
}
err := yaml.Unmarshal(tc.inContent, &e)
if tc.wantedError != nil {
require.EqualError(t, err, tc.wantedError.Error())
} else {
require.NoError(t, err)
// check memberwise dereferenced pointer equality
require.Equal(t, tc.wantedStruct.StringSlice, e.Command.StringSlice)
require.Equal(t, tc.wantedStruct.String, e.Command.String)
}
})
}
} | explode_data.jsonl/79728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 552
} | [
2830,
3393,
4062,
2177,
40687,
27121,
56,
31102,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
17430,
2762,
3056,
3782,
271,
197,
6692,
7566,
9422,
7348,
2177,
198,
197,
6692,
7566,
1454,
220,
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... | 2 |
func TestCT_SchemaLibraryMarshalUnmarshal(t *testing.T) {
v := schemaLibrary.NewCT_SchemaLibrary()
buf, _ := xml.Marshal(v)
v2 := schemaLibrary.NewCT_SchemaLibrary()
xml.Unmarshal(buf, v2)
} | explode_data.jsonl/35420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
1162,
1098,
3416,
16915,
55438,
1806,
27121,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
10802,
16915,
7121,
1162,
1098,
3416,
16915,
741,
26398,
11,
716,
1669,
8396,
37271,
3747,
340,
5195,
17,
1669,
10802,
16915,
7121,
1162,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func Test_JavaScript_WithoutLayout(t *testing.T) {
r := require.New(t)
e := NewEngine()
box := e.TemplatesBox
r.NoError(box.AddString(jsTemplate, "alert(<%= name %>)"))
h := e.JavaScript(jsTemplate)
r.Equal("application/javascript", h.ContentType())
bb := &bytes.Buffer{}
r.NoError(h.Render(bb, Data{"name": "Mark"}))
r.Equal("alert(Mark)", strings.TrimSpace(bb.String()))
} | explode_data.jsonl/44610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 151
} | [
2830,
3393,
10598,
2907,
5910,
62,
26040,
2175,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1373,
7121,
1155,
692,
7727,
1669,
1532,
4571,
2822,
58545,
1669,
384,
836,
76793,
1611,
198,
7000,
35699,
36046,
1904,
703,
53418,
7275,
11,
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 TestShiftRight(t *testing.T) {
for i, test := range rightShiftTests {
var z nat
z = z.shr(test.in, test.shift)
for j, d := range test.out {
if j >= len(z) || z[j] != d {
t.Errorf("#%d: got: %v want: %v", i, z, test.out)
break
}
}
}
} | explode_data.jsonl/2192 | {
"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,
24841,
5979,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
1290,
24841,
18200,
341,
197,
2405,
1147,
17588,
198,
197,
20832,
284,
1147,
2395,
81,
8623,
1858,
11,
1273,
29154,
340,
197,
2023,
502,
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... | 5 |
func TestPersistRoundNum(t *testing.T) {
const maxRetries = 3
const roundNum uint64 = 5555
controller := mock.NewController(t)
defer controller.Finish()
mockOVSBridgeClient := ovsconfigtest.NewMockOVSBridgeClient(controller)
transactionError := ovsconfig.NewTransactionError(fmt.Errorf("Failed to get external IDs"), true)
firstCall := mockOVSBridgeClient.EXPECT().GetExternalIDs().Return(nil, transactionError)
externalIDs := make(map[string]string)
mockOVSBridgeClient.EXPECT().GetExternalIDs().Return(externalIDs, nil).After(firstCall)
newExternalIDs := make(map[string]interface{})
newExternalIDs[roundNumKey] = fmt.Sprint(roundNum)
mockOVSBridgeClient.EXPECT().SetExternalIDs(mock.Eq(newExternalIDs)).Times(1)
// The first call to saveRoundNum will fail. Because we set the retry interval to 0,
// persistRoundNum should retry immediately and the second call will succeed (as per the
// expectations above).
persistRoundNum(roundNum, mockOVSBridgeClient, 0, maxRetries)
} | explode_data.jsonl/36231 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 307
} | [
2830,
3393,
61267,
27497,
4651,
1155,
353,
8840,
836,
8,
341,
4777,
1932,
12020,
4019,
284,
220,
18,
198,
4777,
4778,
4651,
2622,
21,
19,
284,
220,
20,
20,
20,
20,
271,
61615,
1669,
7860,
7121,
2051,
1155,
340,
16867,
6461,
991,
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 TestNewNodeLabelPriority(t *testing.T) {
label1 := map[string]string{"foo": "bar"}
label2 := map[string]string{"bar": "foo"}
label3 := map[string]string{"bar": "baz"}
tests := []struct {
nodes []*v1.Node
label string
presence bool
expectedList schedulerapi.HostPriorityList
name string
}{
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 0}, {Host: "machine2", Score: 0}, {Host: "machine3", Score: 0}},
label: "baz",
presence: true,
name: "no match found, presence true",
},
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: schedulerapi.MaxPriority}, {Host: "machine2", Score: schedulerapi.MaxPriority}, {Host: "machine3", Score: schedulerapi.MaxPriority}},
label: "baz",
presence: false,
name: "no match found, presence false",
},
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: schedulerapi.MaxPriority}, {Host: "machine2", Score: 0}, {Host: "machine3", Score: 0}},
label: "foo",
presence: true,
name: "one match found, presence true",
},
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 0}, {Host: "machine2", Score: schedulerapi.MaxPriority}, {Host: "machine3", Score: schedulerapi.MaxPriority}},
label: "foo",
presence: false,
name: "one match found, presence false",
},
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: 0}, {Host: "machine2", Score: schedulerapi.MaxPriority}, {Host: "machine3", Score: schedulerapi.MaxPriority}},
label: "bar",
presence: true,
name: "two matches found, presence true",
},
{
nodes: []*v1.Node{
{ObjectMeta: metav1.ObjectMeta{Name: "machine1", Labels: label1}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine2", Labels: label2}},
{ObjectMeta: metav1.ObjectMeta{Name: "machine3", Labels: label3}},
},
expectedList: []schedulerapi.HostPriority{{Host: "machine1", Score: schedulerapi.MaxPriority}, {Host: "machine2", Score: 0}, {Host: "machine3", Score: 0}},
label: "bar",
presence: false,
name: "two matches found, presence false",
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
nodeNameToInfo := schedulercache.CreateNodeNameToInfoMap(nil, test.nodes)
labelPrioritizer := &NodeLabelPrioritizer{
label: test.label,
presence: test.presence,
}
list, err := priorityFunction(labelPrioritizer.CalculateNodeLabelPriorityMap, nil, nil)(nil, nodeNameToInfo, test.nodes)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
// sort the two lists to avoid failures on account of different ordering
sort.Sort(test.expectedList)
sort.Sort(list)
if !reflect.DeepEqual(test.expectedList, list) {
t.Errorf("expected %#v, got %#v", test.expectedList, list)
}
})
}
} | explode_data.jsonl/2717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1770
} | [
2830,
3393,
3564,
1955,
2476,
20555,
1155,
353,
8840,
836,
8,
341,
29277,
16,
1669,
2415,
14032,
30953,
4913,
7975,
788,
330,
2257,
16707,
29277,
17,
1669,
2415,
14032,
30953,
4913,
2257,
788,
330,
7975,
16707,
29277,
18,
1669,
2415,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateSplits(t *testing.T) {
splits := []v1.Split{
{
Weight: 90,
Action: &v1.Action{
Pass: "test-1",
},
},
{
Weight: 10,
Action: &v1.Action{
Proxy: &v1.ActionProxy{
Upstream: "test-2",
},
},
},
}
upstreamNames := map[string]sets.Empty{
"test-1": {},
"test-2": {},
}
allErrs := validateSplits(splits, field.NewPath("splits"), upstreamNames, "")
if len(allErrs) > 0 {
t.Errorf("validateSplits() returned errors %v for valid input", allErrs)
}
} | explode_data.jsonl/65844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
17926,
50,
39033,
1155,
353,
8840,
836,
8,
341,
1903,
39033,
1669,
3056,
85,
16,
19823,
515,
197,
197,
515,
298,
197,
8295,
25,
220,
24,
15,
345,
298,
67607,
25,
609,
85,
16,
11360,
515,
571,
10025,
395,
25,
330,
1944,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDeciderIgnoresEnsureSafeSplitKeyOnError(t *testing.T) {
defer leaktest.AfterTest(t)()
intn := rand.New(rand.NewSource(11)).Intn
var d Decider
Init(&d, intn, func() float64 { return 1.0 })
baseKey := keys.MakeTablePrefix(51)
for i := 0; i < 4; i++ {
baseKey = encoding.EncodeUvarintAscending(baseKey, uint64(52+i))
}
c0 := func() roachpb.Span {
return roachpb.Span{Key: append([]byte(nil), encoding.EncodeUvarintAscending(baseKey, math.MaxInt32+1)...)}
}
c1 := func() roachpb.Span {
return roachpb.Span{Key: append([]byte(nil), encoding.EncodeUvarintAscending(baseKey, math.MaxInt32+2)...)}
}
_, err := keys.EnsureSafeSplitKey(c1().Key)
require.Error(t, err)
var k roachpb.Key
var now time.Time
for i := 0; i < 2*int(minSplitSuggestionInterval/time.Second); i++ {
now = now.Add(500 * time.Millisecond)
d.Record(now, 1, c0)
now = now.Add(500 * time.Millisecond)
d.Record(now, 1, c1)
k = d.MaybeSplitKey(now)
if len(k) != 0 {
break
}
}
require.Equal(t, c1().Key, k)
} | explode_data.jsonl/15789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 445
} | [
2830,
3393,
4900,
1776,
40,
70,
2152,
416,
64439,
25663,
20193,
1592,
74945,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
2084,
77,
1669,
10382,
7121,
37595,
7121,
3608,
7,
16,
16,
4579,
1072,
77,
271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAllowPorts(t *testing.T) {
assert := assert.New(t)
// Port not allowed
status, err := util.GetProxyStatus(consts.ADMIN_ADDR, consts.ADMIN_USER, consts.ADMIN_PWD, consts.ProxyTcpPortNotAllowed)
if assert.NoError(err) {
assert.Equal(proxy.ProxyStatusStartErr, status.Status)
assert.True(strings.Contains(status.Err, ports.ErrPortNotAllowed.Error()))
}
status, err = util.GetProxyStatus(consts.ADMIN_ADDR, consts.ADMIN_USER, consts.ADMIN_PWD, consts.ProxyUdpPortNotAllowed)
if assert.NoError(err) {
assert.Equal(proxy.ProxyStatusStartErr, status.Status)
assert.True(strings.Contains(status.Err, ports.ErrPortNotAllowed.Error()))
}
status, err = util.GetProxyStatus(consts.ADMIN_ADDR, consts.ADMIN_USER, consts.ADMIN_PWD, consts.ProxyTcpPortUnavailable)
if assert.NoError(err) {
assert.Equal(proxy.ProxyStatusStartErr, status.Status)
assert.True(strings.Contains(status.Err, ports.ErrPortUnAvailable.Error()))
}
// Port normal
status, err = util.GetProxyStatus(consts.ADMIN_ADDR, consts.ADMIN_USER, consts.ADMIN_PWD, consts.ProxyTcpPortNormal)
if assert.NoError(err) {
assert.Equal(proxy.ProxyStatusRunning, status.Status)
}
status, err = util.GetProxyStatus(consts.ADMIN_ADDR, consts.ADMIN_USER, consts.ADMIN_PWD, consts.ProxyUdpPortNormal)
if assert.NoError(err) {
assert.Equal(proxy.ProxyStatusRunning, status.Status)
}
} | explode_data.jsonl/79666 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 528
} | [
2830,
3393,
18605,
68273,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
197,
322,
5776,
537,
5420,
198,
23847,
11,
1848,
1669,
4094,
2234,
16219,
2522,
2741,
82,
96869,
16058,
11,
95432,
96869,
9107,
11,
95432,
96869,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClaimAlias(t *testing.T) {
store := test.GetStore(t)
db := store.Conn()
defer db.Close()
CreateSchema(store)
db.Create(&Alias{Alias: "foo"})
db.Create(&Alias{Alias: "bar"})
db.Create(&Alias{Alias: "baz"})
ClaimAliasesByPlayer(store, 1, []string{"foo", "bar"})
player1_aliases := GetAliases(store, 1)
if len(player1_aliases) != 2 {
t.Fatalf("expected 2 aliases, got %u",
len(player1_aliases))
}
for _, a := range player1_aliases {
if a.Alias != "foo" && a.Alias != "bar" {
t.Fatalf("unexpected alias: %s", a.Alias)
}
if a.PlayerID != 1 {
t.Fatalf("alias with incorrect player ID %u",
a.PlayerID)
}
}
unclaimed := GetAliases(store, NoUser)
if len(unclaimed) != 1 {
t.Fatal("expected 1 unclaimed alias, got %u",
len(unclaimed))
}
ua := unclaimed[0]
if ua.Alias != "baz" {
t.Fatalf("expected 'baz' to be unclaimed, got %s",
ua.Alias)
}
} | explode_data.jsonl/68027 | {
"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,
45544,
22720,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
1273,
2234,
6093,
1155,
692,
20939,
1669,
3553,
50422,
741,
16867,
2927,
10421,
2822,
75569,
8632,
31200,
692,
20939,
7251,
2099,
22720,
90,
22720,
25,
330,
7975,
23625,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestCacheConfigurationNegative(t *testing.T) {
// set a bad peer.address
viper.Set("peer.addressAutoDetect", true)
viper.Set("peer.address", "testing.com")
_, err := GlobalConfig()
require.Error(t, err, "Expected error for bad configuration")
viper.Set("peer.addressAutoDetect", false)
viper.Set("peer.address", "")
_, err = GlobalConfig()
require.Error(t, err, "Expected error for bad configuration")
viper.Set("peer.address", "wrongAddress")
_, err = GlobalConfig()
require.Error(t, err, "Expected error for bad configuration")
} | explode_data.jsonl/71570 | {
"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,
8233,
7688,
38489,
1155,
353,
8840,
836,
8,
341,
197,
322,
738,
264,
3873,
14397,
13792,
198,
5195,
12858,
4202,
445,
16537,
13792,
13253,
57193,
497,
830,
340,
5195,
12858,
4202,
445,
16537,
13792,
497,
330,
8840,
905,
1138... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCaseBerlinBarcelona(t *testing.T) {
CaseBBARC := TestCase{[4]float64{2.154007, 41.390205, 13.38886, 52.517037}, 4, "Berlin - Barcelona"}
ImageBBARC := NewImage(CaseBBARC.bbox)
// Find Tiles including the zoom level
ImageBBARC.FindRootTile()
tiles, ZoomIncrease := TilesDownload(ImageBBARC.RootTile.X, ImageBBARC.RootTile.Y, ImageBBARC.RootTile.Z)
// Download Tiles with Zoom Level
DownloadTiles(tiles, ImageBBARC.RootTile.Z+ZoomIncrease)
// ImageBBARC.ComposeImage("BerlinBBARC")
CreateImage(tiles, "BerlinBBARC")
ImageBBARC.DrawImage(&ImageBBARC.bbox, tiles, ImageBBARC.RootTile.Z, "BerlinBBARC", ImageBBARC.RootTile.X, ImageBBARC.RootTile.Y)
CheckImages("BerlinBBARC_merged_painted")
} | explode_data.jsonl/81858 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
30573,
94409,
3428,
22365,
1155,
353,
8840,
836,
8,
341,
197,
4207,
10098,
46472,
1669,
30573,
90,
58,
19,
60,
3649,
21,
19,
90,
17,
13,
16,
20,
19,
15,
15,
22,
11,
220,
19,
16,
13,
18,
24,
15,
17,
15,
20,
11,
220,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParse_TimingsMultipleFieldsWithoutTemplate(t *testing.T) {
s := NewTestStatsd()
s.Templates = []string{}
s.Percentiles = []internal.Number{{Value: 90.0}}
acc := &testutil.Accumulator{}
validLines := []string{
"test_timing.success:1|ms",
"test_timing.success:11|ms",
"test_timing.success:1|ms",
"test_timing.success:1|ms",
"test_timing.success:1|ms",
"test_timing.error:2|ms",
"test_timing.error:22|ms",
"test_timing.error:2|ms",
"test_timing.error:2|ms",
"test_timing.error:2|ms",
}
for _, line := range validLines {
err := s.parseStatsdLine(line)
if err != nil {
t.Errorf("Parsing line %s should not have resulted in an error\n", line)
}
}
s.Gather(acc)
expectedSuccess := map[string]interface{}{
"90_percentile": float64(11),
"count": int64(5),
"lower": float64(1),
"mean": float64(3),
"stddev": float64(4),
"sum": float64(15),
"upper": float64(11),
}
expectedError := map[string]interface{}{
"90_percentile": float64(22),
"count": int64(5),
"lower": float64(2),
"mean": float64(6),
"stddev": float64(8),
"sum": float64(30),
"upper": float64(22),
}
acc.AssertContainsFields(t, "test_timing_success", expectedSuccess)
acc.AssertContainsFields(t, "test_timing_error", expectedError)
} | explode_data.jsonl/14382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 654
} | [
2830,
3393,
14463,
1139,
318,
819,
32089,
8941,
26040,
7275,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1532,
2271,
16635,
67,
741,
1903,
836,
76793,
284,
3056,
917,
16094,
1903,
53831,
3658,
284,
3056,
10481,
31182,
2979,
1130,
25,
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... | 3 |
func TestStopCausesJobsToNotRun(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
cron := New()
cron.Start()
cron.Stop()
cron.AddFunc("* * * * * ?", func() { wg.Done() })
select {
case <-time.After(ONE_SECOND):
// No job ran!
case <-wait(wg):
t.FailNow()
}
} | explode_data.jsonl/10553 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
10674,
22571,
4776,
40667,
1249,
2623,
6727,
1155,
353,
8840,
836,
8,
341,
72079,
1669,
609,
12996,
28384,
2808,
16094,
72079,
1904,
7,
16,
692,
1444,
2248,
1669,
1532,
741,
1444,
2248,
12101,
741,
1444,
2248,
30213,
741,
14... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInstallConfigDependencies(t *testing.T) {
stock := &StockImpl{
clusterID: &testAsset{name: "test-cluster-id"},
emailAddress: &testAsset{name: "test-email"},
password: &testAsset{name: "test-password"},
sshKey: &testAsset{name: "test-sshkey"},
baseDomain: &testAsset{name: "test-domain"},
clusterName: &testAsset{name: "test-cluster"},
license: &testAsset{name: "test-license"},
pullSecret: &testAsset{name: "test-pull-secret"},
platform: &testAsset{name: "test-platform"},
}
installConfig := &installConfig{
assetStock: stock,
}
exp := []string{
"test-cluster-id",
"test-email",
"test-password",
"test-sshkey",
"test-domain",
"test-cluster",
"test-license",
"test-pull-secret",
"test-platform",
}
deps := installConfig.Dependencies()
act := make([]string, len(deps))
for i, d := range deps {
a, ok := d.(*testAsset)
assert.True(t, ok, "expected dependency to be a *testAsset")
act[i] = a.name
}
assert.Equal(t, exp, act, "unexpected dependency")
} | explode_data.jsonl/75054 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 427
} | [
2830,
3393,
24690,
2648,
48303,
1155,
353,
8840,
836,
8,
341,
197,
13479,
1669,
609,
19369,
9673,
515,
197,
197,
18855,
915,
25,
262,
609,
1944,
16604,
47006,
25,
330,
1944,
93208,
12897,
7115,
197,
57549,
4286,
25,
609,
1944,
16604,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFailureBadBoolTags(t *testing.T) {
badTagESSpan, err := loadESSpanFixture(1)
require.NoError(t, err)
badTagESSpan.Tags = []KeyValue{
{
Key: "meh",
Value: "meh",
Type: "bool",
},
}
failingSpanTransformAnyMsg(t, &badTagESSpan)
} | explode_data.jsonl/5142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
17507,
17082,
11233,
15930,
1155,
353,
8840,
836,
8,
341,
2233,
329,
5668,
9996,
848,
11,
1848,
1669,
2795,
9996,
848,
18930,
7,
16,
340,
17957,
35699,
1155,
11,
1848,
692,
2233,
329,
5668,
9996,
848,
73522,
284,
3056,
720... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshal_WithDatetime(t *testing.T) {
type testStruct struct {
Datetimeval time.Time
}
testUnmarshal(t, []testcase{
{`datetimeval = 1979-05-27T07:32:00Z`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T07:32:00Z")),
}},
{`datetimeval = 2014-09-13T12:37:39Z`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "2014-09-13T12:37:39Z")),
}},
{`datetimeval = 1979-05-27T00:32:00-07:00`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00-07:00")),
}},
{`datetimeval = 1979-05-27T00:32:00`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00Z")),
}},
{`datetimeval = 1979-05-27T00:32:00.999999-07:00`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "1979-05-27T00:32:00.999999-07:00")),
}},
{`datetimeval = 1979-05-27`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339, "1979-05-27T00:00:00Z")),
}},
{`datetimeval = 07:32:00`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339, "0000-01-01T07:32:00Z")),
}},
{`datetimeval = 00:32:00.999999`, nil, &testStruct{
mustTime(time.Parse(time.RFC3339Nano, "0000-01-01T00:32:00.999999Z")),
}},
})
} | explode_data.jsonl/52956 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 598
} | [
2830,
3393,
1806,
27121,
62,
2354,
94191,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
9422,
2036,
341,
197,
10957,
27662,
831,
882,
16299,
198,
197,
532,
18185,
1806,
27121,
1155,
11,
3056,
1944,
5638,
515,
197,
197,
90,
63,
15450,
831... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCAConfigSecurityProviderPin(t *testing.T) {
backend, err := config.FromFile(configTestFilePath)()
if err != nil {
t.Fatal("Failed to get config backend")
}
customBackend := getCustomBackend(backend...)
cryptoConfig := ConfigFromBackend(customBackend).(*Config)
// Test SecurityProviderPin
val, ok := customBackend.Lookup("client.BCCSP.security.pin")
if !ok || val == nil {
t.Fatal("expected valid value")
}
if val.(string) != cryptoConfig.SecurityProviderPin() {
t.Fatal("Incorrect BCCSP SecurityProviderPin flag")
}
} | explode_data.jsonl/58381 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
5049,
2648,
15352,
5179,
19861,
1155,
353,
8840,
836,
8,
341,
197,
20942,
11,
1848,
1669,
2193,
11439,
1703,
8754,
2271,
19090,
8,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
9408,
311,
633,
2193,
19163,
1138,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestErrorsOnFailure(t *testing.T) {
p := pipeline.New(
pipeline.Node(&NoOpProcessor{ReturnError: true}),
)
err := <-p.Process(&SimpleReader{CountObject: 10})
assert.Error(t, err)
assert.Equal(t, "Processor NoOpProcessor errored: Test error", err.Error())
} | explode_data.jsonl/64696 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
13877,
1925,
17507,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
15301,
7121,
1006,
197,
3223,
8790,
21714,
2099,
2753,
7125,
22946,
90,
5598,
1454,
25,
830,
30793,
197,
692,
9859,
1669,
9119,
79,
29012,
2099,
16374,
5062,
90,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegration_StartAt(t *testing.T) {
t.Parallel()
rpcClient, gethClient, _, assertMockCalls := cltest.NewEthMocksWithStartupAssertions(t)
defer assertMockCalls()
app, cleanup := cltest.NewApplication(t,
eth.NewClientWith(rpcClient, gethClient),
)
defer cleanup()
require.NoError(t, app.Start())
j := cltest.FixtureCreateJobViaWeb(t, app, "fixtures/web/start_at_job.json")
startAt := cltest.ParseISO8601(t, "1970-01-01T00:00:00.000Z")
assert.Equal(t, startAt, j.StartAt.Time)
jr := cltest.CreateJobRunViaWeb(t, app, j)
cltest.WaitForJobRunToComplete(t, app.Store, jr)
} | explode_data.jsonl/75893 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
52464,
38056,
1655,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
3992,
2959,
11,
633,
71,
2959,
11,
8358,
2060,
11571,
55292,
1669,
1185,
1944,
7121,
65390,
11571,
16056,
39076,
90206,
1155,
340,
16867,
2060,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHybiClientRead(t *testing.T) {
wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o',
0x89, 0x05, 'h', 'e', 'l', 'l', 'o', // ping
0x81, 0x05, 'w', 'o', 'r', 'l', 'd'}
br := bufio.NewReader(bytes.NewBuffer(wireData))
bw := bufio.NewWriter(bytes.NewBuffer([]byte{}))
conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil)
msg := make([]byte, 512)
n, err := conn.Read(msg)
if err != nil {
t.Errorf("read 1st frame, error %q", err)
}
if n != 5 {
t.Errorf("read 1st frame, expect 5, got %d", n)
}
if !bytes.Equal(wireData[2:7], msg[:n]) {
t.Errorf("read 1st frame %v, got %v", wireData[2:7], msg[:n])
}
n, err = conn.Read(msg)
if err != nil {
t.Errorf("read 2nd frame, error %q", err)
}
if n != 5 {
t.Errorf("read 2nd frame, expect 5, got %d", n)
}
if !bytes.Equal(wireData[16:21], msg[:n]) {
t.Errorf("read 2nd frame %v, got %v", wireData[16:21], msg[:n])
}
n, err = conn.Read(msg)
if err == nil {
t.Errorf("read not EOF")
}
if n != 0 {
t.Errorf("expect read 0, got %d", n)
}
} | explode_data.jsonl/53445 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 506
} | [
2830,
3393,
30816,
8221,
2959,
4418,
1155,
353,
8840,
836,
8,
341,
6692,
554,
1043,
1669,
3056,
3782,
90,
15,
87,
23,
16,
11,
220,
15,
87,
15,
20,
11,
364,
71,
516,
364,
68,
516,
364,
75,
516,
364,
75,
516,
364,
78,
751,
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... | 9 |
func TestAPIGroupStarCoveringMultiple(t *testing.T) {
escalationTest{
ownerRules: []authorizationapi.PolicyRule{
{APIGroups: []string{"*"}, Verbs: sets.NewString("get"), Resources: sets.NewString("roles")},
},
servantRules: []authorizationapi.PolicyRule{
{APIGroups: []string{"group1", "group2"}, Verbs: sets.NewString("get"), Resources: sets.NewString("roles")},
},
expectedCovered: true,
expectedUncoveredRules: []authorizationapi.PolicyRule{},
}.test(t)
} | explode_data.jsonl/9050 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
7082,
2808,
12699,
30896,
287,
32089,
1155,
353,
8840,
836,
8,
341,
80629,
278,
367,
2271,
515,
197,
197,
8118,
26008,
25,
3056,
39554,
2068,
1069,
8018,
11337,
515,
298,
197,
90,
7082,
22173,
25,
3056,
917,
4913,
9,
14345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerTimeoutError(t *testing.T) {
s := &Server{
Handler: func(ctx *RequestCtx) {
go func() {
ctx.Success("aaa/bbb", []byte("xxxyyy"))
}()
ctx.TimeoutError("should be ignored")
ctx.TimeoutError("stolen ctx")
},
}
rw := &readWriter{}
rw.r.WriteString("GET /foo HTTP/1.1\r\nHost: google.com\r\n\r\n")
rw.r.WriteString("GET /foo HTTP/1.1\r\nHost: google.com\r\n\r\n")
ch := make(chan error)
go func() {
ch <- s.ServeConn(rw)
}()
select {
case err := <-ch:
if err != nil {
t.Fatalf("Unexpected error from serveConn: %s", err)
}
case <-time.After(100 * time.Millisecond):
t.Fatalf("timeout")
}
br := bufio.NewReader(&rw.w)
verifyResponse(t, br, StatusRequestTimeout, string(defaultContentType), "stolen ctx")
data, err := ioutil.ReadAll(br)
if err != nil {
t.Fatalf("Unexpected error when reading remaining data: %s", err)
}
if len(data) != 0 {
t.Fatalf("Unexpected data read after the first response %q. Expecting %q", data, "")
}
} | explode_data.jsonl/73303 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 417
} | [
2830,
3393,
5475,
7636,
1454,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
609,
5475,
515,
197,
197,
3050,
25,
2915,
7502,
353,
1900,
23684,
8,
341,
298,
30680,
2915,
368,
341,
571,
20985,
33320,
445,
32646,
3470,
6066,
497,
3056,
3782,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJobSpecsController_Create_InvalidJob(t *testing.T) {
t.Parallel()
app, cleanup := cltest.NewApplication()
defer cleanup()
client := app.NewHTTPClient()
jsonStr := cltest.LoadJSON("../internal/fixtures/web/run_at_wo_time_job.json")
resp, cleanup := client.Post("/v2/specs", bytes.NewBuffer(jsonStr))
defer cleanup()
assert.Equal(t, 400, resp.StatusCode, "Response should be caller error")
expected := `{"errors":[{"detail":"RunAt must have a time"}]}`
assert.Equal(t, expected, string(cltest.ParseResponseBody(resp)))
} | explode_data.jsonl/53689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
12245,
8327,
82,
2051,
34325,
62,
7928,
12245,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
28236,
11,
21290,
1669,
1185,
1944,
7121,
4988,
741,
16867,
21290,
741,
25291,
1669,
906,
7121,
9230,
2959,
2822,
30847,
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 TestUpdateSelectorToAdopt(t *testing.T) {
// We have pod1, pod2 and rs. rs.spec.replicas=1. At first rs.Selector
// matches pod1 only; change the selector to match pod2 as well. Verify
// there is only one pod left.
s, rm, rsInformer, podInformer, clientSet := rmSetup(t, true)
ns := framework.CreateTestingNamespace("rs-update-selector-to-adopt", s, t)
defer framework.DeleteTestingNamespace(ns, s, t)
rs := newRS("rs", ns.Name, 1)
// let rs's selector only match pod1
rs.Spec.Selector.MatchLabels["uniqueKey"] = "1"
rs.Spec.Template.Labels["uniqueKey"] = "1"
pod1 := newMatchingPod("pod1", ns.Name)
pod1.Labels["uniqueKey"] = "1"
pod2 := newMatchingPod("pod2", ns.Name)
pod2.Labels["uniqueKey"] = "2"
createRSsPods(t, clientSet, []*v1beta1.ReplicaSet{rs}, []*v1.Pod{pod1, pod2}, ns.Name)
stopCh := make(chan struct{})
go rsInformer.Run(stopCh)
go podInformer.Run(stopCh)
go rm.Run(5, stopCh)
waitRSStable(t, clientSet, rs, ns.Name)
// change the rs's selector to match both pods
patch := `{"spec":{"selector":{"matchLabels": {"uniqueKey":null}}}}`
rsClient := clientSet.Extensions().ReplicaSets(ns.Name)
rs, err := rsClient.Patch(rs.Name, api.StrategicMergePatchType, []byte(patch))
if err != nil {
t.Fatalf("Failed to patch replica set: %v", err)
}
t.Logf("patched rs = %#v", rs)
// wait for the rs select both pods and delete one of them
if err := wait.Poll(10*time.Second, 60*time.Second, func() (bool, error) {
return verifyRemainingObjects(t, clientSet, ns.Name, 1, 1)
}); err != nil {
t.Fatal(err)
}
close(stopCh)
} | explode_data.jsonl/73259 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
4289,
5877,
1249,
2589,
2912,
1155,
353,
8840,
836,
8,
341,
197,
322,
1205,
614,
7509,
16,
11,
7509,
17,
323,
10036,
13,
10036,
28326,
68225,
52210,
28,
16,
13,
2411,
1156,
10036,
14752,
269,
198,
197,
322,
9071,
7509,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandlers(t *testing.T) {
t.Parallel()
Convey("InstallHandlers", t, func() {
// Install handlers with fake auth settings.
r := router.New()
r.Use(router.NewMiddlewareChain(func(c *router.Context, next router.Handler) {
fakeAuthState := &authtest.FakeState{
Identity: "user:user@example.com",
IdentityPermissions: []authtest.RealmPermission{
{
Realm: "@internal:test-proj/cas-read-only",
Permission: realms.RegisterPermission("luci.serviceAccounts.mintToken"),
},
},
}
c.Context = auth.WithState(c.Context, fakeAuthState)
c.Context = auth.ModifyConfig(c.Context, func(cfg auth.Config) auth.Config {
cfg.DBProvider = func(context.Context) (authdb.DB, error) {
return fakeAuthState.DB(), nil
}
return cfg
})
next(c)
}))
cc := NewClientCache(context.Background())
t.Cleanup(cc.Clear)
InstallHandlers(r, cc)
srv := httptest.NewServer(r)
t.Cleanup(srv.Close)
Convey("rootHanlder", func() {
resp, err := http.Get(srv.URL)
So(err, ShouldBeNil)
defer resp.Body.Close()
So(resp.StatusCode, ShouldEqual, http.StatusOK)
// Body should contain user email address.
body, err := ioutil.ReadAll(resp.Body)
So(err, ShouldBeNil)
So(string(body), ShouldContainSubstring, "user@example.com")
})
Convey("treeHandler", func() {
resp, err := http.Get(
srv.URL + "/projects/test-proj/instances/default_instance/blobs/12345/6/tree")
So(err, ShouldBeNil)
defer resp.Body.Close()
So(resp.StatusCode, ShouldEqual, http.StatusOK)
})
Convey("getHandler", func() {
resp, err := http.Get(
srv.URL + "/projects/test-proj/instances/default_instance/blobs/12345/6")
So(err, ShouldBeNil)
defer resp.Body.Close()
So(resp.StatusCode, ShouldEqual, http.StatusOK)
})
Convey("checkPermission", func() {
resp, err := http.Get(
srv.URL + "/projects/test-proj-no-perm/instances/default_instance/blobs/12345/6/tree")
So(err, ShouldBeNil)
defer resp.Body.Close()
So(resp.StatusCode, ShouldEqual, http.StatusForbidden)
})
})
} | explode_data.jsonl/70282 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 878
} | [
2830,
3393,
39949,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
93070,
5617,
445,
24690,
39949,
497,
259,
11,
2915,
368,
341,
197,
197,
322,
19242,
24083,
448,
12418,
4166,
5003,
624,
197,
7000,
1669,
9273,
7121,
741,
197,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEventBusPublish(t *testing.T) {
eventBus := NewEventBus()
err := eventBus.Start()
require.NoError(t, err)
defer eventBus.Stop()
const numEventsExpected = 14
sub, err := eventBus.Subscribe(context.Background(), "test", tmquery.Empty{}, numEventsExpected)
require.NoError(t, err)
done := make(chan struct{})
go func() {
numEvents := 0
for range sub.Out() {
numEvents++
if numEvents >= numEventsExpected {
close(done)
return
}
}
}()
err = eventBus.Publish(EventNewBlockHeader, EventDataNewBlockHeader{})
require.NoError(t, err)
err = eventBus.PublishEventNewBlock(EventDataNewBlock{})
require.NoError(t, err)
err = eventBus.PublishEventNewBlockHeader(EventDataNewBlockHeader{})
require.NoError(t, err)
err = eventBus.PublishEventVote(EventDataVote{})
require.NoError(t, err)
err = eventBus.PublishEventNewRoundStep(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventTimeoutPropose(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventTimeoutWait(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventNewRound(EventDataNewRound{})
require.NoError(t, err)
err = eventBus.PublishEventCompleteProposal(EventDataCompleteProposal{})
require.NoError(t, err)
err = eventBus.PublishEventPolka(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventUnlock(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventRelock(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventLock(EventDataRoundState{})
require.NoError(t, err)
err = eventBus.PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates{})
require.NoError(t, err)
select {
case <-done:
case <-time.After(1 * time.Second):
t.Fatalf("expected to receive %d events after 1 sec.", numEventsExpected)
}
} | explode_data.jsonl/13677 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 667
} | [
2830,
3393,
1556,
15073,
50145,
1155,
353,
8840,
836,
8,
341,
28302,
15073,
1669,
1532,
1556,
15073,
741,
9859,
1669,
1538,
15073,
12101,
741,
17957,
35699,
1155,
11,
1848,
340,
16867,
1538,
15073,
30213,
2822,
4777,
1629,
7900,
18896,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAssembleSourceSinkSpecs(t *testing.T) {
Convey("Given a parseStack", t, func() {
ps := parseStack{}
Convey("When the stack contains only SourceSinkParams in the given range", func() {
ps.PushComponent(0, 6, Raw{"PRE"})
ps.PushComponent(6, 7, SourceSinkParamAST{"key", data.String("val")})
ps.PushComponent(7, 8, SourceSinkParamAST{"a", data.String("b")})
ps.AssembleSourceSinkSpecs(6, 8)
Convey("Then AssembleSourceSinkSpecs transforms them into one item", func() {
So(ps.Len(), ShouldEqual, 2)
Convey("And that item is a SourceSinkSpecsAST", func() {
top := ps.Peek()
So(top, ShouldNotBeNil)
So(top.begin, ShouldEqual, 6)
So(top.end, ShouldEqual, 8)
So(top.comp, ShouldHaveSameTypeAs, SourceSinkSpecsAST{})
Convey("And it contains the previously pushed data", func() {
comp := top.comp.(SourceSinkSpecsAST)
So(len(comp.Params), ShouldEqual, 2)
So(comp.Params[0].Key, ShouldEqual, "key")
So(comp.Params[0].Value, ShouldEqual, data.String("val"))
So(comp.Params[1].Key, ShouldEqual, "a")
So(comp.Params[1].Value, ShouldEqual, data.String("b"))
})
})
})
})
Convey("When the stack contains no elements in the given range", func() {
ps.PushComponent(0, 6, Raw{"PRE"})
ps.AssembleSourceSinkSpecs(6, 8)
Convey("Then AssembleSourceSinkSpecs pushes one item onto the stack", func() {
So(ps.Len(), ShouldEqual, 2)
Convey("And that item is a SourceSinkSpecsAST", func() {
top := ps.Peek()
So(top, ShouldNotBeNil)
So(top.begin, ShouldEqual, 6)
So(top.end, ShouldEqual, 8)
So(top.comp, ShouldHaveSameTypeAs, SourceSinkSpecsAST{})
Convey("And it contains an empty list", func() {
comp := top.comp.(SourceSinkSpecsAST)
So(len(comp.Params), ShouldEqual, 0)
})
})
})
})
Convey("When the given range is empty", func() {
ps.PushComponent(0, 6, Raw{"PRE"})
ps.AssembleSourceSinkSpecs(6, 6)
Convey("Then AssembleSourceSinkSpecs pushes one item onto the stack", func() {
So(ps.Len(), ShouldEqual, 2)
Convey("And that item is a SourceSinkSpecsAST", func() {
top := ps.Peek()
So(top, ShouldNotBeNil)
So(top.begin, ShouldEqual, 6)
So(top.end, ShouldEqual, 6)
So(top.comp, ShouldHaveSameTypeAs, SourceSinkSpecsAST{})
Convey("And it contains an empty list", func() {
comp := top.comp.(SourceSinkSpecsAST)
So(len(comp.Params), ShouldEqual, 0)
})
})
})
})
Convey("When the stack contains non-SourceSinkParams in the given range", func() {
ps.PushComponent(0, 6, Raw{"PRE"})
f := func() {
ps.AssembleSourceSinkSpecs(0, 8)
}
Convey("Then AssembleSourceSinkSpecs panics", func() {
So(f, ShouldPanic)
})
})
})
Convey("Given a parser", t, func() {
p := &bqlPeg{}
Convey("When creating a source without a WITH", func() {
p.Buffer = "CREATE SOURCE a TYPE b"
p.Init()
Convey("Then the statement should be parsed correctly", func() {
err := p.Parse()
So(err, ShouldBeNil)
p.Execute()
ps := p.parseStack
So(ps.Len(), ShouldEqual, 1)
top := ps.Peek().comp
So(top, ShouldHaveSameTypeAs, CreateSourceStmt{})
s := top.(CreateSourceStmt)
So(s.Params, ShouldBeNil)
Convey("And String() should return the original statement", func() {
So(s.String(), ShouldEqual, p.Buffer)
})
})
})
Convey("When creating a source with a WITH", func() {
p.Buffer = `CREATE SOURCE a TYPE b WITH port=8080, proto="http"`
p.Init()
Convey("Then the statement should be parsed correctly", func() {
err := p.Parse()
So(err, ShouldBeNil)
p.Execute()
ps := p.parseStack
So(ps.Len(), ShouldEqual, 1)
top := ps.Peek().comp
So(top, ShouldHaveSameTypeAs, CreateSourceStmt{})
s := top.(CreateSourceStmt)
So(s.Params, ShouldNotBeNil)
So(len(s.Params), ShouldEqual, 2)
So(s.Params[0], ShouldResemble,
SourceSinkParamAST{"port", data.Int(8080)})
So(s.Params[1], ShouldResemble,
SourceSinkParamAST{"proto", data.String("http")})
Convey("And String() should return the original statement", func() {
So(s.String(), ShouldEqual, p.Buffer)
})
})
})
})
} | explode_data.jsonl/26062 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1842
} | [
2830,
3393,
2121,
15790,
3608,
45094,
8327,
82,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
4715,
4336,
497,
259,
11,
2915,
368,
341,
197,
35009,
1669,
4715,
4336,
31483,
197,
93070,
5617,
445,
4498,
279,
5611,
5610,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQuerytronNested(t *testing.T) {
is := func(got, expect, message string) {
if got != expect {
t.Errorf("%s failed - got '%s', expected '%s'\n", message, got, expect)
}
}
q := set(Q{
"family": "overridden family",
"name": "overridden name",
"secret": "overridden secret",
"ignored": "overridden ignored (BAD!)",
})
deep := Deep{
Family: "initial family",
Nested: Shallow{
Name: "initial name",
hidden: "initial hidden",
Ignored: "initial ignored",
},
}
is(deep.Family, "initial family", "initial family is set before testing")
is(deep.Nested.Name, "initial name", "initial name is set before testing")
is(deep.Nested.Ignored, "initial ignored", "initial ignored is set before testing")
is(deep.Nested.hidden, "initial hidden", "initial hidden is set before testing")
qs.Override(&deep, q)
is(deep.Family, "overridden family", "Family is overridden from FAMILY env var")
is(deep.Nested.Name, "overridden name", "Name is overridden from NAME env var")
is(deep.Nested.Ignored, "initial ignored", "initial ignored is still set")
is(deep.Nested.hidden, "initial hidden", "hidden fields cannot be overridden")
} | explode_data.jsonl/13874 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 405
} | [
2830,
3393,
2859,
34685,
71986,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
2915,
3268,
354,
11,
1720,
11,
1943,
914,
8,
341,
197,
743,
2684,
961,
1720,
341,
298,
3244,
13080,
4430,
82,
4641,
481,
2684,
7677,
82,
516,
3601,
7677,
82,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.