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 TestRoutes(t *testing.T) {
assert.IsType(t, Routes{}, routes, "Unexpected type of routes")
assert.Len(t, routes, 4, "Unexpected number of routes")
assert.Equal(t, "Index", routes[0].Name, "Unexpected route name")
assert.Equal(t, "AddEvent", routes[1].Name, "Unexpected route name")
assert.Equal(t, "RemoveEvent", routes[2].Name, "Unexpected route name")
assert.Equal(t, "Recommend", routes[3].Name, "Unexpected route name")
} | explode_data.jsonl/63800 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 154
} | [
2830,
3393,
26653,
1155,
353,
8840,
836,
8,
341,
6948,
4506,
929,
1155,
11,
22356,
22655,
11291,
11,
330,
29430,
943,
315,
11291,
1138,
6948,
65819,
1155,
11,
11291,
11,
220,
19,
11,
330,
29430,
1372,
315,
11291,
1138,
6948,
12808,
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 TestAskStreamSendReceiveAskResponse(t *testing.T) {
ctx := context.Background()
testCases := map[string]struct {
senderDisabledNew bool
receiverDisabledNew bool
}{
"both clients current version": {},
"sender old supports old queries": {
senderDisabledNew: true,
},
"receiver only supports old queries": {
receiverDisabledNew: true,
},
}
for testCase, data := range testCases {
t.Run(testCase, func(t *testing.T) {
td := shared_testutil.NewLibp2pTestData(ctx, t)
var fromNetwork, toNetwork network.StorageMarketNetwork
if data.senderDisabledNew {
fromNetwork = network.NewFromLibp2pHost(td.Host1, network.SupportedAskProtocols([]protocol.ID{storagemarket.OldAskProtocolID}))
} else {
fromNetwork = network.NewFromLibp2pHost(td.Host1)
}
if data.receiverDisabledNew {
toNetwork = network.NewFromLibp2pHost(td.Host2, network.SupportedAskProtocols([]protocol.ID{storagemarket.OldAskProtocolID}))
} else {
toNetwork = network.NewFromLibp2pHost(td.Host2)
}
toHost := td.Host2.ID()
// host1 gets no-op receiver
tr := &testReceiver{t: t}
require.NoError(t, fromNetwork.SetDelegate(tr))
// host2 gets receiver
achan := make(chan network.AskResponse)
tr2 := &testReceiver{t: t, askStreamHandler: func(s network.StorageAskStream) {
a, _, err := s.ReadAskResponse()
require.NoError(t, err)
achan <- a
}}
require.NoError(t, toNetwork.SetDelegate(tr2))
assertAskResponseReceived(ctx, t, fromNetwork, toHost, achan)
})
}
} | explode_data.jsonl/19990 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 609
} | [
2830,
3393,
26172,
3027,
11505,
14742,
26172,
2582,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
1903,
1659,
25907,
3564,
256,
1807,
198,
197,
17200,
12862,
25907,
3564... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRestartKillWait(t *testing.T) {
eng := NewTestEngine(t)
runtime := mkDaemonFromEngine(eng, t)
defer runtime.Nuke()
config, hostConfig, _, err := parseRun([]string{"-i", unitTestImageID, "/bin/cat"}, nil)
if err != nil {
t.Fatal(err)
}
id := createTestContainer(eng, config, t)
job := eng.Job("containers")
job.SetenvBool("all", true)
outs, err := job.Stdout.AddListTable()
if err != nil {
t.Fatal(err)
}
if err := job.Run(); err != nil {
t.Fatal(err)
}
if len(outs.Data) != 1 {
t.Errorf("Expected 1 container, %v found", len(outs.Data))
}
job = eng.Job("start", id)
if err := job.ImportEnv(hostConfig); err != nil {
t.Fatal(err)
}
if err := job.Run(); err != nil {
t.Fatal(err)
}
job = eng.Job("kill", id)
if err := job.Run(); err != nil {
t.Fatal(err)
}
eng = newTestEngine(t, false, runtime.Config().Root)
job = eng.Job("containers")
job.SetenvBool("all", true)
outs, err = job.Stdout.AddListTable()
if err != nil {
t.Fatal(err)
}
if err := job.Run(); err != nil {
t.Fatal(err)
}
if len(outs.Data) != 1 {
t.Errorf("Expected 1 container, %v found", len(outs.Data))
}
setTimeout(t, "Waiting on stopped container timedout", 5*time.Second, func() {
job = eng.Job("wait", outs.Data[0].Get("Id"))
if err := job.Run(); err != nil {
t.Fatal(err)
}
})
} | explode_data.jsonl/31467 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 566
} | [
2830,
3393,
59354,
53734,
14190,
1155,
353,
8840,
836,
8,
341,
197,
826,
1669,
1532,
2271,
4571,
1155,
340,
7000,
4466,
1669,
23789,
89177,
3830,
4571,
7,
826,
11,
259,
340,
16867,
15592,
2067,
10430,
2822,
25873,
11,
3468,
2648,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestExtractRegistryFromUrl(t *testing.T) {
registries := [][]string{
// Ok, should work
{"http://core.harbor.domain:8080", "core.harbor.domain:8080"},
{"https://core.harbor.domain:8080", "core.harbor.domain:8080"},
{"https://core.harbor.domain", "core.harbor.domain"},
{"https://core.harbor.domain/path/v1/", "core.harbor.domain"},
// These fail since no scheme.
{"core.harbor.domain", ""},
{"core.harbor.domain:8080", ""},
}
for _, r := range registries {
expected := r[1]
input := r[0]
got, err := ExtractRegistryFromUrl(input)
if err != nil {
if expected != "" {
t.Errorf("error on %v: %v", input, err)
} else {
t.Log("got expected error on input", input)
}
} else if got != expected {
t.Errorf("Expected %v, Got %v", r[1], got)
}
}
return
} | explode_data.jsonl/71412 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
28959,
15603,
3830,
2864,
1155,
353,
8840,
836,
8,
341,
37013,
380,
4019,
1669,
52931,
917,
515,
197,
197,
322,
7622,
11,
1265,
975,
198,
197,
197,
4913,
1254,
1110,
2153,
86455,
9368,
11003,
25,
23,
15,
23,
15,
497,
330... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTelemetryDefaultToVLabs(t *testing.T) {
cs := getDefaultContainerService()
vlabsCS := ConvertContainerServiceToVLabs(cs)
if vlabsCS == nil {
t.Errorf("expected the converted containerService struct to be non-nil")
}
if vlabsCS.Properties.FeatureFlags.EnableTelemetry {
t.Errorf("expected the EnableTelemetry feature flag to be false")
}
} | explode_data.jsonl/34 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
6639,
35958,
3675,
1249,
30698,
3435,
1155,
353,
8840,
836,
8,
341,
71899,
1669,
69106,
4502,
1860,
741,
5195,
70271,
6412,
1669,
7169,
4502,
1860,
1249,
30698,
3435,
41153,
340,
743,
41136,
3435,
6412,
621,
2092,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSnatPortExhausted(t *testing.T) {
tempdir, err := ioutil.TempDir("", "hostagent_test_")
if err != nil {
panic(err)
}
defer os.RemoveAll(tempdir)
agent := testAgent()
agent.config.OpFlexSnatDir = tempdir
agent.config.OpFlexEndpointDir = tempdir
agent.config.OpFlexServiceDir = tempdir
agent.config.UplinkIface = "eth10"
agent.config.NodeName = "test-node"
agent.config.ServiceVlan = 4003
agent.config.UplinkMacAdress = "5a:fd:16:e5:e7:c0"
agent.run()
for _, pt := range podTests {
pod := pod(pt.uuid, pt.namespace, pt.name, pt.eg, pt.sg, pt.qp)
cnimd := cnimd(pt.namespace, pt.name, pt.ip, pt.cont, pt.veth)
agent.epMetadata[pt.namespace+"/"+pt.name] =
map[string]*metadata.ContainerMetadata{
cnimd.Id.ContId: cnimd,
}
agent.fakePodSource.Add(pod)
}
time.Sleep(1000 * time.Millisecond)
for _, pt := range snatpolices {
snatObj := snatpolicydata(pt.name, pt.namespace, pt.snatip, pt.destip, pt.labels)
agent.fakeSnatPolicySource.Add(snatObj)
agent.log.Info("Snat Obj Created #### ", snatObj)
}
time.Sleep(1000 * time.Millisecond)
policy := &snatpolicy.SnatPolicy{
Spec: snatpolicy.SnatPolicySpec{
SnatIp: []string{"172.12.12.11/24"},
DestIp: []string{"100.100.100.100/24"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "policy1",
},
Status: snatpolicy.SnatPolicyStatus{
State: snatpolicy.IpPortsExhausted,
},
}
// set the globalinfo for other node, and port exhausted for policy1
var newglobal []snatglobal.GlobalInfo
var snatglobalinfo *snatglobal.SnatGlobalInfo
var globalinfo snatglobal.GlobalInfo
portrange := make([]snatglobal.PortRange, 1)
portrange[0].Start = 5000
portrange[0].End = 8000
globalinfo.MacAddress = "01:02:03:04"
globalinfo.SnatIp = "192.128.1.1"
globalinfo.SnatIpUid = "policy1-uid"
globalinfo.PortRanges = portrange
globalinfo.SnatPolicyName = "policy1"
newglobal = append(newglobal, globalinfo)
snatglobalinfo = snatglobaldata("policy1-uid", "snatglobalinfo", "test-node-1", "testns", newglobal)
agent.fakeSnatGlobalSource.Add(snatglobalinfo)
time.Sleep(1000 * time.Millisecond)
// modify the policy with port exhaused
agent.fakeSnatPolicySource.Modify(policy)
time.Sleep(1000 * time.Millisecond)
agent.log.Info("SnatLocal Info #### ", agent.snatPods)
// check the policy is deleted from local information as ip/port is not allocated
_, ok := agent.snatPods["policy1"]
assert.Equal(t, true, ok, "create", "Epfile", "uids")
agent.stop()
} | explode_data.jsonl/22816 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 995
} | [
2830,
3393,
20720,
266,
7084,
840,
15074,
291,
1155,
353,
8840,
836,
8,
341,
16280,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
3790,
8092,
4452,
62,
1138,
743,
1848,
961,
2092,
341,
197,
30764,
3964,
340,
197,
532,
16867,
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... | 4 |
func TestConfig_URLRetries3Fails(t *testing.T) {
httpLoadConfigRetryInterval = 0 * time.Second
responseCounter := 0
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
responseCounter++
}))
defer ts.Close()
expected := fmt.Sprintf("Error loading config file %s: Retry 3 of 3 failed to retrieve remote config: 404 Not Found", ts.URL)
c := NewConfig()
err := c.LoadConfig(ts.URL)
require.Error(t, err)
require.Equal(t, expected, err.Error())
require.Equal(t, 4, responseCounter)
} | explode_data.jsonl/72177 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 199
} | [
2830,
3393,
2648,
8000,
12020,
4019,
18,
37,
6209,
1155,
353,
8840,
836,
8,
341,
28080,
5879,
2648,
51560,
10256,
284,
220,
15,
353,
882,
32435,
198,
21735,
14099,
1669,
220,
15,
198,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHappys(t *testing.T) {
happys := gomath.Happys(100)
checkInfInt64Stream(
t,
happys,
100, 103, 109, 129, 130, 133, 139, 167, 176, 188)
} | explode_data.jsonl/23246 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
39,
676,
1047,
1155,
353,
8840,
836,
8,
341,
9598,
676,
1047,
1669,
342,
316,
587,
3839,
676,
1047,
7,
16,
15,
15,
340,
25157,
19433,
1072,
21,
19,
3027,
1006,
197,
3244,
345,
197,
9598,
676,
1047,
345,
197,
197,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVolumeGCStrategy(t *testing.T) {
tests := []struct {
name string
strategy wfv1.VolumeClaimGCStrategy
phase wfv1.NodePhase
expectedVolumesRemaining int
}{{
name: "failed/OnWorkflowCompletion",
strategy: wfv1.VolumeClaimGCOnCompletion,
phase: wfv1.NodeFailed,
expectedVolumesRemaining: 0,
}, {
name: "failed/OnWorkflowSuccess",
strategy: wfv1.VolumeClaimGCOnSuccess,
phase: wfv1.NodeFailed,
expectedVolumesRemaining: 1,
}, {
name: "succeeded/OnWorkflowSuccess",
strategy: wfv1.VolumeClaimGCOnSuccess,
phase: wfv1.NodeSucceeded,
expectedVolumesRemaining: 0,
}, {
name: "succeeded/OnWorkflowCompletion",
strategy: wfv1.VolumeClaimGCOnCompletion,
phase: wfv1.NodeSucceeded,
expectedVolumesRemaining: 0,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
wf := unmarshalWF(makeVolumeGcStrategyTemplate(tt.strategy, tt.phase))
cancel, controller := newController(wf)
defer cancel()
ctx := context.Background()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
woc := newWorkflowOperationCtx(wf, controller)
woc.operate(ctx)
wf, err := wfcset.Get(ctx, wf.ObjectMeta.Name, metav1.GetOptions{})
if assert.NoError(t, err) {
assert.Len(t, wf.Status.PersistentVolumeClaims, tt.expectedVolumesRemaining)
}
})
}
} | explode_data.jsonl/70949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 836
} | [
2830,
3393,
18902,
22863,
19816,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
3824,
914,
198,
197,
11355,
10228,
338,
289,
27890,
16,
79106,
45544,
22863,
19816,
198,
197,
197,
25141,
503,
289,
27890,
16,
2171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateTLSCert(t *testing.T) {
readFile := func(path string) []byte {
fName := filepath.Join("testdata", "dynamic_cert_update", path)
data, err := ioutil.ReadFile(fName)
if err != nil {
panic(fmt.Errorf("Failed reading %s: %v", fName, err))
}
return data
}
loadBytes := func(prefix string) (key, cert, caCert []byte) {
cert = readFile(filepath.Join(prefix, "server.crt"))
key = readFile(filepath.Join(prefix, "server.key"))
caCert = readFile(filepath.Join("ca.crt"))
return
}
key, cert, caCert := loadBytes("notlocalhost")
cfg := comm.ServerConfig{
SecOpts: &comm.SecureOptions{
UseTLS: true,
Key: key,
Certificate: cert,
},
}
srv, err := comm.NewGRPCServer("localhost:8333", cfg)
assert.NoError(t, err)
testpb.RegisterTestServiceServer(srv.Server(), &testServiceServer{})
go srv.Start()
defer srv.Stop()
certPool := x509.NewCertPool()
certPool.AppendCertsFromPEM(caCert)
probeServer := func() error {
_, err = invokeEmptyCall("localhost:8333",
[]grpc.DialOption{grpc.WithTransportCredentials(
credentials.NewTLS(&tls.Config{
RootCAs: certPool})),
grpc.WithBlock()})
return err
}
// bootstrap TLS certificate has a SAN of "notlocalhost" so it should fail
err = probeServer()
assert.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")
// new TLS certificate has a SAN of "localhost" so it should succeed
certPath := filepath.Join("testdata", "dynamic_cert_update", "localhost", "server.crt")
keyPath := filepath.Join("testdata", "dynamic_cert_update", "localhost", "server.key")
tlsCert, err := tls.LoadX509KeyPair(certPath, keyPath)
assert.NoError(t, err)
srv.SetServerCertificate(tlsCert)
err = probeServer()
assert.NoError(t, err)
// revert back to the old certificate, should fail.
certPath = filepath.Join("testdata", "dynamic_cert_update", "notlocalhost", "server.crt")
keyPath = filepath.Join("testdata", "dynamic_cert_update", "notlocalhost", "server.key")
tlsCert, err = tls.LoadX509KeyPair(certPath, keyPath)
assert.NoError(t, err)
srv.SetServerCertificate(tlsCert)
err = probeServer()
assert.Error(t, err)
assert.Contains(t, err.Error(), "context deadline exceeded")
} | explode_data.jsonl/38634 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 841
} | [
2830,
3393,
4289,
13470,
3540,
529,
1155,
353,
8840,
836,
8,
341,
37043,
1703,
1669,
2915,
5581,
914,
8,
3056,
3782,
341,
197,
1166,
675,
1669,
26054,
22363,
445,
92425,
497,
330,
21544,
37097,
8882,
497,
1815,
340,
197,
8924,
11,
184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRDSHTTPProxyDuplicateIncludeConditions(t *testing.T) {
rh, c, done := setup(t)
defer done()
svc1 := fixture.NewService("kuard").
WithPorts(v1.ServicePort{Name: "http", Port: 8080, TargetPort: intstr.FromInt(8080)})
rh.OnAdd(svc1)
svc2 := fixture.NewService("teama/kuard").
WithPorts(v1.ServicePort{Name: "http", Port: 8080, TargetPort: intstr.FromInt(8080)})
rh.OnAdd(svc2)
svc3 := fixture.NewService("teamb/kuard").
WithPorts(v1.ServicePort{Name: "http", Port: 8080, TargetPort: intstr.FromInt(8080)})
rh.OnAdd(svc3)
proxyRoot := &projcontour.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: "root",
Namespace: svc1.Namespace,
},
Spec: projcontour.HTTPProxySpec{
VirtualHost: &projcontour.VirtualHost{
Fqdn: "example.com",
},
Includes: []projcontour.Include{{
Name: "blogteama",
Namespace: "teama",
Conditions: []projcontour.MatchCondition{{
Prefix: "/blog",
Header: &projcontour.HeaderMatchCondition{
Name: "x-header",
Contains: "abc",
},
}},
}, {
Name: "blogteama",
Namespace: "teamb",
Conditions: []projcontour.MatchCondition{{
Prefix: "/blog",
Header: &projcontour.HeaderMatchCondition{
Name: "x-header",
Contains: "abc",
},
}},
}},
Routes: []projcontour.Route{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Name: svc1.Name,
Port: 8080,
}},
}},
},
}
proxyChildA := &projcontour.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: "blogteama",
Namespace: "teama",
},
Spec: projcontour.HTTPProxySpec{
Routes: []projcontour.Route{{
Services: []projcontour.Service{{
Name: svc2.Name,
Port: 8080,
}},
}},
},
}
proxyChildB := &projcontour.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: "blogteamb",
Namespace: "teamb",
},
Spec: projcontour.HTTPProxySpec{
Routes: []projcontour.Route{{
Services: []projcontour.Service{{
Name: svc3.Name,
Port: 8080,
}},
}},
},
}
rh.OnAdd(proxyRoot)
rh.OnAdd(proxyChildA)
rh.OnAdd(proxyChildB)
c.Request(routeType).Equals(&v2.DiscoveryResponse{
VersionInfo: "2",
Resources: routeResources(t,
envoy.RouteConfiguration("ingress_http"),
),
TypeUrl: routeType,
Nonce: "2",
})
} | explode_data.jsonl/24124 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1128
} | [
2830,
3393,
49,
5936,
9230,
16219,
53979,
22283,
35435,
1155,
353,
8840,
836,
8,
341,
7000,
71,
11,
272,
11,
2814,
1669,
6505,
1155,
340,
16867,
2814,
2822,
1903,
7362,
16,
1669,
12507,
7121,
1860,
445,
74,
11034,
38609,
197,
197,
235... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestICodeApi_ExecuteRequest(t *testing.T) {
savePath := os.Getenv("GOPATH") + "/src/github.com/it-chain/engine/.tmp/"
defer os.RemoveAll(savePath)
sshPath := "./id_rsa"
err, tearDown1 := generatePriKey(sshPath)
assert.NoError(t, err)
defer tearDown1()
api, _ := setUp(t)
icode, err := api.Deploy(savePath, "github.com/junbeomlee/learn-icode", sshPath, "")
defer api.UnDeploy(icode.ID)
result, err := api.ExecuteRequest(ivm.Request{
ICodeID: icode.ID,
Function: "initA",
Type: "invoke",
Args: []string{},
})
assert.NoError(t, err)
assert.Equal(t, result.Err, "")
} | explode_data.jsonl/9676 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 260
} | [
2830,
3393,
1317,
534,
6563,
83453,
1900,
1155,
353,
8840,
836,
8,
341,
49230,
1820,
1669,
2643,
64883,
445,
98733,
4827,
899,
488,
3521,
3548,
71120,
905,
14,
275,
65186,
82045,
11930,
5173,
29555,
16867,
2643,
84427,
33546,
1820,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStepper_Descend(t *testing.T) {
st := Stepper{
N: 1,
U: Unum,
}
rng, err := st.Descend(100, 3)
assert.NoError(t, err)
var vals []int
for rng.HasNext() {
vals = append(vals, rng.Next().(int))
}
assert.Equal(t, []int{100, 99, 98}, vals)
} | explode_data.jsonl/78070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
20903,
6922,
92957,
408,
1155,
353,
8840,
836,
8,
341,
18388,
1669,
3360,
6922,
515,
197,
18317,
25,
220,
16,
345,
197,
15980,
25,
1230,
372,
345,
197,
630,
7000,
968,
11,
1848,
1669,
357,
68428,
408,
7,
16,
15,
15,
11... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUtil_Test_GetServiceEnvVar(t *testing.T) {
assert.Equal(t, GetServiceEnvVar("SERVICE_HOST"), "KEYCLOAK_POSTGRESQL_SERVICE_HOST")
assert.Equal(t, GetServiceEnvVar("SERVICE_PORT"), "KEYCLOAK_POSTGRESQL_SERVICE_PORT")
} | explode_data.jsonl/28514 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
2742,
32541,
13614,
1860,
14359,
3962,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
2126,
1860,
14359,
3962,
445,
65075,
17213,
3975,
330,
4784,
34,
1593,
11907,
20506,
57063,
6688,
21590,
17213,
1138,
6948,
12808,
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 |
func TestRESTClientPodCPUEmptyMetrics(t *testing.T) {
tc := restClientTestCase{
resourceName: v1.ResourceCPU,
desiredError: fmt.Errorf("no metrics returned from resource metrics API"),
reportedMetricPoints: []metricPoint{},
reportedPodMetrics: []map[string]int64{},
}
tc.runTest(t)
} | explode_data.jsonl/64906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
38307,
2959,
23527,
7123,
2230,
76,
1595,
27328,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
2732,
2959,
16458,
515,
197,
50346,
675,
25,
260,
348,
16,
20766,
31615,
345,
197,
52912,
2690,
1454,
25,
260,
8879,
13080,
445,
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 TestSortLesserWithNaNs(t *testing.T) {
actual := []float64{ 5.0, 4.1, math.NaN(), 8.6, 0.1 }
expected := []float64{ 0.1, 4.1, 5.0, 8.6, math.NaN() }
sort.Slice(actual, func(i, j int) bool {
return LesserWithNaNs(actual[i], actual[j])
})
test.EqualsWithNans(t, expected, actual)
} | explode_data.jsonl/68392 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
10231,
27451,
261,
2354,
22831,
82,
1155,
353,
8840,
836,
8,
341,
88814,
1669,
3056,
3649,
21,
19,
90,
220,
20,
13,
15,
11,
220,
19,
13,
16,
11,
6888,
78706,
1507,
220,
23,
13,
21,
11,
220,
15,
13,
16,
456,
42400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTxCCInstance(t *testing.T) {
// setup the MSP manager so that we can sign/verify
err := msptesttools.LoadMSPSetupForTesting()
if err != nil {
t.Fatalf("Could not initialize msp, err: %s", err)
}
signer, err := mspmgmt.GetLocalMSP().GetDefaultSigningIdentity()
if err != nil {
t.Fatalf("Could not initialize signer, err: %s", err)
}
chainID := util2.GetTestChainID()
upgradeCCName := "mycc"
upgradeCCVersion := "v1"
env, err := createCCUpgradeEnvelope(chainID, upgradeCCName, upgradeCCVersion, signer)
assert.NoError(t, err)
// get the payload from the envelope
payload, err := protoutil.GetPayload(env)
assert.NoError(t, err)
expectInvokeCCIns := &sysccprovider.ChaincodeInstance{
ChainID: chainID,
ChaincodeName: "lscc",
ChaincodeVersion: "",
}
expectUpgradeCCIns := &sysccprovider.ChaincodeInstance{
ChainID: chainID,
ChaincodeName: upgradeCCName,
ChaincodeVersion: upgradeCCVersion,
}
tValidator := &TxValidator{}
invokeCCIns, upgradeCCIns, err := tValidator.getTxCCInstance(payload)
if err != nil {
t.Fatalf("Get chaincode from tx error: %s", err)
}
assert.EqualValues(t, expectInvokeCCIns, invokeCCIns)
assert.EqualValues(t, expectUpgradeCCIns, upgradeCCIns)
} | explode_data.jsonl/5165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 477
} | [
2830,
3393,
1949,
31584,
3706,
2523,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
279,
68373,
6645,
773,
429,
582,
646,
1841,
14,
12446,
198,
9859,
1669,
9829,
70334,
15918,
13969,
44,
4592,
21821,
2461,
16451,
741,
743,
1848,
961,
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... | 4 |
func TestWithMethod(t *testing.T) {
r, _ := Prepare(mocks.NewRequest(), WithMethod("HEAD"))
if r.Method != "HEAD" {
t.Fatal("autorest: WithMethod failed to set HTTP method header")
}
} | explode_data.jsonl/20952 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 72
} | [
2830,
3393,
2354,
3523,
1155,
353,
8840,
836,
8,
972,
7000,
11,
716,
1669,
31166,
1255,
25183,
75274,
1507,
3085,
3523,
445,
35433,
26043,
743,
435,
20798,
961,
330,
35433,
1,
972,
197,
3244,
26133,
445,
2717,
41419,
25,
3085,
3523,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestRegister(t *testing.T) {
Convey("Given topic, channel, maxInflight and message handler method", t, func() {
Convey("It should not produce any error", func() {
err := Register(topic, channel, maxInFlight, mgsHandle)
So(err, ShouldEqual, nil)
})
})
Convey("Given wrong topic, channel", t, func() {
Convey("It should produce an error", func() {
err := Register("", "", maxInFlight, mgsHandle)
So(err, ShouldNotEqual, nil)
})
})
} | explode_data.jsonl/5601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
8690,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
8544,
11,
5496,
11,
1932,
641,
38390,
323,
1943,
7013,
1714,
497,
259,
11,
2915,
368,
341,
197,
93070,
5617,
445,
2132,
1265,
537,
8193,
894,
1465,
497,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAPIAbortMultipartHandler(t *testing.T) {
defer DetectTestLeak(t)()
ExecObjectLayerAPITest(t, testAPIAbortMultipartHandler, []string{"AbortMultipart"})
} | explode_data.jsonl/10706 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
7082,
85891,
44,
18204,
3050,
1155,
353,
8840,
836,
8,
341,
16867,
33287,
2271,
2304,
585,
1155,
8,
741,
197,
10216,
1190,
9188,
2537,
952,
477,
1155,
11,
1273,
7082,
85891,
44,
18204,
3050,
11,
3056,
917,
4913,
85891,
44,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAliasWriter(t *testing.T) {
for caseNum, currCase := range []struct {
pkg string
name string
aliases []spec.AliasDefinition
want string
}{
{
pkg: "testpkg",
name: "single string alias",
aliases: []spec.AliasDefinition{
{
TypeName: spec.TypeName{
Name: "Month",
Package: "api",
},
Docs: docPtr("These represent months"),
Alias: spec.NewTypeFromPrimitive(spec.PrimitiveTypeString),
},
},
want: `package testpkg
// These represent months
type Month string
`,
},
{
pkg: "testpkg",
name: "single optional string alias",
aliases: []spec.AliasDefinition{
{
TypeName: spec.TypeName{
Name: "Month",
Package: "api",
},
Docs: docPtr("These represent months"),
Alias: spec.NewTypeFromOptional(spec.OptionalType{
ItemType: spec.NewTypeFromPrimitive(spec.PrimitiveTypeString),
}),
},
},
want: `package testpkg
// These represent months
type Month struct {
Value *string
}
func (a Month) MarshalText() ([]byte, error) {
if a.Value == nil {
return nil, nil
}
return []byte(*a.Value), nil
}
func (a *Month) UnmarshalText(data []byte) error {
rawMonth := string(data)
a.Value = &rawMonth
return nil
}
func (a Month) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(a)
if err != nil {
return nil, err
}
return safeyaml.JSONtoYAMLMapSlice(jsonBytes)
}
func (a *Month) UnmarshalYAML(unmarshal func(interface{}) error) error {
jsonBytes, err := safeyaml.UnmarshalerToJSONBytes(unmarshal)
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&a)
}
`,
},
{
pkg: "testpkg",
name: "single object alias",
aliases: []spec.AliasDefinition{
{
TypeName: spec.TypeName{
Name: "Map",
Package: "api",
},
Alias: spec.NewTypeFromMap(spec.MapType{
KeyType: spec.NewTypeFromPrimitive(spec.PrimitiveTypeString),
ValueType: spec.NewTypeFromPrimitive(spec.PrimitiveTypeSafelong),
}),
},
},
want: `package testpkg
type Map map[string]safelong.SafeLong
func (a Map) MarshalJSON() ([]byte, error) {
return safejson.Marshal(map[string]safelong.SafeLong(a))
}
func (a *Map) UnmarshalJSON(data []byte) error {
var rawMap map[string]safelong.SafeLong
if err := safejson.Unmarshal(data, &rawMap); err != nil {
return err
}
*a = Map(rawMap)
return nil
}
func (a Map) MarshalYAML() (interface{}, error) {
jsonBytes, err := safejson.Marshal(a)
if err != nil {
return nil, err
}
return safeyaml.JSONtoYAMLMapSlice(jsonBytes)
}
func (a *Map) UnmarshalYAML(unmarshal func(interface{}) error) error {
jsonBytes, err := safeyaml.UnmarshalerToJSONBytes(unmarshal)
if err != nil {
return err
}
return safejson.Unmarshal(jsonBytes, *&a)
}
`,
},
} {
t.Run(currCase.name, func(t *testing.T) {
info := types.NewPkgInfo("", nil)
var components []astgen.ASTDecl
for _, a := range currCase.aliases {
declers, err := astForAlias(a, info)
require.NoError(t, err)
components = append(components, declers...)
}
got, err := goastwriter.Write(currCase.pkg, components...)
require.NoError(t, err, "Case %d: %s", caseNum, currCase.name)
assert.Equal(t, strings.Split(currCase.want, "\n"), strings.Split(string(got), "\n"))
})
}
} | explode_data.jsonl/73211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1405
} | [
2830,
3393,
22720,
6492,
1155,
353,
8840,
836,
8,
341,
2023,
1142,
4651,
11,
9804,
4207,
1669,
2088,
3056,
1235,
341,
197,
3223,
7351,
257,
914,
198,
197,
11609,
262,
914,
198,
197,
197,
33924,
3056,
9535,
875,
71829,
10398,
198,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestProperServerWithRoutesShutdown(t *testing.T) {
before := runtime.NumGoroutine()
srvA, srvB, _, _ := runServers(t)
srvA.Shutdown()
srvB.Shutdown()
time.Sleep(100 * time.Millisecond)
after := runtime.NumGoroutine()
delta := after - before
// There may be some finalizers or IO, but in general more than
// 2 as a delta represents a problem.
if delta > 2 {
t.Fatalf("Expected same number of goroutines, %d vs %d\n", before, after)
}
} | explode_data.jsonl/5069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
1336,
712,
5475,
2354,
26653,
62004,
1155,
353,
8840,
836,
8,
341,
63234,
1669,
15592,
39847,
38,
269,
14159,
741,
1903,
10553,
32,
11,
43578,
33,
11,
8358,
716,
1669,
1598,
78139,
1155,
340,
1903,
10553,
32,
10849,
18452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocale(t *testing.T) {
trans := New()
expected := "sd_PK"
if trans.Locale() != expected {
t.Errorf("Expected '%s' Got '%s'", expected, trans.Locale())
}
} | explode_data.jsonl/9111 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
19231,
1155,
353,
8840,
836,
8,
1476,
72453,
1669,
1532,
741,
42400,
1669,
330,
13446,
63898,
1837,
743,
1356,
59094,
368,
961,
3601,
341,
197,
3244,
13080,
445,
18896,
7677,
82,
6,
24528,
7677,
82,
22772,
3601,
11,
1356,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQuerySupply(t *testing.T) {
app, ctx := createTestApp(false)
keeper := *app.SupplyKeeper()
cdc := app.Codec()
supplyCoins := chainType.NewCoins(
chainType.NewCoin(constants.DefaultBondDenom, sdk.NewInt(100)),
chainType.NewCoin(constants.ChainMainNameStr+"/"+"photon", sdk.NewInt(50)),
chainType.NewCoin(constants.ChainMainNameStr+"/"+"atom", sdk.NewInt(2000)),
chainType.NewCoin(constants.ChainMainNameStr+"/"+"btc", sdk.NewInt(21000000)),
)
supplyAcc := keeper.GetModuleAccount(ctx, types.ModuleName).GetID()
fInitCoins(t, ctx, *app.AssetKeeper(), supplyCoins, supplyAcc)
query := abci.RequestQuery{
Path: "",
Data: []byte{},
}
querier := keep.NewQuerier(keeper)
//keeper.SetSupply(ctx, types.NewSupply(supplyCoins))
queryTotalSupplyParams := types.NewQueryTotalSupplyParams(1, 10)
bz, errRes := cdc.MarshalJSON(queryTotalSupplyParams)
require.Nil(t, errRes)
query.Path = fmt.Sprintf("/custom/supply/%s", types.QueryTotalSupply)
query.Data = bz
res, err := querier(ctx, []string{types.QueryTotalSupply}, query)
require.Nil(t, err)
var totalCoins chainType.Coins
errRes = cdc.UnmarshalJSON(res, &totalCoins)
require.Nil(t, errRes)
require.Equal(t, supplyCoins, totalCoins)
querySupplyParams := types.NewQuerySupplyOfParams(constants.DefaultBondDenom)
bz, errRes = cdc.MarshalJSON(querySupplyParams)
require.Nil(t, errRes)
query.Path = fmt.Sprintf("/custom/supply/%s", types.QuerySupplyOf)
query.Data = bz
res, err = querier(ctx, []string{types.QuerySupplyOf}, query)
require.Nil(t, err)
var supply sdk.Int
errRes = supply.UnmarshalJSON(res)
require.Nil(t, errRes)
require.True(sdk.IntEq(t, sdk.NewInt(100), supply))
} | explode_data.jsonl/14269 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 680
} | [
2830,
3393,
2859,
51296,
1155,
353,
8840,
836,
8,
341,
28236,
11,
5635,
1669,
1855,
2271,
2164,
3576,
340,
197,
18861,
1669,
353,
676,
38736,
2541,
77233,
741,
1444,
7628,
1669,
906,
20274,
66,
13106,
1903,
83923,
69602,
1669,
8781,
929... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetUsersNotInTeam(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()
Client := th.Client
teamId := th.BasicTeam.Id
rusers, resp := Client.GetUsersNotInTeam(teamId, 0, 60, "")
CheckNoError(t, resp)
for _, u := range rusers {
CheckUserSanitization(t, u)
}
rusers, resp = Client.GetUsersNotInTeam(teamId, 0, 60, resp.Etag)
CheckEtag(t, rusers, resp)
rusers, resp = Client.GetUsersNotInTeam(teamId, 0, 1, "")
CheckNoError(t, resp)
if len(rusers) != 1 {
t.Fatal("should be 1 per page")
}
rusers, resp = Client.GetUsersNotInTeam(teamId, 1, 1, "")
CheckNoError(t, resp)
if len(rusers) != 1 {
t.Fatal("should be 1 per page")
}
rusers, resp = Client.GetUsersNotInTeam(teamId, 10000, 100, "")
CheckNoError(t, resp)
if len(rusers) != 0 {
t.Fatal("should be no users")
}
Client.Logout()
_, resp = Client.GetUsersNotInTeam(teamId, 0, 60, "")
CheckUnauthorizedStatus(t, resp)
user := th.CreateUser()
Client.Login(user.Email, user.Password)
_, resp = Client.GetUsersNotInTeam(teamId, 0, 60, "")
CheckForbiddenStatus(t, resp)
_, resp = th.SystemAdminClient.GetUsersNotInTeam(teamId, 0, 60, "")
CheckNoError(t, resp)
} | explode_data.jsonl/21540 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 481
} | [
2830,
3393,
1949,
7137,
2623,
641,
14597,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1005,
3803,
15944,
1005,
3803,
2320,
7210,
741,
16867,
270,
836,
682,
4454,
741,
71724,
1669,
270,
11716,
198,
197,
9196,
764,
1669,
270,
48868,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetNodeOptions(t *testing.T) {
arrays := getTestArrays()
nodeSvc = &Service{
Fs: fsMock,
ctrlSvc: nil,
iscsiConnector: nil,
fcConnector: nil,
iscsiLib: nil,
nodeID: validNodeID,
useFC: false,
initialized: true,
}
nodeSvc.SetArrays(arrays)
nodeSvc.SetDefaultArray(arrays[firstValidIP])
t.Run("success test", func(t *testing.T) {
csictx.Setenv(context.Background(), common.EnvNodeIDFilePath, "")
csictx.Setenv(context.Background(), common.EnvNodeNamePrefix, "")
csictx.Setenv(context.Background(), common.EnvKubeNodeName, "")
csictx.Setenv(context.Background(), common.EnvNodeChrootPath, "")
csictx.Setenv(context.Background(), common.EnvTmpDir, "")
csictx.Setenv(context.Background(), common.EnvFCPortsFilterFilePath, "")
csictx.Setenv(context.Background(), common.EnvEnableCHAP, "")
getNodeOptions()
})
} | explode_data.jsonl/5886 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 387
} | [
2830,
3393,
1949,
1955,
3798,
1155,
353,
8840,
836,
8,
341,
36511,
942,
1669,
633,
2271,
22182,
741,
20831,
92766,
284,
609,
1860,
515,
197,
12727,
82,
25,
1797,
8619,
11571,
345,
197,
84381,
92766,
25,
286,
2092,
345,
197,
197,
3427,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrincipalRoleNotPeer(t *testing.T) {
msp1, err := setup("testdata/idemix/MSP1OU1Admin", "MSP1OU1")
assert.NoError(t, err)
id1, err := getDefaultSigner(msp1)
assert.NoError(t, err)
principalBytes, err := proto.Marshal(&msp.MSPRole{Role: msp.MSPRole_PEER, MspIdentifier: id1.GetMSPIdentifier()})
assert.NoError(t, err)
principal := &msp.MSPPrincipal{
PrincipalClassification: msp.MSPPrincipal_ROLE,
Principal: principalBytes}
err = id1.SatisfiesPrincipal(principal)
assert.Error(t, err, "Admin should not satisfy PEER principal")
assert.Contains(t, err.Error(), "idemixmsp only supports client use, so it cannot satisfy an MSPRole PEER principal")
} | explode_data.jsonl/46048 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
31771,
9030,
2623,
30888,
1155,
353,
8840,
836,
8,
341,
47691,
79,
16,
11,
1848,
1669,
6505,
445,
92425,
38146,
336,
941,
10270,
4592,
16,
11922,
16,
7210,
497,
330,
44,
4592,
16,
11922,
16,
1138,
6948,
35699,
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 TestRankingsApi(t *testing.T) {
web := setupTestWeb(t)
// Test that empty rankings produces an empty array.
recorder := web.getHttpResponse("/api/rankings")
assert.Equal(t, 200, recorder.Code)
assert.Equal(t, "application/json", recorder.HeaderMap["Content-Type"][0])
rankingsData := struct {
Rankings []RankingWithNickname
TeamNicknames map[string]string
HighestPlayedMatch string
}{}
err := json.Unmarshal([]byte(recorder.Body.String()), &rankingsData)
assert.Nil(t, err)
assert.Equal(t, 0, len(rankingsData.Rankings))
assert.Equal(t, "", rankingsData.HighestPlayedMatch)
ranking1 := RankingWithNickname{*game.TestRanking2(), "Simbots"}
ranking2 := RankingWithNickname{*game.TestRanking1(), "ChezyPof"}
web.arena.Database.CreateRanking(&ranking1.Ranking)
web.arena.Database.CreateRanking(&ranking2.Ranking)
web.arena.Database.CreateMatch(&model.Match{Type: "qualification", DisplayName: "29", Status: model.RedWonMatch})
web.arena.Database.CreateMatch(&model.Match{Type: "qualification", DisplayName: "30"})
web.arena.Database.CreateTeam(&model.Team{Id: 254, Nickname: "ChezyPof"})
web.arena.Database.CreateTeam(&model.Team{Id: 1114, Nickname: "Simbots"})
recorder = web.getHttpResponse("/api/rankings")
assert.Equal(t, 200, recorder.Code)
assert.Equal(t, "application/json", recorder.HeaderMap["Content-Type"][0])
err = json.Unmarshal([]byte(recorder.Body.String()), &rankingsData)
assert.Nil(t, err)
if assert.Equal(t, 2, len(rankingsData.Rankings)) {
assert.Equal(t, ranking1, rankingsData.Rankings[1])
assert.Equal(t, ranking2, rankingsData.Rankings[0])
}
assert.Equal(t, "29", rankingsData.HighestPlayedMatch)
} | explode_data.jsonl/75529 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 625
} | [
2830,
3393,
22550,
819,
6563,
1155,
353,
8840,
836,
8,
341,
97250,
1669,
6505,
2271,
5981,
1155,
692,
197,
322,
3393,
429,
4287,
32307,
18644,
458,
4287,
1334,
624,
67904,
1358,
1669,
3482,
670,
43342,
4283,
2068,
7382,
1180,
819,
1138,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestIsNativeText(t *testing.T) {
tcs := []byte{' ', '0', '9', 'a', 'z'}
fcs := []byte{'!', '@', '^', 'A', '~'}
for _, c := range tcs {
if isNativeText(c) != true {
t.Fatalf("isNativeText(%v) must true", c)
}
}
for _, c := range fcs {
if isNativeText(c) != false {
t.Fatalf("isNativeText(%v) must false", c)
}
}
} | explode_data.jsonl/32227 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
3872,
20800,
1178,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
3782,
13608,
6614,
364,
15,
516,
364,
24,
516,
364,
64,
516,
364,
89,
16418,
1166,
4837,
1669,
3056,
3782,
13608,
38692,
3458,
516,
49438,
516,
364,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEchoWithMessaging(t *testing.T) {
c := PipeConfig{
MessageMode: true, // Use message mode so that CloseWrite() is supported
InputBufferSize: 65536, // Use 64KB buffers to improve performance
OutputBufferSize: 65536,
}
l, err := ListenPipe(testPipeName, &c)
if err != nil {
t.Fatal(err)
}
defer l.Close()
listenerDone := make(chan bool)
clientDone := make(chan bool)
go func() {
// server echo
conn, e := l.Accept()
if e != nil {
t.Fatal(e)
}
defer conn.Close()
time.Sleep(200 * time.Millisecond) // make *sure* we don't begin to read before eof signal is sent
io.Copy(conn, conn)
conn.(CloseWriter).CloseWrite()
close(listenerDone)
}()
timeout := 500 * time.Second
client, err := DialPipe(testPipeName, &timeout)
if err != nil {
t.Fatal(err)
}
defer client.Close()
go func() {
// client read back
bytes := make([]byte, 2)
n, e := client.Read(bytes)
if e != nil {
t.Fatal(e)
}
if n != 2 {
t.Fatalf("expected 2 bytes, got %v", n)
}
close(clientDone)
}()
payload := make([]byte, 2)
payload[0] = 0
payload[1] = 1
n, err := client.Write(payload)
if err != nil {
t.Fatal(err)
}
if n != 2 {
t.Fatalf("expected 2 bytes, got %v", n)
}
client.(CloseWriter).CloseWrite()
<-listenerDone
<-clientDone
} | explode_data.jsonl/11433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 543
} | [
2830,
3393,
74994,
2354,
91049,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
27805,
2648,
515,
197,
46733,
3636,
25,
414,
830,
11,
220,
442,
5443,
1943,
3856,
773,
429,
13032,
7985,
368,
374,
7248,
198,
197,
66588,
52661,
25,
220,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestStandardEnsureHostInPool(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
cloud := GetTestCloud(ctrl)
availabilitySetID := "/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Compute/availabilitySets/myAvailabilitySet"
backendAddressPoolID := "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/lb1-internal/backendAddressPools/backendpool-1"
testCases := []struct {
name string
service *v1.Service
nodeName types.NodeName
backendPoolID string
nicName string
nicID string
vmSetName string
nicProvisionState string
isStandardLB bool
expectedErrMsg error
}{
{
name: "EnsureHostInPool should return nil if node is not in VMSet",
service: &v1.Service{},
nodeName: "vm1",
nicName: "nic1",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic1",
vmSetName: "availabilityset-1",
},
{
name: "EnsureHostInPool should report error if last segment of nicID is nil",
service: &v1.Service{},
nodeName: "vm2",
nicName: "nic2",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/",
vmSetName: "availabilityset-1",
expectedErrMsg: fmt.Errorf("resource name was missing from identifier"),
},
{
name: "EnsureHostInPool should return nil if node's provisioning state is Failed",
service: &v1.Service{},
nodeName: "vm3",
nicName: "nic3",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic3",
nicProvisionState: nicFailedState,
vmSetName: "myAvailabilitySet",
},
{
name: "EnsureHostInPool should report error if service.Spec.ClusterIP is ipv6 but node don't have IPv6 address",
service: &v1.Service{Spec: v1.ServiceSpec{ClusterIP: "2001:0db8:85a3:0000:0000:8a2e:0370:7334"}},
nodeName: "vm4",
nicName: "nic4",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic4",
vmSetName: "myAvailabilitySet",
expectedErrMsg: fmt.Errorf("failed to determine the ipconfig(IPv6=true). nicname=%q", "nic4"),
},
{
name: "EnsureHostInPool should return nil if there is matched backend pool",
service: &v1.Service{},
backendPoolID: backendAddressPoolID,
nodeName: "vm5",
nicName: "nic5",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic5",
vmSetName: "myAvailabilitySet",
},
{
name: "EnsureHostInPool should return nil if there isn't matched backend pool",
service: &v1.Service{},
backendPoolID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/lb1-internal/backendAddressPools/backendpool-2",
nodeName: "vm6",
nicName: "nic6",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic6",
vmSetName: "myAvailabilitySet",
},
{
name: "EnsureHostInPool should return nil if BackendPool is not on same LB",
service: &v1.Service{},
isStandardLB: true,
backendPoolID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/lb2-internal/backendAddressPools/backendpool-3",
nodeName: "vm7",
nicName: "nic7",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic7",
vmSetName: "myAvailabilitySet",
},
{
name: "EnsureHostInPool should report error if the format of backendPoolID is invalid",
service: &v1.Service{},
isStandardLB: true,
backendPoolID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/lb2-internal/backendAddressPool/backendpool-3",
nodeName: "vm8",
nicName: "nic8",
nicID: "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/networkInterfaces/nic7",
vmSetName: "myAvailabilitySet",
expectedErrMsg: fmt.Errorf("new backendPoolID %q is in wrong format", "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/lb2-internal/backendAddressPool/backendpool-3"),
},
}
for _, test := range testCases {
if test.isStandardLB {
cloud.Config.LoadBalancerSku = loadBalancerSkuStandard
}
testVM := compute.VirtualMachine{
Name: to.StringPtr(string(test.nodeName)),
VirtualMachineProperties: &compute.VirtualMachineProperties{
AvailabilitySet: &compute.SubResource{ID: to.StringPtr(availabilitySetID)},
NetworkProfile: &compute.NetworkProfile{
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
{
ID: to.StringPtr(test.nicID),
},
},
},
},
}
testNIC := network.Interface{
Name: to.StringPtr(test.nicName),
ID: to.StringPtr(test.nicID),
InterfacePropertiesFormat: &network.InterfacePropertiesFormat{
ProvisioningState: to.StringPtr(test.nicProvisionState),
IPConfigurations: &[]network.InterfaceIPConfiguration{
{
Name: to.StringPtr("ifconfig1"),
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
LoadBalancerBackendAddressPools: &[]network.BackendAddressPool{
{
ID: to.StringPtr(backendAddressPoolID),
},
},
},
},
},
},
}
mockVMClient := cloud.VirtualMachinesClient.(*mockvmclient.MockInterface)
mockVMClient.EXPECT().Get(gomock.Any(), cloud.ResourceGroup, string(test.nodeName), gomock.Any()).Return(testVM, nil).AnyTimes()
mockInterfaceClient := cloud.InterfacesClient.(*mockinterfaceclient.MockInterface)
mockInterfaceClient.EXPECT().Get(gomock.Any(), cloud.ResourceGroup, test.nicName, gomock.Any()).Return(testNIC, nil).AnyTimes()
mockInterfaceClient.EXPECT().CreateOrUpdate(gomock.Any(), cloud.ResourceGroup, gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
_, _, _, vm, err := cloud.VMSet.EnsureHostInPool(test.service, test.nodeName, test.backendPoolID, test.vmSetName, false)
assert.Equal(t, test.expectedErrMsg, err, test.name)
assert.Nil(t, vm, test.name)
}
} | explode_data.jsonl/7470 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2652
} | [
2830,
3393,
19781,
64439,
9296,
641,
10551,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
23743,
991,
18176,
741,
197,
12361,
1669,
2126,
2271,
16055,
62100,
692,
197,
53062,
1649,
915,
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 TestIsSameUserOrAdmin(t *testing.T) {
tests := []struct {
name string
method string
ctxData map[string]interface{}
userData user.User
wantResponse bool
}{
{
name: "Same User GET",
method: http.MethodGet,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
},
userData: user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
wantResponse: true,
},
{
name: "Different User GET",
method: http.MethodGet,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
},
userData: user.User{
ID: "b9b127c8-6deb-4d16-88ff-cca15bf9ff47",
Email: "anotheruser@test.com",
},
wantResponse: false,
}, {
name: "Different User GET, Admin",
method: http.MethodGet,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
Roles: []string{user.RoleClerk, user.RoleAdmin},
},
},
userData: user.User{
ID: "b9b127c8-6deb-4d16-88ff-cca15bf9ff47",
Email: "anotheruser@test.com",
},
wantResponse: true,
},
{
name: "Same User POST",
method: http.MethodPost,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
},
userData: user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
wantResponse: true,
},
{
name: "Different User POST",
method: http.MethodPost,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
},
},
userData: user.User{
ID: "b9b127c8-6deb-4d16-88ff-cca15bf9ff47",
Email: "anotheruser@test.com",
},
wantResponse: false,
},
{
name: "Different User POST, Admin",
method: http.MethodPost,
ctxData: map[string]interface{}{
"isAuthenticaded": true,
"user": user.User{
ID: "adea27f8-4091-4908-9ad9-3d68e198b488",
Email: "user@test.com",
Roles: []string{user.RoleClerk, user.RoleAdmin},
},
},
userData: user.User{
ID: "b9b127c8-6deb-4d16-88ff-cca15bf9ff47",
Email: "anotheruser@test.com",
},
wantResponse: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
app := web.New(log.New(ioutil.Discard, "", 0),
log.New(ioutil.Discard, "", 0),
nil,
mocks.NewSessionSvc(),
mocks.NewUserSvc(),
mocks.NewMailerMock(nil),
mocks.NewTokenMockSvc(),
nil, nil, nil)
var req *http.Request
if tt.method == http.MethodGet {
req, _ = http.NewRequest(tt.method, "/", nil)
q := req.URL.Query()
q.Add("email", tt.userData.Email)
req.URL.RawQuery = q.Encode()
} else {
body, err := json.Marshal(map[string]string{
"email": tt.userData.Email,
})
if err != nil {
t.Error("could not create request body")
}
req, err = http.NewRequest(tt.method, "/", bytes.NewBuffer(body))
if err != nil {
t.Error("could not create request")
}
req.Header.Set("Content-type", "application/json")
}
usr := tt.ctxData["user"].(user.User)
ctx := context.WithValue(req.Context(), web.ContextKeyIsAuthenticated, tt.ctxData["isAuthenticated"])
ctx = context.WithValue(ctx, web.ContextKeyUser, &usr)
resp := app.IsSameUserOrAdmin(req.WithContext(ctx))
if resp != tt.wantResponse {
t.Errorf("want response %t; got %t", tt.wantResponse, resp)
}
})
}
} | explode_data.jsonl/32438 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1945
} | [
2830,
3393,
3872,
19198,
1474,
2195,
7210,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
42257,
981,
914,
198,
197,
20985,
1043,
414,
2415,
14032,
31344,
16094,
197,
19060,
1043,
257,
1196,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAuthPostSuccess(t *testing.T) {
t.Parallel()
setupMore := func(h *testHarness) *testHarness {
h.bodyReader.Return = mocks.Values{
PID: "test@test.com",
Password: "hello world",
}
h.storer.Users["test@test.com"] = &mocks.User{
Email: "test@test.com",
Password: "$2a$10$IlfnqVyDZ6c1L.kaA/q3bu1nkAC6KukNUsizvlzay1pZPXnX2C9Ji", // hello world
}
h.session.ClientValues[authboss.SessionHalfAuthKey] = "true"
return h
}
t.Run("normal", func(t *testing.T) {
t.Parallel()
h := setupMore(testSetup())
var beforeCalled, afterCalled bool
var beforeHasValues, afterHasValues bool
h.ab.Events.Before(authboss.EventAuth, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
beforeCalled = true
beforeHasValues = r.Context().Value(authboss.CTXKeyValues) != nil
return false, nil
})
h.ab.Events.After(authboss.EventAuth, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
afterCalled = true
afterHasValues = r.Context().Value(authboss.CTXKeyValues) != nil
return false, nil
})
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
}
if resp.Code != http.StatusTemporaryRedirect {
t.Error("code was wrong:", resp.Code)
}
if h.redirector.Options.RedirectPath != "/login/ok" {
t.Error("redirect path was wrong:", h.redirector.Options.RedirectPath)
}
if _, ok := h.session.ClientValues[authboss.SessionHalfAuthKey]; ok {
t.Error("half auth should have been deleted")
}
if pid := h.session.ClientValues[authboss.SessionKey]; pid != "test@test.com" {
t.Error("pid was wrong:", pid)
}
if !beforeCalled {
t.Error("before should have been called")
}
if !afterCalled {
t.Error("after should have been called")
}
if !beforeHasValues {
t.Error("before callback should have access to values")
}
if !afterHasValues {
t.Error("after callback should have access to values")
}
})
t.Run("handledBefore", func(t *testing.T) {
t.Parallel()
h := setupMore(testSetup())
var beforeCalled bool
h.ab.Events.Before(authboss.EventAuth, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
w.WriteHeader(http.StatusTeapot)
beforeCalled = true
return true, nil
})
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
}
if h.responder.Status != 0 {
t.Error("a status should never have been sent back")
}
if _, ok := h.session.ClientValues[authboss.SessionKey]; ok {
t.Error("session key should not have been set")
}
if !beforeCalled {
t.Error("before should have been called")
}
if resp.Code != http.StatusTeapot {
t.Error("should have left the response alone once teapot was sent")
}
})
t.Run("handledAfter", func(t *testing.T) {
t.Parallel()
h := setupMore(testSetup())
var afterCalled bool
h.ab.Events.After(authboss.EventAuth, func(w http.ResponseWriter, r *http.Request, handled bool) (bool, error) {
w.WriteHeader(http.StatusTeapot)
afterCalled = true
return true, nil
})
r := mocks.Request("POST")
resp := httptest.NewRecorder()
w := h.ab.NewResponse(resp)
if err := h.auth.LoginPost(w, r); err != nil {
t.Error(err)
}
if h.responder.Status != 0 {
t.Error("a status should never have been sent back")
}
if _, ok := h.session.ClientValues[authboss.SessionKey]; !ok {
t.Error("session key should have been set")
}
if !afterCalled {
t.Error("after should have been called")
}
if resp.Code != http.StatusTeapot {
t.Error("should have left the response alone once teapot was sent")
}
})
} | explode_data.jsonl/3466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1508
} | [
2830,
3393,
5087,
4133,
7188,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
84571,
7661,
1669,
2915,
3203,
353,
1944,
74248,
8,
353,
1944,
74248,
341,
197,
9598,
5079,
5062,
46350,
284,
68909,
35145,
515,
298,
10025,
915,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidType_Slice(t *testing.T) {
var testVar []int = []int{1, 2, 3, 4}
err := Scrub(testVar, []string{"owner"})
assert.Error(t, err)
err = Scrub(&testVar, []string{"owner"})
assert.Error(t, err)
} | explode_data.jsonl/9430 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 88
} | [
2830,
3393,
7928,
929,
1098,
4754,
1155,
353,
8840,
836,
8,
1476,
2405,
1273,
3962,
3056,
396,
284,
3056,
396,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
630,
9859,
1669,
32134,
392,
8623,
3962,
11,
3056,
917,
4913,
8118,
2362... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmoji(t *testing.T) {
var input = []byte(`{"utf8":"Example emoji, KO: \ud83d\udd13, \ud83c\udfc3 ` +
`OK: \u2764\ufe0f "}`)
value, err := Get(input, "utf8")
if err != nil {
t.Fatal(err)
}
var v map[string]interface{}
if err := json.Unmarshal(input, &v); err != nil {
t.Fatal(err)
}
s, _ := v["utf8"].(string)
x, _ := value.String()
if x != s {
t.Fatalf("expected '%v', got '%v'", s, x)
}
} | explode_data.jsonl/62344 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
92731,
1155,
353,
8840,
836,
8,
341,
262,
762,
1946,
284,
3056,
3782,
5809,
4913,
4762,
23,
3252,
13314,
42365,
11,
37512,
25,
1124,
661,
23,
18,
67,
3770,
631,
16,
18,
11,
1124,
661,
23,
18,
66,
59,
661,
8316,
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... | 4 |
func TestEnabled(t *testing.T) {
type testCase struct {
name string
annotations map[string]string
key string
expect bool
}
testcases := []testCase{
{
name: "include_key",
annotations: map[string]string{
"mytest": "true",
},
key: "mytest",
expect: true,
}, {
name: "exclude_key",
annotations: map[string]string{
"mytest": "true",
},
key: "my",
expect: false,
},
}
for _, testcase := range testcases {
got := enabled(testcase.annotations, testcase.key)
if got != testcase.expect {
t.Errorf("The testcase %s's failed due to expect %v but got %v", testcase.name, testcase.expect, got)
}
}
} | explode_data.jsonl/35571 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
5462,
1155,
353,
8840,
836,
8,
341,
13158,
54452,
2036,
341,
197,
11609,
286,
914,
198,
197,
197,
39626,
2415,
14032,
30953,
198,
197,
23634,
260,
914,
198,
197,
24952,
414,
1807,
198,
197,
630,
18185,
23910,
1669,
3056,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRot1Right(t *testing.T) {
table := []struct {
input *RBNode
expect string
}{
{&RBNode{
10, false,
&RBNode{5, true, nil, nil},
&RBNode{
20, true,
&RBNode{17, false, nil, nil},
&RBNode{25, false, nil, nil},
},
}, "B:5(,R:10(,R:20(B:17(,),B:25(,))))"},
}
for _, te := range table {
result := te.input.Rot1Right()
if result.String() != te.expect {
t.Errorf("Rot1Right() => %q, want %q", result.String(), te.expect)
}
}
} | explode_data.jsonl/9583 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
36936,
16,
5979,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
3056,
1235,
341,
197,
22427,
220,
353,
29259,
1955,
198,
197,
24952,
914,
198,
197,
59403,
197,
197,
90,
5,
29259,
1955,
515,
298,
197,
16,
15,
11,
895,
345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetLogFile(t *testing.T) {
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
if err := c.SetLogFile("/tmp/" + ContainerName); err != nil || c.LogFile() != "/tmp/"+ContainerName {
t.Errorf("SetLogFile failed...")
}
} | explode_data.jsonl/2764 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
1649,
98857,
1155,
353,
8840,
836,
8,
341,
1444,
11,
1848,
1669,
1532,
4502,
75145,
675,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
743,
1848,
1669,
272,
4202,
98857,
4283,
5173,
11225,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestGCHelmSortVersionComplex(t *testing.T) {
test_versions := []string{"jx-p.v3.complex.v2", "jx-p.v1.complex.v3", "jx-p.v2.complex.v1"}
sort.Sort(ByVersion(test_versions))
assert.Equal(t, "jx-p.v2.complex.v1", test_versions[0])
assert.Equal(t, "jx-p.v3.complex.v2", test_versions[1])
assert.Equal(t, "jx-p.v1.complex.v3", test_versions[2])
} | explode_data.jsonl/57814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 171
} | [
2830,
3393,
38,
2149,
23162,
10231,
5637,
31137,
1155,
353,
8840,
836,
8,
341,
18185,
65148,
1669,
3056,
917,
4913,
73,
87,
2268,
3133,
18,
905,
9111,
3133,
17,
497,
330,
73,
87,
2268,
3133,
16,
905,
9111,
3133,
18,
497,
330,
73,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterFeatureWithTags(t *testing.T) {
suite := NewSuite(t, WithFeaturesPath("features/filter_tags_*.feature"), WithTags("@run-this"))
c := false
suite.AddStep(`the test should pass`, func(_ StepTest, _ Context) {
c = true
})
suite.AddStep(`fail the test`, fail)
suite.Run()
if err := assert.Equals(true, c); err != nil {
t.Error(err)
}
} | explode_data.jsonl/69373 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
5632,
13859,
2354,
15930,
1155,
353,
8840,
836,
8,
341,
96572,
1669,
1532,
28000,
1155,
11,
3085,
21336,
1820,
445,
20304,
63524,
16333,
62,
19922,
12753,
3975,
3085,
15930,
10662,
6108,
60191,
5455,
1444,
1669,
895,
271,
9657... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTCPResetSentForACKWhenNotUsingSynCookies(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
// Set TCPLingerTimeout to 5 seconds so that sockets are marked closed
wq := &waiter.Queue{}
ep, err := c.Stack().NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, wq)
if err != nil {
t.Fatalf("NewEndpoint failed: %s", err)
}
if err := ep.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatalf("Bind failed: %s", err)
}
if err := ep.Listen(10); err != nil {
t.Fatalf("Listen failed: %s", err)
}
// Send a SYN request.
iss := seqnum.Value(context.TestInitialSequenceNumber)
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagSyn,
SeqNum: iss,
})
// Receive the SYN-ACK reply.
b := c.GetPacket()
tcpHdr := header.TCP(header.IPv4(b).Payload())
c.IRS = seqnum.Value(tcpHdr.SequenceNumber())
ackHeaders := &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagAck,
SeqNum: iss + 1,
AckNum: c.IRS + 1,
}
// Send ACK.
c.SendPacket(nil, ackHeaders)
// Try to accept the connection.
we, ch := waiter.NewChannelEntry(nil)
wq.EventRegister(&we, waiter.ReadableEvents)
defer wq.EventUnregister(&we)
c.EP, _, err = ep.Accept(nil)
if cmp.Equal(&tcpip.ErrWouldBlock{}, err) {
// Wait for connection to be established.
select {
case <-ch:
c.EP, _, err = ep.Accept(nil)
if err != nil {
t.Fatalf("Accept failed: %s", err)
}
case <-time.After(1 * time.Second):
t.Fatalf("Timed out waiting for accept")
}
}
// Lower stackwide TIME_WAIT timeout so that the reservations
// are released instantly on Close.
tcpTW := tcpip.TCPTimeWaitTimeoutOption(1 * time.Millisecond)
if err := c.Stack().SetTransportProtocolOption(tcp.ProtocolNumber, &tcpTW); err != nil {
t.Fatalf("SetTransportProtocolOption(%d, &%T(%d)): %s", tcp.ProtocolNumber, tcpTW, tcpTW, err)
}
c.EP.Close()
checker.IPv4(t, c.GetPacket(), checker.TCP(
checker.SrcPort(context.StackPort),
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS+1)),
checker.TCPAckNum(uint32(iss)+1),
checker.TCPFlags(header.TCPFlagFin|header.TCPFlagAck)))
finHeaders := &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagAck | header.TCPFlagFin,
SeqNum: iss + 1,
AckNum: c.IRS + 2,
}
c.SendPacket(nil, finHeaders)
// Get the ACK to the FIN we just sent.
c.GetPacket()
// Since an active close was done we need to wait for a little more than
// tcpLingerTimeout for the port reservations to be released and the
// socket to move to a CLOSED state.
time.Sleep(20 * time.Millisecond)
// Now resend the same ACK, this ACK should generate a RST as there
// should be no endpoint in SYN-RCVD state and we are not using
// syn-cookies yet. The reason we send the same ACK is we need a valid
// cookie(IRS) generated by the netstack without which the ACK will be
// rejected.
c.SendPacket(nil, ackHeaders)
checker.IPv4(t, c.GetPacket(), checker.TCP(
checker.SrcPort(context.StackPort),
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS+1)),
checker.TCPAckNum(0),
checker.TCPFlags(header.TCPFlagRst)))
} | explode_data.jsonl/75924 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1322
} | [
2830,
3393,
49896,
14828,
31358,
2461,
4032,
4498,
2623,
16429,
37134,
50672,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
197,
322,
2573,
24591,
2916,
5137,
7636,
31... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestCombinationIterator(t *testing.T) {
assert := assert.New(t)
vs := newTestValueStore()
byTwos, err := NewSet(context.Background(), vs, generateNumbersAsValuesFromToBy(0, 70, 2)...)
assert.NoError(err)
byThrees, err := NewSet(context.Background(), vs, generateNumbersAsValuesFromToBy(0, 70, 3)...)
assert.NoError(err)
byFives, err := NewSet(context.Background(), vs, generateNumbersAsValuesFromToBy(0, 70, 5)...)
assert.NoError(err)
bySevens, err := NewSet(context.Background(), vs, generateNumbersAsValuesFromToBy(0, 70, 7)...)
assert.NoError(err)
it1, err := NewIntersectionIterator(context.Background(), Format_7_18, mustSIter(byTwos.Iterator(context.Background())), mustSIter(bySevens.Iterator(context.Background())))
assert.NoError(err)
it2, err := NewIntersectionIterator(context.Background(), Format_7_18, mustSIter(byFives.Iterator(context.Background())), mustSIter(byThrees.Iterator(context.Background())))
assert.NoError(err)
ut1, err := NewUnionIterator(context.Background(), Format_7_18, it1, it2)
assert.NoError(err)
vals, err := iterToSlice(ut1)
assert.NoError(err)
expectedRes := intsToValueSlice(0, 14, 15, 28, 30, 42, 45, 56, 60)
assert.NoError(err)
assert.True(vals.Equals(expectedRes), "Expected: %v != actual: %v", expectedRes, vs)
ut1, err = NewUnionIterator(context.Background(), Format_7_18, mustSIter(byTwos.Iterator(context.Background())), mustSIter(bySevens.Iterator(context.Background())))
assert.NoError(err)
it2, err = NewIntersectionIterator(context.Background(), Format_7_18, mustSIter(byFives.Iterator(context.Background())), mustSIter(byThrees.Iterator(context.Background())))
assert.NoError(err)
ut2, err := NewIntersectionIterator(context.Background(), Format_7_18, ut1, it2)
assert.NoError(err)
vals, err = iterToSlice(ut2)
assert.NoError(err)
expectedRes = intsToValueSlice(0, 30, 60)
assert.True(vals.Equals(expectedRes), "Expected: %v != actual: %v", expectedRes, vs)
} | explode_data.jsonl/11000 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 679
} | [
2830,
3393,
36192,
2554,
11951,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
5195,
82,
1669,
501,
2271,
1130,
6093,
2822,
197,
1694,
22816,
436,
11,
1848,
1669,
1532,
1649,
5378,
19047,
1507,
6165,
11,
6923,
27237,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomConfigSSL(t *testing.T) {
t.Parallel()
t.Log("Testing the 'custom-config-ssl' example...")
harness := setup(t, timeout, true)
env := []string{}
_, err := harness.runExample("examples/kube/custom-config-ssl/run.sh", env, t)
if err != nil {
t.Fatalf("Could not run example: %s", err)
}
if harness.Cleanup {
defer harness.Client.DeleteNamespace(harness.Namespace)
defer harness.runExample("examples/kube/custom-config-ssl/cleanup.sh", env, t)
}
pods := []string{"custom-config-ssl"}
t.Log("Checking if pods are ready to use...")
if err := harness.Client.CheckPods(harness.Namespace, pods); err != nil {
t.Fatal(err)
}
t.Log("Checking SQL...")
local, remote := randomPort(), 5432
proxy, err := harness.setupProxy("custom-config-ssl", local, remote)
if err != nil {
t.Fatal(err)
}
defer proxy.Close()
certDir := os.ExpandEnv("${CCPROOT}/examples/kube/custom-config-ssl/certs")
os.Setenv("PGSSLROOTCERT", fmt.Sprintf("%s/%s", certDir, "ca.crt"))
os.Setenv("PGSSLCERT", fmt.Sprintf("%s/%s", certDir, "client.crt"))
os.Setenv("PGSSLKEY", fmt.Sprintf("%s/%s", certDir, "client.key"))
db, err := harness.setupDB("userdb", proxy.Hostname, "testuser", "", "require", local)
if err != nil {
t.Fatal(err)
}
defer db.Close()
extensions, err := db.AllExtensions()
if err != nil {
t.Fatal(err)
}
if len(extensions) < 1 {
t.Fatalf("extensions less then 1, it shouldn't be: %d", len(extensions))
}
report, err := harness.createReport()
if err != nil {
t.Fatal(err)
}
t.Log(report)
} | explode_data.jsonl/28875 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 620
} | [
2830,
3393,
10268,
2648,
22594,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3244,
5247,
445,
16451,
279,
364,
9163,
25130,
12,
24635,
6,
3110,
33093,
9598,
23518,
1669,
6505,
1155,
11,
9632,
11,
830,
340,
57538,
1669,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestSyncCreate(t *testing.T) {
storage := SimpleRESTStorage{
injectedFunction: func(obj interface{}) (interface{}, error) {
time.Sleep(200 * time.Millisecond)
return obj, nil
},
}
handler := New(map[string]RESTStorage{
"foo": &storage,
}, "/prefix/version")
server := httptest.NewServer(handler)
client := http.Client{}
simple := Simple{Name: "foo"}
data, _ := api.Encode(simple)
request, err := http.NewRequest("POST", server.URL+"/prefix/version/foo?sync=true", bytes.NewBuffer(data))
expectNoError(t, err)
wg := sync.WaitGroup{}
wg.Add(1)
var response *http.Response
go func() {
response, err = client.Do(request)
wg.Done()
}()
wg.Wait()
expectNoError(t, err)
var itemOut Simple
body, err := extractBody(response, &itemOut)
expectNoError(t, err)
if !reflect.DeepEqual(itemOut, simple) {
t.Errorf("Unexpected data: %#v, expected %#v (%s)", itemOut, simple, string(body))
}
if response.StatusCode != http.StatusOK {
t.Errorf("Unexpected status: %d, Expected: %d, %#v", response.StatusCode, http.StatusOK, response)
}
} | explode_data.jsonl/30466 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 411
} | [
2830,
3393,
12154,
4021,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
8993,
38307,
5793,
515,
197,
17430,
28303,
5152,
25,
2915,
6779,
3749,
28875,
320,
4970,
22655,
1465,
8,
341,
298,
21957,
31586,
7,
17,
15,
15,
353,
882,
71482,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNonKanaCharacters(t *testing.T) {
inputs := []string{
"日本",
"English",
}
for _, input := range inputs {
got, err := KanaToRomaji(input)
assert.Empty(t, got)
assert.NotNil(t, err)
}
} | explode_data.jsonl/11362 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 94
} | [
2830,
3393,
8121,
42,
3362,
37489,
1155,
353,
8840,
836,
8,
341,
22427,
82,
1669,
3056,
917,
515,
197,
197,
1,
101059,
756,
197,
197,
1,
22574,
756,
197,
630,
2023,
8358,
1946,
1669,
2088,
11127,
341,
197,
3174,
354,
11,
1848,
1669,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMakeAndExtractCredential(t *testing.T) {
t.Parallel()
var testcases = []struct {
name string
cred []byte
ek interface{}
ak interface{}
keyBits uint16
}{
{
name: "RSA/AES128",
cred: []byte(`Hello, world!`),
ek: mustGenerateRSAKey(t),
ak: mustGenerateRSAKey(t),
keyBits: 128,
},
{
name: "RSA/AES192",
cred: []byte(`Leave all hope, ye that enter`),
ek: mustGenerateRSAKey(t),
ak: mustGenerateRSAKey(t),
keyBits: 192,
},
{
name: "RSA/AES256",
cred: []byte(`"Commonplace, Watson."`),
ek: mustGenerateRSAKey(t),
ak: mustGenerateRSAKey(t),
keyBits: 256,
},
{
name: "ECC/AES128",
cred: []byte(`Hello, Moon!`),
ek: mustGenerateECCKey(t),
ak: mustGenerateECCKey(t),
keyBits: 128,
},
{
name: "ECC/AES192",
cred: []byte(`perestroika`),
ek: mustGenerateECCKey(t),
ak: mustGenerateECCKey(t),
keyBits: 192,
},
{
name: "ECC/AES256",
cred: []byte(`eiffel tower`),
ek: mustGenerateECCKey(t),
ak: mustGenerateECCKey(t),
keyBits: 256,
},
}
for _, tc := range testcases {
var tc = tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
ekPub := storagePublicAreaFromKey(t, tc.ek, tc.keyBits)
akPub := storagePublicAreaFromKey(t, tc.ak, tc.keyBits)
// Make credential.
blob, encSeed, err := pgtpm.MakeCredential(tc.cred, ekPub, akPub)
if err != nil {
t.Fatalf("couldn't make credential: %v", err)
}
// Extract credential, including some error cases for a sanity
// check.
var subcases = []struct {
name string
blob []byte
encSeed []byte
err error
}{
{
name: "OK",
blob: blob,
encSeed: encSeed,
},
{
name: "BadSeed",
blob: blob,
encSeed: invertByte(encSeed, 4),
err: errors.New("decryption error"),
},
{
name: "BadHMACSize",
blob: invertByte(blob, 1),
encSeed: encSeed,
err: errors.New("incorrect size"),
},
{
name: "BadHMAC",
blob: invertByte(blob, 4),
encSeed: encSeed,
err: errors.New("invalid HMAC"),
},
{
name: "BadCredential",
blob: invertByte(blob, 36),
encSeed: encSeed,
err: errors.New("invalid HMAC due to altered credential"),
},
}
for _, sc := range subcases {
var sc = sc
t.Run(sc.name, func(t *testing.T) {
t.Parallel()
// Extract credential.
got, err := pgtpm.ExtractCredential(tc.ek, sc.blob, sc.encSeed, ekPub, akPub)
if (err == nil) != (sc.err == nil) {
t.Fatalf("got error %v, want %v", err, sc.err)
}
// Check activated credential is as expected.
if err == nil && !bytes.Equal(got, tc.cred) {
t.Fatalf("got %q, want %q", string(got), string(tc.cred))
}
})
}
})
}
} | explode_data.jsonl/60739 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1576
} | [
2830,
3393,
8078,
3036,
28959,
48265,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
1273,
23910,
284,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
197,
10844,
262,
3056,
3782,
198,
197,
197,
1225,
414,
3749,
16094,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRTTMonitor(t *testing.T) {
t.Run("measures the average and minimum RTT", func(t *testing.T) {
t.Parallel()
dialer := DialerFunc(func(_ context.Context, _, _ string) (net.Conn, error) {
return newMockSlowConn(makeHelloReply(), 10*time.Millisecond), nil
})
rtt := newRTTMonitor(&rttConfig{
interval: 10 * time.Millisecond,
createConnectionFn: func() *connection {
return newConnection("", WithDialer(func(Dialer) Dialer { return dialer }))
},
createOperationFn: func(conn driver.Connection) *operation.Hello {
return operation.NewHello().Deployment(driver.SingleConnectionDeployment{C: conn})
},
})
rtt.connect()
defer rtt.disconnect()
assert.Eventuallyf(
t,
func() bool { return rtt.getRTT() > 0 && rtt.getMinRTT() > 0 },
1*time.Second,
10*time.Millisecond,
"expected getRTT() and getMinRTT() to return positive durations within 1 second")
assert.True(
t,
rtt.getRTT() > 0,
"expected getRTT() to return a positive duration, got %v",
rtt.getRTT())
assert.True(
t,
rtt.getMinRTT() > 0,
"expected getMinRTT() to return a positive duration, got %v",
rtt.getMinRTT())
})
t.Run("creates the correct size samples slice", func(t *testing.T) {
t.Parallel()
cases := []struct {
desc string
interval time.Duration
wantSamplesLen int
}{
{
desc: "default",
interval: 10 * time.Second,
wantSamplesLen: 30,
},
{
desc: "min",
interval: 10 * time.Minute,
wantSamplesLen: 5,
},
{
desc: "max",
interval: 1 * time.Millisecond,
wantSamplesLen: 500,
},
}
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
rtt := newRTTMonitor(&rttConfig{
interval: tc.interval,
minRTTWindow: 5 * time.Minute,
})
assert.Equal(t, tc.wantSamplesLen, len(rtt.samples), "expected samples length to match")
})
}
})
t.Run("can connect and disconnect repeatedly", func(t *testing.T) {
t.Parallel()
dialer := DialerFunc(func(_ context.Context, _, _ string) (net.Conn, error) {
return newMockSlowConn(makeHelloReply(), 10*time.Millisecond), nil
})
rtt := newRTTMonitor(&rttConfig{
interval: 10 * time.Second,
createConnectionFn: func() *connection {
return newConnection("", WithDialer(func(Dialer) Dialer {
return dialer
}))
},
createOperationFn: func(conn driver.Connection) *operation.Hello {
return operation.NewHello().Deployment(driver.SingleConnectionDeployment{C: conn})
},
})
for i := 0; i < 100; i++ {
rtt.connect()
rtt.disconnect()
}
})
t.Run("works after reset", func(t *testing.T) {
t.Parallel()
dialer := DialerFunc(func(_ context.Context, _, _ string) (net.Conn, error) {
return newMockSlowConn(makeHelloReply(), 10*time.Millisecond), nil
})
rtt := newRTTMonitor(&rttConfig{
interval: 10 * time.Millisecond,
createConnectionFn: func() *connection {
return newConnection("", WithDialer(func(Dialer) Dialer { return dialer }))
},
createOperationFn: func(conn driver.Connection) *operation.Hello {
return operation.NewHello().Deployment(driver.SingleConnectionDeployment{C: conn})
},
})
rtt.connect()
defer rtt.disconnect()
for i := 0; i < 3; i++ {
assert.Eventuallyf(
t,
func() bool { return rtt.getRTT() > 0 && rtt.getMinRTT() > 0 },
1*time.Second,
10*time.Millisecond,
"expected getRTT() and getMinRTT() to return positive durations within 1 second")
rtt.reset()
}
})
} | explode_data.jsonl/28473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1511
} | [
2830,
3393,
5350,
51,
30098,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
2660,
23471,
279,
5461,
323,
8028,
10635,
51,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
2822,
197,
2698,
530,
261,
1669,
66155,
261,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddCategoryEmpty(t *testing.T) {
t.Parallel()
// arrange
p := podcast.New("title", "link", "description", nil, nil)
// act
p.AddCategory("", nil)
// assert
assert.Len(t, p.ICategories, 0)
assert.Len(t, p.Category, 0)
} | explode_data.jsonl/73069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
2212,
6746,
3522,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
30893,
198,
3223,
1669,
17711,
7121,
445,
2102,
497,
330,
2080,
497,
330,
4684,
497,
2092,
11,
2092,
692,
197,
322,
1160,
198,
3223,
1904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTenantCreate(t *testing.T) {
// Pass collection to package
tenantID := testCreate(t)
testGet(tenantID, t)
testUpdate(tenantID, t)
testList(t)
testDelete(tenantID, t)
//testGet(tenantID, t)
} | explode_data.jsonl/67812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
71252,
4021,
1155,
353,
8840,
836,
8,
1476,
197,
322,
9970,
4426,
311,
6328,
271,
197,
43919,
915,
1669,
1273,
4021,
1155,
340,
18185,
1949,
1155,
25121,
915,
11,
259,
340,
18185,
4289,
1155,
25121,
915,
11,
259,
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... | 1 |
func TestCrComplexLargeRenameCycle(t *testing.T) {
test(t,
users("alice", "bob"),
as(alice,
mkdir("a/b/c"),
mkdir("d/e/f"),
),
as(bob,
disableUpdates(),
),
as(alice,
rename("d", "a/b/c/d"),
),
as(bob, noSync(),
mkdir("d/e/f/g/h/i"),
rename("a", "d/e/f/g/h/i/a"),
reenableUpdates(),
lsdir("a/b/c/d/e/f/g/h/i", m{"a": "SYM"}),
lsdir("a/b/c/d/e/f/g/h/i/a", m{"b": "DIR"}),
),
as(alice,
lsdir("a/b/c/d/e/f/g/h/i", m{"a": "SYM"}),
lsdir("a/b/c/d/e/f/g/h/i/a", m{"b": "DIR"}),
write("a/j", "hello"),
),
as(bob,
read("a/b/c/d/e/f/g/h/i/a/j", "hello"),
),
)
} | explode_data.jsonl/31358 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
16001,
31137,
34253,
88757,
44820,
1155,
353,
8840,
836,
8,
341,
18185,
1155,
345,
197,
90896,
445,
63195,
497,
330,
47086,
4461,
197,
60451,
17643,
558,
345,
298,
88650,
445,
64,
3470,
2899,
4461,
298,
88650,
445,
67,
16546... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewLevelDBReceiptsCreateOK(t *testing.T) {
assert := assert.New(t)
conf := &LevelDBReceiptStoreConf{
Path: tmpdir,
}
r, err := newLevelDBReceipts(conf)
defer r.store.Close()
assert.Equal(conf, r.conf)
assert.Nil(err)
assert.NotNil(r.store)
} | explode_data.jsonl/21448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
3564,
4449,
3506,
67461,
82,
4021,
3925,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
67850,
1669,
609,
4449,
3506,
67461,
6093,
15578,
515,
197,
69640,
25,
4174,
3741,
345,
197,
532,
7000,
11,
1848,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestComplexDelete(t *testing.T) {
ranInt := rand.Intn(writerComplexDeleteTestData.InsertCount)
w := newWriter()
c, err := NewClient(WithURI(fmt.Sprintf("postgres://127.0.0.1:5432/%s?sslmode=disable", writerComplexDeleteTestData.DB)))
if err != nil {
t.Fatalf("unable to initialize connection to postgres, %s", err)
}
defer c.Close()
s, err := c.Connect()
if err != nil {
t.Fatalf("unable to obtain session to postgres, %s", err)
}
msg := message.From(
ops.Delete,
fmt.Sprintf("public.%s", writerComplexDeleteTestData.Table),
data.Data{"id": ranInt, "colvar": randomHeros[ranInt]})
if _, err := w.Write(msg)(s); err != nil {
t.Errorf("unexpected Delete error, %s\n", err)
}
var id int
if err := s.(*Session).pqSession.
QueryRow(fmt.Sprintf("SELECT id FROM %s WHERE id = %d AND colvar = '%s'", writerComplexDeleteTestData.Table, ranInt, randomHeros[ranInt])).
Scan(&id); err == nil {
t.Fatalf("Values were found, but where not expected to be: %v", id)
}
} | explode_data.jsonl/32014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 385
} | [
2830,
3393,
31137,
6435,
1155,
353,
8840,
836,
8,
341,
197,
6576,
1072,
1669,
10382,
7371,
77,
38356,
31137,
6435,
83920,
23142,
2507,
340,
6692,
1669,
501,
6492,
741,
1444,
11,
1848,
1669,
1532,
2959,
7,
2354,
10301,
28197,
17305,
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... | 5 |
func TestParseQuery(t *testing.T) {
for i, test := range parseTests {
form, err := ParseQuery(test.query)
if err != nil {
t.Errorf("test %d: Unexpected error: %v", i, err)
continue
}
if len(form) != len(test.out) {
t.Errorf("test %d: len(form) = %d, want %d", i, len(form), len(test.out))
}
for k, evs := range test.out {
vs, ok := form[k]
if !ok {
t.Errorf("test %d: Missing key %q", i, k)
continue
}
if len(vs) != len(evs) {
t.Errorf("test %d: len(form[%q]) = %d, want %d", i, k, len(vs), len(evs))
continue
}
for j, ev := range evs {
if v := vs[j]; v != ev {
t.Errorf("test %d: form[%q][%d] = %q, want %q", i, k, j, v, ev)
}
}
}
}
} | explode_data.jsonl/71728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
14463,
2859,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
4715,
18200,
341,
197,
37410,
11,
1848,
1669,
14775,
2859,
8623,
4786,
340,
197,
743,
1848,
961,
2092,
341,
298,
3244,
13080,
445,
1944,
1018,
67,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestFailoverPlayground(t *testing.T) {
t.Parallel()
const host = "playground-failover.cloud.example.com"
const gslbPath = "../examples/failover-playground.yaml"
const euGeoTag = "eu"
const usGeoTag = "us"
instanceEU, err := utils.NewWorkflow(t, "k3d-test-gslb1", 5053).
WithGslb(gslbPath, host).
WithTestApp(euGeoTag).
Start()
require.NoError(t, err)
defer instanceEU.Kill()
instanceUS, err := utils.NewWorkflow(t, "k3d-test-gslb2", 5054).
WithGslb(gslbPath, host).
WithTestApp(usGeoTag).
Start()
require.NoError(t, err)
defer instanceUS.Kill()
actAndAssert := func(test, geoTag string, localTargets []string) {
// waiting for DNS sync
err = instanceEU.WaitForExpected(localTargets)
require.NoError(t, err)
err = instanceUS.WaitForExpected(localTargets)
require.NoError(t, err)
// hit testApp from both clusters
httpResult := instanceEU.HitTestApp()
assert.Equal(t, geoTag, httpResult.Message)
httpResult = instanceUS.HitTestApp()
assert.Equal(t, geoTag, httpResult.Message)
}
t.Run("failover on two concurrent clusters with TestApp running", func(t *testing.T) {
err = instanceEU.WaitForAppIsRunning()
require.NoError(t, err)
err = instanceUS.WaitForAppIsRunning()
require.NoError(t, err)
})
euLocalTargets := instanceEU.GetLocalTargets()
usLocalTargets := instanceUS.GetLocalTargets()
t.Run("stop podinfo on eu cluster", func(t *testing.T) {
instanceEU.StopTestApp()
require.NoError(t, instanceEU.WaitForAppIsStopped())
actAndAssert(t.Name(), usGeoTag, usLocalTargets)
})
t.Run("start podinfo again on eu cluster", func(t *testing.T) {
instanceEU.StartTestApp()
require.NoError(t, instanceEU.WaitForAppIsRunning())
actAndAssert(t.Name(), euGeoTag, euLocalTargets)
})
} | explode_data.jsonl/69356 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 693
} | [
2830,
3393,
19524,
1975,
9137,
1951,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
4777,
3468,
284,
330,
1363,
1951,
2220,
604,
1975,
16935,
7724,
905,
698,
4777,
44221,
65,
1820,
284,
7005,
51668,
6663,
604,
1975,
26544,
1951,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApixu_Conditions(t *testing.T) {
data := loadData(t, "conditions")
a := &apixu{
config: Config{},
httpClient: &httpClientMock{
response: &http.Response{
StatusCode: http.StatusOK,
Body: &bodyMock{},
},
err: nil,
},
read: func(r io.Reader) ([]byte, error) {
return data, nil
},
}
expected := &response.Conditions{}
if err := json.Unmarshal(data, expected); err != nil {
assert.Fail(t, err.Error())
}
res, err := a.Conditions()
assert.Equal(t, *expected, res)
assert.NoError(t, err)
} | explode_data.jsonl/14938 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
10611,
941,
84,
920,
2111,
5930,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
62432,
1155,
11,
330,
16495,
5130,
11323,
1669,
609,
391,
941,
84,
515,
197,
25873,
25,
5532,
38837,
197,
28080,
2959,
25,
609,
83417,
11571,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDecryptStringFromAlphabetToIntegerMapping1(t *testing.T) {
s := "10#11#12"
expected := "jkab"
actual := FreqAlphabets(s)
assert.Equal(t, expected, actual)
} | explode_data.jsonl/79310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
89660,
703,
3830,
2101,
18485,
1249,
3486,
6807,
16,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
330,
16,
15,
2,
16,
16,
2,
16,
17,
698,
42400,
1669,
330,
41808,
370,
698,
88814,
1669,
434,
2958,
2101,
759,
370,
1415,
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 |
func TestRobotsTXTOutput(t *testing.T) {
t.Parallel()
var (
cfg, fs = newTestCfg()
th = testHelper{cfg, fs, t}
)
cfg.Set("baseURL", "http://auth/bub/")
cfg.Set("enableRobotsTXT", true)
writeSource(t, fs, filepath.Join("layouts", "robots.txt"), robotTxtTemplate)
writeSourcesToSource(t, "content", fs, weightedSources...)
buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
th.assertFileContent("public/robots.txt", "User-agent: Googlebot")
} | explode_data.jsonl/79481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
14465,
2412,
62865,
5097,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2405,
2399,
197,
50286,
11,
8619,
284,
501,
2271,
42467,
741,
197,
70479,
414,
284,
1273,
5511,
90,
14072,
11,
8619,
11,
259,
532,
197,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_fsimpl_WriteYamls(t *testing.T) {
tests := map[string]struct {
o []interface{}
wantErr string
assertFn func(*testing.T, FS)
}{
"Should write a simple manifest": {
o: []interface{}{
&corev1.Namespace{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Namespace",
},
ObjectMeta: metav1.ObjectMeta{
Name: "namespace",
},
},
},
assertFn: func(t *testing.T, fs FS) {
data, err := fs.ReadFile("filename")
assert.NoError(t, err)
ns := &corev1.Namespace{}
err = yaml.Unmarshal(data, ns)
assert.NoError(t, err)
assert.Equal(t, "namespace", ns.Name)
},
},
"Should write two manifests": {
o: []interface{}{
&corev1.Namespace{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Namespace",
},
ObjectMeta: metav1.ObjectMeta{
Name: "namespace1",
},
},
&corev1.Namespace{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Namespace",
},
ObjectMeta: metav1.ObjectMeta{
Name: "namespace2",
},
},
},
assertFn: func(t *testing.T, fs FS) {
data, err := fs.ReadFile("filename")
assert.NoError(t, err)
manifests := util.SplitManifests(data)
ns1 := &corev1.Namespace{}
ns2 := &corev1.Namespace{}
err = yaml.Unmarshal(manifests[0], ns1)
assert.NoError(t, err)
err = yaml.Unmarshal(manifests[1], ns2)
assert.NoError(t, err)
assert.Equal(t, "namespace1", ns1.Name)
assert.Equal(t, "namespace2", ns2.Name)
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
fs := Create(memfs.New())
if err := fs.WriteYamls("filename", tt.o...); err != nil {
if tt.wantErr != "" {
assert.EqualError(t, err, tt.wantErr)
} else {
t.Errorf("WriteYamls() error = %v", err)
}
return
}
if tt.assertFn != nil {
tt.assertFn(t, fs)
}
})
}
} | explode_data.jsonl/58984 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1016
} | [
2830,
3393,
34470,
6383,
31825,
56,
309,
4730,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
22229,
286,
3056,
4970,
16094,
197,
50780,
7747,
220,
914,
198,
197,
6948,
24911,
2915,
4071,
8840,
836,
11,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_command(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("Command genration", func() {
g.It("should ignore plugin steps", func() {
c := newConfig(&yaml.Container{
Commands: []string{
"go build",
"go test",
},
Vargs: map[string]interface{}{
"depth": 50,
},
})
CommandTransform(c)
g.Assert(len(c.Pipeline[0].Entrypoint)).Equal(0)
g.Assert(len(c.Pipeline[0].Command)).Equal(0)
g.Assert(c.Pipeline[0].Environment["DRONE_SCRIPT"]).Equal("")
})
g.It("should set entrypoint, command and environment variables", func() {
c := newConfig(&yaml.Container{
Commands: []string{
"go build",
"go test",
},
})
CommandTransform(c)
g.Assert(c.Pipeline[0].Entrypoint).Equal([]string{"/bin/sh", "-c"})
g.Assert(c.Pipeline[0].Command).Equal([]string{"echo $DRONE_SCRIPT | base64 -d | /bin/sh -e"})
g.Assert(c.Pipeline[0].Environment["DRONE_SCRIPT"] != "").IsTrue()
})
})
} | explode_data.jsonl/41277 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
10811,
1155,
353,
8840,
836,
8,
1476,
3174,
1669,
342,
47061,
1224,
47061,
1155,
340,
3174,
23548,
3114,
445,
4062,
4081,
2165,
497,
2915,
368,
1476,
197,
3174,
27528,
445,
5445,
10034,
9006,
7354,
497,
2915,
368,
341,
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 |
func TestUnmarshalThrift(t *testing.T) {
addr := func(i int64) *int64 { return &i }
tests := []struct {
name string
filename string
want []*zipkincore.Span
wantErr bool
}{
{
name: "threespans",
filename: "../../testdata/threespans.dat",
want: []*zipkincore.Span{
{
TraceID: 2505404965370368069,
Name: "Child",
ID: 8090652509916334619,
ParentID: addr(22964302721410078),
Timestamp: addr(1498688360851331),
Duration: addr(53106),
Annotations: []*zipkincore.Annotation{},
BinaryAnnotations: []*zipkincore.BinaryAnnotation{
{
Key: "lc",
AnnotationType: zipkincore.AnnotationType_STRING,
Value: []byte("trivial"),
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
},
},
{
TraceID: 2505404965370368069,
Name: "Child",
ID: 103618986556047333,
ParentID: addr(22964302721410078),
Timestamp: addr(1498688360904552),
Duration: addr(50410),
Annotations: []*zipkincore.Annotation{},
BinaryAnnotations: []*zipkincore.BinaryAnnotation{
{
Key: "lc",
AnnotationType: zipkincore.AnnotationType_STRING,
Value: []byte("trivial"),
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
},
},
{
TraceID: 2505404965370368069,
Name: "Parent",
ID: 22964302721410078,
Timestamp: addr(1498688360851318),
Duration: addr(103680),
Annotations: []*zipkincore.Annotation{
{
Timestamp: 1498688360851325,
Value: "Starting child #0",
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
{
Timestamp: 1498688360904545,
Value: "Starting child #1",
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
{
Timestamp: 1498688360954992,
Value: "A Log",
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
},
BinaryAnnotations: []*zipkincore.BinaryAnnotation{
{
Key: "lc",
AnnotationType: zipkincore.AnnotationType_STRING,
Value: []byte("trivial"),
Host: &zipkincore.Endpoint{
Ipv4: 2130706433,
ServiceName: "trivial",
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dat, err := ioutil.ReadFile(tt.filename)
if err != nil {
t.Fatalf("Could not find file %s\n", tt.filename)
}
got, err := UnmarshalThrift(dat)
if (err != nil) != tt.wantErr {
t.Errorf("UnmarshalThrift() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !cmp.Equal(tt.want, got) {
t.Errorf("UnmarshalThrift() got(-)/want(+): %s", cmp.Diff(tt.want, got))
}
})
}
} | explode_data.jsonl/57266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1801
} | [
2830,
3393,
1806,
27121,
1001,
41380,
1155,
353,
8840,
836,
8,
341,
53183,
1669,
2915,
1956,
526,
21,
19,
8,
353,
396,
21,
19,
314,
470,
609,
72,
456,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
66434,
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 TestValidateKubernetesLabelKey(t *testing.T) {
validLabelKeys := []string{"a", "a1", "this--valid--label--is--exactly--sixty--three--characters--long", "123456", "my-label_valid.com", "foo.bar/name", "1.2321.324/key_name.foo", "valid.long.253.characters.label.key.prefix.12345678910.fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo/my-key"}
invalidLabelKeys := []string{"", "a/b/c", ".startswithdot", "spaces in key", "foo/", "/name", "$.$/com", "too-long-254-characters-key-prefix-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------123/name", "wrong-slash\\foo"}
for _, l := range validLabelKeys {
if err := validateKubernetesLabelKey(l); err != nil {
t.Fatalf("Label key %v should not return error: %v", l, err)
}
}
for _, l := range invalidLabelKeys {
if err := validateKubernetesLabelKey(l); err == nil {
t.Fatalf("Label key %v should return an error", l)
}
}
} | explode_data.jsonl/17872 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 328
} | [
2830,
3393,
17926,
42,
29827,
2476,
1592,
1155,
353,
8840,
836,
8,
1476,
56322,
2476,
8850,
1669,
3056,
917,
4913,
64,
497,
330,
64,
16,
497,
330,
574,
313,
1891,
313,
1502,
313,
285,
313,
327,
32739,
313,
50364,
1881,
313,
27856,
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... | 5 |
func TestSelectUserPortinformer(t *testing.T) {
db, mock, err := sqlmock.New()
if err != nil {
t.Fatal(err)
}
defer db.Close()
retRows := sqlmock.NewRows([]string{"fk_portinformer"}).AddRow("28")
mock.ExpectQuery("SELECT fk_portinformer FROM portinformer_managers WHERE fk_user = ?").
WithArgs("7").
WillReturnRows(retRows)
r := Repository{Conn: db}
rows := r.SelectUserPortinformer("7")
assert.Equal(t, rows, "28")
} | explode_data.jsonl/30231 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
3379,
1474,
7084,
258,
34527,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
1848,
1669,
5704,
16712,
7121,
2822,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
16867,
2927,
10421,
2822,
11262,
9024,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergeTags(t *testing.T) {
ec2Key := "ec2Key"
ec2Value := "ec2Value"
localKey := "localKey"
localValue := "localValue"
commonKey := "commonKey"
commonKeyEC2Value := "commonEC2Value"
commonKeyLocalValue := "commonKeyLocalValue"
localTags := []*ecs.Tag{
{
Key: aws.String(localKey),
Value: aws.String(localValue),
},
{
Key: aws.String(commonKey),
Value: aws.String(commonKeyLocalValue),
},
}
ec2Tags := []*ecs.Tag{
{
Key: aws.String(ec2Key),
Value: aws.String(ec2Value),
},
{
Key: aws.String(commonKey),
Value: aws.String(commonKeyEC2Value),
},
}
mergedTags := mergeTags(localTags, ec2Tags)
assert.Equal(t, len(mergedTags), 3)
sort.Slice(mergedTags, func(i, j int) bool {
return aws.StringValue(mergedTags[i].Key) < aws.StringValue(mergedTags[j].Key)
})
assert.Equal(t, commonKey, aws.StringValue(mergedTags[0].Key))
assert.Equal(t, commonKeyLocalValue, aws.StringValue(mergedTags[0].Value))
assert.Equal(t, ec2Key, aws.StringValue(mergedTags[1].Key))
assert.Equal(t, ec2Value, aws.StringValue(mergedTags[1].Value))
assert.Equal(t, localKey, aws.StringValue(mergedTags[2].Key))
assert.Equal(t, localValue, aws.StringValue(mergedTags[2].Value))
} | explode_data.jsonl/41603 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
52096,
15930,
1155,
353,
8840,
836,
8,
341,
197,
757,
17,
1592,
1669,
330,
757,
17,
1592,
698,
197,
757,
17,
1130,
1669,
330,
757,
17,
1130,
698,
8854,
1592,
1669,
330,
2438,
1592,
698,
8854,
1130,
1669,
330,
2438,
1130,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsolation(t *testing.T) {
require := require.New(t)
cmder := &testCommander{T: t}
strg := &StorageMock{}
root, err := ioutil.TempDir("", "flist_root")
require.NoError(err)
defer os.RemoveAll(root)
sys := &testSystem{}
flister := newFlister(root, strg, cmder, sys)
backend, err := ioutil.TempDir("", "flist_backend")
require.NoError(err)
defer os.RemoveAll(backend)
strg.On("VolumeLookup", mock.Anything, mock.Anything).Return(backend, nil)
strg.On("VolumeCreate", mock.Anything, mock.Anything, mock.Anything, uint64(256*mib)).
Return(backend, nil)
name1 := "test1"
sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name1), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil)
name2 := "test2"
sys.On("Mount", "overlay", filepath.Join(root, "mountpoint", name2), "overlay", uintptr(syscall.MS_NOATIME), mock.Anything).Return(nil)
path1, err := flister.Mount(name1, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions)
require.NoError(err)
args1 := cmder.m
path2, err := flister.Mount(name2, "https://hub.grid.tf/thabet/redis.flist", pkg.DefaultMountOptions)
require.NoError(err)
args2 := cmder.m
require.NotEqual(path1, path2)
require.Equal(args1, args2)
} | explode_data.jsonl/16421 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
3872,
34962,
1155,
353,
8840,
836,
8,
341,
17957,
1669,
1373,
7121,
1155,
692,
98316,
1107,
1669,
609,
1944,
4062,
261,
76025,
25,
259,
532,
11355,
70,
1669,
609,
5793,
11571,
31483,
33698,
11,
1848,
1669,
43144,
65009,
6184... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPoolTxRefund(t *testing.T) {
input := CreateTestEnv(t)
defer func() { input.Context.Logger().Info("Asserting invariants at test end"); input.AssertInvariants() }()
ctx := input.Context
var (
now = time.Now().UTC()
mySender, _ = sdk.AccAddressFromBech32("gravity1ahx7f8wyertuus9r20284ej0asrs085ceqtfnm")
notMySender, _ = sdk.AccAddressFromBech32("gravity1ahx7f8wyertuus9r20284ej0asrs085case3km")
myReceiver = "0xd041c41EA1bf0F006ADBb6d2c9ef9D425dE5eaD7"
myTokenContractAddr = "0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5" // Pickle
token, err = types.NewInternalERC20Token(sdk.NewInt(414), myTokenContractAddr)
allVouchers = sdk.NewCoins(token.GravityCoin())
denomToken, dErr = types.NewInternalERC20Token(sdk.NewInt(1), myTokenContractAddr)
myDenom = denomToken.GravityCoin().Denom
)
require.NoError(t, err)
require.NoError(t, dErr)
contract, err := types.NewEthAddress(myTokenContractAddr)
require.NoError(t, err)
receiver, err := types.NewEthAddress(myReceiver)
require.NoError(t, err)
// mint some voucher first
require.NoError(t, input.BankKeeper.MintCoins(ctx, types.ModuleName, allVouchers))
// set senders balance
input.AccountKeeper.NewAccountWithAddress(ctx, mySender)
require.NoError(t, input.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, mySender, allVouchers))
// CREATE FIRST BATCH
// ==================
// add some TX to the pool
for i, v := range []uint64{2, 3, 2, 1} {
amountToken, err := types.NewInternalERC20Token(sdk.NewInt(int64(i+100)), myTokenContractAddr)
require.NoError(t, err)
amount := amountToken.GravityCoin()
feeToken, err := types.NewInternalERC20Token(sdk.NewIntFromUint64(v), myTokenContractAddr)
require.NoError(t, err)
fee := feeToken.GravityCoin()
_, err = input.GravityKeeper.AddToOutgoingPool(ctx, mySender, *receiver, amount, fee)
require.NoError(t, err)
// Should have created:
// 1: amount 100, fee 2
// 2: amount 101, fee 3
// 3: amount 102, fee 2
// 4: amount 103, fee 1
}
// when
ctx = ctx.WithBlockTime(now)
// tx batch size is 2, so that some of them stay behind
// Should have 2: and 3: from above
_, err = input.GravityKeeper.BuildOutgoingTXBatch(ctx, *contract, 2)
require.NoError(t, err)
// try to refund a tx that's in a batch
err1 := input.GravityKeeper.RemoveFromOutgoingPoolAndRefund(ctx, 3, mySender)
require.Error(t, err1)
// try to refund somebody else's tx
err2 := input.GravityKeeper.RemoveFromOutgoingPoolAndRefund(ctx, 4, notMySender)
require.Error(t, err2)
// try to refund a tx that's in the pool
err3 := input.GravityKeeper.RemoveFromOutgoingPoolAndRefund(ctx, 4, mySender)
require.NoError(t, err3)
// make sure refund was issued
balances := input.BankKeeper.GetAllBalances(ctx, mySender)
require.Equal(t, sdk.NewInt(104), balances.AmountOf(myDenom))
} | explode_data.jsonl/21413 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1174
} | [
2830,
3393,
10551,
31584,
3945,
1241,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
4230,
2271,
14359,
1155,
340,
16867,
2915,
368,
314,
1946,
9328,
12750,
1005,
1731,
445,
8534,
287,
304,
54611,
518,
1273,
835,
5038,
1946,
11711,
641,
546... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTeamsService_EditTeamByID(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
input := NewTeam{Name: "n", Privacy: String("closed")}
mux.HandleFunc("/organizations/1/team/1", func(w http.ResponseWriter, r *http.Request) {
v := new(NewTeam)
json.NewDecoder(r.Body).Decode(v)
testMethod(t, r, "PATCH")
if !cmp.Equal(v, &input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
fmt.Fprint(w, `{"id":1}`)
})
ctx := context.Background()
team, _, err := client.Teams.EditTeamByID(ctx, 1, 1, input, false)
if err != nil {
t.Errorf("Teams.EditTeamByID returned error: %v", err)
}
want := &Team{ID: Int64(1)}
if !cmp.Equal(team, want) {
t.Errorf("Teams.EditTeamByID returned %+v, want %+v", team, want)
}
const methodName = "EditTeamByID"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Teams.EditTeamByID(ctx, -1, -1, input, false)
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Teams.EditTeamByID(ctx, 1, 1, input, false)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
} | explode_data.jsonl/4516 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
60669,
1860,
66158,
14597,
60572,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
22427,
1669,
1532,
14597,
63121,
25,
330,
77,
497,
18874,
25,
923,
445,
34087,
899,
630,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConnectAndWriteIntegration(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
server := []string{testutil.GetLocalHost() + ":4150"}
s, _ := serializers.NewInfluxSerializer()
n := &NSQ{
Server: server[0],
Topic: "telegraf",
serializer: s,
}
// Verify that we can connect to the NSQ daemon
err := n.Connect()
require.NoError(t, err)
// Verify that we can successfully write data to the NSQ daemon
err = n.Write(testutil.MockMetrics())
require.NoError(t, err)
} | explode_data.jsonl/35326 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
14611,
3036,
7985,
52464,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
445,
85945,
17590,
1273,
304,
2805,
3856,
1138,
197,
630,
41057,
1669,
3056,
917,
90,
1944,
1314,
2234,
7319,
9296,
368,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReportWorkflowResource_ScheduledWorkflowIDEmpty_Success(t *testing.T) {
store, manager, run := initWithOneTimeRun(t)
defer store.Close()
// report workflow
workflow := util.NewWorkflow(&v1alpha1.Workflow{
ObjectMeta: v1.ObjectMeta{
UID: types.UID(run.UUID),
},
Status: v1alpha1.WorkflowStatus{Phase: v1alpha1.NodeRunning},
})
err := manager.ReportWorkflowResource(workflow)
assert.Nil(t, err)
runDetail, err := manager.GetRun(run.UUID)
assert.Nil(t, err)
expectedRun := model.Run{
UUID: "workflow1",
DisplayName: "run1",
Name: "workflow-name",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 2,
Conditions: "Running",
PipelineSpec: model.PipelineSpec{
WorkflowSpecManifest: testWorkflow.ToStringForStore(),
Parameters: "[{\"name\":\"param1\",\"value\":\"world\"}]",
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "workflow1",
ResourceType: common.Run,
ReferenceUUID: DefaultFakeUUID,
ReferenceType: common.Experiment,
Relationship: common.Owner,
},
},
}
assert.Equal(t, expectedRun, runDetail.Run)
} | explode_data.jsonl/28389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
10361,
62768,
4783,
1098,
26644,
62768,
915,
3522,
87161,
1155,
353,
8840,
836,
8,
341,
57279,
11,
6645,
11,
1598,
1669,
13864,
3966,
1462,
6727,
1155,
340,
16867,
3553,
10421,
741,
197,
322,
1895,
28288,
198,
197,
56249,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAttachmentMarshalJSON(t *testing.T) {
tests := []struct {
name string
att *Attachment
expected string
err string
}{
{
name: "foo.txt",
att: &Attachment{
Content: ioutil.NopCloser(strings.NewReader("test attachment\n")),
Filename: "foo.txt",
ContentType: "text/plain",
},
expected: `{
"content_type": "text/plain",
"data": "dGVzdCBhdHRhY2htZW50Cg=="
}`,
},
{
name: "read error",
att: &Attachment{
Content: ioutil.NopCloser(&errorReader{}),
Filename: "foo.txt",
ContentType: "text/plain",
},
err: "json: error calling MarshalJSON for type *kivik.Attachment: errorReader",
},
}
for _, test := range tests {
result, err := json.Marshal(test.att)
testy.Error(t, test.err, err)
if d := diff.JSON([]byte(test.expected), result); d != nil {
t.Error(d)
}
}
} | explode_data.jsonl/28903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 409
} | [
2830,
3393,
33569,
55438,
5370,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
197,
1587,
414,
353,
33569,
198,
197,
42400,
914,
198,
197,
9859,
414,
914,
198,
197,
59403,
197,
197,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestMergeTideContextPolicyConfig(t *testing.T) {
yes := true
no := false
testCases := []struct {
name string
a, b, c TideContextPolicy
}{
{
name: "all empty",
},
{
name: "empty a",
b: TideContextPolicy{
SkipUnknownContexts: &yes,
FromBranchProtection: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
c: TideContextPolicy{
SkipUnknownContexts: &yes,
FromBranchProtection: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
},
{
name: "empty b",
a: TideContextPolicy{
SkipUnknownContexts: &yes,
FromBranchProtection: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
c: TideContextPolicy{
SkipUnknownContexts: &yes,
FromBranchProtection: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
},
{
name: "merging unset boolean",
a: TideContextPolicy{
FromBranchProtection: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
b: TideContextPolicy{
SkipUnknownContexts: &yes,
RequiredContexts: []string{"r2"},
OptionalContexts: []string{"o2"},
},
c: TideContextPolicy{
SkipUnknownContexts: &yes,
FromBranchProtection: &no,
RequiredContexts: []string{"r1", "r2"},
OptionalContexts: []string{"o1", "o2"},
},
},
{
name: "merging unset contexts in a",
a: TideContextPolicy{
FromBranchProtection: &no,
SkipUnknownContexts: &yes,
},
b: TideContextPolicy{
FromBranchProtection: &yes,
SkipUnknownContexts: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
c: TideContextPolicy{
FromBranchProtection: &yes,
SkipUnknownContexts: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
},
{
name: "merging unset contexts in b",
a: TideContextPolicy{
FromBranchProtection: &yes,
SkipUnknownContexts: &no,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
b: TideContextPolicy{
FromBranchProtection: &no,
SkipUnknownContexts: &yes,
},
c: TideContextPolicy{
FromBranchProtection: &no,
SkipUnknownContexts: &yes,
RequiredContexts: []string{"r1"},
OptionalContexts: []string{"o1"},
},
},
}
for _, tc := range testCases {
c := mergeTideContextPolicy(tc.a, tc.b)
if !reflect.DeepEqual(c, tc.c) {
t.Errorf("%s - expected %v got %v", tc.name, tc.c, c)
}
}
} | explode_data.jsonl/53859 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1223
} | [
2830,
3393,
52096,
51,
577,
1972,
13825,
2648,
1155,
353,
8840,
836,
8,
341,
197,
9693,
1669,
830,
198,
72104,
1669,
895,
198,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
11323,
11,
293,
11,
272,
71016,
1972,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStorePatch(t *testing.T) {
testWithPostgresStoreV2(t, func(s storev2.Interface) {
fixture := corev3.FixtureEntityState("foo")
ctx := context.Background()
req := storev2.NewResourceRequestFromResource(ctx, fixture)
req.UsePostgres = true
wrapper := WrapEntityState(fixture)
if err := s.CreateOrUpdate(req, wrapper); err != nil {
t.Error(err)
}
patcher := &patch.Merge{
MergePatch: []byte(`{"metadata":{"labels":{"food":"hummus"}}}`),
}
if err := s.Patch(req, wrapper, patcher, nil); err != nil {
t.Fatal(err)
}
updatedWrapper, err := s.Get(req)
if err != nil {
t.Fatal(err)
}
updated, err := updatedWrapper.Unwrap()
if err != nil {
t.Fatal(err)
}
if got, want := updated.GetMetadata().Labels["food"], "hummus"; got != want {
t.Errorf("bad patched labels: got %q, want %q", got, want)
}
})
} | explode_data.jsonl/73386 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
6093,
43622,
1155,
353,
8840,
836,
8,
341,
18185,
2354,
4133,
17818,
6093,
53,
17,
1155,
11,
2915,
1141,
3553,
85,
17,
41065,
8,
341,
197,
1166,
12735,
1669,
6200,
85,
18,
991,
12735,
3030,
1397,
445,
7975,
1138,
197,
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... | 6 |
func TestAccAzureRMLoadBalancerNatRule_requiresImport(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_lb_nat_rule", "test")
r := LoadBalancerNatRule{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data, "Basic"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.RequiresImportErrorStep(r.requiresImport),
})
} | explode_data.jsonl/29071 | {
"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,
14603,
78107,
49,
2668,
2731,
93825,
65214,
11337,
54949,
11511,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
25505,
25212,
83920,
1155,
11,
330,
1370,
324,
4195,
63601,
38169,
21124,
497,
330,
1944,
1138,
7000,
1669,
8893,
93825... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApi_GetRequestToken(t *testing.T) {
a := NewAPI("1438129266231705", "UYETICGU2CT3KES")
r := &BaseRequest{
Method: "GET",
Resource: "/auth",
Timestamp: 1445440997,
}
assert.Equal(t, "T2YsCOj2o3Rb79nLPUgx3Gl+nnw=", a.GetRequestToken(r))
} | explode_data.jsonl/50520 | {
"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,
6563,
13614,
1900,
3323,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
7082,
445,
16,
19,
18,
23,
16,
17,
24,
17,
21,
21,
17,
18,
16,
22,
15,
20,
497,
330,
31301,
1348,
1317,
54695,
17,
1162,
18,
42,
1570,
5130,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtractCommand(t *testing.T) {
outdir, err := ioutil.TempDir("", "TestExtractCommand")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(outdir)
if err := testableMain([]string{"goi18n", "extract", "-outdir", outdir, "../example/"}); err != nil {
t.Fatal(err)
}
actual, err := ioutil.ReadFile(filepath.Join(outdir, "active.en.toml"))
if err != nil {
t.Fatal(err)
}
expected := []byte(`HelloPerson = "Hello {{.Name}}"
[MyUnreadEmails]
description = "The number of unread emails I have"
one = "I have {{.PluralCount}} unread email."
other = "I have {{.PluralCount}} unread emails."
[PersonUnreadEmails]
description = "The number of unread emails a person has"
one = "{{.Name}} has {{.UnreadEmailCount}} unread email."
other = "{{.Name}} has {{.UnreadEmailCount}} unread emails."
`)
if !bytes.Equal(actual, expected) {
t.Fatalf("files not equal\nactual:\n%s\nexpected:\n%s", actual, expected)
}
} | explode_data.jsonl/82256 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
28959,
4062,
1155,
353,
8840,
836,
8,
341,
13967,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
2271,
28959,
4062,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
16867,
2643,
84427,
9828,
374... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidPOSTForAccountSwappedKey(t *testing.T) {
wfe, fc := setupWFE(t)
wfe.SA = &mockSADifferentStoredKey{mocks.NewStorageAuthority(fc)}
event := newRequestEvent()
payload := `{"resource":"ima-payload"}`
// Sign a request using test1key
_, _, body := signRequestKeyID(t, 1, nil, "http://localhost:4000/test", payload, wfe.nonceService)
request := makePostRequestWithPath("test", body)
// Ensure that ValidPOSTForAccount produces an error since the
// mockSADifferentStoredKey will return a different key than the one we used to
// sign the request
_, _, _, prob := wfe.validPOSTForAccount(request, ctx, event)
test.Assert(t, prob != nil, "No error returned for request signed by wrong key")
test.AssertEquals(t, prob.Type, probs.MalformedProblem)
test.AssertEquals(t, prob.Detail, "JWS verification error")
} | explode_data.jsonl/15358 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 278
} | [
2830,
3393,
4088,
2946,
2461,
7365,
13218,
5677,
1592,
1155,
353,
8840,
836,
8,
341,
6692,
1859,
11,
25563,
1669,
6505,
54,
11419,
1155,
340,
6692,
1859,
808,
32,
284,
609,
16712,
50,
1808,
18277,
93243,
1592,
90,
16712,
82,
7121,
579... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackupRestoreWithConcurrentWrites(t *testing.T) {
defer leaktest.AfterTest(t)()
const rows = 10
const numBackgroundTasks = MultiNode
_, tc, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, MultiNode, rows, InitNone)
defer cleanupFn()
bgActivity := make(chan struct{})
// allowErrors is used as an atomic bool to tell bg workers when to allow
// errors, between dropping and restoring the table they are using.
var allowErrors int32
for task := 0; task < numBackgroundTasks; task++ {
taskNum := task
tc.Stopper().RunWorker(context.Background(), func(context.Context) {
conn := tc.Conns[taskNum%len(tc.Conns)]
// Use different sql gateways to make sure leasing is right.
if err := startBackgroundWrites(tc.Stopper(), conn, rows, bgActivity, &allowErrors); err != nil {
t.Error(err)
}
})
}
// Use the data.bank table as a key (id), value (balance) table with a
// payload.The background tasks are mutating the table concurrently while we
// backup and restore.
<-bgActivity
// Set, break, then reset the id=balance invariant -- while doing concurrent
// writes -- to get multiple MVCC revisions as well as txn conflicts.
sqlDB.Exec(t, `UPDATE data.bank SET balance = id`)
<-bgActivity
sqlDB.Exec(t, `UPDATE data.bank SET balance = -1`)
<-bgActivity
sqlDB.Exec(t, `UPDATE data.bank SET balance = id`)
<-bgActivity
// Backup DB while concurrent writes continue.
sqlDB.Exec(t, `BACKUP DATABASE data TO $1`, LocalFoo)
// Drop the table and restore from backup and check our invariant.
atomic.StoreInt32(&allowErrors, 1)
sqlDB.Exec(t, `DROP TABLE data.bank`)
sqlDB.Exec(t, `RESTORE data.* FROM $1`, LocalFoo)
atomic.StoreInt32(&allowErrors, 0)
bad := sqlDB.QueryStr(t, `SELECT id, balance, payload FROM data.bank WHERE id != balance`)
for _, r := range bad {
t.Errorf("bad row ID %s = bal %s (payload: %q)", r[0], r[1], r[2])
}
} | explode_data.jsonl/57592 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 652
} | [
2830,
3393,
56245,
56284,
2354,
1109,
3231,
93638,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
6978,
284,
220,
16,
15,
198,
4777,
1629,
8706,
25449,
284,
17439,
1955,
271,
197,
6878,
17130,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestServeCached(t *testing.T) {
// Prepare the proxy server.
dnsProxy := createTestProxy(t, nil)
dnsProxy.CacheEnabled = true // just one request per second is allowed
// Start listening.
err := dnsProxy.Start()
require.NoErrorf(t, err, "cannot start the DNS proxy: %s", err)
testutil.CleanupAndRequireSuccess(t, dnsProxy.Stop)
// Fill the cache.
reply := (&dns.Msg{
MsgHdr: dns.MsgHdr{
Response: true,
},
Answer: []dns.RR{newRR(t, "google.com. 3600 IN A 8.8.8.8")},
}).SetQuestion("google.com.", dns.TypeA)
reply.SetEdns0(defaultUDPBufSize, false)
dnsProxy.cache.set(&cacheItem{
m: reply,
u: testUpsAddr,
})
// Create a DNS-over-UDP client connection.
addr := dnsProxy.Addr(ProtoUDP)
client := &dns.Client{Net: "udp", Timeout: 500 * time.Millisecond}
// Create a DNS request.
request := (&dns.Msg{}).SetQuestion("google.com.", dns.TypeA)
request.SetEdns0(defaultUDPBufSize, false)
r, _, err := client.Exchange(request, addr.String())
require.NoErrorf(t, err, "error in the first request: %s", err)
requireEqualMsgs(t, r, reply)
} | explode_data.jsonl/18903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 428
} | [
2830,
3393,
60421,
70293,
1155,
353,
8840,
836,
8,
341,
197,
322,
31166,
279,
13291,
3538,
624,
2698,
4412,
16219,
1669,
1855,
2271,
16219,
1155,
11,
2092,
340,
2698,
4412,
16219,
46130,
5462,
284,
830,
442,
1101,
825,
1681,
817,
2086,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportCardsWithImportError(t *testing.T) {
setService := MockSetService{}
cardService := MockCardService{
FakeImport: func(count int, c *card.Card) error {
if count > 0 {
return fmt.Errorf("card import failed [%s]", c.Number)
}
return nil
},
}
wantCards := 1
importer := NewImporter(&setService, &cardService)
_, err := importer.Import(fromFile(t, "testdata/twoSetsSetMultipleCards.json"))
assert.Contains(t, err.Error(), "card import failed")
if len(cardService.Cards) != wantCards {
t.Errorf("unexpected card count, got: %d, wanted: %d", len(cardService.Cards), wantCards)
}
} | explode_data.jsonl/37499 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
11511,
28448,
2354,
11511,
1454,
1155,
353,
8840,
836,
8,
341,
8196,
1860,
1669,
14563,
1649,
1860,
16094,
80084,
1860,
1669,
14563,
5770,
1860,
515,
197,
12727,
726,
11511,
25,
2915,
11512,
526,
11,
272,
353,
4951,
48613,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMinNumberInRotateArrray(t *testing.T) {
var cases = []struct {
input []int
output int
}{
{
input: []int{3, 4, 5, 1, 2},
output: 1,
},
{
input: []int{3, 100, 200, 3},
output: 3,
},
{
input: []int{1, 0, 1, 1, 1},
output: 0,
},
{
input: []int{2, 2, 2, 1, 2},
output: 1,
},
}
for i, c := range cases {
expeced := minNumberInRotateArray(c.input)
if expeced != c.output {
t.Errorf("[%d] fails, %v != %v", i, expeced, c.output)
}
}
} | explode_data.jsonl/57692 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
6217,
2833,
641,
34540,
8838,
11611,
1155,
353,
8840,
836,
8,
341,
2405,
5048,
284,
3056,
1235,
341,
197,
22427,
220,
3056,
396,
198,
197,
21170,
526,
198,
197,
59403,
197,
197,
515,
298,
22427,
25,
220,
3056,
396,
90,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestOptionEquals(t *testing.T) {
o := gs.Some(100)
eq := o.Equals(gs.Eq[int])
assert.True(t, eq(o))
assert.True(t, eq(gs.Some(100)))
assert.False(t, eq(gs.Some(101)))
assert.False(t, eq(gs.None[int]()))
o = gs.None[int]()
eq = o.Equals(gs.Eq[int])
assert.False(t, eq(gs.Some(0)))
assert.False(t, eq(gs.Some(100)))
assert.True(t, eq(gs.None[int]()))
} | explode_data.jsonl/32430 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
5341,
4315,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
28081,
86833,
7,
16,
15,
15,
340,
7727,
80,
1669,
297,
16207,
83394,
5142,
80,
18640,
9604,
6948,
32443,
1155,
11,
8939,
10108,
1171,
6948,
32443,
1155,
11,
8939,
8339... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientSniffNode(t *testing.T) {
client, err := NewClient()
if err != nil {
t.Fatal(err)
}
ch := make(chan []*conn)
go func() { ch <- client.sniffNode(context.Background(), DefaultURL) }()
select {
case nodes := <-ch:
if len(nodes) != 1 {
t.Fatalf("expected %d nodes; got: %d", 1, len(nodes))
}
pattern := `http:\/\/[\d\.]+:9200`
matched, err := regexp.MatchString(pattern, nodes[0].URL())
if err != nil {
t.Fatal(err)
}
if !matched {
t.Fatalf("expected node URL pattern %q; got: %q", pattern, nodes[0].URL())
}
case <-time.After(2 * time.Second):
t.Fatal("expected no timeout in sniff node")
break
}
} | explode_data.jsonl/38006 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
2959,
20720,
3092,
1955,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
1532,
2959,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
23049,
1669,
1281,
35190,
29838,
5148,
340,
30680,
2915,
368,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetVersionInfo(t *testing.T) {
testVersion := "TestVersion"
metadata.Version = testVersion
expected := fmt.Sprintf("%s:\n Version: %s\n Go version: %s\n OS/Arch: %s",
metadata.ProgramName, testVersion, runtime.Version(),
fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH))
assert.Equal(t, expected, metadata.GetVersionInfo())
} | explode_data.jsonl/14705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
1949,
5637,
1731,
1155,
353,
8840,
836,
8,
341,
18185,
5637,
1669,
330,
2271,
5637,
698,
2109,
7603,
35842,
284,
1273,
5637,
271,
42400,
1669,
8879,
17305,
4430,
82,
7190,
77,
6079,
25,
1018,
82,
1699,
5994,
2319,
25,
1018... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServer_Request_Get_Authority(t *testing.T) {
const host = "example.com"
testServerRequest(t, func(st *serverTester) {
st.writeHeaders(HeadersFrameParam{
StreamID: 1, // clients send odd numbers
BlockFragment: st.encodeHeader(":authority", host),
EndStream: true,
EndHeaders: true,
})
}, func(r *http.Request) {
if r.Host != host {
t.Errorf("Host = %q; want %q", r.Host, host)
}
})
} | explode_data.jsonl/71615 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
5475,
44024,
13614,
1566,
1553,
487,
1155,
353,
8840,
836,
8,
341,
4777,
3468,
284,
330,
8687,
905,
698,
18185,
5475,
1900,
1155,
11,
2915,
5895,
353,
4030,
58699,
8,
341,
197,
18388,
3836,
10574,
7,
10574,
4369,
2001,
515... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInspect(t *testing.T) {
for _, fname := range []string{
"../../testdata/run-header_golden.slcio",
"../../testdata/event_golden.slcio",
} {
t.Run(fname, func(t *testing.T) {
buf := new(bytes.Buffer)
inspect(buf, fname, -1, false)
got := buf.Bytes()
want, err := ioutil.ReadFile(fname + ".txt")
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(got, want) {
t.Fatalf("error.\ngot = %q\nwant= %q\n", string(got), string(want))
}
})
}
} | explode_data.jsonl/40679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
58533,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
22548,
1669,
2088,
3056,
917,
515,
197,
197,
1,
2748,
92425,
48385,
9351,
54696,
268,
514,
17257,
815,
756,
197,
197,
1,
2748,
92425,
40763,
54696,
268,
514,
17257,
815,
756... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Problem230(t *testing.T) {
qs := []question230{
{
para230{[]int{}, 0},
ans230{0},
},
{
para230{[]int{3, 1, 4, structures.NULL, 2}, 1},
ans230{1},
},
{
para230{[]int{5, 3, 6, 2, 4, structures.NULL, structures.NULL, 1}, 3},
ans230{3},
},
}
fmt.Printf("------------------------Leetcode Problem 230------------------------\n")
for _, q := range qs {
_, p := q.ans230, q.para230
fmt.Printf("【input】:%v ", p)
root := structures.Ints2TreeNode(p.one)
fmt.Printf("【output】:%v \n", kthSmallest(root, p.k))
}
fmt.Printf("\n\n\n")
} | explode_data.jsonl/65015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 287
} | [
2830,
3393,
16670,
10121,
17,
18,
15,
1155,
353,
8840,
836,
8,
1476,
18534,
82,
1669,
3056,
7841,
17,
18,
15,
4257,
197,
197,
515,
298,
197,
14794,
17,
18,
15,
90,
1294,
396,
22655,
220,
15,
1583,
298,
43579,
17,
18,
15,
90,
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,
1,
1,
1,
1,
1... | 2 |
func TestLen(t *testing.T) {
assert := tassert.New(t)
clusters := clusterWeightByName([]*xds_route.WeightedCluster_ClusterWeight{
{
Name: "hello1",
Weight: &wrappers.UInt32Value{Value: uint32(50)},
},
{
Name: "hello2",
Weight: &wrappers.UInt32Value{Value: uint32(50)},
},
})
actual := clusters.Len()
assert.Equal(2, actual)
} | explode_data.jsonl/75521 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
11271,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
259,
2207,
7121,
1155,
692,
39407,
14605,
1669,
10652,
8295,
16898,
85288,
87,
5356,
28109,
22404,
64507,
28678,
85110,
4993,
8295,
515,
197,
197,
515,
298,
21297,
25,
256,
33... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRegister(t *testing.T) {
if err := Register("dummy1", nil); err != nil {
t.Fatal(err)
}
if err := Register("dummy1", nil); err == nil {
t.Fatalf("Expecting error, got none")
}
eng := newTestEngine(t)
//Should fail because globan handlers are copied
//at the engine creation
if err := eng.Register("dummy1", nil); err == nil {
t.Fatalf("Expecting error, got none")
}
if err := eng.Register("dummy2", nil); err != nil {
t.Fatal(err)
}
if err := eng.Register("dummy2", nil); err == nil {
t.Fatalf("Expecting error, got none")
}
} | explode_data.jsonl/45348 | {
"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,
8690,
1155,
353,
8840,
836,
8,
341,
743,
1848,
1669,
8451,
445,
31390,
16,
497,
2092,
1215,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
743,
1848,
1669,
8451,
445,
31390,
16,
497,
2092,
1215,
1848,
621,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestDB_Concurrent_WriteTo(t *testing.T) {
o := &bolt.Options{NoFreelistSync: false}
db := MustOpenWithOption(o)
defer db.MustClose()
var wg sync.WaitGroup
wtxs, rtxs := 5, 5
wg.Add(wtxs * rtxs)
f := func(tx *bolt.Tx) {
defer wg.Done()
f, err := ioutil.TempFile("", "bolt-")
if err != nil {
panic(err)
}
time.Sleep(time.Duration(rand.Intn(20)+1) * time.Millisecond)
tx.WriteTo(f)
tx.Rollback()
f.Close()
snap := &DB{nil, f.Name(), o}
snap.MustReopen()
defer snap.MustClose()
snap.MustCheck()
}
tx1, err := db.Begin(true)
if err != nil {
t.Fatal(err)
}
if _, err := tx1.CreateBucket([]byte("abc")); err != nil {
t.Fatal(err)
}
if err := tx1.Commit(); err != nil {
t.Fatal(err)
}
for i := 0; i < wtxs; i++ {
tx, err := db.Begin(true)
if err != nil {
t.Fatal(err)
}
if err := tx.Bucket([]byte("abc")).Put([]byte{0}, []byte{0}); err != nil {
t.Fatal(err)
}
for j := 0; j < rtxs; j++ {
rtx, rerr := db.Begin(false)
if rerr != nil {
t.Fatal(rerr)
}
go f(rtx)
}
if err := tx.Commit(); err != nil {
t.Fatal(err)
}
}
wg.Wait()
} | explode_data.jsonl/27474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 565
} | [
2830,
3393,
3506,
15100,
3231,
31825,
1249,
1155,
353,
8840,
836,
8,
341,
22229,
1669,
609,
52433,
22179,
90,
2753,
36731,
19230,
12154,
25,
895,
532,
20939,
1669,
15465,
5002,
2354,
5341,
10108,
340,
16867,
2927,
50463,
7925,
2822,
2405,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestValidateValidRequest(t *testing.T) {
client := NewWebhookRequestHandler(getRequest())
data, err := client.ValidateAndGetData()
assert.IsType(t, Event{}, data)
assert.Equal(t, 1337, data.ID)
assert.NoError(t, err)
} | explode_data.jsonl/25838 | {
"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,
17926,
4088,
1900,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
1532,
5981,
20873,
1900,
3050,
5433,
1900,
2398,
8924,
11,
1848,
1669,
2943,
47667,
3036,
68957,
2822,
6948,
4506,
929,
1155,
11,
3665,
22655,
821,
340,
6948,
128... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBadPath(t *testing.T) {
handler := New(map[string]RESTStorage{}, "/prefix/version")
server := httptest.NewServer(handler)
client := http.Client{}
request, err := http.NewRequest("GET", server.URL+"/foobar", nil)
expectNoError(t, err)
response, err := client.Do(request)
expectNoError(t, err)
if response.StatusCode != 404 {
t.Errorf("Unexpected response %#v", response)
}
} | explode_data.jsonl/30461 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
17082,
1820,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
1532,
9147,
14032,
60,
38307,
5793,
22655,
3521,
11849,
64413,
1138,
41057,
1669,
54320,
70334,
7121,
5475,
36514,
340,
25291,
1669,
1758,
11716,
31483,
23555,
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 TestStoreCommitDuplicate(t *testing.T) {
assert := assert.New(t)
db := dbm.NewMemDB()
store := NewStore(db)
priority := int64(10)
ev := types.NewMockGoodEvidence(2, 1, []byte("val1"))
store.MarkEvidenceAsCommitted(ev)
added := store.AddNewEvidence(ev, priority)
assert.False(added)
} | explode_data.jsonl/47405 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
6093,
33441,
53979,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
20939,
1669,
2927,
76,
7121,
18816,
3506,
741,
57279,
1669,
1532,
6093,
9791,
692,
3223,
8773,
1669,
526,
21,
19,
7,
16,
15,
340,
74837,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateMultipleContainers(t *testing.T) {
ka := string(prowjobv1.KubernetesAgent)
yes := true
defCfg := prowapi.DecorationConfig{
UtilityImages: &prowjobv1.UtilityImages{
CloneRefs: "clone-me",
InitUpload: "upload-me",
Entrypoint: "enter-me",
Sidecar: "official-drink-of-the-org",
},
GCSCredentialsSecret: pStr("upload-secret"),
GCSConfiguration: &prowjobv1.GCSConfiguration{
PathStrategy: prowjobv1.PathStrategyExplicit,
DefaultOrg: "so-org",
DefaultRepo: "very-repo",
},
}
goodSpec := v1.PodSpec{
Containers: []v1.Container{
{
Name: "test1",
Command: []string{"hello", "world"},
},
{
Name: "test2",
Args: []string{"hello", "world"},
},
},
}
cfg := Config{
ProwConfig: ProwConfig{PodNamespace: "target-namespace"},
}
cases := []struct {
name string
base JobBase
pass bool
}{
{
name: "valid kubernetes job with multiple containers",
base: JobBase{
Name: "name",
Agent: ka,
UtilityConfig: UtilityConfig{Decorate: &yes, DecorationConfig: &defCfg},
Spec: &goodSpec,
Namespace: &cfg.PodNamespace,
},
pass: true,
},
{
name: "invalid: containers with no cmd or args",
base: JobBase{
Name: "name",
Agent: ka,
UtilityConfig: UtilityConfig{Decorate: &yes, DecorationConfig: &defCfg},
Spec: &v1.PodSpec{
Containers: []v1.Container{
{
Name: "test1",
},
{
Name: "test2",
},
},
},
Namespace: &cfg.PodNamespace,
},
},
{
name: "invalid: containers with no names",
base: JobBase{
Name: "name",
Agent: ka,
UtilityConfig: UtilityConfig{Decorate: &yes, DecorationConfig: &defCfg},
Spec: &v1.PodSpec{
Containers: []v1.Container{
{
Command: []string{"hello", "world"},
},
{
Args: []string{"hello", "world"},
},
},
},
Namespace: &cfg.PodNamespace,
},
},
{
name: "invalid: no decoration enabled",
base: JobBase{
Name: "name",
Agent: ka,
Spec: &goodSpec,
Namespace: &cfg.PodNamespace,
},
},
{
name: "invalid: container names reserved for decoration",
base: JobBase{
Name: "name",
Agent: ka,
UtilityConfig: UtilityConfig{Decorate: &yes, DecorationConfig: &defCfg},
Spec: &v1.PodSpec{
Containers: []v1.Container{
{
Name: "place-entrypoint",
Command: []string{"hello", "world"},
},
{
Name: "sidecar",
Args: []string{"hello", "world"},
},
},
}, Namespace: &cfg.PodNamespace,
},
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
switch err := cfg.validateJobBase(tc.base, prowjobv1.PresubmitJob); {
case err == nil && !tc.pass:
t.Error("validation failed to raise an error")
case err != nil && tc.pass:
t.Errorf("validation should have passed, got: %v", err)
}
})
}
} | explode_data.jsonl/41014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1470
} | [
2830,
3393,
17926,
32089,
74632,
1155,
353,
8840,
836,
8,
341,
197,
4554,
1669,
914,
1295,
651,
8799,
85,
16,
11352,
29827,
16810,
340,
197,
9693,
1669,
830,
198,
7452,
42467,
1669,
47558,
2068,
22442,
7614,
2648,
515,
197,
15980,
12189... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTeamSanitization(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
team, resp := th.Client.CreateTeam(&model.Team{
DisplayName: t.Name() + "_1",
Name: GenerateTestTeamName(),
Email: th.GenerateTestEmail(),
Type: model.TEAM_OPEN,
AllowedDomains: "simulator.amazonses.com,localhost",
})
CheckNoError(t, resp)
t.Run("team user", func(t *testing.T) {
th.LinkUserToTeam(th.BasicUser2, team)
client := th.CreateClient()
th.LoginBasic2WithClient(client)
rteam, resp := client.GetTeam(team.Id, "")
CheckNoError(t, resp)
require.Empty(t, rteam.Email, "should have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
})
t.Run("team user without invite permissions", func(t *testing.T) {
th.RemovePermissionFromRole(model.PERMISSION_INVITE_USER.Id, model.TEAM_USER_ROLE_ID)
th.LinkUserToTeam(th.BasicUser2, team)
client := th.CreateClient()
th.LoginBasic2WithClient(client)
rteam, resp := client.GetTeam(team.Id, "")
CheckNoError(t, resp)
require.Empty(t, rteam.Email, "should have sanitized email")
require.Empty(t, rteam.InviteId, "should have sanitized inviteid")
})
t.Run("team admin", func(t *testing.T) {
rteam, resp := th.Client.GetTeam(team.Id, "")
CheckNoError(t, resp)
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
})
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
rteam, resp := client.GetTeam(team.Id, "")
CheckNoError(t, resp)
require.NotEmpty(t, rteam.Email, "should not have sanitized email")
require.NotEmpty(t, rteam.InviteId, "should not have sanitized inviteid")
}, "system admin")
} | explode_data.jsonl/70701 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 703
} | [
2830,
3393,
1949,
14597,
23729,
275,
2022,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
197,
9196,
11,
9039,
1669,
270,
11716,
7251,
14597,
2099,
2528,
65842,
515,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_parseHumanTimeString(t *testing.T) {
testcases := []struct {
valid bool
t string
}{
{valid: true, t: "00:00:00"},
{valid: true, t: "01:01:01"},
{valid: true, t: "01:01:01.100"},
{valid: false, t: "invalid"},
{valid: false, t: "01"},
{valid: false, t: "01:"},
{valid: false, t: "01:01"},
{valid: false, t: "01:01:01:"},
{valid: false, t: "01:01:01."},
{valid: false, t: "-01:00:00"},
{valid: false, t: "01:-01:00"},
{valid: false, t: "01:01:-01"},
{valid: false, t: "01:01:01.-100"},
{valid: false, t: "25:00:00"},
{valid: false, t: "01:60:00"},
{valid: false, t: "01:01:60"},
{valid: false, t: "01:01:01.1000000"},
}
for _, tc := range testcases {
if tc.valid {
assert.NoError(t, parseHumanTimeString(tc.t))
} else {
assert.Error(t, parseHumanTimeString(tc.t))
}
}
} | explode_data.jsonl/69234 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
21039,
33975,
96941,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
56322,
1807,
198,
197,
3244,
257,
914,
198,
197,
59403,
197,
197,
90,
1891,
25,
830,
11,
259,
25,
330,
15,
15,
25,
15,
15,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestRouter_AllVerbs(t *testing.T) {
path := "/path1"
router := Router{}
_ = router.Get(path, testHandlerFunc)
_ = router.Head(path, testHandlerFunc)
_ = router.Post(path, testHandlerFunc)
_ = router.Put(path, testHandlerFunc)
_ = router.Patch(path, testHandlerFunc)
_ = router.Delete(path, testHandlerFunc)
_ = router.Connect(path, testHandlerFunc)
_ = router.Options(path, testHandlerFunc)
_ = router.Trace(path, testHandlerFunc)
assertPathFound(t, router, "GET", path)
assertPathFound(t, router, "HEAD", path)
assertPathFound(t, router, "POST", path)
assertPathFound(t, router, "PUT", path)
assertPathFound(t, router, "PATCH", path)
assertPathFound(t, router, "DELETE", path)
assertPathFound(t, router, "CONNECT", path)
assertPathFound(t, router, "OPTIONS", path)
assertPathFound(t, router, "TRACE", path)
} | explode_data.jsonl/31722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
9523,
53629,
10141,
1279,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
3521,
2343,
16,
1837,
67009,
1669,
10554,
16094,
197,
62,
284,
9273,
2234,
5581,
11,
1273,
3050,
9626,
340,
197,
62,
284,
9273,
90478,
5581,
11,
1273,
30... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestVerifies_InvalidV2(t *testing.T) {
path, file := NewTempTombstone(t)
defer os.RemoveAll(path)
WriteTombstoneHeader(t, file, v2header)
WriteBadData(t, file)
verify := NewVerifyTombstoneCommand()
verify.SetArgs([]string{"--engine-path", path})
verify.SetOut(bytes.NewBufferString(""))
require.Error(t, verify.Execute())
} | explode_data.jsonl/24021 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
10141,
9606,
62,
7928,
53,
17,
1155,
353,
8840,
836,
8,
341,
26781,
11,
1034,
1669,
1532,
12151,
51,
2855,
10812,
1155,
340,
16867,
2643,
84427,
5581,
692,
60373,
51,
2855,
10812,
4047,
1155,
11,
1034,
11,
348,
17,
2708,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecordWithUnknownOID(t *testing.T) {
conn := testutil.MustConnectPgx(t)
defer testutil.MustClose(t, conn)
_, err := conn.Exec(`drop type if exists floatrange;
create type floatrange as range (
subtype = float8,
subtype_diff = float8mi
);`)
if err != nil {
t.Fatal(err)
}
defer conn.Exec("drop type floatrange")
var result pgtype.Record
err = conn.QueryRow("select row('foo'::text, floatrange(1, 10), 'bar'::text)").Scan(&result)
if err == nil {
t.Errorf("expected error but none")
}
} | explode_data.jsonl/26140 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 193
} | [
2830,
3393,
6471,
2354,
13790,
29805,
1155,
353,
8840,
836,
8,
341,
32917,
1669,
1273,
1314,
50463,
14611,
47,
59957,
1155,
340,
16867,
1273,
1314,
50463,
7925,
1155,
11,
4534,
692,
197,
6878,
1848,
1669,
4534,
30798,
5809,
6719,
943,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestETCDIsUpToDate(t *testing.T) {
// We want to check:
// The cache is properly initialized
// LatestTemplateIdx and NumAdTemplates are properly set
// If the number of ADTemplate is modified we update
// If nothing changed we don't update
ctx := context.Background()
backend := &etcdTest{}
resp := new(client.Response)
configPath := new(client.Node)
node1 := createTestNode("check_names")
node2 := createTestNode("init_configs")
node3 := createTestNode("instances")
nodes := []*client.Node{node1, node2, node3}
configPath.Key = "/datadog/check_configs/"
nginx := &client.Node{
Key: "/datadog/check_configs/nginx",
Dir: true,
Nodes: nodes,
}
adTemplate := []*client.Node{nginx}
configPath.Nodes = adTemplate
resp.Node = configPath
backend.On("Get", context.Background(), "/datadog/check_configs", &client.GetOptions{Recursive: true}).Return(resp, nil).Times(1)
cache := NewCPCache()
etcd := EtcdConfigProvider{Client: backend, templateDir: "/datadog/check_configs", cache: cache}
update, _ := etcd.IsUpToDate(ctx)
assert.False(t, update)
assert.Equal(t, float64(123456), etcd.cache.LatestTemplateIdx)
assert.Equal(t, 1, etcd.cache.NumAdTemplates)
node4 := &client.Node{
Key: "instances",
Value: "val",
CreatedIndex: 123457,
ModifiedIndex: 9000000,
TTL: 123456789,
}
nodes = []*client.Node{node1, node2, node4}
apache := &client.Node{
Key: "/datadog/check_configs/nginx",
Dir: true,
Nodes: nodes,
}
adTemplate = []*client.Node{nginx, apache}
configPath.Nodes = adTemplate
resp.Node = configPath
backend.On("Get", context.Background(), "/datadog/check_configs", &client.GetOptions{Recursive: true}).Return(resp, nil).Times(1)
update, _ = etcd.IsUpToDate(ctx)
assert.False(t, update)
assert.Equal(t, float64(9000000), etcd.cache.LatestTemplateIdx)
assert.Equal(t, 2, etcd.cache.NumAdTemplates)
backend.On("Get", context.Background(), "/datadog/check_configs", &client.GetOptions{Recursive: true}).Return(resp, nil).Times(1)
update, _ = etcd.IsUpToDate(ctx)
assert.True(t, update)
assert.Equal(t, float64(9000000), etcd.cache.LatestTemplateIdx)
assert.Equal(t, 2, etcd.cache.NumAdTemplates)
backend.AssertExpectations(t)
} | explode_data.jsonl/53944 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 867
} | [
2830,
3393,
1348,
6484,
3872,
2324,
76054,
1155,
353,
8840,
836,
8,
341,
197,
322,
1205,
1366,
311,
1779,
510,
197,
322,
576,
6500,
374,
10277,
17271,
198,
197,
322,
28157,
7275,
11420,
323,
16212,
2589,
51195,
525,
10277,
738,
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... | 1 |
func TestMakeSprintUpdateStatus(t *testing.T) {
assert := assert.New(t)
evt := sdk.AgileSprintUpdateMutation{}
v := sdk.AgileSprintStatusClosed
evt.Set.Status = &v
update, updated, err := makeSprintUpdate("5", &evt)
assert.NoError(err)
assert.True(updated)
assert.Equal("{\"id\":5,\"state\":\"closed\"}", sdk.Stringify(update))
} | explode_data.jsonl/3687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
8078,
50,
1350,
4289,
2522,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
197,
28734,
1669,
45402,
49850,
457,
50,
1350,
4289,
53998,
16094,
5195,
1669,
45402,
49850,
457,
50,
1350,
2522,
26884,
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 TestOSType(t *testing.T) {
t.Parallel()
// This test might seem like it's redundant, but it's designed to ensure that
// the exact values for existing types remain unchanged.
cases := []struct {
t OSType
exp int
}{
{OSTypeUnknown, 0},
{OSTypeIOS, 1},
{OSTypeAndroid, 2},
}
for _, tc := range cases {
tc := tc
t.Run(tc.t.Display(), func(t *testing.T) {
t.Parallel()
if got, want := int(tc.t), tc.exp; got != want {
t.Errorf("Expected %d to be %d", got, want)
}
})
}
} | explode_data.jsonl/42274 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 215
} | [
2830,
3393,
4233,
499,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
197,
322,
1096,
1273,
2578,
2803,
1075,
432,
594,
47732,
11,
714,
432,
594,
6188,
311,
5978,
429,
198,
197,
322,
279,
4734,
2750,
369,
6350,
4494,
7146,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.