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 TestPipelinesBuilder_Build(t *testing.T) {
tests := []struct {
name string
pipelineName string
exporterNames []string
}{
{
name: "one-exporter",
pipelineName: "traces",
exporterNames: []string{"exampleexporter"},
},
{
name: "multi-exporter",
pipelineName: "traces/2",
exporterNames: []string{"exampleexporter", "exampleexporter/2"},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
testPipeline(t, test.pipelineName, test.exporterNames)
})
}
} | explode_data.jsonl/10201 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
47,
93997,
3297,
96686,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
3223,
8790,
675,
220,
914,
198,
197,
59440,
261,
7980,
3056,
917,
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,
1... | 1 |
func TestAccAzureRMLoadBalancerNatRule_updateMultipleRules(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_lb_nat_rule", "test")
data2 := acceptance.BuildTestData(t, "azurerm_lb_nat_rule", "test2")
r := LoadBalancerNatRule{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.multipleRules(data, data2),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data2.ResourceName).ExistsInAzure(r),
check.That(data2.ResourceName).Key("frontend_port").HasValue("3390"),
check.That(data2.ResourceName).Key("backend_port").HasValue("3390"),
),
},
data.ImportStep(),
{
Config: r.multipleRulesUpdate(data, data2),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data2.ResourceName).ExistsInAzure(r),
check.That(data2.ResourceName).Key("frontend_port").HasValue("3391"),
check.That(data2.ResourceName).Key("backend_port").HasValue("3391"),
),
},
data.ImportStep(),
})
} | explode_data.jsonl/29073 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 419
} | [
2830,
3393,
14603,
78107,
49,
2668,
2731,
93825,
65214,
11337,
8882,
32089,
26008,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
25505,
25212,
83920,
1155,
11,
330,
1370,
324,
4195,
63601,
38169,
21124,
497,
330,
1944,
1138,
8924,
17,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSHA3(t *testing.T) {
d, _ := hex.DecodeString(data)
h := SHA3_256.Hash(d)
r, _ := hex.DecodeString(SHA3_256R)
if !bytes.Equal(h, r) {
t.Errorf("SHA3-256: need: %v, but got: %v \n", r, h)
}
} | explode_data.jsonl/55349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
33145,
18,
1155,
353,
8840,
836,
8,
341,
2698,
11,
716,
1669,
12371,
56372,
703,
2592,
340,
9598,
1669,
21721,
18,
62,
17,
20,
21,
15103,
1500,
340,
7000,
11,
716,
1669,
12371,
56372,
703,
3759,
17020,
18,
62,
17,
20,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestClientTLSHandshakeTimeout(t *testing.T) {
t.Parallel()
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
addr := listener.Addr().String()
defer listener.Close()
complete := make(chan bool)
defer close(complete)
go func() {
conn, err := listener.Accept()
if err != nil {
t.Error(err)
return
}
<-complete
conn.Close()
}()
client := Client{
WriteTimeout: 100 * time.Millisecond,
ReadTimeout: 100 * time.Millisecond,
}
_, _, err = client.Get(nil, "https://"+addr)
if err == nil {
t.Fatal("tlsClientHandshake completed successfully")
}
if err != ErrTLSHandshakeTimeout {
t.Errorf("resulting error not a timeout: %v\nType %T: %#v", err, err, err)
}
} | explode_data.jsonl/79384 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
2959,
45439,
2314,
29661,
7636,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
14440,
798,
11,
1848,
1669,
4179,
68334,
445,
27161,
497,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
15,
1138,
743,
1848,
961,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSyncPodsDoesNothing(t *testing.T) {
dm, fakeDocker := newTestDockerManager()
container := api.Container{Name: "bar"}
pod := makePod("foo", &api.PodSpec{
Containers: []api.Container{
container,
},
})
fakeDocker.SetFakeRunningContainers([]*FakeContainer{
{
ID: "1234",
Name: "/k8s_bar." + strconv.FormatUint(kubecontainer.HashContainer(&container), 16) + "_foo_new_12345678_0",
},
{
ID: "9876",
Name: "/k8s_POD." + strconv.FormatUint(generatePodInfraContainerHash(pod), 16) + "_foo_new_12345678_0",
}})
runSyncPod(t, dm, fakeDocker, pod, nil, false)
verifyCalls(t, fakeDocker, []string{})
} | explode_data.jsonl/31168 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
12154,
23527,
82,
21468,
23780,
1155,
353,
8840,
836,
8,
341,
2698,
76,
11,
12418,
35,
13659,
1669,
501,
2271,
35,
13659,
2043,
741,
53290,
1669,
6330,
33672,
63121,
25,
330,
2257,
16707,
3223,
347,
1669,
1281,
23527,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBase_newBase(t *testing.T) {
model := config.ModelConfig{}
archivePath := "/tmp/gobackup/test-storeage/foo.zip"
base := newBase(model, archivePath)
assert.Equal(t, base.archivePath, archivePath)
assert.Equal(t, base.model, model)
assert.Equal(t, base.viper, model.Viper)
assert.Equal(t, base.keep, 0)
} | explode_data.jsonl/28840 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
3978,
5921,
3978,
1155,
353,
8840,
836,
8,
341,
19727,
1669,
2193,
5659,
2648,
16094,
197,
16019,
1820,
1669,
3521,
5173,
4846,
674,
473,
454,
12697,
33252,
424,
60555,
20991,
698,
24195,
1669,
501,
3978,
7635,
11,
18132,
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 TestUnmarshalLocalDate(t *testing.T) {
t.Run("ToLocalDate", func(t *testing.T) {
type dateStruct struct {
Date LocalDate
}
toml := `date = 1979-05-27`
var obj dateStruct
err := Unmarshal([]byte(toml), &obj)
if err != nil {
t.Fatal(err)
}
if obj.Date.Year != 1979 {
t.Errorf("expected year 1979, got %d", obj.Date.Year)
}
if obj.Date.Month != 5 {
t.Errorf("expected month 5, got %d", obj.Date.Month)
}
if obj.Date.Day != 27 {
t.Errorf("expected day 27, got %d", obj.Date.Day)
}
})
t.Run("ToLocalDate", func(t *testing.T) {
type dateStruct struct {
Date time.Time
}
toml := `date = 1979-05-27`
var obj dateStruct
err := Unmarshal([]byte(toml), &obj)
if err != nil {
t.Fatal(err)
}
if obj.Date.Year() != 1979 {
t.Errorf("expected year 1979, got %d", obj.Date.Year())
}
if obj.Date.Month() != 5 {
t.Errorf("expected month 5, got %d", obj.Date.Month())
}
if obj.Date.Day() != 27 {
t.Errorf("expected day 27, got %d", obj.Date.Day())
}
})
} | explode_data.jsonl/46359 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 466
} | [
2830,
3393,
1806,
27121,
7319,
1916,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
96856,
1916,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
13158,
2400,
9422,
2036,
341,
298,
48730,
40816,
198,
197,
197,
630,
197,
3244,
316,
75,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetReturnsValidDevice(t *testing.T) {
t.Skip("FIXME: not a unit test")
d := newDriver(t)
defer cleanup(d)
if err := d.Create("1", ""); err != nil {
t.Fatal(err)
}
if !d.HasDevice("1") {
t.Fatalf("Expected id 1 to be in device set")
}
if _, err := d.Get("1"); err != nil {
t.Fatal(err)
}
if !d.HasActivatedDevice("1") {
t.Fatalf("Expected id 1 to be activated")
}
if !d.HasInitializedDevice("1") {
t.Fatalf("Expected id 1 to be initialized")
}
} | explode_data.jsonl/45485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 205
} | [
2830,
3393,
1949,
16446,
4088,
6985,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
445,
81019,
25,
537,
264,
4982,
1273,
1138,
2698,
1669,
501,
11349,
1155,
340,
16867,
21290,
1500,
692,
743,
1848,
1669,
294,
7251,
445,
16,
497,
93754,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProvider_TailscaleDNSPreferences(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testProviderPreCheck(t) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
testResourceCreated("tailscale_dns_preferences.test_preferences", testDNSPreferences),
testResourceDestroyed("tailscale_dns_preferences.test_preferences", testDNSPreferences),
},
})
} | explode_data.jsonl/3144 | {
"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,
5179,
1139,
6209,
2246,
61088,
14306,
1155,
353,
8840,
836,
8,
341,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
688,
2915,
368,
314,
1273,
5179,
4703,
3973,
1155,
8,
1153,
197,
197,
5179,
17417,
2433... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncident_Manage_status(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/incidents", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
_, _ = w.Write([]byte(`{"incidents": [{"title": "foo", "id": "1", "status": "acknowledged"}]}`))
})
listObj := APIListObject{Limit: 0, Offset: 0, More: false, Total: 0}
client := defaultTestClient(server.URL, "foo")
from := "foo@bar.com"
input := []ManageIncidentsOptions{
{
ID: "1",
Type: "incident",
Status: "acknowledged",
},
}
want := &ListIncidentsResponse{
APIListObject: listObj,
Incidents: []Incident{
{
Id: "1",
Title: "foo",
Status: "acknowledged",
},
},
}
res, err := client.ManageIncidents(from, input)
if err != nil {
t.Fatal(err)
}
testEqual(t, want, res)
} | explode_data.jsonl/76387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 363
} | [
2830,
3393,
39245,
1713,
71628,
424,
4773,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
2840,
6880,
497,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
18185,
3523,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMonitorActivities(t *testing.T) {
activityChan := make(chan *vocab.ActivityType)
l := &mockActivityLogger{}
go monitorActivities(activityChan, l)
activityChan <- vocab.NewRejectActivity(vocab.NewObjectProperty(),
vocab.WithID(vocab.MustParseURL("https://domain1.com/123")),
vocab.WithActor(vocab.MustParseURL("https://domain2.com/456")),
)
activityChan <- vocab.NewAcceptActivity(vocab.NewObjectProperty(),
vocab.WithID(vocab.MustParseURL("https://domain2.com/456")),
vocab.WithActor(vocab.MustParseURL("https://domain1.com/123")),
)
time.Sleep(10 * time.Millisecond)
close(activityChan)
require.Contains(t, l.getWarns(),
"Received activity [https://domain1.com/123] of type Reject from [https://domain2.com/456]")
require.Contains(t, l.getInfos(),
"Received activity [https://domain2.com/456] of type Accept from [https://domain1.com/123]")
} | explode_data.jsonl/57252 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
30098,
67820,
1155,
353,
8840,
836,
8,
341,
197,
7175,
46019,
1669,
1281,
35190,
353,
86847,
24925,
929,
692,
8810,
1669,
609,
16712,
4052,
7395,
31483,
30680,
8718,
67820,
30212,
46019,
11,
326,
692,
197,
7175,
46019,
9119,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCatalog_Deregister(t *testing.T) {
t.Parallel()
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
codec := rpcClient(t, s1)
defer codec.Close()
arg := structs.DeregisterRequest{
Datacenter: "dc1",
Node: "foo",
}
var out struct{}
err := msgpackrpc.CallWithCodec(codec, "Catalog.Deregister", &arg, &out)
if err != nil {
t.Fatalf("err: %v", err)
}
testrpc.WaitForLeader(t, s1.RPC, "dc1")
if err := msgpackrpc.CallWithCodec(codec, "Catalog.Deregister", &arg, &out); err != nil {
t.Fatalf("err: %v", err)
}
} | explode_data.jsonl/49217 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 262
} | [
2830,
3393,
41606,
1557,
52633,
1571,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
1155,
340,
16867,
2643,
84427,
14161,
16,
340,
16867,
274,
16,
10849,
18452,
741,
43343,
66,
1669,
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... | 3 |
func TestRobotsTxt(t *testing.T) {
opts := baseTestOptions()
err := validation.Validate(opts)
assert.NoError(t, err)
proxy, err := NewOAuthProxy(opts, func(string) bool { return true })
if err != nil {
t.Fatal(err)
}
rw := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/robots.txt", nil)
proxy.ServeHTTP(rw, req)
assert.Equal(t, 200, rw.Code)
assert.Equal(t, "User-agent: *\r\nDisallow: /\r\n", rw.Body.String())
} | explode_data.jsonl/36382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
14465,
2412,
35629,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
2331,
2271,
3798,
741,
9859,
1669,
10519,
47667,
30885,
340,
6948,
35699,
1155,
11,
1848,
692,
197,
22803,
11,
1848,
1669,
1532,
57850,
16219,
30885,
11,
2915,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegrationBasicAuth(t *testing.T) {
_, teardown := prepService(t)
defer teardown()
client := &http.Client{Timeout: 5 * time.Second}
req, err := http.NewRequest("GET", "http://127.0.0.1:8089/private", nil)
require.Nil(t, err)
resp, err := client.Do(req)
require.Nil(t, err)
assert.Equal(t, 401, resp.StatusCode)
defer resp.Body.Close()
req, err = http.NewRequest("GET", "http://127.0.0.1:8089/private", nil)
require.Nil(t, err)
req.SetBasicAuth("admin", "password")
resp, err = client.Do(req)
require.Nil(t, err)
assert.Equal(t, 200, resp.StatusCode)
assert.NoError(t, resp.Body.Close())
} | explode_data.jsonl/34041 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
52464,
15944,
5087,
1155,
353,
8840,
836,
8,
1476,
197,
6878,
49304,
1669,
21327,
1860,
1155,
340,
16867,
49304,
2822,
25291,
1669,
609,
1254,
11716,
90,
7636,
25,
220,
20,
353,
882,
32435,
532,
24395,
11,
1848,
1669,
1758,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileCluster(t *testing.T) {
cluster1 := builder.Cluster(metav1.NamespaceDefault, "cluster1").
Build()
cluster1WithReferences := builder.Cluster(metav1.NamespaceDefault, "cluster1").
WithInfrastructureCluster(builder.InfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster1").
Build()).
WithControlPlane(builder.ControlPlane(metav1.NamespaceDefault, "control-plane1").Build()).
Build()
cluster2WithReferences := cluster1WithReferences.DeepCopy()
cluster2WithReferences.SetGroupVersionKind(cluster1WithReferences.GroupVersionKind())
cluster2WithReferences.Name = "cluster2"
tests := []struct {
name string
current *clusterv1.Cluster
desired *clusterv1.Cluster
want *clusterv1.Cluster
wantErr bool
}{
{
name: "Should update the cluster if infrastructure and control plane references are not set",
current: cluster1,
desired: cluster1WithReferences,
want: cluster1WithReferences,
wantErr: false,
},
{
name: "Should be a no op if infrastructure and control plane references are already set",
current: cluster2WithReferences,
desired: cluster2WithReferences,
want: cluster2WithReferences,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
fakeObjs := make([]client.Object, 0)
if tt.current != nil {
fakeObjs = append(fakeObjs, tt.current)
}
fakeClient := fake.NewClientBuilder().
WithScheme(fakeScheme).
WithObjects(fakeObjs...).
Build()
s := scope.New(tt.current)
s.Desired = &scope.ClusterState{Cluster: tt.desired}
r := Reconciler{
Client: fakeClient,
recorder: env.GetEventRecorderFor("test"),
}
err := r.reconcileCluster(ctx, s)
if tt.wantErr {
g.Expect(err).To(HaveOccurred())
return
}
g.Expect(err).ToNot(HaveOccurred())
got := tt.want.DeepCopy()
err = fakeClient.Get(ctx, client.ObjectKeyFromObject(tt.want), got)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(got.Spec.InfrastructureRef).To(EqualObject(tt.want.Spec.InfrastructureRef))
g.Expect(got.Spec.ControlPlaneRef).To(EqualObject(tt.want.Spec.ControlPlaneRef))
})
}
} | explode_data.jsonl/11657 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 866
} | [
2830,
3393,
693,
40446,
457,
28678,
1155,
353,
8840,
836,
8,
341,
197,
18855,
16,
1669,
7363,
72883,
1255,
295,
402,
16,
46011,
3675,
11,
330,
18855,
16,
38609,
197,
197,
11066,
741,
197,
18855,
16,
2354,
31712,
1669,
7363,
72883,
125... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInMemoryIndex(t *testing.T) {
builder := InMemoryBuilder(3)
for i := 0; i < len(vectorTests); i ++ {
v := vectorTests[i]
builder.AddWord(v.word, NewVector(v.vec))
}
memory_index := Contextionary(builder.Build(3))
shared_tests(t, &memory_index)
} | explode_data.jsonl/10278 | {
"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,
641,
10642,
1552,
1155,
353,
8840,
836,
8,
341,
220,
7363,
1669,
758,
10642,
3297,
7,
18,
340,
220,
369,
600,
1669,
220,
15,
26,
600,
366,
2422,
19066,
18200,
1215,
600,
3443,
341,
262,
348,
1669,
4621,
18200,
989,
921,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanonicalEncryptedTicketL2Digest(t *testing.T) {
m := TicketBundle{
EncryptedTicketL2: []byte{
201, 51, 244, 7, 147, 7, 41, 29, 159, 198, 30, 107, 203, 213, 189, 183, 1, 180, 56, 142, 138, 144, 167, 46, 22, 54, 32, 128, 95, 77, 189, 230, 188, 33, 118, 53, 140, 213, 98, 128, 4, 6, 55, 164, 28, 243, 8, 141, 231, 54, 105, 32, 125, 133, 230, 239, 6, 29, 199, 230, 139, 111, 149, 70, 222, 129, 200, 220, 151, 185, 18, 205, 239, 107, 236, 125, 103, 158, 64, 250,
},
}
digest := m.canonicalEncryptedTicketL2Digest()
expected := []byte{89, 79, 30, 185, 194, 189, 21, 204, 134, 107, 117, 162, 132, 43, 241, 35, 32, 38, 182, 248, 10, 99, 16, 194, 106, 239, 182, 4, 195, 228, 212, 200, 221, 239, 202, 129, 48, 13, 17, 72, 66, 164, 212, 253, 249, 252, 94, 190}
assert.Equal(t, expected, digest)
} | explode_data.jsonl/45220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
70914,
7408,
14026,
34058,
43,
17,
45217,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
28397,
8409,
515,
197,
197,
7408,
14026,
34058,
43,
17,
25,
3056,
3782,
515,
298,
197,
17,
15,
16,
11,
220,
20,
16,
11,
220,
17,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRecognizeIdentifierRecognizeNormalizeUnneeded(t *testing.T) {
a := assert.New(t)
opts := makeOptions(strings.NewReader("Ni\u00f1o"))
s, _ := scanner.Scan(opts)
l := &lexer{
s: s,
opts: opts,
}
l.indent.PushBack(1)
r := &recognizeIdentifier{
l: l,
s: recogString(l).(*recognizeString),
}
ch := l.s.Next()
r.Recognize(ch)
a.Equal(s, l.s)
a.Equal(1, l.tokens.Len())
a.Equal(&common.Token{
Sym: common.TokIdent,
Loc: common.Location{
File: "file",
B: common.FilePos{L: 1, C: 1},
E: common.FilePos{L: 1, C: 5},
},
Val: "Ni\u00f1o",
}, l.tokens.Front().Value.(*common.Token))
} | explode_data.jsonl/7679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
17915,
551,
8714,
17915,
551,
87824,
1806,
40817,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
340,
64734,
1669,
1281,
3798,
51442,
68587,
445,
56494,
3770,
15,
15,
69,
16,
78,
5455,
1903,
11,
716,
1669,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateBlockReferenceTime(t *testing.T) {
with.Context(func(ctx context.Context) {
with.Logging(t, func(harness *with.LoggingHarness) {
s := newHarness(harness.Logger, false)
s.management.Reset()
now := time.Now()
currentRefTime := primitives.TimestampSeconds(now.Unix())
genesisRefTime := primitives.TimestampSeconds(now.Add(-s.config.CommitteeGracePeriod() * 2).Unix()) // invalid committee grace wise
setManagementValues(s.management, 1, currentRefTime, genesisRefTime)
// validate genesis block (prev refTime := Management.genesis)
input := &services.ValidateBlockReferenceTimeInput{
BlockHeight: 1,
PrevBlockReferenceTime: 0,
}
// genesis block with an invalid genesis ref time
_, err := s.service.ValidateBlockReferenceTime(ctx, input) // note: ValidateBlockReferenceTime uses time.now within function
require.Error(t, err, "validation should fail as genesis reference time is outdated (not within committee grace - honesty assumption time)")
// genesis block with valid genesis ref time
s.management.Reset()
genesisRefTime = primitives.TimestampSeconds(now.Add(-s.config.CommitteeGracePeriod() / 2).Unix())
setManagementValues(s.management, 1, currentRefTime, genesisRefTime)
_, err = s.service.ValidateBlockReferenceTime(ctx, input)
require.NoError(t, err, "validation should succeed as genesis reference time is within committee grace - honesty assumption time")
// too old ref time (non genesis)
input.BlockHeight = primitives.BlockHeight(10)
input.PrevBlockReferenceTime = primitives.TimestampSeconds(now.Add(-s.config.CommitteeGracePeriod() * 2).Unix()) // invalid committee grace wise
_, err = s.service.ValidateBlockReferenceTime(ctx, input)
require.Error(t, err, "validation should fail as prev block reference time is outdated (not within committee grace - honesty assumption time)")
// valid ref time
input.PrevBlockReferenceTime = primitives.TimestampSeconds(now.Add(-s.config.CommitteeGracePeriod() / 2).Unix()) // valid refTime - committee grace wise
_, err = s.service.ValidateBlockReferenceTime(ctx, input)
require.NoError(t, err, "validation should succeed as prev reference time is within committee grace - honesty assumption time")
})
})
} | explode_data.jsonl/11019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 714
} | [
2830,
3393,
17926,
4713,
8856,
1462,
1155,
353,
8840,
836,
8,
341,
46948,
9328,
18552,
7502,
2266,
9328,
8,
341,
197,
46948,
41945,
1155,
11,
2915,
3203,
23518,
353,
4197,
41945,
74248,
8,
341,
298,
1903,
1669,
501,
74248,
3203,
23518,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetGroupsByType(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.CreateGroup()
th.CreateGroup()
th.CreateGroup()
groups, err := th.App.GetGroupsBySource(model.GroupSourceLdap)
require.Nil(t, err)
require.NotEmpty(t, groups)
groups, err = th.App.GetGroupsBySource(model.GroupSource("blah"))
require.Nil(t, err)
require.Empty(t, groups)
} | explode_data.jsonl/37035 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
1949,
22173,
1359,
929,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
741,
70479,
7251,
2808,
741,
70479,
7251,
2808,
741,
70479,
7251,
2808,
2822,
44260,
82,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_fetchRepoIndexUserAgent(t *testing.T) {
tests := []struct {
name string
version string
userAgentComment string
expectedUserAgent string
}{
{"default user agent", "", "", "asset-syncer/devel"},
{"custom version no app", "1.0", "", "asset-syncer/1.0"},
{"custom version and app", "1.0", "monocular/1.2", "asset-syncer/1.0 (monocular/1.2)"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Override global variables used to generate the userAgent
if tt.version != "" {
version = tt.version
}
if tt.userAgentComment != "" {
userAgentComment = tt.userAgentComment
}
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
assert.Equal(t, tt.expectedUserAgent, req.Header.Get("User-Agent"), "expected user agent")
rw.Write([]byte(validRepoIndexYAML))
}))
// Close the server when test finishes
defer server.Close()
netClient = server.Client()
_, err := fetchRepoIndex(server.URL, "")
assert.NoErr(t, err)
})
}
} | explode_data.jsonl/67800 | {
"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,
11803,
25243,
1552,
1474,
16810,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
1060,
914,
198,
197,
74954,
1843,
914,
198,
197,
19060,
16810,
10677,
220,
914,
198,
197,
42400,
1474,
16810,
914,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUserFindEmail(t *testing.T) {
defer gock.Off()
gock.New("https://bitbucket.example.com").
Get("plugins/servlet/applinks/whoami").
Reply(200).
Type("text/plain").
BodyString("jcitizen")
gock.New("https://bitbucket.example.com").
Get("rest/api/1.0/users/jcitizen").
Reply(200).
Type("application/json").
File("testdata/user.json")
client, _ := New("https://bitbucket.example.com")
email, _, err := client.Users.FindEmail(context.Background())
if err != nil {
t.Error(err)
}
if got, want := email, "jane@example.com"; got != want {
t.Errorf("Want email %s, got %s", want, got)
}
} | explode_data.jsonl/45534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
1474,
9885,
4781,
1155,
353,
8840,
836,
8,
341,
16867,
728,
377,
13,
4596,
2822,
3174,
1176,
7121,
445,
2428,
1110,
4489,
30410,
7724,
905,
38609,
197,
37654,
445,
18716,
2687,
4560,
24670,
500,
15504,
14,
14623,
10606,
3860... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDeferDeleteSlow(t *testing.T) {
ks := []complex128{0, 1, 2, 3}
m := make(map[interface{}]int)
for i, k := range ks {
m[k] = i
}
if len(m) != len(ks) {
t.Errorf("want %d elements, got %d", len(ks), len(m))
}
func() {
for _, k := range ks {
defer delete(m, k)
}
}()
if len(m) != 0 {
t.Errorf("want 0 elements, got %d", len(m))
}
} | explode_data.jsonl/19927 | {
"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,
1912,
802,
6435,
58289,
1155,
353,
8840,
836,
8,
341,
197,
2787,
1669,
3056,
23247,
16,
17,
23,
90,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
630,
2109,
1669,
1281,
9147,
58,
4970,
78134,
396,
340,
2023,
600,
11,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStoreSuggestedCompactionKeyDecode(t *testing.T) {
origStart := roachpb.Key("a")
origEnd := roachpb.Key("z")
key := StoreSuggestedCompactionKey(origStart, origEnd)
start, end, err := DecodeStoreSuggestedCompactionKey(key)
if err != nil {
t.Fatal(err)
}
if !start.Equal(origStart) {
t.Errorf("expected %s == %s", start, origStart)
}
if !end.Equal(origEnd) {
t.Errorf("expected %s == %s", end, origEnd)
}
} | explode_data.jsonl/56584 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
6093,
50,
53276,
13552,
1311,
1592,
32564,
1155,
353,
8840,
836,
8,
341,
197,
4670,
3479,
1669,
926,
610,
16650,
9610,
445,
64,
1138,
197,
4670,
3727,
1669,
926,
610,
16650,
9610,
445,
89,
1138,
23634,
1669,
9129,
50,
5327... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_convert(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want int
}{
{
name: "Case1",
args: args{s: "-91283472332"},
want: -2147483648,
},
{
name: "Case2",
args: args{s: "91283472332"},
want: 2147483647,
},
{
name: "Case3",
args: args{s: "0"},
want: 0,
},
{
name: "Case4",
args: args{s: "234"},
want: 234,
},
{
name: "Case5",
args: args{s: "-901"},
want: -901,
},
{
name: "Case6",
args: args{s: "+1"},
want: 1,
},
{
name: "Case7",
args: args{s: "9223372036854775808"},
want: 2147483647,
},
{
name: "Case8",
args: args{s: "2147483646"},
want: 2147483646,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := convert(tt.args.s); got != tt.want {
t.Errorf("convert() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34953 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 500
} | [
2830,
3393,
34910,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1903,
914,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
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 TestInputService2ProtocolTestStructureWithLocationNameAndQueryNameAppliedToMembersCase1(t *testing.T) {
svc := NewInputService2ProtocolTest(nil)
svc.Endpoint = "https://test"
input := &InputService2TestShapeInputShape{
Bar: aws.String("val2"),
Foo: aws.String("val1"),
Yuck: aws.String("val3"),
}
req, _ := svc.InputService2TestCaseOperation1Request(input)
r := req.HTTPRequest
// build request
ec2query.Build(req)
assert.NoError(t, req.Error)
// assert body
assert.NotNil(t, r.Body)
body, _ := ioutil.ReadAll(r.Body)
assert.Equal(t, util.Trim(`Action=OperationName&BarLocationName=val2&Foo=val1&Version=2014-01-01&yuckQueryName=val3`), util.Trim(string(body)))
// assert URL
assert.Equal(t, "https://test/", r.URL.String())
// assert headers
} | explode_data.jsonl/53202 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
2505,
1860,
17,
20689,
2271,
22952,
2354,
4707,
675,
3036,
2859,
675,
75856,
1249,
24371,
4207,
16,
1155,
353,
8840,
836,
8,
341,
1903,
7362,
1669,
1532,
2505,
1860,
17,
20689,
2271,
27907,
340,
1903,
7362,
90409,
284,
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 TestGetBranchProtection(t *testing.T) {
contexts := []string{"foo-pr-test", "other"}
pushers := []Team{{Slug: "movers"}, {Slug: "awesome-team"}, {Slug: "shakers"}}
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
t.Errorf("Bad method: %s", r.Method)
}
if r.URL.Path != "/repos/org/repo/branches/master/protection" {
t.Errorf("Bad request path: %s", r.URL.Path)
}
bp := BranchProtection{
RequiredStatusChecks: &RequiredStatusChecks{
Contexts: contexts,
},
Restrictions: &Restrictions{
Teams: pushers,
},
}
b, err := json.Marshal(&bp)
if err != nil {
t.Fatalf("Didn't expect error: %v", err)
}
fmt.Fprint(w, string(b))
}))
defer ts.Close()
c := getClient(ts.URL)
bp, err := c.GetBranchProtection("org", "repo", "master")
if err != nil {
t.Errorf("Didn't expect error: %v", err)
}
switch {
case bp.Restrictions == nil:
t.Errorf("RestrictionsRequest unset")
case bp.Restrictions.Teams == nil:
t.Errorf("Teams unset")
case len(bp.Restrictions.Teams) != len(pushers):
t.Errorf("Bad teams: expected %v, got: %v", pushers, bp.Restrictions.Teams)
case bp.RequiredStatusChecks == nil:
t.Errorf("RequiredStatusChecks unset")
case len(bp.RequiredStatusChecks.Contexts) != len(contexts):
t.Errorf("Bad contexts: expected: %v, got: %v", contexts, bp.RequiredStatusChecks.Contexts)
default:
mc := map[string]bool{}
for _, k := range bp.RequiredStatusChecks.Contexts {
mc[k] = true
}
var missing []string
for _, k := range contexts {
if mc[k] != true {
missing = append(missing, k)
}
}
if n := len(missing); n > 0 {
t.Errorf("missing %d required contexts: %v", n, missing)
}
mp := map[string]bool{}
for _, k := range bp.Restrictions.Teams {
mp[k.Slug] = true
}
missing = nil
for _, k := range pushers {
if mp[k.Slug] != true {
missing = append(missing, k.Slug)
}
}
if n := len(missing); n > 0 {
t.Errorf("missing %d pushers: %v", n, missing)
}
}
} | explode_data.jsonl/6294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 887
} | [
2830,
3393,
1949,
18197,
78998,
1155,
353,
8840,
836,
8,
341,
28413,
82,
1669,
3056,
917,
4913,
7975,
26650,
16839,
497,
330,
1575,
16707,
43155,
388,
1669,
3056,
14597,
2979,
54968,
25,
330,
76,
8969,
14345,
314,
54968,
25,
330,
16875,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRktConfig(t *testing.T) {
validChannels := []string{
"alpha",
"beta",
"stable",
}
conf := func(channel string) string {
return fmt.Sprintf(`containerRuntime: rkt
releaseChannel: %s
`, channel)
}
for _, channel := range validChannels {
confBody := singleAzConfigYaml + conf(channel)
_, err := ClusterFromBytes([]byte(confBody))
if err != nil {
t.Errorf("failed to parse config %s: %v", confBody, err)
}
}
} | explode_data.jsonl/4376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
49,
5840,
2648,
1155,
353,
8840,
836,
8,
341,
56322,
35925,
1669,
3056,
917,
515,
197,
197,
1,
7141,
756,
197,
197,
1,
19127,
756,
197,
197,
1,
27992,
756,
197,
630,
67850,
1669,
2915,
25923,
914,
8,
914,
341,
197,
853... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBoolInt_MarshalJSON_GotTrue(t *testing.T) {
var sampleInp struct {
Val BoolInt `json:"val"`
}
sampleInp.Val.Flag = true
var sampleOut = []byte(`{"val":true}`)
data, _ := json.Marshal(sampleInp)
if bytes.Compare(data, sampleOut) != 0 {
t.Errorf("should be %s but got %s", sampleOut, data)
}
} | explode_data.jsonl/31043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
11233,
1072,
1245,
28423,
5370,
2646,
354,
2514,
1155,
353,
8840,
836,
8,
341,
2405,
6077,
641,
79,
2036,
341,
197,
197,
2208,
12608,
1072,
1565,
2236,
2974,
831,
8805,
197,
532,
1903,
1516,
641,
79,
77819,
80911,
284,
830... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBasicTokenFile(t *testing.T) {
token := "exampletoken"
f, err := ioutil.TempFile("", "tokenfile")
if err != nil {
t.Errorf("Unexpected error: %v", err)
return
}
defer os.Remove(f.Name())
if err := ioutil.WriteFile(f.Name(), []byte(token), 0644); err != nil {
t.Errorf("Unexpected error: %v", err)
return
}
config := clientcmdapi.NewConfig()
config.Clusters["clean"] = &clientcmdapi.Cluster{
Server: "https://localhost:8443",
}
config.AuthInfos["clean"] = &clientcmdapi.AuthInfo{
TokenFile: f.Name(),
}
config.Contexts["clean"] = &clientcmdapi.Context{
Cluster: "clean",
AuthInfo: "clean",
}
config.CurrentContext = "clean"
clientBuilder := NewNonInteractiveClientConfig(*config, "clean", &ConfigOverrides{}, nil)
clientConfig, err := clientBuilder.ClientConfig()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
matchStringArg(token, clientConfig.BearerToken, t)
} | explode_data.jsonl/56162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 345
} | [
2830,
3393,
15944,
3323,
1703,
1155,
353,
8840,
836,
8,
341,
43947,
1669,
330,
8687,
5839,
698,
1166,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
5839,
1192,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
29430,
1465,
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... | 4 |
func TestNewCloudProvider(t *testing.T) {
t.Run("with an unknown cloud provider", func(t *testing.T) {
c, err := NewCloudProvider("foobar")
assert.Nil(t, c)
assert.Equal(t, errors.New("Unknown cloud provider \"foobar\""), err)
})
t.Run("with the aws cloud provider", func(t *testing.T) {
c, err := NewCloudProvider("aws")
assert.Nil(t, err)
assert.IsType(t, &aws.CloudProvider{}, c)
})
t.Run("with the test cloud provider", func(t *testing.T) {
c, err := NewCloudProvider("test")
assert.Nil(t, err)
assert.IsType(t, &test.CloudProvider{}, c)
})
} | explode_data.jsonl/58658 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
3564,
16055,
5179,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
4197,
458,
9788,
9437,
9109,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
1444,
11,
1848,
1669,
1532,
16055,
5179,
445,
50267,
1138,
197,
6948,
59678,
115... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsCompatibleCodeVersion(t *testing.T) {
tests := []struct {
desc string
thisCodeVersion semver.Version
dbCodeVersion semver.Version
expectCompatible bool
}{
{
desc: "backwards compatible 1 minor version",
thisCodeVersion: codeVersion,
dbCodeVersion: semver.Version{Major: codeVersion.Major, Minor: (codeVersion.Minor - 1)},
expectCompatible: true,
},
{
desc: "forwards compatible 1 minor version",
thisCodeVersion: codeVersion,
dbCodeVersion: semver.Version{Major: codeVersion.Major, Minor: (codeVersion.Minor + 1)},
expectCompatible: true,
},
{
desc: "compatible with self",
thisCodeVersion: codeVersion,
dbCodeVersion: codeVersion,
expectCompatible: true,
},
{
desc: "not backwards compatible 2 minor versions",
thisCodeVersion: codeVersion,
dbCodeVersion: semver.Version{Major: codeVersion.Major, Minor: (codeVersion.Minor - 2)},
expectCompatible: false,
},
{
desc: "not forwards compatible 2 minor versions",
thisCodeVersion: codeVersion,
dbCodeVersion: semver.Version{Major: codeVersion.Major, Minor: (codeVersion.Minor + 2)},
expectCompatible: false,
},
{
desc: "not compatible with different major version but same minor",
thisCodeVersion: codeVersion,
dbCodeVersion: semver.Version{Major: (codeVersion.Major + 1), Minor: codeVersion.Minor},
expectCompatible: false,
},
{
desc: "forwards compatible to 1.0 from 0.12",
thisCodeVersion: semver.Version{Major: 0, Minor: 12},
dbCodeVersion: semver.Version{Major: 1, Minor: 0},
expectCompatible: true,
},
{
desc: "backwards compatible to 0.12 from 1.0",
thisCodeVersion: semver.Version{Major: 1, Minor: 0},
dbCodeVersion: semver.Version{Major: 0, Minor: 12},
expectCompatible: true,
},
{
desc: "not forwards compatible to 1.1 from 0.12",
thisCodeVersion: semver.Version{Major: 0, Minor: 12},
dbCodeVersion: semver.Version{Major: 1, Minor: 1},
expectCompatible: false,
},
{
desc: "not backwards compatible to 0.12 from 1.1",
thisCodeVersion: semver.Version{Major: 1, Minor: 1},
dbCodeVersion: semver.Version{Major: 0, Minor: 12},
expectCompatible: false,
},
}
for _, tt := range tests {
tt := tt // alias loop variable as it is used in the closure
t.Run(tt.desc, func(t *testing.T) {
compatible := isCompatibleCodeVersion(tt.thisCodeVersion, tt.dbCodeVersion)
assert.Equal(t, tt.expectCompatible, compatible)
})
}
} | explode_data.jsonl/43223 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1090
} | [
2830,
3393,
3872,
29161,
2078,
5637,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41653,
1797,
914,
198,
197,
2046,
2078,
5637,
220,
5234,
423,
35842,
198,
197,
20939,
2078,
5637,
262,
5234,
423,
35842,
198,
197,
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 TestUniformUint(t *testing.T) {
cases := []struct {
sequence []uint
choose uint
chosen []uint
}{
{
sequence: []uint{11, 21, 31, 41, 51},
choose: 0,
chosen: []uint{},
},
{
sequence: []uint{11, 21, 31, 41, 51},
choose: 1,
chosen: []uint{11},
},
{
sequence: []uint{11, 21, 31, 41, 51},
choose: 2,
chosen: []uint{11, 51},
},
{
sequence: []uint{11, 21, 31, 41, 51},
choose: 10,
chosen: []uint{11, 21, 31, 41, 51},
},
{
sequence: []uint{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 21, 31, 35, 41},
choose: 5,
chosen: []uint{1, 11, 21, 31, 41},
},
{
sequence: []uint{0, 2, 3, 40, 100},
choose: 4,
chosen: []uint{0, 3, 40, 100},
},
}
for _, c := range cases {
indices := UniformUint(c.sequence, c.choose)
chosen := make([]uint, len(indices))
for i, j := range indices {
chosen[i] = c.sequence[j]
}
assert.Equal(chosen, c.chosen, t)
}
} | explode_data.jsonl/13501 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 504
} | [
2830,
3393,
20152,
21570,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
197,
15512,
3056,
2496,
198,
197,
197,
27052,
256,
2622,
198,
197,
23049,
8313,
256,
3056,
2496,
198,
197,
59403,
197,
197,
515,
298,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMap(t *testing.T) {
q := New()
q.Put(2)
q.Put(1)
var value int
mapFunc := func(a interface{}) bool {
if v, ok := a.(int); ok {
return v == value
}
return false
}
value = 1
b := q.Map(mapFunc)
assert.Equal(t, 1, b.(int))
value = 2
c := q.Map(mapFunc)
assert.Equal(t, 2, c.(int))
value = 3
d := q.Map(mapFunc)
assert.Nil(t, d)
} | explode_data.jsonl/81682 | {
"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,
2227,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
1532,
2822,
18534,
39825,
7,
17,
340,
18534,
39825,
7,
16,
692,
2405,
897,
526,
198,
19567,
9626,
1669,
2915,
2877,
3749,
28875,
1807,
341,
197,
743,
348,
11,
5394,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEntryHooksPanic(t *testing.T) {
logger := New()
logger.Out = &bytes.Buffer{}
logger.Level = InfoLevel
logger.Hooks.Add(&panickyHook{})
defer func() {
p := recover()
assert.NotNil(t, p)
assert.Equal(t, panicMessage, p)
entry := NewEntry(logger)
entry.Info("another message")
}()
entry := NewEntry(logger)
entry.Info(badMessage)
} | explode_data.jsonl/13867 | {
"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,
5874,
67769,
47,
31270,
1155,
353,
8840,
836,
8,
341,
17060,
1669,
1532,
741,
17060,
47178,
284,
609,
9651,
22622,
16094,
17060,
25259,
284,
13074,
4449,
198,
17060,
3839,
14685,
1904,
2099,
848,
18964,
31679,
6257,
692,
16867... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsertAllDefaults(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
vtParams := mysql.ConnParams{
Host: "localhost",
Port: clusterInstance.VtgateMySQLPort,
}
conn, err := mysql.Connect(ctx, &vtParams)
require.NoError(t, err)
defer conn.Close()
exec(t, conn, `insert into allDefaults () values ()`)
assertMatches(t, conn, `select * from allDefaults`, "[[INT64(1) NULL]]")
} | explode_data.jsonl/70822 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
13780,
2403,
16273,
1155,
353,
8840,
836,
8,
341,
16867,
10652,
1069,
31270,
3050,
1155,
340,
20985,
1669,
2266,
19047,
741,
5195,
83,
4870,
1669,
10564,
50422,
4870,
515,
197,
197,
9296,
25,
330,
8301,
756,
197,
98459,
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 TestWithRouter(t *testing.T) {
// test increments in the ante
anteKey := []byte("ante-key")
anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) }
// test increments in the handler
deliverKey := []byte("deliver-key")
routerOpt := func(bapp *BaseApp) {
bapp.SetRouter(&testCustomRouter{routes: sync.Map{}})
bapp.Router().AddRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey))
}
app := setupBaseApp(t, anteOpt, routerOpt)
app.InitChain(abci.RequestInitChain{})
// Create same codec used in txDecoder
codec := codec.New()
registerTestCodec(codec)
nBlocks := 3
txPerHeight := 5
for blockN := 0; blockN < nBlocks; blockN++ {
header := abci.Header{Height: int64(blockN) + 1}
app.BeginBlock(abci.RequestBeginBlock{Header: header})
for i := 0; i < txPerHeight; i++ {
counter := int64(blockN*txPerHeight + i)
tx := newTxCounter(counter, counter)
txBytes, err := codec.MarshalBinaryBare(tx)
require.NoError(t, err)
res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})
require.True(t, res.IsOK(), fmt.Sprintf("%v", res))
}
app.EndBlock(abci.RequestEndBlock{})
app.Commit()
}
} | explode_data.jsonl/67066 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
2354,
9523,
1155,
353,
8840,
836,
8,
341,
197,
322,
1273,
61600,
304,
279,
39424,
198,
197,
4942,
1592,
1669,
3056,
3782,
445,
4942,
16173,
1138,
197,
4942,
21367,
1669,
2915,
1883,
676,
353,
3978,
2164,
8,
314,
293,
676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSubsetWhenMaxIsGreaterThanLengthOfSlice(t *testing.T) {
var ps []pstore.PeerInfo
sizeofSlice := 100
for i := 0; i < sizeofSlice; i++ {
pid, err := testutil.RandPeerID()
if err != nil {
t.Fatal(err)
}
ps = append(ps, pstore.PeerInfo{ID: pid})
}
out := randomSubsetOfPeers(ps, 2*sizeofSlice)
if len(out) != len(ps) {
t.Fail()
}
} | explode_data.jsonl/32032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
70584,
4498,
5974,
3872,
85720,
4373,
2124,
33236,
1155,
353,
8840,
836,
8,
341,
2405,
4726,
3056,
79,
4314,
1069,
34756,
1731,
198,
63435,
33236,
1669,
220,
16,
15,
15,
198,
2023,
600,
1669,
220,
15,
26,
600,
366,
3935,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMockRemittanceOriginator(t *testing.T) {
ro := mockRemittanceOriginator()
require.NoError(t, ro.Validate(), "mockRemittanceOriginator does not validate and will break other tests")
} | explode_data.jsonl/32916 | {
"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,
11571,
6590,
87191,
13298,
850,
1155,
353,
8840,
836,
8,
341,
197,
299,
1669,
7860,
6590,
87191,
13298,
850,
2822,
17957,
35699,
1155,
11,
926,
47667,
1507,
330,
16712,
6590,
87191,
13298,
850,
1558,
537,
9593,
323,
686,
143... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEnvVarMalformed(t *testing.T) {
if v := EnvironmentValueOrConst("HOSTNAME", 42.0); v != 42.0 {
t.Errorf("Wrong value returned %f", v)
}
} | explode_data.jsonl/49827 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 61
} | [
2830,
3393,
14359,
3962,
29600,
10155,
1155,
353,
8840,
836,
8,
341,
743,
348,
1669,
11586,
1130,
2195,
19167,
445,
28687,
7535,
497,
220,
19,
17,
13,
15,
1215,
348,
961,
220,
19,
17,
13,
15,
341,
197,
3244,
13080,
445,
29185,
897,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestViperProvider_Secrets(t *testing.T) {
p := config.MustNew(t, logrusx.New("", ""), configx.SkipValidation())
def := p.SecretsDefault()
assert.NotEmpty(t, def)
assert.Equal(t, def, p.SecretsSession())
assert.Equal(t, def, p.SecretsDefault())
} | explode_data.jsonl/52910 | {
"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,
53,
12858,
5179,
1098,
50856,
82,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
2193,
50463,
3564,
1155,
11,
1487,
20341,
87,
7121,
19814,
77130,
2193,
87,
57776,
13799,
12367,
7452,
1669,
281,
74779,
82,
3675,
741,
6948,
15000,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDirValidation(t *testing.T) {
validate := New()
tests := []struct {
title string
param string
expected bool
}{
{"existing dir", "testdata", true},
{"existing self dir", ".", true},
{"existing parent dir", "..", true},
{"empty dir", "", false},
{"missing dir", "non_existing_testdata", false},
{"a file not a directory", filepath.Join("testdata", "a.go"), false},
}
for _, test := range tests {
errs := validate.Var(test.param, "dir")
if test.expected {
if !IsEqual(errs, nil) {
t.Fatalf("Test: '%s' failed Error: %s", test.title, errs)
}
} else {
if IsEqual(errs, nil) {
t.Fatalf("Test: '%s' failed Error: %s", test.title, errs)
}
}
}
PanicMatches(t, func() {
_ = validate.Var(2, "dir")
}, "Bad field type int")
} | explode_data.jsonl/77364 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 329
} | [
2830,
3393,
6184,
13799,
1155,
353,
8840,
836,
8,
341,
197,
7067,
1669,
1532,
2822,
78216,
1669,
3056,
1235,
341,
197,
24751,
262,
914,
198,
197,
36037,
262,
914,
198,
197,
42400,
1807,
198,
197,
59403,
197,
197,
4913,
36895,
5419,
49... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVerifyInclusionAtIndex(t *testing.T) {
ctx := context.Background()
env, client := clientEnvForTest(ctx, t, stestonly.PreorderedLogTree)
defer env.Close()
// Add a few test leaves.
leafData := [][]byte{
[]byte("A"),
[]byte("B"),
}
if err := addSequencedLeaves(ctx, env, client, leafData); err != nil {
t.Fatalf("Failed to add leaves: %v", err)
}
root := client.GetRoot()
for i, l := range leafData {
if err := client.GetAndVerifyInclusionAtIndex(ctx, l, int64(i), root); err != nil {
t.Errorf("VerifyInclusion(%s) = %v, want nil", l, err)
}
}
// Ask for inclusion in a too-large tree.
root.TreeSize += 1000
if err := client.GetAndVerifyInclusionAtIndex(ctx, leafData[0], 0, root); err == nil {
t.Errorf("GetAndVerifyInclusionAtIndex(0, %d)=nil, want error", root.TreeSize)
}
} | explode_data.jsonl/54602 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
32627,
641,
8957,
22556,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
57538,
11,
2943,
1669,
2943,
14359,
2461,
2271,
7502,
11,
259,
11,
357,
477,
3243,
28770,
10544,
2201,
6533,
340,
16867,
6105,
10421,
2822... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGasPrice(t *testing.T) {
input := CreateTestInput(t)
var newContractAddress sdk.AccAddress
t.Run("deploy contract", func(t *testing.T) {
code, err2 := hex.DecodeString(GasTestsBytecodeString)
require.Nil(t, err2)
result, err := input.CvmKeeper.Call(input.Ctx, Addrs[0], nil, 0, code, []*payload.ContractMeta{}, false, false, false)
require.Nil(t, err)
require.NotNil(t, result)
newContractAddress = sdk.AccAddress(result)
})
addTwoNumbersCall, _, err := abi.EncodeFunctionCall(
GasTestsAbiJsonString,
"addTwoNumbers",
WrapLogger(input.Ctx.Logger()),
3, 5,
)
require.Nil(t, err)
t.Run("add two numbers with not enough gas and see it fail", func(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(AddTwoNumbersGasCost - 5000))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, addTwoNumbersCall, []*payload.ContractMeta{}, false, false, false)
require.NotNil(t, err2)
require.Equal(t, err2.Error(), types.ErrCodedError(errors.Codes.InsufficientGas).Error())
})
t.Run("add two numbers with the right gas amount", func(t *testing.T) {
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(AddTwoNumbersGasCost + 50000))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, addTwoNumbersCall, []*payload.ContractMeta{}, false, false, false)
require.Nil(t, err2)
})
hashMeCall, _, err := abi.EncodeFunctionCall(
GasTestsAbiJsonString,
"hashMe",
WrapLogger(input.Ctx.Logger()),
[]byte("abcdefghij"),
)
t.Run("hash some bytes with not enough gas and see it fail", func(t *testing.T) {
require.Nil(t, err)
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(HashMeGasCost - 4000))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, hashMeCall, nil, false, false, false)
require.NotNil(t, err2)
require.Equal(t, err2, types.ErrCodedError(errors.Codes.InsufficientGas))
})
t.Run("hash some bytes with the right gas amount", func(t *testing.T) {
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(HashMeGasCost + 50000))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, hashMeCall, nil, false, false, false)
require.Nil(t, err2)
})
var deployAnotherContractCall []byte
t.Run("deploy another contract with not enough gas and see it fail", func(t *testing.T) {
deployAnotherContractCall, _, err = abi.EncodeFunctionCall(
GasTestsAbiJsonString,
"deployAnotherContract",
WrapLogger(input.Ctx.Logger()),
)
require.Nil(t, err)
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(DeployAnotherContractGasCost - 150000)) //DeployAnotherContractGasCost - 20))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, deployAnotherContractCall, []*payload.ContractMeta{}, false, false, false)
require.NotNil(t, err2)
require.Equal(t, err2, types.ErrCodedError(errors.Codes.InsufficientGas))
})
t.Run("deploy another contract with the right gas amount", func(t *testing.T) {
input.Ctx = input.Ctx.WithGasMeter(NewGasMeter(DeployAnotherContractGasCost))
_, err2 := input.CvmKeeper.Call(input.Ctx, Addrs[0], newContractAddress, 0, deployAnotherContractCall, []*payload.ContractMeta{}, false, false, false)
require.Nil(t, err2)
})
} | explode_data.jsonl/14832 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1313
} | [
2830,
3393,
58728,
6972,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
2505,
1155,
340,
2405,
501,
14067,
4286,
45402,
77538,
4286,
198,
3244,
16708,
445,
35794,
5116,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
43343,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJsonScannerInvalidInputs(t *testing.T) {
cases := []jsonScannerTestCase{
{desc: "missing quotation", input: `"missing`},
{desc: "invalid escape character--first character", input: `"\invalid"`},
{desc: "invalid escape character--middle", input: `"i\nv\alid"`},
{desc: "invalid literal--trueee", input: "trueee"},
{desc: "invalid literal--tire", input: "tire"},
{desc: "invalid literal--nulll", input: "nulll"},
{desc: "invalid literal--fals", input: "fals"},
{desc: "invalid literal--falsee", input: "falsee"},
{desc: "invalid literal--fake", input: "fake"},
{desc: "invalid literal--bad", input: "bad"},
{desc: "invalid number: -", input: "-"},
{desc: "invalid number: --0", input: "--0"},
{desc: "invalid number: -a", input: "-a"},
{desc: "invalid number: 00", input: "00"},
{desc: "invalid number: 01", input: "01"},
{desc: "invalid number: 0-", input: "0-"},
{desc: "invalid number: 1-", input: "1-"},
{desc: "invalid number: 0..", input: "0.."},
{desc: "invalid number: 0.-", input: "0.-"},
{desc: "invalid number: 0..0", input: "0..0"},
{desc: "invalid number: 0.1.0", input: "0.1.0"},
{desc: "invalid number: 0e", input: "0e"},
{desc: "invalid number: 0e.", input: "0e."},
{desc: "invalid number: 0e1.", input: "0e1."},
{desc: "invalid number: 0e1e", input: "0e1e"},
{desc: "invalid number: 0e+.1", input: "0e+.1"},
{desc: "invalid number: 0e+1.", input: "0e+1."},
{desc: "invalid number: 0e+1e", input: "0e+1e"},
}
for _, tc := range cases {
js := &jsonScanner{r: strings.NewReader(tc.input)}
c, err := js.nextToken()
expectNilToken(t, c, tc.desc)
expectError(t, err, tc.desc)
}
} | explode_data.jsonl/39074 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 699
} | [
2830,
3393,
5014,
31002,
7928,
31946,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
2236,
31002,
16458,
515,
197,
197,
90,
8614,
25,
330,
30616,
54231,
497,
1946,
25,
53305,
30616,
63,
1583,
197,
197,
90,
8614,
25,
330,
11808,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEntryLogLevel(t *testing.T) {
out := &bytes.Buffer{}
logger := New()
logger.Out = out
logger.Level = DebugLevel
entry := NewEntry(logger)
assert.Equal(t, DebugLevel, entry.Level)
entry.Level = WarnLevel
entry.Info("it should not be displayed")
assert.Equal(t, "", out.String())
entry.Warn("it should be displayed")
assert.Contains(t, out.String(), "it should be displayed")
} | explode_data.jsonl/31852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 163
} | [
2830,
3393,
5874,
72676,
1155,
353,
8840,
836,
8,
341,
256,
13967,
1669,
609,
9651,
22622,
16094,
256,
17060,
1669,
1532,
741,
256,
17060,
47178,
284,
700,
198,
256,
17060,
25259,
284,
11091,
4449,
198,
256,
48344,
1669,
1532,
5874,
378... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestZeroRequest(t *testing.T) {
// A pod with no resources. We expect spreading to count it as having the default resources.
noResources := v1.PodSpec{
Containers: []v1.Container{
{},
},
}
noResources1 := noResources
noResources1.NodeName = "machine1"
// A pod with the same resources as a 0-request pod gets by default as its resources (for spreading).
small := v1.PodSpec{
Containers: []v1.Container{
{
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse(
strconv.FormatInt(priorityutil.DefaultMilliCPURequest, 10) + "m"),
v1.ResourceMemory: resource.MustParse(
strconv.FormatInt(priorityutil.DefaultMemoryRequest, 10)),
},
},
},
},
}
small2 := small
small2.NodeName = "machine2"
// A larger pod.
large := v1.PodSpec{
Containers: []v1.Container{
{
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse(
strconv.FormatInt(priorityutil.DefaultMilliCPURequest*3, 10) + "m"),
v1.ResourceMemory: resource.MustParse(
strconv.FormatInt(priorityutil.DefaultMemoryRequest*3, 10)),
},
},
},
},
}
large1 := large
large1.NodeName = "machine1"
large2 := large
large2.NodeName = "machine2"
tests := []struct {
pod *v1.Pod
pods []*v1.Pod
nodes []*v1.Node
name string
expectedScore int
}{
// The point of these next two tests is to show you get the same priority for a zero-request pod
// as for a pod with the defaults requests, both when the zero-request pod is already on the machine
// and when the zero-request pod is the one being scheduled.
{
pod: &v1.Pod{Spec: noResources},
nodes: []*v1.Node{makeNode("machine1", 1000, priorityutil.DefaultMemoryRequest*10), makeNode("machine2", 1000, priorityutil.DefaultMemoryRequest*10)},
name: "test priority of zero-request pod with machine with zero-request pod",
pods: []*v1.Pod{
{Spec: large1}, {Spec: noResources1},
{Spec: large2}, {Spec: small2},
},
expectedScore: 25,
},
{
pod: &v1.Pod{Spec: small},
nodes: []*v1.Node{makeNode("machine1", 1000, priorityutil.DefaultMemoryRequest*10), makeNode("machine2", 1000, priorityutil.DefaultMemoryRequest*10)},
name: "test priority of nonzero-request pod with machine with zero-request pod",
pods: []*v1.Pod{
{Spec: large1}, {Spec: noResources1},
{Spec: large2}, {Spec: small2},
},
expectedScore: 25,
},
// The point of this test is to verify that we're not just getting the same score no matter what we schedule.
{
pod: &v1.Pod{Spec: large},
nodes: []*v1.Node{makeNode("machine1", 1000, priorityutil.DefaultMemoryRequest*10), makeNode("machine2", 1000, priorityutil.DefaultMemoryRequest*10)},
name: "test priority of larger pod with machine with zero-request pod",
pods: []*v1.Pod{
{Spec: large1}, {Spec: noResources1},
{Spec: large2}, {Spec: small2},
},
expectedScore: 23,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
// This should match the configuration in defaultPriorities() in
// pkg/scheduler/algorithmprovider/defaults/defaults.go if you want
// to test what's actually in production.
priorityConfigs := []algorithm.PriorityConfig{
{Map: algorithmpriorities.LeastRequestedPriorityMap, Weight: 1},
{Map: algorithmpriorities.BalancedResourceAllocationMap, Weight: 1},
}
selectorSpreadPriorityMap, selectorSpreadPriorityReduce := algorithmpriorities.NewSelectorSpreadPriority(
schedulertesting.FakeServiceLister([]*v1.Service{}),
schedulertesting.FakeControllerLister([]*v1.ReplicationController{}),
schedulertesting.FakeReplicaSetLister([]*apps.ReplicaSet{}),
schedulertesting.FakeStatefulSetLister([]*apps.StatefulSet{}))
pc := algorithm.PriorityConfig{Map: selectorSpreadPriorityMap, Reduce: selectorSpreadPriorityReduce, Weight: 1}
priorityConfigs = append(priorityConfigs, pc)
nodeNameToInfo := schedulernodeinfo.CreateNodeNameToInfoMap(test.pods, test.nodes)
metaDataProducer := algorithmpriorities.NewPriorityMetadataFactory(
schedulertesting.FakeServiceLister([]*v1.Service{}),
schedulertesting.FakeControllerLister([]*v1.ReplicationController{}),
schedulertesting.FakeReplicaSetLister([]*apps.ReplicaSet{}),
schedulertesting.FakeStatefulSetLister([]*apps.StatefulSet{}))
metaData := metaDataProducer(test.pod, nodeNameToInfo)
list, err := PrioritizeNodes(
test.pod, nodeNameToInfo, metaData, priorityConfigs,
schedulertesting.FakeNodeLister(test.nodes), []algorithm.SchedulerExtender{})
if err != nil {
t.Errorf("unexpected error: %v", err)
}
for _, hp := range list {
if hp.Score != test.expectedScore {
t.Errorf("expected %d for all priorities, got list %#v", test.expectedScore, list)
}
}
})
}
} | explode_data.jsonl/6748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1891
} | [
2830,
3393,
17999,
1900,
1155,
353,
8840,
836,
8,
341,
197,
322,
362,
7509,
448,
902,
4963,
13,
1205,
1720,
30035,
311,
1760,
432,
438,
3432,
279,
1638,
4963,
624,
72104,
11277,
1669,
348,
16,
88823,
8327,
515,
197,
197,
74632,
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... | 4 |
func TestServerSingleNode(t *testing.T) {
s := newTestServer("1", &testTransporter{})
if s.State() != Stopped {
t.Fatalf("Unexpected server state: %v", s.State())
}
s.Start()
time.Sleep(testHeartbeatTimeout)
// Join the server to itself.
if _, err := s.Do(&DefaultJoinCommand{Name: "1"}); err != nil {
t.Fatalf("Unable to join: %v", err)
}
debugln("finish command")
if s.State() != Leader {
t.Fatalf("Unexpected server state: %v", s.State())
}
s.Stop()
if s.State() != Stopped {
t.Fatalf("Unexpected server state: %v", s.State())
}
} | explode_data.jsonl/44070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
5475,
72352,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
2271,
5475,
445,
16,
497,
609,
1944,
27560,
261,
37790,
743,
274,
18942,
368,
961,
794,
17573,
341,
197,
3244,
30762,
445,
29430,
3538,
1584,
25,
1018,
85,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTransformFuse(t *testing.T) {
var x int64 = 1000
ctrl.SetLogger(zap.New(func(o *zap.Options) {
o.Development = true
}))
var tests = []struct {
runtime *datav1alpha1.AlluxioRuntime
dataset *datav1alpha1.Dataset
value *Alluxio
expect []string
}{
{&datav1alpha1.AlluxioRuntime{
Spec: datav1alpha1.AlluxioRuntimeSpec{
Fuse: datav1alpha1.AlluxioFuseSpec{},
},
}, &datav1alpha1.Dataset{
Spec: datav1alpha1.DatasetSpec{
Mounts: []datav1alpha1.Mount{datav1alpha1.Mount{
MountPoint: "local:///mnt/test",
Name: "test",
}},
Owner: &datav1alpha1.User{
UID: &x,
GID: &x,
},
},
}, &Alluxio{}, []string{"fuse", "--fuse-opts=kernel_cache,rw,max_read=131072,attr_timeout=7200,entry_timeout=7200,nonempty,uid=1000,gid=1000,allow_other"}},
}
for _, test := range tests {
engine := &AlluxioEngine{}
engine.Log = ctrl.Log
err := engine.transformFuse(test.runtime, test.dataset, test.value)
if err != nil {
t.Errorf("error %v", err)
}
if test.value.Fuse.Args[1] != test.expect[1] {
t.Errorf("expected %v, got %v", test.expect, test.value.Fuse.Args)
}
}
} | explode_data.jsonl/18659 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 547
} | [
2830,
3393,
8963,
48600,
1155,
353,
8840,
836,
8,
1476,
2405,
856,
526,
21,
19,
284,
220,
16,
15,
15,
15,
198,
84381,
4202,
7395,
13174,
391,
7121,
18552,
10108,
353,
92371,
22179,
8,
341,
197,
22229,
8934,
75831,
284,
830,
198,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestBetween(t *testing.T) {
t.Parallel()
for i, c := range []struct {
stmt stmt.Statement
sql string
sqlIndent string
values []interface{}
}{
{
stmt.NewColumn("foo").Between(
stmt.NewVal(100),
stmt.NewVal(200),
),
`"foo" BETWEEN ? AND ?`,
`> "foo" BETWEEN ? AND ?
`,
[]interface{}{
100,
200,
},
},
{
stmt.NewColumn("joined_users").Between(
stmt.NewVal(100),
stmt.NewSubquery(
stmt.NewSelect(stmt.NewCount(stmt.NewWildcard())).
From(stmt.NewTable("users")),
),
),
`"joined_users" BETWEEN ? AND (SELECT COUNT(*) FROM "users")`,
`> "joined_users" BETWEEN ? AND (
> SELECT
> COUNT(*)
> FROM
> "users"
> )
`,
[]interface{}{
100,
},
},
{
stmt.NewColumn("joined_users").Between(
stmt.NewSubquery(
stmt.NewSelect(stmt.NewCount(stmt.NewWildcard())).
From(stmt.NewTable("users")),
),
stmt.NewVal(500),
),
`"joined_users" BETWEEN (SELECT COUNT(*) FROM "users") AND ?`,
`> "joined_users" BETWEEN (
> SELECT
> COUNT(*)
> FROM
> "users"
> ) AND ?
`,
[]interface{}{
500,
},
},
{
stmt.NewColumn("joined_users").Between(
stmt.NewSubquery(
stmt.NewSelect(stmt.NewCount(stmt.NewWildcard())).
From(stmt.NewTable("super_users")),
),
stmt.NewSubquery(
stmt.NewSelect(stmt.NewCount(stmt.NewWildcard())).
From(stmt.NewTable("users")),
),
),
`"joined_users" BETWEEN (SELECT COUNT(*) FROM "super_users") AND (SELECT COUNT(*) FROM "users")`,
`> "joined_users" BETWEEN (
> SELECT
> COUNT(*)
> FROM
> "super_users"
> ) AND (
> SELECT
> COUNT(*)
> FROM
> "users"
> )
`,
nil,
},
} {
c := c
t.Run(fmt.Sprintf("%d Build", i), func(t *testing.T) {
t.Parallel()
sql, values := b.Build(c.stmt)
if sql != c.sql {
t.Error(diff.SQL(sql, c.sql))
}
if !reflect.DeepEqual(values, c.values) {
t.Error(diff.Values(values, c.values))
}
})
t.Run(fmt.Sprintf("%d BuildIndent", i), func(t *testing.T) {
t.Parallel()
sql, values := bi.Build(c.stmt)
if sql != c.sqlIndent {
t.Error(diff.SQL(sql, c.sqlIndent))
}
if !reflect.DeepEqual(values, c.values) {
t.Error(diff.Values(values, c.values))
}
})
}
} | explode_data.jsonl/374 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1165
} | [
2830,
3393,
25477,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2023,
600,
11,
272,
1669,
2088,
3056,
1235,
341,
197,
55822,
414,
20020,
70215,
198,
197,
30633,
981,
914,
198,
197,
30633,
42729,
914,
198,
197,
45939,
262,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBadMethodToServer(t *testing.T) {
l := startServer(t)
resp, err := http.Get("http://" + l.Addr().String() + "/")
assert.NoError(t, err, "Making a Get request to the server should not have errored")
if err == nil {
assert.True(t, resp.StatusCode == 405, "Response should have indicated a bad method")
}
} | explode_data.jsonl/15726 | {
"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,
17082,
3523,
1249,
5475,
1155,
353,
8840,
836,
8,
341,
8810,
1669,
1191,
5475,
1155,
340,
34653,
11,
1848,
1669,
1758,
2234,
445,
1254,
52136,
488,
326,
93626,
1005,
703,
368,
488,
3521,
1138,
6948,
35699,
1155,
11,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLog_NewLog_Config(t *testing.T) {
invalidtests := map[string]configuration.Log{
"InvalidAdapter": configuration.Log{Level: "Debug", Adapter: "invalid", Formatter: "text"},
"InvalidLevel": configuration.Log{Level: "Invalid", Adapter: "zerolog", Formatter: "text"},
"InvalidFormatter": configuration.Log{Level: "Debug", Adapter: "zerolog", Formatter: "invalid"},
}
for name, test := range invalidtests {
t.Run(name, func(t *testing.T) {
logger, err := NewLog(test)
assert.Nil(t, logger)
assert.Error(t, err)
})
}
validtests := map[string]configuration.Log{
"WithAdapter": configuration.Log{Level: "Debug", Adapter: "zerolog", Formatter: "text"},
}
for name, test := range validtests {
t.Run(name, func(t *testing.T) {
logger, err := NewLog(test)
assert.NotNil(t, logger)
assert.NoError(t, err)
})
}
} | explode_data.jsonl/40294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
2201,
39582,
2201,
35412,
1155,
353,
8840,
836,
8,
341,
197,
11808,
23841,
1669,
2415,
14032,
60,
21138,
5247,
515,
197,
197,
1,
7928,
5940,
788,
256,
6546,
5247,
90,
4449,
25,
330,
7939,
497,
28807,
25,
330,
11808,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_parseFailureSummaries(t *testing.T) {
type args struct {
failureSummariesData []plistutil.PlistData
}
tests := []struct {
name string
args args
want []FailureSummary
wantErr bool
}{
{
name: "Ok case",
args: args{[]plistutil.PlistData{{
"FileName": "/tmp/ios_simple_objcUITests.m",
"LineNumber": uint64(64),
"Message": "((NO) is true) failed",
"PerformanceFailure": false,
}}},
want: []FailureSummary{{
FileName: "/tmp/ios_simple_objcUITests.m",
LineNumber: 64,
Message: "((NO) is true) failed",
IsPerformanceFailure: false,
}},
wantErr: false,
},
{
name: "Key FileName not found",
args: args{[]plistutil.PlistData{{
"LineNumber": uint64(64),
"Message": "((NO) is true) failed",
"PerformanceFailure": false,
}}},
want: nil,
wantErr: true,
},
{
name: "Key LineNumber not found",
args: args{[]plistutil.PlistData{{
"FileName": "/tmp/ios_simple_objcUITests.m",
"Message": "((NO) is true) failed",
"PerformanceFailure": false,
}}},
want: nil,
wantErr: true,
},
{
name: "Key Message not found",
args: args{[]plistutil.PlistData{{
"FileName": "/tmp/ios_simple_objcUITests.m",
"LineNumber": uint64(64),
"PerformanceFailure": false,
}}},
want: nil,
wantErr: true,
},
{
name: "Key PerformanceFailure not found",
args: args{[]plistutil.PlistData{{
"FileName": "/tmp/ios_simple_objcUITests.m",
"LineNumber": uint64(64),
"Message": "((NO) is true) failed",
}}},
want: nil,
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parseFailureSummaries(tt.args.failureSummariesData)
if (err != nil) != tt.wantErr {
t.Errorf("parseFailureSummaries() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("parseFailureSummaries() = %v, want %v", pretty.Object(got), pretty.Object(tt.want))
}
})
}
} | explode_data.jsonl/12518 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1058
} | [
2830,
3393,
21039,
17507,
9190,
89333,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
1166,
9373,
9190,
89333,
1043,
3056,
39934,
1314,
1069,
1607,
1043,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIsolateFinalizer(t *testing.T) {
t.Parallel()
iso := NewIsolate()
fin := make(chan bool)
// Reset the finalizer so we test if it is working
runtime.SetFinalizer(iso, nil)
runtime.SetFinalizer(iso, func(iso *Isolate) {
close(fin)
iso.release()
})
iso = nil
if !runGcUntilReceivedOrTimedOut(fin, 4*time.Second) {
t.Fatal("finalizer of iso didn't run, no context is associated with the iso.")
}
iso = NewIsolate()
iso.NewContext()
fin = make(chan bool)
// Reset the finalizer so we test if it is working
runtime.SetFinalizer(iso, nil)
runtime.SetFinalizer(iso, func(iso *Isolate) {
close(fin)
iso.release()
})
iso = nil
if !runGcUntilReceivedOrTimedOut(fin, 4*time.Second) {
t.Fatal("finalizer of iso didn't run, iso created one context.")
}
} | explode_data.jsonl/81586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 295
} | [
2830,
3393,
3872,
33066,
19357,
3135,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
15420,
1669,
1532,
3872,
33066,
2822,
1166,
258,
1669,
1281,
35190,
1807,
340,
197,
322,
16932,
279,
1590,
3135,
773,
582,
1273,
421,
432,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRejectsMirrorPodWithSecretVolumes(t *testing.T) {
pod := &api.Pod{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
kubelet.ConfigMirrorAnnotationKey: "true",
},
},
Spec: api.PodSpec{
Volumes: []api.Volume{
{VolumeSource: api.VolumeSource{Secret: &api.SecretVolumeSource{}}},
},
},
}
attrs := admission.NewAttributesRecord(pod, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
err := NewServiceAccount().Admit(attrs)
if err == nil {
t.Errorf("Expected a mirror pod to be prevented from referencing a secret volume")
}
} | explode_data.jsonl/61341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 246
} | [
2830,
3393,
78413,
82,
54216,
23527,
2354,
19773,
96325,
1155,
353,
8840,
836,
8,
341,
3223,
347,
1669,
609,
2068,
88823,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
197,
21418,
25,
2415,
14032,
30953,
515,
571,
16463,
3760,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreSendWithZeroTime(t *testing.T) {
defer leaktest.AfterTest(t)()
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
store, _ := createTestStore(t, testStoreOpts{createSystemRanges: true}, stopper)
args := getArgs([]byte("a"))
var ba roachpb.BatchRequest
ba.Add(&args)
br, pErr := store.TestSender().Send(context.Background(), ba)
if pErr != nil {
t.Fatal(pErr)
}
// The Logical time will increase over the course of the command
// execution so we can only rely on comparing the WallTime.
if br.Timestamp.WallTime != store.cfg.Clock.Now().WallTime {
t.Errorf("expected reply to have store clock time %s; got %s",
store.cfg.Clock.Now(), br.Timestamp)
}
} | explode_data.jsonl/93 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
6093,
11505,
2354,
17999,
1462,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
62644,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
2936,
712,
30213,
5378,
19047,
2398,
57279,
11,
716,
1669,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTeamsService_ListChildTeamsByParentSlug(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/orgs/o/teams/s/teams", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"page": "2"})
fmt.Fprint(w, `[{"id":2}]`)
})
opt := &ListOptions{Page: 2}
ctx := context.Background()
teams, _, err := client.Teams.ListChildTeamsByParentSlug(ctx, "o", "s", opt)
if err != nil {
t.Errorf("Teams.ListChildTeamsByParentSlug returned error: %v", err)
}
want := []*Team{{ID: Int64(2)}}
if !cmp.Equal(teams, want) {
t.Errorf("Teams.ListChildTeamsByParentSlug returned %+v, want %+v", teams, want)
}
const methodName = "ListChildTeamsByParentSlug"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Teams.ListChildTeamsByParentSlug(ctx, "\n", "\n", opt)
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Teams.ListChildTeamsByParentSlug(ctx, "o", "s", opt)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
} | explode_data.jsonl/4523 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 482
} | [
2830,
3393,
60669,
1860,
27104,
3652,
60669,
1359,
8387,
54968,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
1775,
82,
20271,
14,
38496,
2687,
14,
38496,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMessagerCacheEmpty(t *testing.T) {
mc := newCache(2)
if !mc.Add(&MessageRow{
TimeNext: 1,
Epoch: 0,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row01")},
}) {
t.Fatal("Add returned false")
}
mc.Clear()
if row := mc.Pop(); row != nil {
t.Errorf("Pop(empty): %v, want nil", row)
}
if !mc.Add(&MessageRow{
TimeNext: 1,
Epoch: 0,
Row: []sqltypes.Value{sqltypes.NewVarBinary("row01")},
}) {
t.Fatal("Add returned false")
}
if row := mc.Pop(); row == nil {
t.Errorf("Pop(non-empty): nil, want %v", row)
}
} | explode_data.jsonl/24952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
84423,
1409,
8233,
3522,
1155,
353,
8840,
836,
8,
341,
97662,
1669,
501,
8233,
7,
17,
340,
743,
753,
12887,
1904,
2099,
2052,
3102,
515,
197,
67567,
5847,
25,
220,
16,
345,
197,
197,
44338,
25,
262,
220,
15,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestNestedMethods(t *testing.T) {
typ := TypeOf((*outer)(nil))
if typ.NumMethod() != 1 || typ.Method(0).Func.Pointer() != ValueOf((*outer).M).Pointer() {
t.Errorf("Wrong method table for outer: (M=%p)", (*outer).M)
for i := 0; i < typ.NumMethod(); i++ {
m := typ.Method(i)
t.Errorf("\t%d: %s %#x\n", i, m.Name, m.Func.Pointer())
}
}
} | explode_data.jsonl/29567 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
71986,
17856,
1155,
353,
8840,
836,
8,
341,
25314,
1669,
3990,
2124,
26609,
2676,
2376,
8385,
1171,
743,
3582,
39847,
3523,
368,
961,
220,
16,
1369,
3582,
20798,
7,
15,
568,
9626,
41275,
368,
961,
5162,
2124,
26609,
2676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBefore(t *testing.T) {
before := MiddlewareChain{m1, m2}
r := &Route{}
r.SetBefore(m1, m2)
if !compareMiddlewareFunc(r.Before, before) {
t.Error("Before middlewares do not match.")
}
} | explode_data.jsonl/59907 | {
"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,
10227,
1155,
353,
8840,
836,
8,
341,
63234,
1669,
72012,
18837,
90,
76,
16,
11,
296,
17,
630,
7000,
1669,
609,
4899,
16094,
7000,
4202,
10227,
1255,
16,
11,
296,
17,
692,
743,
753,
18948,
24684,
9626,
2601,
31153,
11,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestAgentConnectAuthorize_denyTrustDomain(t *testing.T) {
t.Parallel()
assert := assert.New(t)
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
target := "db"
// Create some intentions
{
req := structs.IntentionRequest{
Datacenter: "dc1",
Op: structs.IntentionOpCreate,
Intention: structs.TestIntention(t),
}
req.Intention.SourceNS = structs.IntentionDefaultNamespace
req.Intention.SourceName = "web"
req.Intention.DestinationNS = structs.IntentionDefaultNamespace
req.Intention.DestinationName = target
req.Intention.Action = structs.IntentionActionAllow
var reply string
assert.Nil(a.RPC("Intention.Apply", &req, &reply))
}
{
args := &structs.ConnectAuthorizeRequest{
Target: target,
ClientCertURI: "spiffe://fake-domain.consul/ns/default/dc/dc1/svc/web",
}
req, _ := http.NewRequest("POST", "/v1/agent/connect/authorize", jsonReader(args))
resp := httptest.NewRecorder()
respRaw, err := a.srv.AgentConnectAuthorize(resp, req)
assert.Nil(err)
assert.Equal(200, resp.Code)
obj := respRaw.(*connectAuthorizeResp)
assert.False(obj.Authorized)
assert.Contains(obj.Reason, "Identity from an external trust domain")
}
} | explode_data.jsonl/33671 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
16810,
14611,
37483,
814,
32395,
45548,
13636,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
14676,
16867,
264,
10849,
18452,
2822,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestScanValues(t *testing.T) {
testcases := append(scanvalid, []string{
string(mapValue),
string(allValueIndent),
string(allValueCompact),
string(pallValueIndent),
string(pallValueCompact),
}...)
config := NewDefaultConfig()
jsn := config.NewJson(make([]byte, 0, 1024*1024))
for _, tcase := range testcases {
var ref interface{}
t.Logf("%v", tcase)
json.Unmarshal([]byte(tcase), &ref)
jsn.Reset([]byte(tcase))
_, val := jsn.Tovalue()
if reflect.DeepEqual(val, ref) == false {
t.Errorf("%q should be parsed as: %v, got %v", tcase, ref, val)
}
}
} | explode_data.jsonl/70407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 247
} | [
2830,
3393,
26570,
6227,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
8737,
71588,
1891,
11,
3056,
917,
515,
197,
11357,
9147,
1130,
1326,
197,
11357,
20388,
1130,
42729,
1326,
197,
11357,
20388,
1130,
98335,
1326,
197,
11357,
1295,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterfaceToIntDowncast(t *testing.T) {
var out int
var ok bool
out, ok = InterfaceToIntDowncast(int(1))
require.True(t, ok)
require.Equal(t, int(1), out)
out, ok = InterfaceToIntDowncast(float32(2))
require.True(t, ok)
require.Equal(t, int(2), out)
out, ok = InterfaceToIntDowncast(float32(2.0))
require.True(t, ok)
require.Equal(t, int(2), out)
_, ok = InterfaceToIntDowncast(float32(2.2))
require.False(t, ok)
out, ok = InterfaceToIntDowncast(float64(3))
require.True(t, ok)
require.Equal(t, int(3), out)
out, ok = InterfaceToIntDowncast(float64(3.0))
require.True(t, ok)
require.Equal(t, int(3), out)
_, ok = InterfaceToIntDowncast(float64(3.3))
require.False(t, ok)
_, ok = InterfaceToIntDowncast("test")
require.False(t, ok)
} | explode_data.jsonl/52293 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
5051,
38544,
4454,
3829,
1155,
353,
8840,
836,
8,
341,
2405,
700,
526,
198,
2405,
5394,
1807,
271,
13967,
11,
5394,
284,
20019,
38544,
4454,
3829,
1548,
7,
16,
1171,
17957,
32443,
1155,
11,
5394,
340,
17957,
12808,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLightMetricSet_VerifyHostDataURI_NonParsableHost(t *testing.T) {
const (
postgresHost = "host1:5432"
postgresEndpoint = "postgres://user1:pass@host1:5432?connect_timeout=2"
postgresParsed = "connect_timeout=3 host=host1 password=pass port=5432 user=user1"
)
r := NewRegister()
r.MustAddMetricSet("http", "json", newMetricSetWithOption,
WithHostParser(func(module Module, host string) (HostData, error) {
return HostData{
Host: postgresHost,
URI: postgresParsed,
}, nil
}))
r.SetSecondarySource(NewLightModulesSource("testdata/lightmodules"))
config, err := common.NewConfigFrom(
common.MapStr{
"module": "httpextended",
"metricsets": []string{"extends"},
"hosts": []string{postgresEndpoint},
})
require.NoError(t, err)
_, metricSets, err := NewModule(config, r)
require.NoError(t, err)
require.Len(t, metricSets, 1)
assert.Equal(t, postgresHost, metricSets[0].Host())
assert.Equal(t, postgresParsed, metricSets[0].HostData().URI)
} | explode_data.jsonl/9717 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 408
} | [
2830,
3393,
13911,
54310,
1649,
2334,
261,
1437,
9296,
1043,
10301,
1604,
263,
47,
1561,
480,
9296,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
197,
43070,
9296,
257,
284,
330,
3790,
16,
25,
20,
19,
18,
17,
698,
197,
197,
43070,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMap_Stat(t *testing.T) {
fs := Map(map[string][]byte{
"foo/bar/three.txt": []byte("333"),
"foo/bar.txt": []byte("22"),
"top.txt": []byte("top.txt file"),
"other-top.txt": []byte("other-top.txt file"),
})
tests := []struct {
path string
want os.FileInfo
}{
{path: "", want: dirInfo("/")},
{path: "foo", want: dirInfo("foo")},
{path: "foo/", want: dirInfo("foo")},
{path: "foo/bar", want: dirInfo("bar")},
{path: "foo/bar/", want: dirInfo("bar")},
{path: "foo/bar/three.txt", want: fileInfo{"three.txt", 3}},
}
for _, leadingSlashOrEmpty := range []string{"", "/"} {
for _, tt := range tests {
path := leadingSlashOrEmpty + tt.path
if path == "" {
continue
}
fi, err := fs.Stat(nil, path)
if err != nil {
t.Errorf("Stat(%q) = %v", path, err)
continue
}
if !reflect.DeepEqual(fi, tt.want) {
t.Errorf("Stat(%q) = %#v; want %#v", path, fi, tt.want)
continue
}
}
}
_, err := fs.Stat(nil, "/xxxx")
if !os.IsNotExist(err) {
t.Errorf("Stat /xxxx = %v; want os.IsNotExist error", err)
}
} | explode_data.jsonl/42381 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 518
} | [
2830,
3393,
2227,
62,
15878,
1155,
353,
8840,
836,
8,
341,
53584,
1669,
5027,
9147,
14032,
45725,
3782,
515,
197,
197,
1,
7975,
49513,
20439,
765,
3909,
788,
3056,
3782,
445,
18,
18,
18,
4461,
197,
197,
1,
7975,
49513,
3909,
788,
98... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestStream_SetReadPos(t *testing.T) {
t.Run("test", func(t *testing.T) {
assert := base.NewAssert(t)
for i := 0; i < 3*streamBlockSize; i++ {
stream := NewStream()
if i < streamPosBody {
assert(stream.SetReadPos(i)).IsFalse()
assert(stream.GetReadPos()).Equals(streamPosBody)
} else if i == streamPosBody {
stream.SetWritePos(i)
assert(stream.SetReadPos(i)).IsTrue()
assert(stream.GetReadPos()).Equals(i)
assert(stream.SetReadPos(i + 1)).IsFalse()
assert(stream.GetReadPos()).Equals(i)
} else {
stream.SetWritePos(i)
assert(stream.SetReadPos(i - 1)).IsTrue()
assert(stream.GetReadPos()).Equals(i - 1)
assert(stream.SetReadPos(i)).IsTrue()
assert(stream.GetReadPos()).Equals(i)
assert(stream.SetReadPos(i + 1)).IsFalse()
assert(stream.GetReadPos()).Equals(i)
}
stream.Release()
}
})
} | explode_data.jsonl/21183 | {
"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,
3027,
14812,
4418,
4859,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
340,
197,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
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... | 4 |
func TestAddOrdersHandlersCorrectly(t *testing.T) {
middlewareBase := func(tag string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(tag))
h.ServeHTTP(w, r)
})
}
}
t1 := middlewareBase("t1\n")
testEndpoint := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("endpoint\n"))
})
chained := New(t1)
copyChained := chained.Copy()
t2 := middlewareBase("t2\n")
t3 := middlewareBase("t3\n")
copyChained.Add(t2, t3)
w := httptest.NewRecorder()
r, err := http.NewRequest(http.MethodGet, "/", nil)
if err != nil {
t.Fatal(err)
}
copyChained.Then(testEndpoint).ServeHTTP(w, r)
if w.Body.String() != "t1\nt2\nt3\nendpoint\n" {
t.Errorf("Then does not order handlers correctly (Order: %s)", w.Body.String())
return
}
} | explode_data.jsonl/46279 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 368
} | [
2830,
3393,
2212,
24898,
39949,
33092,
398,
1155,
353,
8840,
836,
8,
1476,
2109,
11603,
3978,
1669,
2915,
19343,
914,
8,
72012,
341,
197,
853,
2915,
3203,
1758,
31010,
8,
1758,
31010,
341,
298,
853,
1758,
89164,
18552,
3622,
1758,
37508... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetMilestones(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
test := func(sortType string, sortCond func(*Milestone) int) {
for _, page := range []int{0, 1} {
milestones, err := GetMilestones(repo.ID, page, false, sortType)
assert.NoError(t, err)
assert.Len(t, milestones, repo.NumMilestones-repo.NumClosedMilestones)
values := make([]int, len(milestones))
for i, milestone := range milestones {
values[i] = sortCond(milestone)
}
assert.True(t, sort.IntsAreSorted(values))
milestones, err = GetMilestones(repo.ID, page, true, sortType)
assert.NoError(t, err)
assert.Len(t, milestones, repo.NumClosedMilestones)
values = make([]int, len(milestones))
for i, milestone := range milestones {
values[i] = sortCond(milestone)
}
assert.True(t, sort.IntsAreSorted(values))
}
}
test("furthestduedate", func(milestone *Milestone) int {
return -int(milestone.DeadlineUnix)
})
test("leastcomplete", func(milestone *Milestone) int {
return milestone.Completeness
})
test("mostcomplete", func(milestone *Milestone) int {
return -milestone.Completeness
})
test("leastissues", func(milestone *Milestone) int {
return milestone.NumIssues
})
test("mostissues", func(milestone *Milestone) int {
return -milestone.NumIssues
})
test("soonestduedate", func(milestone *Milestone) int {
return int(milestone.DeadlineUnix)
})
} | explode_data.jsonl/21823 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 558
} | [
2830,
3393,
1949,
44,
457,
32510,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
31166,
2271,
5988,
2398,
17200,
5368,
1669,
5319,
15575,
3036,
5879,
10437,
1155,
11,
609,
4624,
90,
915,
25,
220,
16,
16630,
4071,
4624,
340,
1818... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParsePointNumberNonNumeric(t *testing.T) {
_, err := models.ParsePointsString(`cpu,host=serverA,region=us-west value=.1a`)
if err == nil {
t.Errorf(`ParsePoints("%s") mismatch. got nil, exp error`, `cpu,host=serverA,region=us-west value=.1a`)
}
} | explode_data.jsonl/16913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
14463,
2609,
2833,
8121,
36296,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
4119,
8937,
11411,
703,
5809,
16475,
11,
3790,
28,
4030,
32,
11,
3943,
28,
355,
37602,
897,
45934,
16,
64,
24183,
743,
1848,
621,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCluster_Coordinator(t *testing.T) {
uri1 := NewTestURIFromHostPort("node1", 0)
uri2 := NewTestURIFromHostPort("node2", 0)
node1 := &Node{ID: "node1", URI: uri1}
node2 := &Node{ID: "node2", URI: uri2}
c1 := *newCluster()
c1.Node = node1
c1.Coordinator = node1.ID
c2 := *newCluster()
c2.Node = node2
c2.Coordinator = node1.ID
t.Run("IsCoordinator", func(t *testing.T) {
if !c1.isCoordinator() {
t.Errorf("!IsCoordinator error: %v", c1.Node)
} else if c2.isCoordinator() {
t.Errorf("IsCoordinator error: %v", c2.Node)
}
})
} | explode_data.jsonl/59881 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
28678,
920,
78,
17442,
1155,
353,
8840,
836,
8,
341,
197,
6070,
16,
1669,
1532,
2271,
1511,
2773,
441,
9296,
7084,
445,
3509,
16,
497,
220,
15,
340,
197,
6070,
17,
1669,
1532,
2271,
1511,
2773,
441,
9296,
7084,
445,
3509... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDecodeYAMLUnexpectedStream(t *testing.T) {
f := newFixture(t)
defer f.TearDown()
tf := fmt.Sprintf("observed = decode_yaml('''%s''')\n", yamlStream)
f.File("Tiltfile", tf)
_, err := f.ExecFile("Tiltfile")
if err != nil {
fmt.Println(f.PrintOutput())
}
require.Error(t, err)
require.Contains(t, err.Error(), "expected a yaml document but found a yaml stream")
} | explode_data.jsonl/10616 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
32564,
56,
31102,
29430,
3027,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
836,
682,
4454,
2822,
3244,
69,
1669,
8879,
17305,
445,
5481,
2771,
284,
16895,
64380,
83434,
4,
82,
4605,
863,
59... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSessionShell(t *testing.T) {
conn := dial(shellHandler, t)
defer conn.Close()
session, err := conn.NewSession()
if err != nil {
t.Fatalf("Unable to request new session: %v", err)
}
defer session.Close()
stdout := new(bytes.Buffer)
session.Stdout = stdout
if err := session.Shell(); err != nil {
t.Fatalf("Unable to execute command: %s", err)
}
if err := session.Wait(); err != nil {
t.Fatalf("Remote command did not exit cleanly: %v", err)
}
actual := stdout.String()
if actual != "golang" {
t.Fatalf("Remote shell did not return expected string: expected=golang, actual=%s", actual)
}
} | explode_data.jsonl/34792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
5283,
25287,
1155,
353,
8840,
836,
8,
341,
32917,
1669,
27860,
93558,
3050,
11,
259,
340,
16867,
4534,
10421,
741,
25054,
11,
1848,
1669,
4534,
7121,
5283,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
17075,
311,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestCtxRedirectHTTPSSchemeless(t *testing.T) {
var ctx RequestCtx
s := "GET /foo/bar?baz HTTP/1.1\nHost: aaa.com\n\n"
br := bufio.NewReader(bytes.NewBufferString(s))
if err := ctx.Request.Read(br); err != nil {
t.Fatalf("cannot read request: %s", err)
}
ctx.Request.isTLS = true
ctx.Redirect("//foobar.com/aa/bbb", StatusFound)
location := ctx.Response.Header.Peek("Location")
expectedLocation := "https://foobar.com/aa/bbb"
if string(location) != expectedLocation {
t.Fatalf("Unexpected location: %q. Expecting %q", location, expectedLocation)
}
} | explode_data.jsonl/73267 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 223
} | [
2830,
3393,
1900,
23684,
17725,
9230,
1220,
8058,
1717,
1155,
353,
8840,
836,
8,
341,
2405,
5635,
6145,
23684,
271,
1903,
1669,
330,
3806,
608,
7975,
49513,
30,
42573,
10130,
14,
16,
13,
16,
1699,
9296,
25,
83465,
905,
1699,
1699,
698... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleCountDistinctMultiCol(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
{
"SELECT COUNT(DISTINCT col, col2) FROM tbl;",
},
{
"SELECT COUNT(DISTINCT col) FROM tbl;",
`SELECT JSON_OBJECT( "key", p.id, "title", p.name, "manufacturer", p.manufacturer, "price", p.price, "specifications", JSON_OBJECTAGG(a.name, v.value)) as product FROM product as p JOIN value as v ON p.id = v.prod_id JOIN attribute as a ON a.id = v.attribute_id GROUP BY v.prod_id`,
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleCountDistinctMultiCol()
if rule.Item != "DIS.002" {
t.Error("Rule not match:", rule.Item, "Expect : DIS.002")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleCountDistinctMultiCol()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76795 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 492
} | [
2830,
3393,
11337,
2507,
72767,
20358,
6127,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
515,
298,
197,
1,
4858,
23989,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestMergeRunTimeAlerts(t *testing.T) {
for _, c := range []struct {
desc string
old *storage.Alert
new *storage.Alert
expectedNew *storage.Alert
expectedOutput bool
}{
{
desc: "dfdf",
old: appendViolations(
getFakeResourceRuntimeAlert(storage.Alert_Resource_SECRETS, "rn", "cid", "nid", "nn"),
firstKubeEventViolation,
),
new: appendViolations(
getFakeResourceRuntimeAlert(storage.Alert_Resource_SECRETS, "rn", "cid", "nid", "nn"),
secondKubeEventViolation,
),
expectedNew: appendViolations(
getFakeResourceRuntimeAlert(storage.Alert_Resource_SECRETS, "rn", "cid", "nid", "nn"),
secondKubeEventViolation,
firstKubeEventViolation,
),
expectedOutput: true,
},
{
desc: "No process; no event",
old: getFakeRuntimeAlert(),
new: getFakeRuntimeAlert(),
expectedOutput: false,
},
{
desc: "No new process; no event",
old: getFakeRuntimeAlert(yesterdayProcess),
new: getFakeRuntimeAlert(),
expectedOutput: false,
},
{
desc: "No process; no new event",
old: appendViolations(getFakeRuntimeAlert(), firstKubeEventViolation),
new: getFakeRuntimeAlert(),
expectedOutput: false,
},
{
desc: "No process; new event",
old: getFakeRuntimeAlert(),
new: appendViolations(getFakeRuntimeAlert(), firstKubeEventViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(), firstKubeEventViolation),
expectedOutput: true,
},
{
desc: "Equal process; no new event",
old: appendViolations(getFakeRuntimeAlert(yesterdayProcess), firstKubeEventViolation),
new: appendViolations(getFakeRuntimeAlert(yesterdayProcess)),
expectedOutput: false,
},
{
desc: "Equal process; new event",
old: appendViolations(getFakeRuntimeAlert(yesterdayProcess), firstKubeEventViolation),
new: appendViolations(getFakeRuntimeAlert(yesterdayProcess), secondKubeEventViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(yesterdayProcess), secondKubeEventViolation, firstKubeEventViolation),
expectedOutput: true,
},
{
desc: "New process; new event ",
old: appendViolations(getFakeRuntimeAlert(yesterdayProcess), firstKubeEventViolation),
new: appendViolations(getFakeRuntimeAlert(nowProcess), secondKubeEventViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(yesterdayProcess, nowProcess), secondKubeEventViolation, firstKubeEventViolation),
expectedOutput: true,
},
{
desc: "New process; no new event ",
old: appendViolations(getFakeRuntimeAlert(yesterdayProcess), firstKubeEventViolation),
new: getFakeRuntimeAlert(nowProcess),
expectedNew: getFakeRuntimeAlert(yesterdayProcess, nowProcess),
expectedOutput: true,
},
{
desc: "Many new process; many new events",
old: getFakeRuntimeAlert(twoDaysAgoProcess, yesterdayProcess),
new: appendViolations(getFakeRuntimeAlert(yesterdayProcess, nowProcess), firstKubeEventViolation, secondKubeEventViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(twoDaysAgoProcess, yesterdayProcess, nowProcess), firstKubeEventViolation, secondKubeEventViolation),
expectedOutput: true,
},
{
desc: "No process; new network flow",
old: getFakeRuntimeAlert(),
new: appendViolations(getFakeRuntimeAlert(), firstNetworkFlowViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(), firstNetworkFlowViolation),
expectedOutput: true,
},
{
desc: "Old process with old flow; new network flow",
old: appendViolations(getFakeRuntimeAlert(nowProcess), firstNetworkFlowViolation),
new: appendViolations(getFakeRuntimeAlert(nowProcess), secondNetworkFlowViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(nowProcess), secondNetworkFlowViolation, firstNetworkFlowViolation),
expectedOutput: true,
},
{
desc: "Many new process; many new flow",
old: appendViolations(getFakeRuntimeAlert(twoDaysAgoProcess)),
new: appendViolations(getFakeRuntimeAlert(yesterdayProcess, nowProcess), firstNetworkFlowViolation, secondNetworkFlowViolation),
expectedNew: appendViolations(getFakeRuntimeAlert(twoDaysAgoProcess, yesterdayProcess, nowProcess), firstNetworkFlowViolation, secondNetworkFlowViolation),
expectedOutput: true,
},
} {
t.Run(c.desc, func(t *testing.T) {
out := mergeRunTimeAlerts(c.old, c.new)
assert.Equal(t, c.expectedOutput, out)
if c.expectedNew != nil {
assert.Equal(t, c.expectedNew, c.new)
}
})
}
} | explode_data.jsonl/52660 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1960
} | [
2830,
3393,
52096,
6727,
1462,
9676,
82,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
272,
1669,
2088,
3056,
1235,
341,
197,
41653,
1843,
914,
198,
197,
61828,
310,
353,
16172,
40143,
198,
197,
8638,
310,
353,
16172,
40143,
198,
197,
424... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecover_sendRecoverMail_FailToSend(t *testing.T) {
t.Parallel()
r, _, logger := testSetup()
mailer := mocks.NewMockMailer()
mailer.SendErr = "failed to send"
r.Mailer = mailer
r.sendRecoverEmail(r.NewContext(), "", "")
if !strings.Contains(logger.String(), "failed to send") {
t.Error("Expected logged to have msg:", "failed to send")
}
} | explode_data.jsonl/61499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
693,
3688,
13565,
693,
3688,
16702,
1400,
604,
80576,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
7000,
11,
8358,
5925,
1669,
1273,
21821,
2822,
2109,
38782,
1669,
68909,
7121,
11571,
47608,
741,
2109,
38782,
20176,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVPCs_Update(t *testing.T) {
setup()
defer teardown()
svc := client.VPCs
path := "/v2/vpcs"
want := vTestObj
id := "880b7f98-f062-404d-b33c-458d545696f6"
req := &VPCUpdateRequest{
Name: "my-new-vpc",
}
jsonBlob := `
{
"vpc":
` + vTestJSON + `
}
`
mux.HandleFunc(path+"/"+id, func(w http.ResponseWriter, r *http.Request) {
c := new(VPCUpdateRequest)
err := json.NewDecoder(r.Body).Decode(c)
if err != nil {
t.Fatal(err)
}
testMethod(t, r, http.MethodPut)
require.Equal(t, c, req)
fmt.Fprint(w, jsonBlob)
})
got, _, err := svc.Update(ctx, id, req)
require.NoError(t, err)
require.Equal(t, want, got)
} | explode_data.jsonl/41242 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
53,
4872,
82,
47393,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
1903,
7362,
1669,
2943,
5058,
4872,
82,
198,
26781,
1669,
3521,
85,
17,
5457,
47313,
698,
50780,
1669,
348,
2271,
5261,
198,
15710,
1669,
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_Resolve_Operations_Pass_CustomType(t *testing.T) {
data := `
http:
test:
some_url:
endpoint: GET /some/url
body: Custom1
response:
ok: Custom2
models:
Custom1:
field: string
Custom2:
field: string
`
old, err := unmarshalSpec([]byte(data))
assert.Equal(t, err, nil)
errors := enrichSpec(old)
assert.Equal(t, len(errors), 0)
} | explode_data.jsonl/79848 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
62,
56808,
2232,
712,
804,
1088,
395,
57402,
929,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
22074,
1254,
510,
262,
1273,
510,
286,
1045,
2903,
510,
310,
14887,
25,
7890,
608,
14689,
57254,
198,
310,
2487,
25,
8406,
16,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_Mock_AssertExpectations(t *testing.T) {
var mockedService = new(TestExampleImplementation)
mockedService.On("Test_Mock_AssertExpectations", 1, 2, 3).Return(5, 6, 7)
tt := new(testing.T)
assert.False(t, mockedService.AssertExpectations(tt))
// make the call now
mockedService.Called(1, 2, 3)
// now assert expectations
assert.True(t, mockedService.AssertExpectations(tt))
} | explode_data.jsonl/8599 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
1245,
1176,
62222,
529,
17536,
804,
1155,
353,
8840,
836,
8,
8022,
2405,
46149,
1860,
284,
501,
31159,
13314,
36850,
7229,
2109,
67385,
1860,
8071,
445,
2271,
1245,
1176,
62222,
529,
17536,
804,
497,
220,
16,
11,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_wagerService_Place(t *testing.T) {
type fields struct {
wagerRepository repositories.WagerRepository
}
type args struct {
ctx context.Context
req *dtos.PlaceWagerRequest
}
var (
wagerRepository = &mocksRepo.WagerRepository{}
errWagerRepository = &mocksRepo.WagerRepository{}
reqs map[string]*dtos.PlaceWagerRequest = map[string]*dtos.PlaceWagerRequest{
"good": {
TotalWagerValue: 10000.1,
Odds: 30,
SellingPercentage: 5,
SellingPrice: 1000.64,
},
"sell below percentage": {
TotalWagerValue: 10000.1,
Odds: 30,
SellingPercentage: 100,
SellingPrice: 1000.64,
},
"create error": {
TotalWagerValue: 10000,
Odds: 1,
SellingPercentage: 10,
SellingPrice: 10000,
},
}
)
wagerRepository.On("Create", mock.Anything, mock.Anything).Return(nil)
errWagerRepository.On("Create", mock.Anything, mock.Anything).Return(errors.New("just an error"))
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
{
name: "good",
fields: fields{wagerRepository: wagerRepository},
args: args{
ctx: context.Background(),
req: reqs["good"],
},
wantErr: false,
},
{
name: "sell below percentage",
fields: fields{wagerRepository: wagerRepository},
args: args{
ctx: context.Background(),
req: reqs["sell below percentage"],
},
wantErr: true,
},
{
name: "create error",
fields: fields{wagerRepository: errWagerRepository},
args: args{
ctx: context.Background(),
req: reqs["create error"],
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &wagerService{
wagerRepository: tt.fields.wagerRepository,
}
got, err := s.Place(tt.args.ctx, tt.args.req)
if (err != nil) != tt.wantErr {
t.Errorf("Place() error = %v, wantErr %v", err, tt.wantErr)
return
}
if tt.wantErr {
return
}
if got.CurrentSellingPrice != got.SellingPrice {
t.Errorf("Place() current_selling_price != selling_price")
}
if got.AmountSold != nil {
t.Error("Place() amount_sold != nil")
}
if got.PercentageSold != nil {
t.Error("Place() percentage_sold != nil")
}
})
}
} | explode_data.jsonl/47643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1131
} | [
2830,
3393,
1670,
1409,
1860,
1088,
26536,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
6692,
1409,
4624,
49657,
1175,
1409,
4624,
198,
197,
532,
13158,
2827,
2036,
341,
197,
20985,
2266,
9328,
198,
197,
24395,
353,
8047,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAgentConnectAuthorize_defaultAllow(t *testing.T) {
t.Parallel()
assert := assert.New(t)
a := NewTestAgent(t.Name(), `
acl_datacenter = "dc1"
acl_default_policy = "allow"
acl_master_token = "root"
acl_agent_token = "root"
acl_agent_master_token = "towel"
acl_enforce_version_8 = true
`)
defer a.Shutdown()
args := &structs.ConnectAuthorizeRequest{
Target: "foo",
ClientCertURI: connect.TestSpiffeIDService(t, "web").URI().String(),
}
req, _ := http.NewRequest("POST", "/v1/agent/connect/authorize?token=root", jsonReader(args))
resp := httptest.NewRecorder()
respRaw, err := a.srv.AgentConnectAuthorize(resp, req)
assert.Nil(err)
assert.Equal(200, resp.Code)
obj := respRaw.(*connectAuthorizeResp)
assert.True(obj.Authorized)
assert.Contains(obj.Reason, "Default behavior")
} | explode_data.jsonl/33675 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 322
} | [
2830,
3393,
16810,
14611,
37483,
9993,
18605,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
22074,
197,
11323,
564,
1769,
3057,
284,
330,
7628,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateRootfs(t *testing.T) {
assert := assert.New(t)
tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)
rootfsDir := filepath.Join(tmpdir, "rootfs")
assert.False(katautils.FileExists(rootfsDir))
err = createRootfs(rootfsDir)
assert.NoError(err)
// non-comprehensive list of expected directories
expectedDirs := []string{"bin", "dev", "etc", "usr", "var"}
assert.True(katautils.FileExists(rootfsDir))
for _, dir := range expectedDirs {
dirPath := filepath.Join(rootfsDir, dir)
assert.True(katautils.FileExists(dirPath))
}
} | explode_data.jsonl/52190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 226
} | [
2830,
3393,
4021,
8439,
3848,
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,
33698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHashJoinerProjection(t *testing.T) {
defer leaktest.AfterTest(t)()
ctx := context.Background()
st := cluster.MakeTestingClusterSettings()
evalCtx := tree.MakeTestingEvalContext(st)
defer evalCtx.Stop(ctx)
flowCtx := &runbase.FlowCtx{
EvalCtx: &evalCtx,
Cfg: &runbase.ServerConfig{
Settings: st,
},
}
leftTypes := []types.T{types.Bool, types.Int, types.Bytes}
leftColTypes := []coltypes.T{coltypes.Bool, coltypes.Int64, coltypes.Bytes}
rightTypes := []types.T{types.Int, types.Float, types.Decimal}
rightColTypes := []coltypes.T{coltypes.Int64, coltypes.Float64, coltypes.Decimal}
leftTuples := tuples{{false, 1, "foo"}}
rightTuples := tuples{{1, 1.1, decs[1]}}
lcts, _ := sqlbase.DatumTypesToColumnTypes(leftTypes)
rcts, _ := sqlbase.DatumTypesToColumnTypes(rightTypes)
spec := &distsqlpb.ProcessorSpec{
Core: distsqlpb.ProcessorCoreUnion{
HashJoiner: &distsqlpb.HashJoinerSpec{
LeftEqColumns: []uint32{1},
RightEqColumns: []uint32{0},
LeftEqColumnsAreKey: true,
RightEqColumnsAreKey: true,
},
},
Input: []distsqlpb.InputSyncSpec{
{ColumnTypes: lcts},
{ColumnTypes: rcts},
},
Post: distsqlpb.PostProcessSpec{
Projection: true,
// The "core" of the test - we ask for a projection in which the columns
// from the left and from the right are intertwined.
OutputColumns: []uint32{3, 1, 0, 5, 4, 2},
},
}
leftSource := newOpTestInput(1, leftTuples, leftColTypes)
rightSource := newOpTestInput(1, rightTuples, rightColTypes)
args := NewColOperatorArgs{
Spec: spec,
Inputs: []Operator{leftSource, rightSource},
StreamingMemAccount: testMemAcc,
UseStreamingMemAccountForBuffering: true,
}
hjOp, err := NewColOperator(ctx, flowCtx, args)
require.NoError(t, err)
hjOp.Op.Init()
for {
b := hjOp.Op.Next(ctx)
// The output types should be {Int64, Int64, Bool, Decimal, Float64, Bytes}
// and we check this explicitly.
b.ColVec(0).Int64()
b.ColVec(1).Int64()
b.ColVec(2).Bool()
b.ColVec(3).Decimal()
b.ColVec(4).Float64()
b.ColVec(5).Bytes()
if b.Length() == 0 {
break
}
}
} | explode_data.jsonl/4249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 967
} | [
2830,
3393,
6370,
12292,
261,
46321,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
20985,
1669,
2266,
19047,
741,
18388,
1669,
10652,
50133,
16451,
28678,
6086,
741,
93413,
23684,
1669,
4916,
50133,
16451,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMarshalAPReq(t *testing.T) {
t.Parallel()
var a APReq
b, err := hex.DecodeString(testdata.MarshaledKRB5ap_req)
if err != nil {
t.Fatalf("Test vector read error: %v", err)
}
err = a.Unmarshal(b)
if err != nil {
t.Fatalf("Unmarshal error: %v", err)
}
mb, err := a.Marshal()
if err != nil {
t.Fatalf("Marshal of ticket errored: %v", err)
}
assert.Equal(t, b, mb, "Marshal bytes of Authenticator not as expected")
} | explode_data.jsonl/62186 | {
"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,
55438,
2537,
27234,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2405,
264,
10106,
27234,
198,
2233,
11,
1848,
1669,
12371,
56372,
703,
8623,
691,
83691,
75303,
42,
29259,
20,
391,
17644,
340,
743,
1848,
961,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestIngestLoadInvalid(t *testing.T) {
mem := vfs.NewMem()
f, err := mem.Create("invalid")
require.NoError(t, err)
require.NoError(t, f.Close())
opts := &Options{
Comparer: DefaultComparer,
FS: mem,
}
if _, _, err := ingestLoad(opts, []string{"invalid"}, 0, []FileNum{1}); err == nil {
t.Fatalf("expected error, but found success")
}
} | explode_data.jsonl/40254 | {
"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,
641,
6969,
5879,
7928,
1155,
353,
8840,
836,
8,
341,
14145,
1669,
92941,
7121,
18816,
741,
1166,
11,
1848,
1669,
1833,
7251,
445,
11808,
1138,
17957,
35699,
1155,
11,
1848,
340,
17957,
35699,
1155,
11,
282,
10421,
12367,
647... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddFieldToFuncDeclParams(t *testing.T) {
t.Run("add field to empty decl", func(t *testing.T) {
var src = `
package main
func f() {}
`
var expected = `
package main
func f(i int) {}
`
cases := []struct {
pos int
}{
{-1},
{0},
{1},
{2},
{3},
}
intField := &dst.Field{
Names: []*dst.Ident{dst.NewIdent("i")},
Type: dst.NewIdent("int"),
}
for _, c := range cases {
df, _ := ParseSrcFileFromBytes([]byte(src))
var buf *bytes.Buffer
assert.True(t, AddFieldToFuncDeclParams(df, "f", intField, c.pos))
buf = printToBuf(df)
assertCodesEqual(t, expected, buf.String())
}
})
t.Run("add field to pos", func(t *testing.T) {
var src = `
package main
func f(b float, c bool, d string) {}
`
var expectedTemplate = `
package main
func f(%s) {}
`
intField := &dst.Field{
Names: []*dst.Ident{dst.NewIdent("a")},
Type: dst.NewIdent("int"),
}
cases := []struct {
expectedFields string
pos int
}{
{"a int, b float, c bool, d string", 0},
{"b float, a int, c bool, d string", 1},
{"b float, c bool, a int, d string", 2},
{"b float, c bool, d string, a int", 3},
{"b float, c bool, d string, a int", -1},
}
for _, c := range cases {
var buf *bytes.Buffer
expected := fmt.Sprintf(expectedTemplate, c.expectedFields)
df, _ := ParseSrcFileFromBytes([]byte(src))
assert.True(t, AddFieldToFuncDeclParams(df, "f", intField, c.pos))
buf = printToBuf(df)
assertCodesEqual(t, expected, buf.String())
}
})
} | explode_data.jsonl/7165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 710
} | [
2830,
3393,
2212,
1877,
1249,
9626,
21629,
4870,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
718,
2070,
311,
4287,
3963,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2405,
2286,
284,
22074,
197,
197,
1722,
1887,
271,
197,
29244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListener_Addr(t *testing.T) {
addr := &net.TCPAddr{
IP: net.IPv4(127, 0, 0, 1),
Port: 443,
Zone: "",
}
l := Listener{listener: mockListener{addr: addr}}
require.Equal(t, addr, l.Addr())
} | explode_data.jsonl/49525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
2743,
21346,
81,
1155,
353,
8840,
836,
8,
341,
53183,
1669,
609,
4711,
836,
7123,
13986,
515,
197,
197,
3298,
25,
256,
4179,
46917,
85,
19,
7,
16,
17,
22,
11,
220,
15,
11,
220,
15,
11,
220,
16,
1326,
197,
98459,
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 TestIssue20730(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("DROP TABLE IF EXISTS tmp;")
tk.MustExec("CREATE TABLE tmp (id int(11) NOT NULL,value int(1) NOT NULL,PRIMARY KEY (id))")
tk.MustExec("INSERT INTO tmp VALUES (1, 1),(2,2),(3,3),(4,4),(5,5)")
tk.MustExec("SET @sum := 10")
tk.MustQuery("SELECT @sum := IF(@sum=20,4,@sum + tmp.value) sum FROM tmp ORDER BY tmp.id").Check(testkit.Rows("11", "13", "16", "20", "4"))
} | explode_data.jsonl/65555 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
42006,
17,
15,
22,
18,
15,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSuspendResumeAfterTemplateNoWait(t *testing.T) {
cancel, controller := newController()
defer cancel()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
// operate the workflow. it should become in a suspended state after
ctx := context.Background()
wf := unmarshalWF(suspendResumeAfterTemplate)
wf, err := wfcset.Create(ctx, wf, metav1.CreateOptions{})
assert.NoError(t, err)
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
wf, err = wfcset.Get(ctx, wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
assert.True(t, util.IsWorkflowSuspended(wf))
// operate again and verify no pods were scheduled
woc = newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
pods, err := listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 0, len(pods.Items))
// don't wait
// operate the workflow. it should have not reached the second step since not enough time passed
woc = newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
pods, err = listPods(woc)
assert.NoError(t, err)
assert.Equal(t, 0, len(pods.Items))
} | explode_data.jsonl/70976 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 407
} | [
2830,
3393,
50,
12758,
28563,
6025,
7275,
2753,
14190,
1155,
353,
8840,
836,
8,
341,
84441,
11,
6461,
1669,
501,
2051,
741,
16867,
9121,
741,
6692,
8316,
746,
1669,
6461,
1418,
69,
2972,
746,
18979,
45926,
73,
53,
16,
7141,
16,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCacheZeroTTL(t *testing.T) {
c := New()
c.minpttl = 0
c.minnttl = 0
c.Next = zeroTTLBackend()
req := new(dns.Msg)
req.SetQuestion("example.org.", dns.TypeA)
ctx := context.TODO()
c.ServeDNS(ctx, &test.ResponseWriter{}, req)
if c.pcache.Len() != 0 {
t.Errorf("Msg with 0 TTL should not have been cached")
}
if c.ncache.Len() != 0 {
t.Errorf("Msg with 0 TTL should not have been cached")
}
} | explode_data.jsonl/39109 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
8233,
17999,
51,
13470,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
741,
1444,
4358,
417,
11544,
284,
220,
15,
198,
1444,
4358,
406,
11544,
284,
220,
15,
198,
1444,
18501,
284,
7168,
51,
13470,
29699,
2822,
24395,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSubmitTaskStateChangeWithoutAttachments(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
client, _, mockSubmitStateClient := NewMockClient(mockCtrl, ec2.NewBlackholeEC2MetadataClient(), nil)
mockSubmitStateClient.EXPECT().SubmitTaskStateChange(&taskSubmitInputMatcher{
ecs.SubmitTaskStateChangeInput{
Cluster: aws.String(configuredCluster),
Task: aws.String("task_arn"),
Reason: aws.String(""),
Status: aws.String("RUNNING"),
},
})
err := client.SubmitTaskStateChange(api.TaskStateChange{
TaskARN: "task_arn",
Status: apitaskstatus.TaskRunning,
})
assert.NoError(t, err, "Unable to submit task state change with no attachments")
} | explode_data.jsonl/61456 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
8890,
6262,
1397,
4072,
26040,
75740,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
2822,
25291,
11,
8358,
7860,
8890,
1397,
2959,
1669,
1532,
11571,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewGroup(t *testing.T) {
type args struct {
app string
onBehalfTenant string
firstScope string
secondScope string
role string
}
tests := []struct {
name string
args args
want *Group
}{
{
name: "plain",
args: args{
app: "kaas",
onBehalfTenant: "all",
firstScope: "mycluster",
secondScope: "myns",
role: "myrole",
},
want: &Group{
AppPrefix: "kaas",
OnBehalfTenant: "all",
FirstScope: "mycluster",
SecondScope: "myns",
Role: "myrole",
},
},
{
name: "encode",
args: args{
app: "kaas",
onBehalfTenant: "all",
firstScope: "my-cluster",
secondScope: "my-ns",
role: "myrole",
},
want: &Group{
AppPrefix: "kaas",
OnBehalfTenant: "all",
FirstScope: "my$cluster",
SecondScope: "my$ns",
Role: "myrole",
},
},
}
grpr := MustNewGrpr(Config{ProviderTenant: "tnnt"})
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
if got := grpr.NewGroup(tt.args.app, tt.args.onBehalfTenant, tt.args.firstScope, tt.args.secondScope, tt.args.role); !reflect.DeepEqual(got, tt.want) {
//nolint:errorlint
t.Errorf("NewGroup() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/79845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 732
} | [
2830,
3393,
3564,
2808,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
28236,
310,
914,
198,
197,
24630,
10021,
3104,
71252,
914,
198,
197,
42190,
10803,
257,
914,
198,
197,
197,
5569,
10803,
262,
914,
198,
197,
197,
5778,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClient_New_NilArgs(t *testing.T) {
rng := test.Prng(t)
id := wtest.NewRandomAddress(rng)
backend := &ctest.MockBackend{}
b, f, a, w := &DummyBus{t}, backend, backend, wtest.RandomWallet()
assert.Panics(t, func() { client.New(nil, b, f, a, w) })
assert.Panics(t, func() { client.New(id, nil, f, a, w) })
assert.Panics(t, func() { client.New(id, b, nil, a, w) })
assert.Panics(t, func() { client.New(id, b, f, nil, w) })
assert.Panics(t, func() { client.New(id, b, f, a, nil) })
} | explode_data.jsonl/2341 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 222
} | [
2830,
3393,
2959,
39582,
1604,
321,
4117,
1155,
353,
8840,
836,
8,
341,
7000,
968,
1669,
1273,
17947,
968,
1155,
340,
15710,
1669,
289,
1944,
7121,
13999,
4286,
87597,
340,
197,
20942,
1669,
609,
67880,
24664,
29699,
16094,
2233,
11,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRpc_GenerateTokenAddress(t *testing.T) {
err := client.Connect()
if err != nil {
t.Fatalf("error %s", err.Error())
}
resp, err := client.Gc.GenerateTokenAddress(context.Background(), &GenerateTokenReq{
Network: "mainnet",
Address: "FMejc9bjiTeQzKQG9fSDPGdsRzzEdEQe6se",
Abbr: "ANBJ",
})
if err != nil {
t.Fatalf("error %s", err.Error())
}
if bytes.Compare(resp.Result, []byte("FTgeasx9fmkEiVu69xr56hC9c1QTv4rKM8e")) != 0 {
t.Fatal("error")
}
} | explode_data.jsonl/35236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 225
} | [
2830,
3393,
60248,
2646,
13220,
3323,
4286,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
2943,
43851,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
1018,
82,
497,
1848,
6141,
2398,
197,
532,
34653,
11,
1848,
1669,
2943,
122... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSeverity(t *testing.T) {
t.Run("should return critical vulnerability", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "10.0",
}
assert.Equal(t, severities.Critical, vulnerability.getSeverity())
})
t.Run("should return high vulnerability", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "8.0",
}
assert.Equal(t, severities.High, vulnerability.getSeverity())
})
t.Run("should return medium vulnerability", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "6.0",
}
assert.Equal(t, severities.Medium, vulnerability.getSeverity())
})
t.Run("should return low vulnerability", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "2.0",
}
assert.Equal(t, severities.Low, vulnerability.getSeverity())
})
t.Run("should return unknown vulnerability", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "0",
}
assert.Equal(t, severities.Unknown, vulnerability.getSeverity())
})
t.Run("should return unknown vulnerability when failed to parse score", func(t *testing.T) {
vulnerability := nancyVulnerability{
CvssScore: "test",
}
assert.Equal(t, severities.Unknown, vulnerability.getSeverity())
})
} | explode_data.jsonl/39591 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 461
} | [
2830,
3393,
1949,
65594,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5445,
470,
9023,
33004,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
5195,
58401,
2897,
1669,
308,
6572,
53,
58401,
2897,
515,
298,
6258,
85,
778,
10570,
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 TestAcceptTimeout(t *testing.T) {
testenv.SkipFlaky(t, 17948)
t.Parallel()
switch runtime.GOOS {
case "plan9":
t.Skipf("not supported on %s", runtime.GOOS)
}
ln := newLocalListener(t, "tcp")
defer ln.Close()
var wg sync.WaitGroup
for i, tt := range acceptTimeoutTests {
if tt.timeout < 0 {
wg.Add(1)
go func() {
defer wg.Done()
d := Dialer{Timeout: 100 * time.Millisecond}
c, err := d.Dial(ln.Addr().Network(), ln.Addr().String())
if err != nil {
t.Error(err)
return
}
c.Close()
}()
}
if err := ln.(*TCPListener).SetDeadline(time.Now().Add(tt.timeout)); err != nil {
t.Fatalf("$%d: %v", i, err)
}
for j, xerr := range tt.xerrs {
for {
c, err := ln.Accept()
if xerr != nil {
if perr := parseAcceptError(err); perr != nil {
t.Errorf("#%d/%d: %v", i, j, perr)
}
if !isDeadlineExceeded(err) {
t.Fatalf("#%d/%d: %v", i, j, err)
}
}
if err == nil {
c.Close()
time.Sleep(10 * time.Millisecond)
continue
}
break
}
}
}
wg.Wait()
} | explode_data.jsonl/77446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 559
} | [
2830,
3393,
16646,
7636,
1155,
353,
8840,
836,
8,
341,
18185,
3160,
57776,
3882,
28100,
1155,
11,
220,
16,
22,
24,
19,
23,
340,
3244,
41288,
7957,
2822,
8961,
15592,
97574,
3126,
341,
2722,
330,
10393,
24,
4660,
197,
3244,
57776,
69,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestOnlyWhitelistedAuthProvidersAccepted(t *testing.T) {
httpHost, _ := url.Parse("localhost")
config := &ServerConfig{
AuthProviders: []goth.Provider{
azuread.New("key", "secret", "localhost:80/callback", nil),
},
HTTPHost: httpHost,
IsDebug: true,
}
testRouter := Router(config)
writer := httptest.NewRecorder()
urls := []string{
"/auth/callback?provider=stripe",
"/auth/authenticate?provider=stripe",
"/auth/logout?provider=stripe",
"/auth/authenticate",
"/auth/logout",
"/auth/callback",
}
for _, url := range urls {
request, err := http.NewRequest("GET", url, nil)
if err != nil {
t.Fatal(err)
}
testRouter.ServeHTTP(writer, request)
if writer.Code != 400 {
t.Fatalf("Expected status code 400 for %v, got %v", url, writer.Code)
}
}
} | explode_data.jsonl/29019 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
7308,
1639,
56643,
13236,
5087,
37351,
65906,
1155,
353,
8840,
836,
8,
341,
28080,
9296,
11,
716,
1669,
2515,
8937,
445,
8301,
1138,
25873,
1669,
609,
5475,
2648,
515,
197,
197,
5087,
37351,
25,
3056,
3346,
339,
36208,
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... | 4 |
func TestPanicHandling(t *testing.T) {
// v8 runtime can register its own signal handlers which would interfere
// with Go's signal handlers which are needed for panic handling
defer func() {
if r := recover(); r != nil {
// if we reach this point, Go's panic mechanism is still intact
_, ok := r.(runtime.Error)
if !ok {
t.Errorf("expected runtime error, actual %v", r)
}
}
}()
var f *big.Float
_ = NewIsolate()
_ = *f
} | explode_data.jsonl/81594 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
47,
31270,
38606,
1155,
353,
8840,
836,
8,
341,
197,
322,
348,
23,
15592,
646,
4161,
1181,
1828,
8286,
24083,
892,
1035,
39878,
198,
197,
322,
448,
5994,
594,
8286,
24083,
892,
525,
4362,
369,
21975,
11589,
198,
16867,
291... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetMaxUnhealthy(t *testing.T) {
testCases := []struct {
name string
maxUnhealthy *intstr.IntOrString
expectedMaxUnhealthy int
expectedMachines int
expectedErr error
}{
{
name: "when maxUnhealthy is nil",
maxUnhealthy: nil,
expectedMaxUnhealthy: 7,
expectedMachines: 7,
expectedErr: nil,
},
{
name: "when maxUnhealthy is not an int or percentage",
maxUnhealthy: &intstr.IntOrString{Type: intstr.String, StrVal: "abcdef"},
expectedMaxUnhealthy: 0,
expectedMachines: 3,
expectedErr: errors.New("invalid value for IntOrString: invalid value \"abcdef\": strconv.Atoi: parsing \"abcdef\": invalid syntax"),
},
{
name: "when maxUnhealthy is an int",
maxUnhealthy: &intstr.IntOrString{Type: intstr.Int, IntVal: 3},
expectedMachines: 2,
expectedMaxUnhealthy: 3,
expectedErr: nil,
},
{
name: "when maxUnhealthy is a 40% (of 5)",
maxUnhealthy: &intstr.IntOrString{Type: intstr.String, StrVal: "40%"},
expectedMachines: 5,
expectedMaxUnhealthy: 2,
expectedErr: nil,
},
{
name: "when maxUnhealthy is a 60% (of 7)",
maxUnhealthy: &intstr.IntOrString{Type: intstr.String, StrVal: "60%"},
expectedMachines: 7,
expectedMaxUnhealthy: 4,
expectedErr: nil,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
g := NewWithT(t)
mhc := &mapiv1beta1.MachineHealthCheck{
Spec: mapiv1beta1.MachineHealthCheckSpec{
MaxUnhealthy: tc.maxUnhealthy,
},
Status: mapiv1beta1.MachineHealthCheckStatus{
ExpectedMachines: &tc.expectedMachines,
},
}
maxUnhealthy, err := getMaxUnhealthy(mhc)
if tc.expectedErr != nil {
g.Expect(err).To(Equal(tc.expectedErr))
} else {
g.Expect(err).ToNot(HaveOccurred())
}
g.Expect(maxUnhealthy).To(Equal(tc.expectedMaxUnhealthy))
})
}
} | explode_data.jsonl/31011 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1000
} | [
2830,
3393,
1949,
5974,
1806,
37028,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
22543,
1806,
37028,
260,
353,
396,
495,
7371,
2195,
703,
198,
197,
42400,
5974,
1806,
37028,
526,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetVersionsHelm(t *testing.T) {
// Ensure a clean environment.
tests := []struct {
Name string
Path string
ResponseBody string
ExpectedErr string
ExpectedVer string
}{
{
"RC releases are skipped",
"/rcs_are_skiipped",
`apiVersion: v1
entries:
dapr:
- apiVersion: v1
appVersion: 1.2.3-rc.1
created: "2021-06-17T03:13:24.179849371Z"
description: A Helm chart for Dapr on Kubernetes
digest: 60d8d17b58ca316cdcbdb8529cf9ba2c9e2e0834383c677cafbf99add86ee7a0
name: dapr
urls:
- https://dapr.github.io/helm-charts/dapr-1.2.3-rc.1.tgz
version: 1.2.3-rc.1
- apiVersion: v1
appVersion: 1.2.2
created: "2021-06-17T03:13:24.179849371Z"
description: A Helm chart for Dapr on Kubernetes
digest: 60d8d17b58ca316cdcbdb8529cf9ba2c9e2e0834383c677cafbf99add86ee7a0
name: dapr
urls:
- https://dapr.github.io/helm-charts/dapr-1.2.2.tgz
version: 1.2.2 `,
"",
"1.2.2",
},
{
"Malformed YAML",
"/malformed",
"[",
"yaml: line 1: did not find expected node content",
"",
},
{
"Empty YAML",
"/empty",
"",
"no releases",
"",
},
{
"Only RCs",
"/only_rcs",
`apiVersion: v1
entries:
dapr:
- apiVersion: v1
appVersion: 1.2.3-rc.1
created: "2021-06-17T03:13:24.179849371Z"
description: A Helm chart for Dapr on Kubernetes
digest: 60d8d17b58ca316cdcbdb8529cf9ba2c9e2e0834383c677cafbf99add86ee7a0
name: dapr
urls:
- https://dapr.github.io/helm-charts/dapr-1.2.3-rc.1.tgz
version: 1.2.3-rc.1 `,
"no releases",
"",
},
}
m := http.NewServeMux()
s := http.Server{Addr: ":12346", Handler: m}
for _, tc := range tests {
body := tc.ResponseBody
m.HandleFunc(tc.Path, func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, body)
})
}
go func() {
s.ListenAndServe()
}()
for _, tc := range tests {
t.Run(tc.Name, func(t *testing.T) {
version, err := GetLatestReleaseHelmChart(fmt.Sprintf("http://localhost:12346%s", tc.Path))
assert.Equal(t, tc.ExpectedVer, version)
if tc.ExpectedErr != "" {
assert.EqualError(t, err, tc.ExpectedErr)
}
})
}
s.Shutdown(context.Background())
} | explode_data.jsonl/11968 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1117
} | [
2830,
3393,
1949,
69015,
39,
23162,
1155,
353,
8840,
836,
8,
341,
197,
322,
29279,
264,
4240,
4573,
382,
78216,
1669,
3056,
1235,
341,
197,
21297,
260,
914,
198,
197,
69640,
260,
914,
198,
197,
197,
29637,
914,
198,
197,
197,
18896,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.