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 TestDataPutV1IfNoneMatch(t *testing.T) { f := newFixture(t) if err := f.v1(http.MethodPut, "/data/a/b/c", "0", 204, ""); err != nil { t.Fatalf("Unexpected error from PUT /data/a/b/c: %v", err) } req := newReqV1(http.MethodPut, "/data/a/b/c", "1") req.Header.Set("If-None-Match", "*") if err := f.executeRequest(req, 304, ""); err != nil { t.Fatalf("Unexpected error from PUT with If-None-Match=*: %v", err) } }
explode_data.jsonl/78990
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 189 }
[ 2830, 93200, 19103, 53, 16, 2679, 4064, 8331, 1155, 353, 8840, 836, 8, 341, 1166, 1669, 501, 18930, 1155, 340, 743, 1848, 1669, 282, 3133, 16, 19886, 20798, 19103, 11, 3521, 691, 14186, 3470, 2899, 497, 330, 15, 497, 220, 17, 15, 19...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
3
func TestNormalizeInstallURL(t *testing.T) { for _, tc := range []struct { in, siteURL, out, err string }{ // Happy {"http://mmtest.somedomain.net", "", "http://mmtest.somedomain.net", ""}, {"https://mmtest.somedomain.net", "", "https://mmtest.somedomain.net", ""}, {"some://mmtest.somedomain.net", "", "some://mmtest.somedomain.net", ""}, {"mmtest.somedomain.net", "", "https://mmtest.somedomain.net", ""}, {"mmtest.somedomain.net/", "", "https://mmtest.somedomain.net", ""}, {"mmtest.somedomain.net/abc", "", "https://mmtest.somedomain.net/abc", ""}, {"mmtest.somedomain.net/abc/", "", "https://mmtest.somedomain.net/abc", ""}, {"mmtest", "", "https://mmtest", ""}, {"mmtest/", "", "https://mmtest", ""}, {"//xyz.com", "", "https://xyz.com", ""}, {"//xyz.com/", "", "https://xyz.com", ""}, // Errors {"[jdsh", "", "", `parse //[jdsh: missing ']' in host`}, {"/mmtest", "", "", `Invalid URL, no hostname: "/mmtest"`}, {"/mmtest/", "", "", `Invalid URL, no hostname: "/mmtest/"`}, {"http:/mmtest/", "", "", `Invalid URL, no hostname: "http:/mmtest/"`}, {"hƒƒp://xyz.com", "", "", `parse hƒƒp://xyz.com: first path segment in URL cannot contain colon`}, {"https://mattermost.site.url", "https://mattermost.site.url/", "", "https://mattermost.site.url is the Mattermost site URL. Please use the remote application's URL."}, } { t.Run(tc.in, func(t *testing.T) { out, err := NormalizeInstallURL(tc.siteURL, tc.in) require.Equal(t, tc.out, out) errTxt := "" if err != nil { errTxt = err.Error() } require.Equal(t, tc.err, errTxt) }) } }
explode_data.jsonl/37381
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 719 }
[ 2830, 3393, 87824, 24690, 3144, 1155, 353, 8840, 836, 8, 341, 2023, 8358, 17130, 1669, 2088, 3056, 1235, 341, 197, 17430, 11, 2747, 3144, 11, 700, 11, 1848, 914, 198, 197, 59403, 197, 197, 322, 23355, 198, 197, 197, 4913, 1254, 1110, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestACMEService_List(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() httpmock.RegisterResponder("GET", "https://cert-manager.com/api/acme/v1/account?organizationId=1", httpmock.NewStringResponder(200, `[{"id":81,"name":"OV ACME Account","status":"Pending","macKey":"6687b6b1-e6cd-4388-9ac2-5742381b9519","macId":"b60f9263-9fd3-4c53-a919-c1ff3c4f5cbd","acmeServer":"OV ACME Server","organizationId":1988,"certValidationType":"OV","accountId":"b60f9263-9fd3-4c53-a919-c1ff3c4f5cbd","ovOrderNumber":1946394478,"contacts":"","evDetails":{},"domains":[{"name":"domain.ccmqa.com"},{"name":"sub.domain.ccmqa.com"}]}]`)) logger, _ := zap.NewProduction() c := NewClient(http.DefaultClient, logger, "", "", "") list, err := c.AcmeService.List(acme.ListRequest{OrganizationID: 1}) assert.Nil(t, err) assert.Equal(t, []acme.ListACMEItem{{ID: 81, Name: "OV ACME Account", Status: "Pending", MacKey: "6687b6b1-e6cd-4388-9ac2-5742381b9519", MacID: "b60f9263-9fd3-4c53-a919-c1ff3c4f5cbd", AcmeServer: "OV ACME Server", OrganizationID: 1988, CertValidationType: "OV", AccountID: "b60f9263-9fd3-4c53-a919-c1ff3c4f5cbd", OvOrderNumber: 1946394478, Contacts: "", Domains: []acme.Domain{{Name: "domain.ccmqa.com"}, {Name: "sub.domain.ccmqa.com"}}}}, *list) }
explode_data.jsonl/40535
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 547 }
[ 2830, 3393, 1706, 87711, 1017, 27104, 1155, 353, 8840, 836, 8, 341, 28080, 16712, 14140, 731, 741, 16867, 1758, 16712, 8934, 16856, 3036, 14828, 741, 28080, 16712, 19983, 30884, 445, 3806, 497, 330, 2428, 1110, 12246, 44896, 905, 10508, 6...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestContainerCapabilities(t *testing.T) { testID := "test-id" testSandboxID := "sandbox-id" testPid := uint32(1234) for desc, test := range map[string]struct { capability *runtime.Capability includes []string excludes []string }{ "should be able to add/drop capabilities": { capability: &runtime.Capability{ AddCapabilities: []string{"SYS_ADMIN"}, DropCapabilities: []string{"CHOWN"}, }, includes: []string{"CAP_SYS_ADMIN"}, excludes: []string{"CAP_CHOWN"}, }, "should be able to add all capabilities": { capability: &runtime.Capability{ AddCapabilities: []string{"ALL"}, }, includes: oci.GetAllCapabilities(), }, "should be able to drop all capabilities": { capability: &runtime.Capability{ DropCapabilities: []string{"ALL"}, }, excludes: oci.GetAllCapabilities(), }, "should be able to drop capabilities with add all": { capability: &runtime.Capability{ AddCapabilities: []string{"ALL"}, DropCapabilities: []string{"CHOWN"}, }, includes: util.SubtractStringSlice(oci.GetAllCapabilities(), "CAP_CHOWN"), excludes: []string{"CAP_CHOWN"}, }, "should be able to add capabilities with drop all": { capability: &runtime.Capability{ AddCapabilities: []string{"SYS_ADMIN"}, DropCapabilities: []string{"ALL"}, }, includes: []string{"CAP_SYS_ADMIN"}, excludes: util.SubtractStringSlice(oci.GetAllCapabilities(), "CAP_SYS_ADMIN"), }, } { t.Logf("TestCase %q", desc) containerConfig, sandboxConfig, imageConfig, specCheck := getCreateContainerTestData() ociRuntime := config.Runtime{} c := newTestCRIService() containerConfig.Linux.SecurityContext.Capabilities = test.capability spec, err := c.containerSpec(testID, testSandboxID, testPid, "", containerConfig, sandboxConfig, imageConfig, nil, ociRuntime) require.NoError(t, err) specCheck(t, testID, testSandboxID, testPid, spec) for _, include := range test.includes { assert.Contains(t, spec.Process.Capabilities.Bounding, include) assert.Contains(t, spec.Process.Capabilities.Effective, include) assert.Contains(t, spec.Process.Capabilities.Inheritable, include) assert.Contains(t, spec.Process.Capabilities.Permitted, include) } for _, exclude := range test.excludes { assert.NotContains(t, spec.Process.Capabilities.Bounding, exclude) assert.NotContains(t, spec.Process.Capabilities.Effective, exclude) assert.NotContains(t, spec.Process.Capabilities.Inheritable, exclude) assert.NotContains(t, spec.Process.Capabilities.Permitted, exclude) } assert.Empty(t, spec.Process.Capabilities.Ambient) } }
explode_data.jsonl/6404
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 953 }
[ 2830, 3393, 4502, 55315, 1155, 353, 8840, 836, 8, 341, 18185, 915, 1669, 330, 1944, 12897, 698, 18185, 50, 31536, 915, 1669, 330, 76756, 12897, 698, 18185, 32339, 1669, 2622, 18, 17, 7, 16, 17, 18, 19, 340, 2023, 6560, 11, 1273, 166...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
4
func TestSyncReadBytes(t *testing.T) { s := NewSyncScanner(strings.NewReader("\005\000\000\000helloworld")) reader, err := s.ReadBytes() assert.NoError(t, err) assert.NotNil(t, reader) str, err := ioutil.ReadAll(reader) assert.NoError(t, err) assert.Equal(t, "hello", string(str)) }
explode_data.jsonl/80533
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 117 }
[ 2830, 3393, 12154, 4418, 7078, 1155, 353, 8840, 836, 8, 341, 1903, 1669, 1532, 12154, 31002, 51442, 68587, 4921, 15, 15, 20, 59, 15, 15, 15, 59, 15, 15, 15, 59, 15, 15, 15, 71, 95292, 28075, 61477, 11, 1848, 1669, 274, 6503, 7078,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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_Service_Configure_Enable(t *testing.T) { bkoff := backoff.NewExponentialBackOff() bkoff.MaxElapsedTime = time.Second * 15 err := backoff.Retry(func() error { logger, _ := test.NewNullLogger() logger.SetLevel(logrus.DebugLevel) c := service.NewContainer(logger) c.Register(ID, &Service{}) err := c.Init(&testCfg{httpCfg: `{ "enable": true, "address": ":8070", "maxRequestSize": 1024, "uploads": { "dir": ` + tmpDir() + `, "forbid": [] }, "workers":{ "command": "php ../../tests/http/client.php echo pipes", "relay": "pipes", "pool": { "numWorkers": 1, "allocateTimeout": 10000000, "destroyTimeout": 10000000 } } }`}) if err != nil { return err } s, st := c.Get(ID) assert.NotNil(t, s) assert.Equal(t, service.StatusOK, st) return nil }, bkoff) if err != nil { t.Fatal(err) } }
explode_data.jsonl/34497
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 414 }
[ 2830, 3393, 52548, 15100, 17781, 65216, 1155, 353, 8840, 836, 8, 341, 2233, 74, 1847, 1669, 1182, 1847, 7121, 840, 59825, 3707, 4596, 741, 2233, 74, 1847, 14535, 98483, 284, 882, 32435, 353, 220, 16, 20, 271, 9859, 1669, 1182, 1847, 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...
2
func TestWithdraw(t *testing.T) { p.SetDefaults() TestSetup(t) var withdrawCryptoRequest = exchange.WithdrawRequest{ Amount: 100, Currency: currency.LTC, Address: "1F5zVDgNjorJ51oGebSvNCrSAHpwGkUdDB", Description: "WITHDRAW IT ALL", } if areTestAPIKeysSet() && !canManipulateRealOrders { t.Skip("API keys set, canManipulateRealOrders false, skipping test") } _, err := p.WithdrawCryptocurrencyFunds(&withdrawCryptoRequest) if !areTestAPIKeysSet() && err == nil { t.Error("Expecting an error when no keys are set") } if areTestAPIKeysSet() && err != nil { t.Errorf("Withdraw failed to be placed: %v", err) } }
explode_data.jsonl/23575
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 262 }
[ 2830, 3393, 92261, 1155, 353, 8840, 836, 8, 341, 3223, 4202, 16273, 741, 73866, 21821, 1155, 340, 2405, 14798, 58288, 1900, 284, 9289, 26124, 7633, 1900, 515, 197, 197, 10093, 25, 414, 220, 16, 15, 15, 345, 197, 6258, 5088, 25, 262, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
7
func TestInitWithEC2metadataAZErr(t *testing.T) { ctrl, mockMetadata, _ := setup(t) defer ctrl.Finish() mockMetadata.EXPECT().GetMetadata(metadataAZ).Return(az, errors.New("Error on metadata AZ")) ins := &EC2InstanceMetadataCache{ec2Metadata: mockMetadata} err := ins.initWithEC2Metadata() assert.Error(t, err) }
explode_data.jsonl/19285
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 117 }
[ 2830, 3393, 3803, 2354, 7498, 17, 17637, 23563, 7747, 1155, 353, 8840, 836, 8, 341, 84381, 11, 7860, 14610, 11, 716, 1669, 6505, 1155, 340, 16867, 23743, 991, 18176, 2822, 77333, 14610, 22402, 7285, 1005, 1949, 14610, 54436, 23563, 568, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestPriorityQueueWait(t *testing.T) { queue := NewPriorityQueue(nil) done := make(chan struct{}) go func() { assert.Nil(t, queue.Dequeue(), "Expect nil dequeue") close(done) }() queue.Close() runtime.Gosched() select { case <-done: case <-time.After(100 * time.Millisecond): t.Fatal("Close didn't unblock Dequeue.") } }
explode_data.jsonl/69352
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 135 }
[ 2830, 3393, 20555, 7554, 14190, 1155, 353, 8840, 836, 8, 341, 46993, 1669, 1532, 20555, 7554, 27907, 692, 40495, 1669, 1281, 35190, 2036, 37790, 30680, 2915, 368, 341, 197, 6948, 59678, 1155, 11, 7177, 8934, 4584, 1507, 330, 17536, 2092, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestRuntimeStorageWrite(t *testing.T) { modules := map[string]string{ "test": ` local nk = require("nakama") local new_objects = { {collection = "settings", key = "a", user_id = nil, value = {}}, {collection = "settings", key = "b", user_id = nil, value = {}}, {collection = "settings", key = "c", user_id = nil, value = {}} } nk.storage_write(new_objects)`, } _, err := runtimeWithModules(t, modules) if err != nil { t.Fatal(err.Error()) } }
explode_data.jsonl/59794
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 176 }
[ 2830, 3393, 15123, 5793, 7985, 1155, 353, 8840, 836, 8, 341, 42228, 2425, 1669, 2415, 14032, 30953, 515, 197, 197, 1, 1944, 788, 22074, 2438, 79491, 284, 1373, 445, 42874, 3029, 5130, 2438, 501, 24873, 284, 341, 197, 90, 13421, 284, 3...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestUptimeMonitorMonitorsToBaseMonitorsMapper(t *testing.T) { uptimeMonitorObject1 := UptimeMonitorMonitor{ Name: "Test Monitor", PK: 124, MspAddress: "https://stakater.com", MspInterval: 5, CheckType: "HTTP", Locations: []string{"US-Central"}, ContactGroups: []string{"Default"}, Tags: []string{"Core"}} uptimeMonitorObject2 := UptimeMonitorMonitor{ Name: "Test Monitor 2", PK: 125, MspAddress: "https://facebook.com", MspInterval: 10, CheckType: "ICMP", Locations: []string{"US-Central"}, ContactGroups: []string{"Default"}, Tags: []string{"Shared"}} config1 := &endpointmonitorv1alpha1.UptimeConfig{ Interval: 5, CheckType: "HTTP", Locations: "US-Central", Contacts: "Default", Tags: "Core", } config2 := &endpointmonitorv1alpha1.UptimeConfig{ Interval: 10, CheckType: "ICMP", Locations: "US-Central", Contacts: "Default", Tags: "Shared", } correctMonitors := []models.Monitor{ { Name: "Test Monitor", ID: "124", URL: "https://stakater.com", Config: config1}, { Name: "Test Monitor 2", ID: "125", URL: "https://facebook.com", Config: config2}} var uptimeMonitors []UptimeMonitorMonitor uptimeMonitors = append(uptimeMonitors, uptimeMonitorObject1) uptimeMonitors = append(uptimeMonitors, uptimeMonitorObject2) monitors := UptimeMonitorMonitorsToBaseMonitorsMapper(uptimeMonitors) for index := 0; index < len(monitors); index++ { if !reflect.DeepEqual(correctMonitors[index], monitors[index]) { t.Error("Correct: ", correctMonitors[index], "Parsed", monitors[index]) t.Error("Monitor object should be the same") } } }
explode_data.jsonl/37447
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 746 }
[ 2830, 3393, 52, 28941, 30098, 11095, 11905, 1249, 3978, 11095, 11905, 10989, 1155, 353, 8840, 836, 8, 341, 197, 74659, 30098, 1190, 16, 1669, 547, 28941, 30098, 30098, 515, 197, 21297, 25, 688, 330, 2271, 23519, 756, 197, 10025, 42, 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 TestApply(t *testing.T) { buf := new(bytes.Buffer) fs, cleanup, err := wiretest.InitializeKustomization() defer cleanup() assert.NoError(t, err) assert.NotEmpty(t, fs) args := []string{fmt.Sprintf("--server=%s", host), "--namespace=default", fs[0]} cmd := apply.GetApplyCommand(args) cmd.SetOutput(buf) cmd.SetArgs(args) wirek8s.Flags(cmd.PersistentFlags()) assert.NoError(t, cmd.Execute()) assert.Equal(t, "Doing `cli-experimental apply`\napplied ConfigMap/inventory\napplied ConfigMap/test-map-k6tb869f64\nResources: 2\n", buf.String()) // nolint }
explode_data.jsonl/74057
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 221 }
[ 2830, 3393, 28497, 1155, 353, 8840, 836, 8, 341, 26398, 1669, 501, 23158, 22622, 340, 53584, 11, 21290, 11, 1848, 1669, 9067, 1944, 45829, 42, 1450, 2022, 741, 16867, 21290, 741, 6948, 35699, 1155, 11, 1848, 340, 6948, 15000, 3522, 1155...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestWhereUpdates(t *testing.T) { type OwnerEntity struct { gorm.Model OwnerID uint OwnerType string } type SomeEntity struct { gorm.Model Name string OwnerEntity OwnerEntity `gorm:"polymorphic:Owner"` } DB.DropTable(&SomeEntity{}) DB.AutoMigrate(&SomeEntity{}) a := SomeEntity{Name: "test"} DB.Model(&a).Where(a).Updates(SomeEntity{Name: "test2"}) }
explode_data.jsonl/28076
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 153 }
[ 2830, 3393, 9064, 37091, 1155, 353, 8840, 836, 8, 341, 13158, 25833, 3030, 2036, 341, 197, 3174, 493, 5659, 198, 197, 197, 13801, 915, 256, 2622, 198, 197, 197, 13801, 929, 914, 198, 197, 630, 13158, 4329, 3030, 2036, 341, 197, 3174, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestDirectory(t *testing.T) { dirname, err := ioutil.TempDir("", "") if err != nil { t.Fatal(err) } defer os.RemoveAll(dirname) fd, err := os.Open(dirname) if err != nil { t.Error(err) return } for i := 0; i < 10; i++ { f, err := ioutil.TempFile(dirname, "dirtest") if err != nil { t.Error(err) } f.Close() } _, err = ioutil.TempDir(dirname, "dirtest-dir") if err != nil { t.Error(err) return } dir := NewDir(fd, dirname, qidpool.New()) // We know that we can read a single Stat by only // asking for 1 * MaxStatLen bytes. This is an implementation // detail that may not be true in the future. buf := make([]byte, styxproto.MaxStatLen) var offset int64 for { n, err := dir.ReadAt(buf, offset) if err == io.EOF { break } if err != nil { t.Error(err) break } offset += int64(n) stat := styxproto.Stat(buf) t.Logf("%s", stat) } }
explode_data.jsonl/60328
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 404 }
[ 2830, 3393, 9310, 1155, 353, 8840, 836, 8, 341, 48532, 606, 11, 1848, 1669, 43144, 65009, 6184, 19814, 14676, 743, 1848, 961, 2092, 341, 197, 3244, 26133, 3964, 340, 197, 532, 16867, 2643, 84427, 38802, 692, 61721, 11, 1848, 1669, 2643,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestHelmDownload(t *testing.T) { lookPathDir = func(cwd string, env expand.Environ, file string) (string, error) { return "", errors.New("not found") } stdout := &bytes.Buffer{} stderr := &bytes.Buffer{} err := ExecuteShellCommand("helm", nil, ".", stdout, stderr, nil) if err != nil { t.Fatal(err) } stdout1 := &bytes.Buffer{} err = ExecuteShellCommand("helm version", nil, ".", stdout1, stderr, nil) if err != nil { t.Fatal(err) } assert.Assert(t, strings.Contains(stdout1.String(), `Version:"v3`)) }
explode_data.jsonl/31033
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 210 }
[ 2830, 3393, 39, 23162, 11377, 1155, 353, 8840, 836, 8, 341, 197, 7201, 1820, 6184, 284, 2915, 1337, 6377, 914, 11, 6105, 9225, 22834, 2772, 11, 1034, 914, 8, 320, 917, 11, 1465, 8, 341, 197, 853, 7342, 5975, 7121, 445, 1921, 1730, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestNegotiationResponses(t *testing.T) { // Write/Read acceptance buf := new(bytes.Buffer) err := WriteNegotiationAcceptance(buf) if err != nil { t.Fatal(err) } err = ReadNegotiationAcceptance(buf) if err != nil { t.Fatal(err) } // Write/Read rejection buf.Reset() err = WriteNegotiationRejection(buf, ErrLowBalance) if err != ErrLowBalance { t.Fatal(err) } err = ReadNegotiationAcceptance(buf) // can't compare to ErrLowBalance directly; contents are the same, but pointer is different if err == nil || err.Error() != ErrLowBalance.Error() { t.Fatal(err) } // Write/Read StopResponse buf.Reset() err = WriteNegotiationStop(buf) if err != nil { t.Fatal(err) } err = ReadNegotiationAcceptance(buf) if err != ErrStopResponse { t.Fatal(err) } }
explode_data.jsonl/61148
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 295 }
[ 2830, 3393, 47800, 354, 7101, 70743, 1155, 353, 8840, 836, 8, 341, 197, 322, 9645, 14, 4418, 25505, 198, 26398, 1669, 501, 23158, 22622, 340, 9859, 1669, 9645, 47800, 354, 7101, 16646, 681, 10731, 340, 743, 1848, 961, 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...
8
func TestReconcileServiceInstanceFailsWithDeletedClass(t *testing.T) { fakeKubeClient, fakeCatalogClient, fakeClusterServiceBrokerClient, testController, sharedInformers := newTestController(t, noFakeActions()) addGetNamespaceReaction(fakeKubeClient) sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker()) sc := getTestClusterServiceClass() sc.Status.RemovedFromBrokerCatalog = true sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(sc) sharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan()) instance := getTestServiceInstanceWithClusterRefs() if err := reconcileServiceInstance(t, testController, instance); err == nil { t.Fatalf("This should have failed") } brokerActions := fakeClusterServiceBrokerClient.Actions() assertNumberOfBrokerActions(t, brokerActions, 0) instanceKey := testNamespace + "/" + testServiceInstanceName // Since synchronous operation, must not make it into the polling queue. if testController.instancePollingQueue.NumRequeues(instanceKey) != 0 { t.Fatalf("Expected polling queue to not have any record of test instance") } actions := fakeCatalogClient.Actions() assertNumberOfActions(t, actions, 1) // verify no kube actions kubeActions := fakeKubeClient.Actions() assertNumberOfActions(t, kubeActions, 0) updatedServiceInstance := assertUpdateStatus(t, actions[0], instance) assertServiceInstanceReadyFalse(t, updatedServiceInstance, errorDeletedClusterServiceClassReason) events := getRecordedEvents(testController) expectedEvent := warningEventBuilder(errorDeletedClusterServiceClassReason).msgf( "ClusterServiceClass (K8S: %q ExternalName: %q) has been deleted; cannot provision.", "cscguid", "test-clusterserviceclass", ) if err := checkEvents(events, expectedEvent.stringArr()); err != nil { t.Fatal(err) } }
explode_data.jsonl/58143
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 567 }
[ 2830, 3393, 693, 40446, 457, 1860, 2523, 37, 6209, 2354, 26039, 1957, 1155, 353, 8840, 836, 8, 341, 1166, 726, 42, 3760, 2959, 11, 12418, 41606, 2959, 11, 12418, 28678, 1860, 65545, 2959, 11, 1273, 2051, 11, 6094, 37891, 388, 1669, 50...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
4
func TestDecodeJSON(t *testing.T) { t.Parallel() t.Run("normal test", func(t *testing.T) { payload, err := DecodeJSON(strings.NewReader(`{"test":"test"}`)) assert.NoError(t, err) assert.NotNil(t, payload) assert.Equal(t, "test", payload.String("test")) }) }
explode_data.jsonl/29915
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 112 }
[ 2830, 3393, 32564, 5370, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 2822, 3244, 16708, 445, 8252, 1273, 497, 2915, 1155, 353, 8840, 836, 8, 341, 197, 76272, 11, 1848, 1669, 50194, 5370, 51442, 68587, 5809, 4913, 1944, 3252, 1944, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestGetTrafficPoliciesForService(t *testing.T) { assert := tassert.New(t) type getTrafficPoliciesForServiceTest struct { input service.MeshService output []trafficpolicy.TrafficTarget } getTrafficPoliciesForServiceTests := []getTrafficPoliciesForServiceTest{ { input: tests.BookbuyerService, output: []trafficpolicy.TrafficTarget{ { Name: utils.GetTrafficTargetName(tests.TrafficTargetName, tests.BookbuyerService, tests.BookstoreV1Service), Destination: tests.BookstoreV1Service, Source: tests.BookbuyerService, HTTPRouteMatches: tests.BookstoreV1TrafficPolicy.HTTPRouteMatches, }, { Name: utils.GetTrafficTargetName(tests.TrafficTargetName, tests.BookbuyerService, tests.BookstoreV2Service), Destination: tests.BookstoreV2Service, Source: tests.BookbuyerService, HTTPRouteMatches: tests.BookstoreV2TrafficPolicy.HTTPRouteMatches, }, { Name: utils.GetTrafficTargetName(tests.TrafficTargetName, tests.BookbuyerService, tests.BookstoreApexService), Destination: tests.BookstoreApexService, Source: tests.BookbuyerService, HTTPRouteMatches: tests.BookstoreApexTrafficPolicy.HTTPRouteMatches, }, }, }, } mc := newFakeMeshCatalog() for _, test := range getTrafficPoliciesForServiceTests { allTrafficPolicies, err := getTrafficPoliciesForService(mc, tests.RoutePolicyMap, test.input) assert.Nil(err) assert.ElementsMatch(allTrafficPolicies, test.output) } }
explode_data.jsonl/69750
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 651 }
[ 2830, 3393, 1949, 87229, 47, 42038, 2461, 1860, 1155, 353, 8840, 836, 8, 341, 6948, 1669, 259, 2207, 7121, 1155, 692, 13158, 633, 87229, 47, 42038, 2461, 1860, 2271, 2036, 341, 197, 22427, 220, 2473, 50155, 1860, 198, 197, 21170, 3056, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestReturnsCredentials(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() defer leaktest.Check(t)() r, _ := http.NewRequest("GET", "/latest/meta-data/iam/security-credentials/role", nil) rr := httptest.NewRecorder() client := st.NewStubClient().WithRoles(st.GetRoleResult{"role", nil}).WithCredentials(st.GetCredentialsResult{&sts.Credentials{AccessKeyId: "A1", SecretAccessKey: "S1"}, nil}) handler := newCredentialsHandler(client, getBlankClientIP) router := mux.NewRouter() handler.Install(router) router.ServeHTTP(rr, r.WithContext(ctx)) if rr.Code != http.StatusOK { t.Error("unexpected status, was", rr.Code) } content := rr.Header().Get("Content-Type") if content != "application/json" { t.Error("expected json result", content) } var creds sts.Credentials decoder := json.NewDecoder(rr.Body) err := decoder.Decode(&creds) if err != nil { t.Error(err.Error()) } if creds.AccessKeyId != "A1" { t.Error("unexpected key, was", creds.AccessKeyId) } if creds.SecretAccessKey != "S1" { t.Error("unexpected secret key, was", creds.SecretAccessKey) } }
explode_data.jsonl/19347
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 433 }
[ 2830, 3393, 16446, 27025, 1155, 353, 8840, 836, 8, 341, 20985, 11, 9121, 1669, 2266, 26124, 7636, 5378, 19047, 1507, 882, 32435, 9, 20, 340, 16867, 9121, 741, 16867, 23352, 1944, 10600, 1155, 8, 2822, 7000, 11, 716, 1669, 1758, 75274, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestWriter(t *testing.T) { ctx := context.Background() flags.Set(t, "auth.enable_anonymous_usage", "true") te := getTestEnv(t, emptyUserMap) ctx, err := prefix.AttachUserPrefixToContext(ctx, te) if err != nil { t.Errorf("error attaching user prefix: %v", err) } peer := fmt.Sprintf("localhost:%d", app.FreePort(t)) c := cacheproxy.NewCacheProxy(te, te.GetCache(), peer) if err := c.StartListening(); err != nil { t.Fatalf("Error setting up cacheproxy: %s", err) } waitUntilServerIsAlive(peer) randomSrc := &randomDataMaker{rand.NewSource(time.Now().Unix())} testSizes := []int64{ 1, 10, 100, 1000, 10000, 1000000, 10000000, } for _, testSize := range testSizes { remoteInstanceName := fmt.Sprintf("prefix/%d", testSize) isolation := &dcpb.Isolation{CacheType: dcpb.Isolation_CAS_CACHE, RemoteInstanceName: remoteInstanceName} // Read some random bytes. buf := new(bytes.Buffer) io.CopyN(buf, randomSrc, testSize) readSeeker := bytes.NewReader(buf.Bytes()) // Compute a digest for the random bytes. d, err := digest.Compute(readSeeker) if err != nil { t.Fatal(err) } readSeeker.Seek(0, 0) // Remote-write the random bytes to the cache (with a prefix). wc, err := c.RemoteWriter(ctx, peer, noHandoff, isolation, d) if err != nil { t.Fatal(err) } if err := copyAndClose(wc, readSeeker); err != nil { t.Fatal(err) } // Read the bytes back directly from the cache and check that // they match.. cache, err := te.GetCache().WithIsolation(ctx, interfaces.CASCacheType, remoteInstanceName) require.NoError(t, err) r, err := cache.Reader(ctx, d, 0) if err != nil { t.Fatal(err) } d2 := testdigest.ReadDigestAndClose(t, r) if d.GetHash() != d2.GetHash() { t.Fatalf("Digest uploaded %q != %q downloaded", d.GetHash(), d2.GetHash()) } } }
explode_data.jsonl/69642
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 718 }
[ 2830, 3393, 6492, 1155, 353, 8840, 836, 8, 341, 20985, 1669, 2266, 19047, 741, 59516, 4202, 1155, 11, 330, 3242, 28697, 12008, 9757, 31507, 497, 330, 1866, 1138, 197, 665, 1669, 633, 2271, 14359, 1155, 11, 4287, 1474, 2227, 692, 20985, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestFormatFromFrontMatterType(t *testing.T) { c := qt.New(t) for _, test := range []struct { typ ItemType expect metadecoders.Format }{ {TypeFrontMatterJSON, metadecoders.JSON}, {TypeFrontMatterTOML, metadecoders.TOML}, {TypeFrontMatterYAML, metadecoders.YAML}, {TypeFrontMatterORG, metadecoders.ORG}, {TypeIgnore, ""}, } { c.Assert(FormatFromFrontMatterType(test.typ), qt.Equals, test.expect) } }
explode_data.jsonl/35605
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 188 }
[ 2830, 3393, 4061, 3830, 23395, 44, 1650, 929, 1155, 353, 8840, 836, 8, 341, 1444, 1669, 38949, 7121, 1155, 340, 2023, 8358, 1273, 1669, 2088, 3056, 1235, 341, 197, 25314, 262, 73081, 198, 197, 24952, 2270, 329, 757, 52498, 9978, 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...
2
func TestAnalyticsModulesAccountingUpdate(t *testing.T) { logger, err := zap.NewDevelopment() require.NoError(t, err, "failed to get logger") testParam := analyticsModuleTestEnvCreate(t, logger) // case 1: run the packet as if the Auth packet was dropped & not received. we should ignore the packet bcz we didnt create the XWFEntRadiusSession testFullRADIUSSessiontWithAnalyticsModulesAccountingUpdate(t, logger, testParam, true) // case 2: create the session state we expect would be created by the AuthRequest & then fire the packet server := testParam.Server sessionID := getSessionIDStrings(server, testParam.CallingStationID, testParam.CalledStationID, "") stg := server.getSessionStateAPI(sessionID) stg.Set(session.State{RadiusSessionFBID: 123 /* non-zero value*/}) testFullRADIUSSessiontWithAnalyticsModulesAccountingUpdate(t, logger, testParam, false) analyticsModuleTestEnvDestroy(testParam) }
explode_data.jsonl/59966
{ "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, 60539, 28201, 7365, 287, 4289, 1155, 353, 8840, 836, 8, 341, 17060, 11, 1848, 1669, 32978, 7121, 39419, 741, 17957, 35699, 1155, 11, 1848, 11, 330, 16091, 311, 633, 5925, 1138, 18185, 2001, 1669, 27875, 3332, 2271, 14359, 40...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestPrintStatus(t *testing.T) { tests := []struct { description string rs []*resource.Deployment expectedOut string expected bool }{ { description: "single resource successful marked complete - skip print", rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), }, expected: true, }, { description: "single resource in error marked complete -skip print", rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: "error"}, ), }, expected: true, }, { description: "multiple resources 1 not complete", rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), withStatus( resource.NewDeployment("r2", "test", 1). WithPodStatuses([]proto.StatusCode{proto.StatusCode_STATUSCHECK_IMAGE_PULL_ERR}), proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_DEPLOYMENT_ROLLOUT_PENDING, Message: "pending\n"}, ), }, expectedOut: ` - test:deployment/r2: pending - test:pod/foo: pod failed `, }, { description: "multiple resources 1 not complete and retry-able error", rs: []*resource.Deployment{ withStatus( resource.NewDeployment("r1", "test", 1), proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}, ), withStatus( resource.NewDeployment("r2", "test", 1). WithPodStatuses([]proto.StatusCode{proto.StatusCode_STATUSCHECK_IMAGE_PULL_ERR}), proto.ActionableErr{ ErrCode: proto.StatusCode_STATUSCHECK_KUBECTL_CONNECTION_ERR, Message: resource.MsgKubectlConnection}, ), }, expectedOut: ` - test:deployment/r2: kubectl connection error - test:pod/foo: pod failed `, }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) { out := new(bytes.Buffer) event.InitializeState(latest.Pipeline{}, "test", true, true, true) actual := printStatus(test.rs, out) t.CheckDeepEqual(test.expectedOut, out.String()) t.CheckDeepEqual(test.expected, actual) }) } }
explode_data.jsonl/65255
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 983 }
[ 2830, 3393, 8994, 2522, 1155, 353, 8840, 836, 8, 341, 78216, 1669, 3056, 1235, 341, 197, 42407, 914, 198, 197, 41231, 688, 29838, 9233, 34848, 39130, 198, 197, 42400, 2662, 914, 198, 197, 42400, 262, 1807, 198, 197, 59403, 197, 197, 5...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestMessageToQueryParametersWithEnumAsInt(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_DOUBLE.Enum(), Number: proto.Int32(2), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Required: false, Type: "string", }, { Name: "b", In: "query", Required: false, Type: "number", Format: "double", }, { Name: "c", In: "query", Required: false, Type: "array", CollectionFormat: "multi", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested"), Number: proto.Int32(1), }, }, }, { Name: proto.String("Nested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("deep"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested.DeepNested"), Number: proto.Int32(2), }, }, NestedType: []*descriptorpb.DescriptorProto{{ Name: proto.String("DeepNested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.Nested.DeepNested.DeepEnum"), Number: proto.Int32(2), }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("DeepEnum"), Value: []*descriptorpb.EnumValueDescriptorProto{ {Name: proto.String("FALSE"), Number: proto.Int32(0)}, {Name: proto.String("TRUE"), Number: proto.Int32(1)}, }, }, }, }}, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "nested.a", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.b", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.c", In: "query", Required: false, Type: "integer", Enum: []string{"0", "1"}, Default: "0", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetEnumsAsInts(true) msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil) if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } }
explode_data.jsonl/32781
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2604 }
[ 2830, 3393, 2052, 1249, 2859, 9706, 2354, 10766, 2121, 1072, 1155, 353, 8840, 836, 8, 341, 13158, 1273, 2036, 341, 197, 197, 6611, 11065, 82, 29838, 53132, 16650, 23548, 6820, 31549, 198, 197, 46733, 220, 914, 198, 197, 197, 4870, 256, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
8
func TestIsKubeletProbe(t *testing.T) { req, err := http.NewRequest(http.MethodGet, "http://example.com/", nil) if err != nil { t.Fatal("Error building request:", err) } if IsKubeletProbe(req) { t.Error("Not a kubelet probe but counted as such") } req.Header.Set("User-Agent", KubeProbeUAPrefix+"1.14") if !IsKubeletProbe(req) { t.Error("kubelet probe but not counted as such") } req.Header.Del("User-Agent") if IsKubeletProbe(req) { t.Error("Not a kubelet probe but counted as such") } req.Header.Set(KubeletProbeHeaderName, "no matter") if !IsKubeletProbe(req) { t.Error("kubelet probe but not counted as such") } }
explode_data.jsonl/58828
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 263 }
[ 2830, 3393, 3872, 42, 3760, 1149, 81426, 1155, 353, 8840, 836, 8, 341, 24395, 11, 1848, 1669, 1758, 75274, 19886, 20798, 1949, 11, 330, 1254, 1110, 8687, 905, 28105, 2092, 340, 743, 1848, 961, 2092, 341, 197, 3244, 26133, 445, 1454, 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...
6
func TestV1CreateKeyFail(t *testing.T) { tests.RunServer(func(s *server.Server) { v := url.Values{} v.Set("value", "XXX") v.Set("prevValue", "") fullURL := fmt.Sprintf("%s%s", s.URL(), "/v1/keys/foo/bar") resp, _ := tests.PutForm(fullURL, v) assert.Equal(t, resp.StatusCode, http.StatusOK) tests.ReadBody(resp) resp, _ = tests.PutForm(fullURL, v) assert.Equal(t, resp.StatusCode, http.StatusPreconditionFailed) body := tests.ReadBodyJSON(resp) assert.Equal(t, body["errorCode"], 105, "") assert.Equal(t, body["message"], "Key already exists", "") assert.Equal(t, body["cause"], "/foo/bar", "") }) }
explode_data.jsonl/24838
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 261 }
[ 2830, 3393, 53, 16, 4021, 1592, 19524, 1155, 353, 8840, 836, 8, 341, 78216, 16708, 5475, 18552, 1141, 353, 4030, 22997, 8, 341, 197, 5195, 1669, 2515, 35145, 16094, 197, 5195, 4202, 445, 957, 497, 330, 30100, 1138, 197, 5195, 4202, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestErrNoTrace(t *testing.T) { e := Wrap(func() error { return Wrap(func() error { return Wrap(func() error { return Wrap(func() error { return New("Turtles").WithContext(" all the way down.") }()).WithContext("%d", 1) }()).WithContext("%d", 2) }()).WithContext("%d", 3) }()).WithContext("%d", 4) et := e.(ErrMadNet) fmt.Printf("%s\n", et) }
explode_data.jsonl/54722
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 164 }
[ 2830, 3393, 7747, 2753, 6550, 1155, 353, 8840, 836, 8, 341, 7727, 1669, 42187, 18552, 368, 1465, 341, 197, 853, 42187, 18552, 368, 1465, 341, 298, 853, 42187, 18552, 368, 1465, 341, 571, 853, 42187, 18552, 368, 1465, 341, 464, 853, 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...
1
func TestTestBuildFromService(t *testing.T) { Convey("With a list of models to compare", t, func() { sTime := time.Unix(12345, 6789) eTime := time.Unix(9876, 54321) modelPairs := []testCompare{ { at: APITest{ Status: utility.ToStringPtr("testStatus"), TestFile: utility.ToStringPtr("testFile"), DisplayTestName: utility.ToStringPtr("display"), Logs: TestLogs{ URL: utility.ToStringPtr("testUrl"), LineNum: 15, URLRaw: utility.ToStringPtr("testUrlRaw"), LogId: utility.ToStringPtr(""), }, ExitCode: 1, StartTime: &sTime, EndTime: &eTime, }, st: testresult.TestResult{ Status: "testStatus", TestFile: "testFile", DisplayTestName: "display", URL: "testUrl", URLRaw: "testUrlRaw", LineNum: 15, LogID: "", ExitCode: 1, StartTime: utility.ToPythonTime(sTime), EndTime: utility.ToPythonTime(eTime), }, }, { at: APITest{ StartTime: ToTimePtr(time.Unix(0, 0)), EndTime: ToTimePtr(time.Unix(0, 0)), }, st: testresult.TestResult{}, }, } Convey("running BuildFromService(), should produce the equivalent model", func() { for _, tc := range modelPairs { apiTest := &APITest{} err := apiTest.BuildFromService(&tc.st) So(err, ShouldBeNil) So(utility.FromStringPtr(apiTest.TestFile), ShouldEqual, utility.FromStringPtr(tc.at.TestFile)) } }) }) }
explode_data.jsonl/36442
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 754 }
[ 2830, 3393, 2271, 11066, 3830, 1860, 1155, 353, 8840, 836, 8, 341, 93070, 5617, 445, 2354, 264, 1140, 315, 4119, 311, 9429, 497, 259, 11, 2915, 368, 341, 197, 1903, 1462, 1669, 882, 10616, 941, 7, 16, 17, 18, 19, 20, 11, 220, 21, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestCommandSide_ChangeProjectMember(t *testing.T) { type fields struct { eventstore *eventstore.Eventstore zitadelRoles []authz.RoleMapping } type args struct { ctx context.Context member *domain.Member resourceOwner string } type res struct { want *domain.Member err func(error) bool } tests := []struct { name string fields fields args args res res }{ { name: "invalid member, error", fields: fields{ eventstore: eventstoreExpect( t, ), }, args: args{ ctx: context.Background(), member: &domain.Member{ ObjectRoot: models.ObjectRoot{ AggregateID: "project1", }, }, resourceOwner: "org1", }, res: res{ err: caos_errs.IsErrorInvalidArgument, }, }, { name: "invalid roles, error", fields: fields{ eventstore: eventstoreExpect( t, ), }, args: args{ ctx: context.Background(), member: &domain.Member{ ObjectRoot: models.ObjectRoot{ AggregateID: "project1", }, UserID: "user1", Roles: []string{"PROJECT_OWNER"}, }, resourceOwner: "org1", }, res: res{ err: caos_errs.IsErrorInvalidArgument, }, }, { name: "member not existing, not found error", fields: fields{ eventstore: eventstoreExpect( t, expectFilter(), ), zitadelRoles: []authz.RoleMapping{ { Role: domain.RoleProjectOwner, }, }, }, args: args{ ctx: context.Background(), member: &domain.Member{ ObjectRoot: models.ObjectRoot{ AggregateID: "project1", }, UserID: "user1", Roles: []string{"PROJECT_OWNER"}, }, resourceOwner: "org1", }, res: res{ err: caos_errs.IsNotFound, }, }, { name: "member not changed, precondition error", fields: fields{ eventstore: eventstoreExpect( t, expectFilter( eventFromEventPusher( project.NewProjectMemberAddedEvent(context.Background(), &project.NewAggregate("project1", "org1").Aggregate, "user1", []string{"PROJECT_OWNER"}..., ), ), ), ), zitadelRoles: []authz.RoleMapping{ { Role: domain.RoleProjectOwner, }, }, }, args: args{ ctx: context.Background(), member: &domain.Member{ ObjectRoot: models.ObjectRoot{ AggregateID: "project1", }, UserID: "user1", Roles: []string{"PROJECT_OWNER"}, }, resourceOwner: "org1", }, res: res{ err: caos_errs.IsPreconditionFailed, }, }, { name: "member change, ok", fields: fields{ eventstore: eventstoreExpect( t, expectFilter( eventFromEventPusher( project.NewProjectMemberAddedEvent(context.Background(), &project.NewAggregate("project1", "org1").Aggregate, "user1", []string{"PROJECT_OWNER"}..., ), ), ), expectPush( []*repository.Event{ eventFromEventPusher(project.NewProjectMemberChangedEvent(context.Background(), &project.NewAggregate("project1", "org1").Aggregate, "user1", []string{"PROJECT_OWNER", "PROJECT_VIEWER"}..., )), }, ), ), zitadelRoles: []authz.RoleMapping{ { Role: domain.RoleProjectOwner, }, { Role: "PROJECT_VIEWER", }, }, }, args: args{ ctx: context.Background(), member: &domain.Member{ ObjectRoot: models.ObjectRoot{ AggregateID: "project1", }, UserID: "user1", Roles: []string{"PROJECT_OWNER", "PROJECT_VIEWER"}, }, resourceOwner: "org1", }, res: res{ want: &domain.Member{ ObjectRoot: models.ObjectRoot{ ResourceOwner: "org1", AggregateID: "project1", }, UserID: "user1", Roles: []string{domain.RoleProjectOwner, "PROJECT_VIEWER"}, }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { r := &Commands{ eventstore: tt.fields.eventstore, zitadelRoles: tt.fields.zitadelRoles, } got, err := r.ChangeProjectMember(tt.args.ctx, tt.args.member, tt.args.resourceOwner) if tt.res.err == nil { assert.NoError(t, err) } if tt.res.err != nil && !tt.res.err(err) { t.Errorf("got wrong err: %v ", err) } if tt.res.err == nil { assert.Equal(t, tt.res.want, got) } }) } }
explode_data.jsonl/41752
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2155 }
[ 2830, 3393, 4062, 16384, 27588, 844, 7849, 9366, 1155, 353, 8840, 836, 8, 341, 13158, 5043, 2036, 341, 197, 28302, 4314, 256, 353, 3087, 4314, 6904, 4314, 198, 197, 20832, 275, 15151, 25116, 3056, 3242, 89, 35955, 6807, 198, 197, 532, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestCopyFileCopyDest(t *testing.T) { ctx := context.Background() ci := fs.GetConfig(ctx) r := fstest.NewRun(t) defer r.Finalise() if r.Fremote.Features().Copy == nil { t.Skip("Skipping test as remote does not support server-side copy") } ci.CopyDest = r.FremoteName + "/CopyDest" defer func() { ci.CopyDest = "" }() fdst, err := fs.NewFs(ctx, r.FremoteName+"/dst") require.NoError(t, err) // check empty dest, empty copy file1 := r.WriteFile("one", "one", t1) fstest.CheckItems(t, r.Flocal, file1) err = operations.CopyFile(ctx, fdst, r.Flocal, file1.Path, file1.Path) require.NoError(t, err) file1dst := file1 file1dst.Path = "dst/one" fstest.CheckItems(t, r.Fremote, file1dst) // check old dest, empty copy file1b := r.WriteFile("one", "onet2", t2) fstest.CheckItems(t, r.Fremote, file1dst) fstest.CheckItems(t, r.Flocal, file1b) err = operations.CopyFile(ctx, fdst, r.Flocal, file1b.Path, file1b.Path) require.NoError(t, err) file1bdst := file1b file1bdst.Path = "dst/one" fstest.CheckItems(t, r.Fremote, file1bdst) // check old dest, new copy, backup-dir ci.BackupDir = r.FremoteName + "/BackupDir" file3 := r.WriteObject(ctx, "dst/one", "one", t1) file2 := r.WriteObject(ctx, "CopyDest/one", "onet2", t2) file1c := r.WriteFile("one", "onet2", t2) fstest.CheckItems(t, r.Fremote, file2, file3) fstest.CheckItems(t, r.Flocal, file1c) err = operations.CopyFile(ctx, fdst, r.Flocal, file1c.Path, file1c.Path) require.NoError(t, err) file2dst := file2 file2dst.Path = "dst/one" file3.Path = "BackupDir/one" fstest.CheckItems(t, r.Fremote, file2, file2dst, file3) ci.BackupDir = "" // check empty dest, new copy file4 := r.WriteObject(ctx, "CopyDest/two", "two", t2) file5 := r.WriteFile("two", "two", t2) fstest.CheckItems(t, r.Fremote, file2, file2dst, file3, file4) fstest.CheckItems(t, r.Flocal, file1c, file5) err = operations.CopyFile(ctx, fdst, r.Flocal, file5.Path, file5.Path) require.NoError(t, err) file4dst := file4 file4dst.Path = "dst/two" fstest.CheckItems(t, r.Fremote, file2, file2dst, file3, file4, file4dst) // check new dest, new copy err = operations.CopyFile(ctx, fdst, r.Flocal, file5.Path, file5.Path) require.NoError(t, err) fstest.CheckItems(t, r.Fremote, file2, file2dst, file3, file4, file4dst) // check empty dest, old copy file6 := r.WriteObject(ctx, "CopyDest/three", "three", t2) file7 := r.WriteFile("three", "threet3", t3) fstest.CheckItems(t, r.Fremote, file2, file2dst, file3, file4, file4dst, file6) fstest.CheckItems(t, r.Flocal, file1c, file5, file7) err = operations.CopyFile(ctx, fdst, r.Flocal, file7.Path, file7.Path) require.NoError(t, err) file7dst := file7 file7dst.Path = "dst/three" fstest.CheckItems(t, r.Fremote, file2, file2dst, file3, file4, file4dst, file6, file7dst) }
explode_data.jsonl/51945
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1233 }
[ 2830, 3393, 12106, 1703, 12106, 34830, 1155, 353, 8840, 836, 8, 341, 20985, 1669, 2266, 19047, 741, 1444, 72, 1669, 8619, 2234, 2648, 7502, 340, 7000, 1669, 48434, 477, 7121, 6727, 1155, 340, 16867, 435, 991, 977, 1064, 2822, 743, 435, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestPrune(t *testing.T) { t.Parallel() ctx := namespaces.WithNamespace(context.Background(), "buildkit-test") tmpdir, err := ioutil.TempDir("", "cachemanager") require.NoError(t, err) defer os.RemoveAll(tmpdir) snapshotter, err := native.NewSnapshotter(filepath.Join(tmpdir, "snapshots")) require.NoError(t, err) co, cleanup, err := newCacheManager(ctx, cmOpt{ snapshotter: snapshotter, snapshotterName: "native", }) require.NoError(t, err) defer cleanup() cm := co.manager active, err := cm.New(ctx, nil, nil) require.NoError(t, err) snap, err := active.Commit(ctx) require.NoError(t, err) active, err = cm.New(ctx, snap, nil, CachePolicyRetain) require.NoError(t, err) snap2, err := active.Commit(ctx) require.NoError(t, err) checkDiskUsage(ctx, t, cm, 2, 0) dirs, err := ioutil.ReadDir(filepath.Join(tmpdir, "snapshots/snapshots")) require.NoError(t, err) require.Equal(t, 2, len(dirs)) // prune with keeping refs does nothing buf := pruneResultBuffer() err = cm.Prune(ctx, buf.C, client.PruneInfo{}) buf.close() require.NoError(t, err) checkDiskUsage(ctx, t, cm, 2, 0) require.Equal(t, len(buf.all), 0) dirs, err = ioutil.ReadDir(filepath.Join(tmpdir, "snapshots/snapshots")) require.NoError(t, err) require.Equal(t, 2, len(dirs)) err = snap2.Release(ctx) require.NoError(t, err) checkDiskUsage(ctx, t, cm, 1, 1) // prune with keeping single refs deletes one buf = pruneResultBuffer() err = cm.Prune(ctx, buf.C, client.PruneInfo{}) buf.close() require.NoError(t, err) checkDiskUsage(ctx, t, cm, 1, 0) require.Equal(t, len(buf.all), 1) dirs, err = ioutil.ReadDir(filepath.Join(tmpdir, "snapshots/snapshots")) require.NoError(t, err) require.Equal(t, 1, len(dirs)) err = snap.Release(ctx) require.NoError(t, err) active, err = cm.New(ctx, snap, nil, CachePolicyRetain) require.NoError(t, err) snap2, err = active.Commit(ctx) require.NoError(t, err) err = snap.Release(ctx) require.NoError(t, err) checkDiskUsage(ctx, t, cm, 2, 0) // prune with parent released does nothing buf = pruneResultBuffer() err = cm.Prune(ctx, buf.C, client.PruneInfo{}) buf.close() require.NoError(t, err) checkDiskUsage(ctx, t, cm, 2, 0) require.Equal(t, len(buf.all), 0) // releasing last reference err = snap2.Release(ctx) require.NoError(t, err) checkDiskUsage(ctx, t, cm, 0, 2) buf = pruneResultBuffer() err = cm.Prune(ctx, buf.C, client.PruneInfo{}) buf.close() require.NoError(t, err) checkDiskUsage(ctx, t, cm, 0, 0) require.Equal(t, len(buf.all), 2) dirs, err = ioutil.ReadDir(filepath.Join(tmpdir, "snapshots/snapshots")) require.NoError(t, err) require.Equal(t, 0, len(dirs)) }
explode_data.jsonl/3977
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1094 }
[ 2830, 3393, 3533, 2886, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 741, 20985, 1669, 58091, 26124, 22699, 5378, 19047, 1507, 330, 5834, 8226, 16839, 5130, 20082, 3741, 11, 1848, 1669, 43144, 65009, 6184, 19814, 330, 66, 610, 336, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestListDeviceZoneAllPages(t *testing.T) { th.SetupHTTP() defer th.TeardownHTTP() th.Mux.HandleFunc("/API/ScreenEventFGHADeviceGet", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "GET") th.TestHeader(t, r, "X-Auth-Token", fakeclient.TokenID) w.Header().Add("Content-Type", "application/json") fmt.Fprintf(w, listResponse) }) allPages, err := security.List(fakeclient.ServiceClient(), nil).AllPages() th.AssertNoErr(t, err) allDevices, err := security.ExtractHADevices(allPages) th.AssertNoErr(t, err) th.CheckEquals(t, 2, len(allDevices)) }
explode_data.jsonl/45984
{ "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, 852, 6985, 15363, 2403, 17713, 1155, 353, 8840, 836, 8, 341, 70479, 39820, 9230, 741, 16867, 270, 94849, 37496, 9230, 2822, 70479, 1321, 2200, 63623, 4283, 7082, 14, 7971, 1556, 12001, 39, 1808, 63924, 1949, 497, 2915, 3622, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestMessage_PrivateSendTemplate(t *testing.T) { rc := NewRongCloud( os.Getenv("APP_KEY"), os.Getenv("APP_SECRET"), ) tpl1 := TemplateMsgContent{ TargetID: "4kIvGJmETlYqDoVFgWdYdM", Data: map[string]string{ "{name}": "小明", "{score}": "90", }, PushContent: "{name} 你的成绩出来了", } tpl2 := TemplateMsgContent{ TargetID: "GvYBoFJQTggripS_qoiVaA", Data: map[string]string{ "{name}": "小红", "{score}": "95", }, PushContent: "{name} 你的成绩出来了", } msg := TXTMsg{ Content: "{name}, 语文成绩 {score} 分", Extra: "helloExtra", } var tpl []TemplateMsgContent tpl = append(tpl, tpl1) tpl = append(tpl, tpl2) err := rc.PrivateSendTemplate( "7Szq13MKRVortoknTAk7W8", "RC:TxtMsg", msg, tpl) t.Log(err) }
explode_data.jsonl/38995
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 412 }
[ 2830, 3393, 2052, 43830, 11505, 7275, 1155, 353, 8840, 836, 8, 1476, 30295, 1669, 1532, 49, 644, 16055, 1006, 197, 25078, 64883, 445, 14707, 6600, 4461, 197, 25078, 64883, 445, 14707, 31408, 4461, 197, 692, 3244, 500, 16, 1669, 14355, 6...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestNewCurrencyPairFromString(t *testing.T) { t.Parallel() pairStr := "BTC-USD" pair := NewCurrencyPairFromString(pairStr) actual := pair.Pair() expected := CurrencyItem("BTC-USD") if actual != expected { t.Errorf( "Test failed. Pair(): %s was not equal to expected value: %s", actual, expected, ) } pairStr = "BTCUSD" pair = NewCurrencyPairFromString(pairStr) actual = pair.Pair() expected = CurrencyItem("BTCUSD") if actual != expected { t.Errorf( "Test failed. Pair(): %s was not equal to expected value: %s", actual, expected, ) } }
explode_data.jsonl/55836
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 218 }
[ 2830, 3393, 3564, 26321, 12443, 44491, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 741, 3223, 1310, 2580, 1669, 330, 59118, 12, 26749, 698, 3223, 1310, 1669, 1532, 26321, 12443, 44491, 39144, 2580, 340, 88814, 1669, 6716, 1069, 1310,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestJoinViaRoomIDAndServerName(t *testing.T) { deployment := Deploy(t, b.BlueprintFederationOneToOneRoom) defer deployment.Destroy(t) acceptMakeSendJoinRequests := true srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), ) srv.UnexpectedRequestsAreErrors = false // we will be sent transactions but that's okay cancel := srv.Listen() defer cancel() srv.Mux().Handle("/_matrix/federation/v1/make_join/{roomID}/{userID}", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { if !acceptMakeSendJoinRequests { w.WriteHeader(502) return } federation.MakeJoinRequestsHandler(srv, w, req) })).Methods("GET") srv.Mux().Handle("/_matrix/federation/v2/send_join/{roomID}/{eventID}", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { if !acceptMakeSendJoinRequests { w.WriteHeader(502) return } federation.SendJoinRequestsHandler(srv, w, req) })).Methods("PUT") ver := gomatrixserverlib.RoomVersionV5 charlie := srv.UserID("charlie") serverRoom := srv.MustMakeRoom(t, ver, federation.InitialRoomEvents(ver, charlie)) // join the room by room ID, providing the serverName to join via alice := deployment.Client(t, "hs1", "@alice:hs1") alice.JoinRoom(t, serverRoom.RoomID, []string{srv.ServerName}) // remove the make/send join paths from the Complement server to force HS2 to join via HS1 acceptMakeSendJoinRequests = false // join the room using ?server_name on HS2 bob := deployment.Client(t, "hs2", "@bob:hs2") queryParams := url.Values{} queryParams.Set("server_name", "hs1") res := bob.DoFunc(t, "POST", []string{"_matrix", "client", "r0", "join", serverRoom.RoomID}, client.WithQueries(queryParams)) must.MatchResponse(t, res, match.HTTPResponse{ StatusCode: 200, JSON: []match.JSON{ match.JSONKeyEqual("room_id", serverRoom.RoomID), }, }) }
explode_data.jsonl/37598
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 688 }
[ 2830, 3393, 12292, 54428, 14003, 915, 3036, 5475, 675, 1155, 353, 8840, 836, 8, 341, 197, 82213, 1669, 70595, 1155, 11, 293, 60159, 1350, 37, 96013, 3966, 28190, 14003, 340, 16867, 23172, 57011, 1155, 692, 197, 10330, 8078, 11505, 12292, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestDelete(t *testing.T) { // test for https://github.com/pingcap/tidb/pull/1135 store, clean := realtikvtest.CreateMockStoreAndSetup(t) defer clean() tk := testkit.NewTestKit(t, store) tk.MustExec("use test") tk1 := testkit.NewTestKit(t, store) tk1.MustExec("create database test1") tk1.MustExec("use test1") tk1.MustExec("create table t (F1 VARCHAR(30));") tk1.MustExec("insert into t (F1) values ('1'), ('4');") tk.MustExec("create table t (F1 VARCHAR(30));") tk.MustExec("insert into t (F1) values ('1'), ('2');") tk.MustExec("delete m1 from t m2,t m1 where m1.F1>1;") tk.MustQuery("select * from t;").Check(testkit.Rows("1")) tk.MustExec("drop table if exists t") tk.MustExec("create table t (F1 VARCHAR(30));") tk.MustExec("insert into t (F1) values ('1'), ('2');") tk.MustExec("delete m1 from t m1,t m2 where true and m1.F1<2;") tk.MustQuery("select * from t;").Check(testkit.Rows("2")) tk.MustExec("drop table if exists t") tk.MustExec("create table t (F1 VARCHAR(30));") tk.MustExec("insert into t (F1) values ('1'), ('2');") tk.MustExec("delete m1 from t m1,t m2 where false;") tk.MustQuery("select * from t;").Check(testkit.Rows("1", "2")) tk.MustExec("drop table if exists t") tk.MustExec("create table t (F1 VARCHAR(30));") tk.MustExec("insert into t (F1) values ('1'), ('2');") tk.MustExec("delete m1, m2 from t m1,t m2 where m1.F1>m2.F1;") tk.MustQuery("select * from t;").Check(testkit.Rows()) tk.MustExec("drop table if exists t") tk.MustExec("create table t (F1 VARCHAR(30));") tk.MustExec("insert into t (F1) values ('1'), ('2');") tk.MustExec("delete test1.t from test1.t inner join test.t where test1.t.F1 > test.t.F1") tk1.MustQuery("select * from t;").Check(testkit.Rows("1")) }
explode_data.jsonl/5789
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 704 }
[ 2830, 3393, 6435, 1155, 353, 8840, 836, 8, 341, 197, 322, 1273, 369, 3703, 1110, 5204, 905, 4322, 287, 11346, 5523, 307, 65, 4322, 617, 14, 16, 16, 18, 20, 271, 57279, 11, 4240, 1669, 1931, 83, 1579, 85, 1944, 7251, 11571, 6093, 3...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestApplicationResolver_CreateApplication_Error(t *testing.T) { // GIVEN fixName := "fix-name" appSvc := automock.NewApplicationSvc() appSvc.On("Create", fixName, "", gqlschema.Labels(nil)).Return(nil, errors.New("fix")) // WHEN resolver := application.NewApplicationResolver(appSvc, nil) _, err := resolver.CreateApplication(context.Background(), fixName, nil, nil) // THEN assert.EqualError(t, err, fmt.Sprintf("internal error [name: \"%s\"]", fixName)) }
explode_data.jsonl/28760
{ "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, 4988, 18190, 34325, 4988, 28651, 1155, 353, 8840, 836, 8, 341, 197, 322, 89836, 198, 1166, 941, 675, 1669, 330, 5743, 11494, 698, 28236, 92766, 1669, 5006, 1176, 7121, 4988, 92766, 741, 28236, 92766, 8071, 445, 4021, 497, 50...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestCacheQueryer_ServicesForIngress(t *testing.T) { ingress1 := &extv1beta1.Ingress{ TypeMeta: metav1.TypeMeta{APIVersion: "extensions/v1beta1", Kind: "Ingress"}, ObjectMeta: metav1.ObjectMeta{Name: "ingress1", Namespace: "default"}, Spec: extv1beta1.IngressSpec{ Backend: &extv1beta1.IngressBackend{ ServiceName: "service1", }, }, } ingress2 := &extv1beta1.Ingress{ TypeMeta: metav1.TypeMeta{APIVersion: "extensions/v1beta1", Kind: "Ingress"}, ObjectMeta: metav1.ObjectMeta{Name: "ingress2", Namespace: "default"}, Spec: extv1beta1.IngressSpec{ Rules: []extv1beta1.IngressRule{ { IngressRuleValue: extv1beta1.IngressRuleValue{ HTTP: &extv1beta1.HTTPIngressRuleValue{ Paths: []extv1beta1.HTTPIngressPath{ { Backend: extv1beta1.IngressBackend{ ServiceName: "service2", }, }, { Backend: extv1beta1.IngressBackend{ ServiceName: "service1", }, }, }, }, }, }, }, }, } service1 := &corev1.Service{ TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "Service"}, ObjectMeta: metav1.ObjectMeta{Name: "service1", Namespace: "default"}, Spec: corev1.ServiceSpec{ Selector: map[string]string{ "app": "one", }, }, } service2 := &corev1.Service{ TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: "Service"}, ObjectMeta: metav1.ObjectMeta{Name: "service2", Namespace: "default"}, Spec: corev1.ServiceSpec{ Selector: map[string]string{ "app": "two", }, }, } cases := []struct { name string ingress *extv1beta1.Ingress setup func(t *testing.T, o *storeFake.MockStore) expected []string isErr bool }{ { name: "in general: service defined as backend", ingress: ingress1, setup: func(t *testing.T, o *storeFake.MockStore) { key := store.Key{ Namespace: "default", APIVersion: "v1", Kind: "Service", Name: "service1", } o.EXPECT(). Get(gomock.Any(), gomock.Eq(key)). Return(testutil.ToUnstructured(t, service1), true, nil) }, expected: []string{"service1"}, }, { name: "in general: services defined in rules", ingress: ingress2, setup: func(t *testing.T, o *storeFake.MockStore) { key1 := store.Key{ Namespace: "default", APIVersion: "v1", Kind: "Service", Name: "service1", } o.EXPECT(). Get(gomock.Any(), gomock.Eq(key1)). Return(testutil.ToUnstructured(t, service1), true, nil) key2 := store.Key{ Namespace: "default", APIVersion: "v1", Kind: "Service", Name: "service2", } o.EXPECT(). Get(gomock.Any(), gomock.Eq(key2)). Return(testutil.ToUnstructured(t, service2), true, nil) }, expected: []string{"service1", "service2"}, }, { name: "ingress is nil", ingress: nil, isErr: true, }, { name: "object store list failure", ingress: ingress1, setup: func(t *testing.T, c *storeFake.MockStore) { key := store.Key{ Namespace: "default", APIVersion: "v1", Kind: "Service", Name: "service1", } c.EXPECT(). Get(gomock.Any(), gomock.Eq(key)). Return(nil, false, errors.New("failed")) }, isErr: true, }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { controller := gomock.NewController(t) defer controller.Finish() o := storeFake.NewMockStore(controller) discovery := queryerFake.NewMockDiscoveryInterface(controller) if tc.setup != nil { tc.setup(t, o) } oq := New(o, discovery) ctx := context.Background() services, err := oq.ServicesForIngress(ctx, tc.ingress) if tc.isErr { require.Error(t, err) return } require.NoError(t, err) var got []string for _, service := range services { got = append(got, service.Name) } sort.Strings(got) sort.Strings(tc.expected) assert.Equal(t, tc.expected, got) }) } }
explode_data.jsonl/45672
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1946 }
[ 2830, 3393, 8233, 2859, 261, 1098, 2161, 2461, 641, 2483, 1155, 353, 8840, 836, 8, 341, 197, 287, 673, 16, 1669, 609, 427, 85, 16, 19127, 16, 5337, 2483, 515, 197, 27725, 12175, 25, 256, 77520, 16, 10184, 12175, 90, 7082, 5637, 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 TestInitializeOpenshiftAPIVersionRouteHandler(t *testing.T) { service := new(restful.WebService) initAPIVersionRoute(service, "v1beta1") if len(service.Routes()) != 1 { t.Fatalf("Exp. the OSAPI route but found none") } route := service.Routes()[0] if !contains(route.Produces, restful.MIME_JSON) { t.Fatalf("Exp. route to produce mimetype json") } if !contains(route.Consumes, restful.MIME_JSON) { t.Fatalf("Exp. route to consume mimetype json") } }
explode_data.jsonl/81674
{ "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, 9928, 36771, 47833, 7082, 5637, 4899, 3050, 1155, 353, 8840, 836, 8, 341, 52934, 1669, 501, 62036, 1262, 6473, 1860, 340, 28248, 7082, 5637, 4899, 21656, 11, 330, 85, 16, 19127, 16, 5130, 743, 2422, 21656, 2013, 5495, 2140, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestBlobListJSON(t *testing.T) { bl := restic.NewBlobList() b := restic.Blob{ID: randomID()} bl.Insert(b) b2, err := bl.Find(b) ok(t, err) assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2) buf, err := json.Marshal(bl) ok(t, err) bl2 := restic.BlobList{} json.Unmarshal(buf, &bl2) b2, err = bl2.Find(b) ok(t, err) assert(t, b2.Compare(b) == 0, "items are not equal: want %v, got %v", b, b2) buf, err = json.Marshal(bl2) ok(t, err) }
explode_data.jsonl/66169
{ "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, 37985, 852, 5370, 1155, 353, 8840, 836, 8, 341, 96421, 1669, 2732, 292, 7121, 37985, 852, 741, 2233, 1669, 2732, 292, 1785, 1684, 90, 915, 25, 4194, 915, 23509, 96421, 23142, 1883, 692, 2233, 17, 11, 1848, 1669, 1501, 9998...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestContextGetString(t *testing.T) { c, _ := CreateTestContext(httptest.NewRecorder()) c.Set("string", "this is a string") assert.Equal(t, "this is a string", c.GetString("string")) }
explode_data.jsonl/26746
{ "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, 1972, 48905, 1155, 353, 8840, 836, 8, 341, 1444, 11, 716, 1669, 4230, 2271, 1972, 73392, 83, 70334, 7121, 47023, 2398, 1444, 4202, 445, 917, 497, 330, 574, 374, 264, 914, 1138, 6948, 12808, 1155, 11, 330, 574, 374, 264, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestIsPort(t *testing.T) { if HasPort("blah.not.port:") { t.Fatal("Failed to parse port when : at end") } if !HasPort("host:1") { t.Fatal("Failed to parse with port = 1") } if HasPort("https://example.com") { t.Fatal("Failed when scheme is specified") } }
explode_data.jsonl/22509
{ "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, 3872, 7084, 1155, 353, 8840, 836, 8, 1476, 743, 11443, 7084, 445, 70614, 11971, 14598, 90220, 341, 197, 3244, 26133, 445, 9408, 311, 4715, 2635, 979, 549, 518, 835, 1138, 197, 630, 743, 753, 10281, 7084, 445, 3790, 25, 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...
4
func TestIAMRoleNameReferencerForIAMRolePolicyAttachment_AssignValidType_ReturnsExpected(t *testing.T) { r := &IAMRoleNameReferencerForIAMRolePolicyAttachment{} res := &IAMRolePolicyAttachment{} var expectedErr error err := r.Assign(res, "mockValue") if diff := cmp.Diff(expectedErr, err, test.EquateErrors()); diff != "" { t.Errorf("Assign(...): -want error, +got error:\n%s", diff) } if diff := cmp.Diff(res.Spec.RoleName, "mockValue"); diff != "" { t.Errorf("Assign(...): -want value, +got value:\n%s", diff) } }
explode_data.jsonl/69166
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 205 }
[ 2830, 3393, 73707, 9030, 675, 47447, 19529, 2461, 73707, 9030, 13825, 33569, 62222, 622, 4088, 929, 53316, 82, 18896, 1155, 353, 8840, 836, 8, 1476, 7000, 1669, 609, 73707, 9030, 675, 47447, 19529, 2461, 73707, 9030, 13825, 33569, 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...
3
func TestInitialBoardAdvanceP2Wins(t *testing.T) { b := InitialBoard() b.P1.Direction = Left b.P2.Direction = Left w, _ := b.Advance() assert.Equal(t, w, (Winner)(P2Wins)) }
explode_data.jsonl/7802
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 79 }
[ 2830, 3393, 6341, 11932, 95027, 47, 17, 96186, 1155, 353, 8840, 836, 8, 341, 2233, 1669, 4127, 11932, 2822, 2233, 1069, 16, 47282, 284, 13727, 198, 2233, 1069, 17, 47282, 284, 13727, 271, 6692, 11, 716, 1669, 293, 17865, 85, 681, 2822...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
1
func TestIRCemptyNick(t *testing.T) { irccon := IRC("", "go-eventirc") irccon = nil if irccon != nil { t.Error("empty nick didn't result in error") t.Fail() } }
explode_data.jsonl/63353
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 71 }
[ 2830, 3393, 51840, 3194, 30356, 1155, 353, 8840, 836, 8, 341, 197, 2437, 443, 1669, 59328, 19814, 330, 3346, 39687, 2437, 1138, 197, 2437, 443, 284, 2092, 198, 743, 79923, 443, 961, 2092, 341, 197, 3244, 6141, 445, 3194, 15988, 3207, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestDhcpServer(t *testing.T) { clientMac, _ := net.ParseMAC(clientMacAddrs[0]) for _, tc := range []struct { name string csn network.ContainerSideNetwork expectedSubstrings []string }{ { name: "with classless routes", csn: network.ContainerSideNetwork{ Result: &cnicurrent.Result{ Interfaces: []*cnicurrent.Interface{ { Name: "eth0", Mac: clientMacAddrs[0], // Sandbox is clientNS dependent // so it must be set in runtime }, }, IPs: []*cnicurrent.IPConfig{ { Version: "4", Interface: 0, Address: net.IPNet{ IP: net.IP{10, 1, 90, 5}, Mask: net.IPMask{255, 255, 255, 0}, }, Gateway: net.IP{10, 1, 90, 1}, }, }, Routes: []*cnitypes.Route{ { Dst: net.IPNet{ IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0}, }, GW: net.IP{10, 1, 90, 1}, }, { Dst: net.IPNet{ IP: net.IP{10, 10, 42, 0}, Mask: net.IPMask{255, 255, 255, 0}, }, GW: net.IP{10, 1, 90, 90}, }, }, }, Interfaces: []*network.InterfaceDescription{ { HardwareAddr: clientMac, MTU: 9000, }, }, }, expectedSubstrings: []string{ "new_broadcast_address='10.1.90.255'", "new_classless_static_routes='10.10.42.0/24 10.1.90.90 0.0.0.0/0 10.1.90.1'", "new_dhcp_lease_time='86400'", "new_dhcp_rebinding_time='64800'", "new_dhcp_renewal_time='43200'", "new_dhcp_server_identifier='169.254.254.2'", "new_domain_name_servers='8.8.8.8'", "new_ip_address='10.1.90.5'", "new_interface_mtu='9000'", "new_network_number='10.1.90.0'", "new_subnet_cidr='24'", "new_subnet_mask='255.255.255.0'", "veth0: offered 10.1.90.5 from 169.254.254.2", }, }, { name: "without classless routes", csn: network.ContainerSideNetwork{ Result: &cnicurrent.Result{ Interfaces: []*cnicurrent.Interface{ { Name: "eth0", Mac: clientMacAddrs[0], // Sandbox is clientNS dependent // so it must be set in runtime }, }, IPs: []*cnicurrent.IPConfig{ { Version: "4", Interface: 0, Address: net.IPNet{ IP: net.IP{10, 1, 90, 5}, Mask: net.IPMask{255, 255, 255, 0}, }, Gateway: net.IP{10, 1, 90, 1}, }, }, Routes: []*cnitypes.Route{ { Dst: net.IPNet{ IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0}, }, GW: net.IP{10, 1, 90, 1}, }, }, }, Interfaces: []*network.InterfaceDescription{ { HardwareAddr: clientMac, MTU: 9000, }, }, }, expectedSubstrings: []string{ "new_broadcast_address='10.1.90.255'", "new_dhcp_lease_time='86400'", "new_dhcp_rebinding_time='64800'", "new_dhcp_renewal_time='43200'", "new_dhcp_server_identifier='169.254.254.2'", "new_domain_name_servers='8.8.8.8'", "new_ip_address='10.1.90.5'", "new_interface_mtu='9000'", "new_network_number='10.1.90.0'", "new_routers='10.1.90.1'", "new_subnet_cidr='24'", "new_subnet_mask='255.255.255.0'", "veth0: offered 10.1.90.5 from 169.254.254.2", }, }, // TODO: add dns test case here } { t.Run(tc.name, func(t *testing.T) { serverNS, err := ns.NewNS() if err != nil { t.Fatalf("Failed to create ns for dhcp server: %v", err) } defer serverNS.Close() clientNS, err := ns.NewNS() if err != nil { t.Fatalf("Failed to create ns for dhcp client: %v", err) } defer clientNS.Close() // Sandbox is clientNS dependent so it needs to be set there on all interfaces for _, iface := range tc.csn.Result.Interfaces { iface.Sandbox = clientNS.Path() } var clientVeth, serverVeth netlink.Link if err := serverNS.Do(func(ns.NetNS) error { serverVeth, clientVeth, err = nettools.CreateEscapeVethPair(clientNS, "veth0", 1500) if err != nil { return fmt.Errorf("failed to create escape veth pair: %v", err) } addr, err := netlink.ParseAddr("169.254.254.2/24") if err != nil { return fmt.Errorf("failed to parse dhcp interface address: %v", err) } if err = netlink.AddrAdd(serverVeth, addr); err != nil { return fmt.Errorf("failed to add addr for serverVeth: %v", err) } return nil }); err != nil { t.Fatal(err) } if err := clientNS.Do(func(ns.NetNS) error { mac, _ := net.ParseMAC(clientMacAddrs[0]) if err = nettools.SetHardwareAddr(clientVeth, mac); err != nil { return fmt.Errorf("can't set MAC address on the client interface: %v", err) } return nil }); err != nil { t.Fatal(err) } g := NewNetTestGroup(t, 15*time.Second) defer g.Stop() g.Add(serverNS, NewDhcpServerTester(&tc.csn)) g.Add(clientNS, NewDhcpClient("veth0", tc.expectedSubstrings)) g.Wait() }) } }
explode_data.jsonl/31988
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2625 }
[ 2830, 3393, 35, 62169, 5475, 1155, 353, 8840, 836, 8, 341, 25291, 19552, 11, 716, 1669, 4179, 8937, 25788, 12805, 19552, 2212, 5428, 58, 15, 2546, 2023, 8358, 17130, 1669, 2088, 3056, 1235, 341, 197, 11609, 2290, 914, 198, 197, 1444, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestRegisterCustomClientReserved(t *testing.T) { for _, tc := range []string{"true", "false"} { t.Run(fmt.Sprintf("%v", tc), func(t *testing.T) { err := RegisterCustomClient(tc, &http.Client{}) if err == nil { t.Fatal("client key name supposed to fail:", tc) } }) } }
explode_data.jsonl/62437
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 120 }
[ 2830, 3393, 8690, 10268, 2959, 53003, 1155, 353, 8840, 836, 8, 341, 2023, 8358, 17130, 1669, 2088, 3056, 917, 4913, 1866, 497, 330, 3849, 9207, 341, 197, 3244, 16708, 28197, 17305, 4430, 85, 497, 17130, 701, 2915, 1155, 353, 8840, 836, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestHello(t *testing.T) { want := "Hi, world." if got := Hello(); got != want { t.Errorf("Hello() = %q, want %q", got, want) } }
explode_data.jsonl/41423
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 69 }
[ 2830, 3393, 9707, 1155, 353, 8840, 836, 8, 341, 262, 1366, 1669, 330, 13048, 11, 1879, 10040, 262, 421, 2684, 1669, 21927, 2129, 2684, 961, 1366, 341, 286, 259, 13080, 445, 9707, 368, 284, 1018, 80, 11, 1366, 1018, 80, 497, 2684, 11...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
2
func TestTLSMutualAuth(t *testing.T) { Convey("Make a new controller", t, func() { caCert, err := ioutil.ReadFile(CACert) So(err, ShouldBeNil) caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert) port := test.GetFreePort() baseURL := test.GetBaseURL(port) secureBaseURL := test.GetSecureBaseURL(port) resty.SetTLSClientConfig(&tls.Config{RootCAs: caCertPool, MinVersion: tls.VersionTLS12}) defer func() { resty.SetTLSClientConfig(nil) }() conf := config.New() conf.HTTP.Port = port conf.HTTP.TLS = &config.TLSConfig{ Cert: ServerCert, Key: ServerKey, CACert: CACert, } ctlr := api.NewController(conf) ctlr.Config.Storage.RootDirectory = t.TempDir() go startServer(ctlr) defer stopServer(ctlr) test.WaitTillServerReady(baseURL) // accessing insecure HTTP site should fail resp, err := resty.R().Get(baseURL) So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusBadRequest) // without client certs and creds, should get conn error _, err = resty.R().Get(secureBaseURL) So(err, ShouldNotBeNil) // with creds but without certs, should get conn error _, err = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(err, ShouldNotBeNil) // setup TLS mutual auth cert, err := tls.LoadX509KeyPair("../../test/data/client.cert", "../../test/data/client.key") So(err, ShouldBeNil) resty.SetCertificates(cert) defer func() { resty.SetCertificates(tls.Certificate{}) }() // with client certs but without creds, should succeed resp, err = resty.R().Get(secureBaseURL + "/v2/") So(err, ShouldBeNil) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusOK) // with client certs and creds, should get expected status code resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL) So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusNotFound) // with client certs, creds shouldn't matter resp, _ = resty.R().SetBasicAuth(username, passphrase).Get(secureBaseURL + "/v2/") So(resp, ShouldNotBeNil) So(resp.StatusCode(), ShouldEqual, http.StatusOK) }) }
explode_data.jsonl/77689
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 840 }
[ 2830, 3393, 45439, 51440, 928, 5087, 1155, 353, 8840, 836, 8, 341, 93070, 5617, 445, 8078, 264, 501, 6461, 497, 259, 11, 2915, 368, 341, 197, 197, 924, 36934, 11, 1848, 1669, 43144, 78976, 3025, 1706, 529, 340, 197, 76912, 3964, 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 TestEtcdDeleteMinion(t *testing.T) { ctx := api.NewContext() fakeClient := tools.NewFakeEtcdClient(t) registry := NewTestEtcdRegistry(fakeClient) err := registry.DeleteMinion(ctx, "foo") if err != nil { t.Errorf("unexpected error: %v", err) } if len(fakeClient.DeletedKeys) != 1 { t.Errorf("Expected 1 delete, found %#v", fakeClient.DeletedKeys) } key := "/registry/minions/foo" if fakeClient.DeletedKeys[0] != key { t.Errorf("Unexpected key: %s, expected %s", fakeClient.DeletedKeys[0], key) } }
explode_data.jsonl/8183
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 205 }
[ 2830, 3393, 31860, 4385, 6435, 6217, 290, 1155, 353, 8840, 836, 8, 341, 20985, 1669, 6330, 7121, 1972, 741, 1166, 726, 2959, 1669, 7375, 7121, 52317, 31860, 4385, 2959, 1155, 340, 197, 29172, 1669, 1532, 2271, 31860, 4385, 15603, 74138, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestRunStatus(t *testing.T) { pJob := proto.Job{ Id: "j1", Type: "jtype", Name: "jname", } realJob := &mock.Job{ StatusResp: "foo", } expectStatus := runner.Status{ Job: pJob, StartedAt: time.Time{}, Try: 1, Status: "foo", Sleeping: false, } now := time.Now() jr := runner.NewRunner(pJob, realJob, "abc", 0, 0, &mock.RMClient{}) gotStatus := jr.Status() startTime := gotStatus.StartedAt if startTime.IsZero() { t.Error("StartedAt is zero, expected value") } if !startTime.After(now) { t.Errorf("StartedAt %s after now %s", startTime, now) } gotStatus.StartedAt = time.Time{} if diff := deep.Equal(gotStatus, expectStatus); diff != nil { t.Error(diff) } }
explode_data.jsonl/72732
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 324 }
[ 2830, 3393, 6727, 2522, 1155, 353, 8840, 836, 8, 341, 3223, 12245, 1669, 18433, 45293, 515, 197, 67211, 25, 256, 330, 73, 16, 756, 197, 27725, 25, 330, 73, 1313, 756, 197, 21297, 25, 330, 73, 606, 756, 197, 532, 91874, 12245, 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...
4
func Test_CoreEdgeRouterSvc(t *testing.T) { var parts []string want := serviceBuilder("edge-router", "ClusterIP", 8080, 8080) runSvcTest(parts, "./tmp/openfaas-cloud/templates/ofc-core/edge-router-svc.yaml", want, t) }
explode_data.jsonl/32006
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 90 }
[ 2830, 3393, 41990, 11656, 9523, 92766, 1155, 353, 8840, 836, 8, 341, 2405, 5479, 3056, 917, 198, 50780, 1669, 2473, 3297, 445, 7186, 14266, 497, 330, 28678, 3298, 497, 220, 23, 15, 23, 15, 11, 220, 23, 15, 23, 15, 340, 56742, 92766,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestInitOrderInfo(t *testing.T) { var tests = []struct { src string inits []string }{ {`package p0; var (x = 1; y = x)`, []string{ "x = 1", "y = x", }}, {`package p1; var (a = 1; b = 2; c = 3)`, []string{ "a = 1", "b = 2", "c = 3", }}, {`package p2; var (a, b, c = 1, 2, 3)`, []string{ "a = 1", "b = 2", "c = 3", }}, {`package p3; var _ = f(); func f() int { return 1 }`, []string{ "_ = f()", // blank var }}, {`package p4; var (a = 0; x = y; y = z; z = 0)`, []string{ "a = 0", "z = 0", "y = z", "x = y", }}, {`package p5; var (a, _ = m[0]; m map[int]string)`, []string{ "a, _ = m[0]", // blank var }}, {`package p6; var a, b = f(); func f() (_, _ int) { return z, z }; var z = 0`, []string{ "z = 0", "a, b = f()", }}, {`package p7; var (a = func() int { return b }(); b = 1)`, []string{ "b = 1", "a = (func() int literal)()", }}, {`package p8; var (a, b = func() (_, _ int) { return c, c }(); c = 1)`, []string{ "c = 1", "a, b = (func() (_, _ int) literal)()", }}, {`package p9; type T struct{}; func (T) m() int { _ = y; return 0 }; var x, y = T.m, 1`, []string{ "y = 1", "x = T.m", }}, {`package p10; var (d = c + b; a = 0; b = 0; c = 0)`, []string{ "a = 0", "b = 0", "c = 0", "d = c + b", }}, {`package p11; var (a = e + c; b = d + c; c = 0; d = 0; e = 0)`, []string{ "c = 0", "d = 0", "b = d + c", "e = 0", "a = e + c", }}, // emit an initializer for n:1 initializations only once (not for each node // on the lhs which may appear in different order in the dependency graph) {`package p12; var (a = x; b = 0; x, y = m[0]; m map[int]int)`, []string{ "b = 0", "x, y = m[0]", "a = x", }}, // test case from spec section on package initialization {`package p12 var ( a = c + b b = f() c = f() d = 3 ) func f() int { d++ return d }`, []string{ "d = 3", "b = f()", "c = f()", "a = c + b", }}, // test case for issue 7131 {`package main var counter int func next() int { counter++; return counter } var _ = makeOrder() func makeOrder() []int { return []int{f, b, d, e, c, a} } var a = next() var b, c = next(), next() var d, e, f = next(), next(), next() `, []string{ "a = next()", "b = next()", "c = next()", "d = next()", "e = next()", "f = next()", "_ = makeOrder()", }}, // test case for issue 10709 {`package p13 var ( v = t.m() t = makeT(0) ) type T struct{} func (T) m() int { return 0 } func makeT(n int) T { if n > 0 { return makeT(n-1) } return T{} }`, []string{ "t = makeT(0)", "v = t.m()", }}, // test case for issue 10709: same as test before, but variable decls swapped {`package p14 var ( t = makeT(0) v = t.m() ) type T struct{} func (T) m() int { return 0 } func makeT(n int) T { if n > 0 { return makeT(n-1) } return T{} }`, []string{ "t = makeT(0)", "v = t.m()", }}, // another candidate possibly causing problems with issue 10709 {`package p15 var y1 = f1() func f1() int { return g1() } func g1() int { f1(); return x1 } var x1 = 0 var y2 = f2() func f2() int { return g2() } func g2() int { return x2 } var x2 = 0`, []string{ "x1 = 0", "y1 = f1()", "x2 = 0", "y2 = f2()", }}, } for _, test := range tests { info := Info{} name := mustTypecheck(t, "InitOrderInfo", test.src, &info) // number of initializers must match if len(info.InitOrder) != len(test.inits) { t.Errorf("package %s: got %d initializers; want %d", name, len(info.InitOrder), len(test.inits)) continue } // initializers must match for i, want := range test.inits { got := info.InitOrder[i].String() if got != want { t.Errorf("package %s, init %d: got %s; want %s", name, i, got, want) continue } } } }
explode_data.jsonl/55543
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1847 }
[ 2830, 3393, 3803, 4431, 1731, 1155, 353, 8840, 836, 8, 341, 2405, 7032, 284, 3056, 1235, 341, 197, 41144, 256, 914, 198, 197, 17430, 1199, 3056, 917, 198, 197, 59403, 197, 197, 90, 63, 1722, 281, 15, 26, 762, 320, 87, 284, 220, 16...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
5
func TestHCL_SQL(t *testing.T) { file, err := decode(` schema "hi" { } table "users" { schema = schema.hi column "id" { type = int null = false default = 123 } column "age" { type = int null = false default = 10 } column "active" { type = boolean default = true } column "account_active" { type = boolean default = true } primary_key { columns = [table.users.column.id, table.users.column.age] } index "age" { unique = true columns = [table.users.column.age] } index "active" { unique = false columns = [table.users.column.active] } foreign_key "fk" { columns = [table.users.column.account_active] ref_columns = [table.accounts.column.active] on_delete = "SET NULL" } } table "accounts" { schema = schema.hi column "id" { type = int null = false default = 123 } column "age" { type = int null = false default = 10 } column "active" { type = boolean default = true } column "user_active" { type = boolean default = true } primary_key { columns = [table.accounts.column.id] } index "age" { unique = true columns = [table.accounts.column.age] } index "active" { unique = false columns = [table.accounts.column.active] } foreign_key "fk" { columns = [table.accounts.column.user_active] ref_columns = [table.users.column.active] on_delete = "SET NULL" } } `) require.NoError(t, err) expected := &db{ Schemas: []*sqlspec.Schema{ {Name: "hi"}, }, Tables: []*sqlspec.Table{ { Name: "users", Schema: &schemaspec.Ref{V: "$schema.hi"}, Columns: []*sqlspec.Column{ { Name: "id", Type: &schemaspec.Type{T: "int"}, Null: false, Default: &schemaspec.LiteralValue{V: "123"}, }, { Name: "age", Type: &schemaspec.Type{T: "int"}, Null: false, Default: &schemaspec.LiteralValue{V: "10"}, }, { Name: "active", Type: &schemaspec.Type{T: "boolean"}, Null: false, Default: &schemaspec.LiteralValue{V: "true"}, }, { Name: "account_active", Type: &schemaspec.Type{T: "boolean"}, Null: false, Default: &schemaspec.LiteralValue{V: "true"}, }, }, PrimaryKey: &sqlspec.PrimaryKey{ Columns: []*schemaspec.Ref{ { V: "$table.users.$column.id", }, { V: "$table.users.$column.age", }, }, }, Indexes: []*sqlspec.Index{ { Name: "age", Unique: true, Columns: []*schemaspec.Ref{ { V: "$table.users.$column.age", }, }, }, { Name: "active", Unique: false, Columns: []*schemaspec.Ref{ { V: "$table.users.$column.active", }, }, }, }, ForeignKeys: []*sqlspec.ForeignKey{ { Symbol: "fk", Columns: []*schemaspec.Ref{ { V: "$table.users.$column.account_active", }, }, RefColumns: []*schemaspec.Ref{ { V: "$table.accounts.$column.active", }, }, OnDelete: &schemaspec.Ref{V: string(schema.SetNull)}, }, }, }, { Name: "accounts", Schema: &schemaspec.Ref{V: "$schema.hi"}, Columns: []*sqlspec.Column{ { Name: "id", Type: &schemaspec.Type{T: "int"}, Null: false, Default: &schemaspec.LiteralValue{V: "123"}, }, { Name: "age", Type: &schemaspec.Type{T: "int"}, Null: false, Default: &schemaspec.LiteralValue{V: "10"}, }, { Name: "active", Type: &schemaspec.Type{T: "boolean"}, Null: false, Default: &schemaspec.LiteralValue{V: "true"}, }, { Name: "user_active", Type: &schemaspec.Type{T: "boolean"}, Null: false, Default: &schemaspec.LiteralValue{V: "true"}, }, }, PrimaryKey: &sqlspec.PrimaryKey{ Columns: []*schemaspec.Ref{ { V: "$table.accounts.$column.id", }, }, }, Indexes: []*sqlspec.Index{ { Name: "age", Unique: true, Columns: []*schemaspec.Ref{ { V: "$table.accounts.$column.age", }, }, }, { Name: "active", Unique: false, Columns: []*schemaspec.Ref{ { V: "$table.accounts.$column.active", }, }, }, }, ForeignKeys: []*sqlspec.ForeignKey{ { Symbol: "fk", Columns: []*schemaspec.Ref{ { V: "$table.accounts.$column.user_active", }, }, RefColumns: []*schemaspec.Ref{ { V: "$table.users.$column.active", }, }, OnDelete: &schemaspec.Ref{V: string(schema.SetNull)}, }, }, }, }, } require.EqualValues(t, expected, file) }
explode_data.jsonl/81312
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2638 }
[ 2830, 3393, 39, 3140, 46625, 1155, 353, 8840, 836, 8, 341, 17661, 11, 1848, 1669, 16895, 61528, 17349, 330, 6023, 1, 1476, 630, 2005, 330, 4218, 1, 341, 1903, 3416, 284, 10802, 860, 72, 17642, 51661, 330, 307, 1, 341, 197, 13158, 28...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestPostUnmarshalTaskWithPIDSharing(t *testing.T) { for _, aTest := range namespaceTests { testTaskFromACS := ecsacs.Task{ Arn: strptr("myArn"), DesiredStatus: strptr("RUNNING"), Family: strptr("myFamily"), PidMode: strptr(aTest.PIDMode), IpcMode: strptr(aTest.IPCMode), Version: strptr("1"), Containers: []*ecsacs.Container{ { Name: strptr("container1"), }, { Name: strptr("container2"), }, }, } seqNum := int64(42) task, err := TaskFromACS(&testTaskFromACS, &ecsacs.PayloadMessage{SeqNum: &seqNum}) assert.Nil(t, err, "Should be able to handle acs task") assert.Equal(t, aTest.PIDMode, task.getPIDMode()) assert.Equal(t, aTest.IPCMode, task.getIPCMode()) assert.Equal(t, 2, len(task.Containers)) // before PostUnmarshalTask cfg := config.Config{} task.PostUnmarshalTask(&cfg, nil, nil, nil, nil) if aTest.ShouldProvision { assert.Equal(t, 3, len(task.Containers), "Namespace Pause Container should be created.") } else { assert.Equal(t, 2, len(task.Containers), "Namespace Pause Container should NOT be created.") } } }
explode_data.jsonl/37205
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 510 }
[ 2830, 3393, 4133, 1806, 27121, 6262, 2354, 33751, 83756, 1155, 353, 8840, 836, 8, 341, 2023, 8358, 264, 2271, 1669, 2088, 4473, 18200, 341, 197, 18185, 6262, 3830, 62687, 1669, 78422, 19252, 28258, 515, 298, 197, 58331, 25, 1843, 607, 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 TestSample(t *testing.T) { n := 5 l, r := int64(1), int64(4) nums := []int64{1, 2, 3, 4, 5} res := solve(n, l, r, nums) if res != 3 { t.Errorf("the sample should give anser 3, but got %d", res) } }
explode_data.jsonl/64117
{ "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, 17571, 1155, 353, 8840, 836, 8, 341, 9038, 1669, 220, 20, 198, 8810, 11, 435, 1669, 526, 21, 19, 7, 16, 701, 526, 21, 19, 7, 19, 340, 22431, 82, 1669, 3056, 396, 21, 19, 90, 16, 11, 220, 17, 11, 220, 18, 11, 220,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestUdpSetNoFragment_negative(t *testing.T) { assert.Equal(t, syscall.EINVAL, UDPSetNoFragment(&net.UDPConn{})) conn, err := net.Dial("udp", "127.0.0.1:1") udpConn := conn.(*net.UDPConn) assert.NoError(t, err) fd := (**struct{ a [65536]byte })((unsafe.Pointer)(reflect.ValueOf(unsafetools.FieldByName(udpConn, `fd`)).Elem().UnsafeAddr())) *fd = &struct{ a [65536]byte }{} assert.Equal(t, syscall.ENOTSOCK, UDPSetNoFragment(udpConn)) }
explode_data.jsonl/9576
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 201 }
[ 2830, 3393, 52, 9796, 1649, 2753, 9488, 53865, 1155, 353, 8840, 836, 8, 341, 6948, 12808, 1155, 11, 49345, 5142, 27842, 11, 42394, 1649, 2753, 9488, 2099, 4711, 13, 41648, 9701, 6257, 1171, 32917, 11, 1848, 1669, 4179, 98462, 445, 31101...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestTrimPrefix(t *testing.T) { e := Engine{prefix: []byte("e-prefix")} for _, d := range []struct { n string k string }{ {"empty key", ""}, {"no engine prefix", "no-e-prefix)"}, {"no mapping prefix", "e-prefix-no-mapping-prefix"}, {"short mapping prefix", "e-prefix-mapping"}, } { t.Run(d.n, func(t *testing.T) { prefix, err := e.trimPrefix([]byte(d.k), []byte("-mapping-prefix")) require.Nil(t, prefix) require.ErrorIs(t, err, ErrIllegalMappedKey) }) } for _, d := range []struct { n string k string p string }{ {"correct prefix", "e-prefix-mapping-prefix-key", "-key"}, {"exact prefix", "e-prefix-mapping-prefix", ""}, } { t.Run(d.n, func(t *testing.T) { prefix, err := e.trimPrefix([]byte(d.k), []byte("-mapping-prefix")) require.NoError(t, err) require.NotNil(t, prefix) require.EqualValues(t, []byte(d.p), prefix) }) } }
explode_data.jsonl/64091
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 393 }
[ 2830, 3393, 25656, 14335, 1155, 353, 8840, 836, 8, 341, 7727, 1669, 8200, 90, 11849, 25, 3056, 3782, 445, 68, 67181, 899, 630, 2023, 8358, 294, 1669, 2088, 3056, 1235, 341, 197, 9038, 914, 198, 197, 16463, 914, 198, 197, 59403, 197, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestHashNotIgnoredForNonExistingSecret(t *testing.T) { t.Parallel() deploymentSpec := apps_v1.Deployment{ TypeMeta: meta_v1.TypeMeta{ Kind: "Deployment", APIVersion: apps_v1.SchemeGroupVersion.String(), }, ObjectMeta: meta_v1.ObjectMeta{ Namespace: testNs, }, Spec: apps_v1.DeploymentSpec{ Template: core_v1.PodTemplateSpec{ Spec: core_v1.PodSpec{ Containers: []core_v1.Container{ core_v1.Container{}, // empty EnvFrom core_v1.Container{ Env: []core_v1.EnvVar{ core_v1.EnvVar{ Name: "blah2", ValueFrom: &core_v1.EnvVarSource{ SecretKeyRef: &core_v1.SecretKeySelector{ Key: "parameters", LocalObjectReference: core_v1.LocalObjectReference{ Name: "secret1", }, }, }, }, }, }, }, }, }, }, } spec := runtimeToUnstructured(t, &deploymentSpec) store := speccheckertesting.FakeStore{Namespace: testNs} logger := zaptest.NewLogger(t) defer logger.Sync() // nolint: errcheck _, err := deployment{}.BeforeCreate(&specchecker.Context{Logger: logger, Store: store}, spec) require.Error(t, err) }
explode_data.jsonl/78683
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 584 }
[ 2830, 3393, 6370, 2623, 43337, 3018, 2461, 8121, 53067, 19773, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 2822, 197, 82213, 8327, 1669, 10500, 2273, 16, 34848, 39130, 515, 197, 27725, 12175, 25, 8823, 2273, 16, 10184, 12175, 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 TestInit(t *testing.T) { gaia.Cfg = &gaia.Config{} tmp, _ := ioutil.TempDir("", "TestInit") gaia.Cfg.Logger = hclog.New(&hclog.LoggerOptions{ Level: hclog.Trace, Output: hclog.DefaultOutput, Name: "Gaia", }) emptyPlugin := &Plugin{} p := emptyPlugin.NewPlugin(new(fakeCAAPI)) logpath := filepath.Join(tmp, "test") err := p.Init(exec.Command("echo", "world"), &logpath) if !strings.Contains(err.Error(), "Unrecognized remote plugin message") { // Sometimes go-plugin throws this error instead... if !strings.Contains(err.Error(), "plugin exited before we could connect") { t.Fatalf("Error should contain 'Unrecognized remote plugin message' but was '%s'", err.Error()) } } }
explode_data.jsonl/25825
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 267 }
[ 2830, 3393, 3803, 1155, 353, 8840, 836, 8, 341, 3174, 64, 685, 727, 4817, 284, 609, 6743, 685, 10753, 16094, 20082, 11, 716, 1669, 43144, 65009, 6184, 19814, 330, 2271, 3803, 1138, 3174, 64, 685, 727, 4817, 12750, 284, 50394, 839, 712...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestGetVersion(t *testing.T) { t.Parallel() rawTx := "01000000014c6ec863cf3e0284b407a1a1b8138c76f98280812cb9653231f385a0305fc76f010000006b483045022100f01c1a1679c9437398d691c8497f278fa2d615efc05115688bf2c3335b45c88602201b54437e54fb53bc50545de44ea8c64e9e583952771fcc663c8687dc2638f7854121037e87bbd3b680748a74372640628a8f32d3a841ceeef6f75626ab030c1a04824fffffffff021d784500000000001976a914e9b62e25d4c6f97287dfe62f8063b79a9638c84688ac60d64f00000000001976a914bb4bca2306df66d72c6e44a470873484d8808b8888ac00000000" tx, err := bt.NewTxFromString(rawTx) assert.NoError(t, err) assert.NotNil(t, tx) assert.Equal(t, uint32(1), tx.Version) }
explode_data.jsonl/28739
{ "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, 1949, 5637, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 2822, 76559, 31584, 1669, 330, 15, 16, 15, 15, 15, 15, 15, 15, 15, 16, 19, 66, 21, 757, 23, 21, 18, 9792, 18, 68, 15, 17, 23, 19, 65, 19, 15, 22, 64, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestReviewHandler_GetReviewStatistics(t *testing.T) { productId := uint64(4) statistics := models.ReviewStatistics{} t.Run("GetReviewStatistics_success", func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() reviewUCase := mock.NewMockUseCase(ctrl) reviewUCase. EXPECT(). GetStatisticsByProductId(productId). Return(&statistics, nil) reviewHandler := NewHandler(reviewUCase) ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New()) req, _ := http.NewRequestWithContext(ctx, "GET", "/api/v1/review/product/{id:[0-9]+}", bytes.NewBuffer(nil)) vars := map[string]string{ "id": fmt.Sprintf("%d", productId), } req = mux.SetURLVars(req, vars) rr := httptest.NewRecorder() handler := http.HandlerFunc(reviewHandler.GetReviewStatistics) handler.ServeHTTP(rr, req) assert.Equal(t, rr.Code, http.StatusOK, "incorrect http code") }) t.Run("GetReviewStatistics_incorrect_id", func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() reviewUCase := mock.NewMockUseCase(ctrl) reviewHandler := NewHandler(reviewUCase) ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New()) req, _ := http.NewRequestWithContext(ctx, "GET", "/api/v1/review/product/{id:[0-9]+}", bytes.NewBuffer(nil)) vars := map[string]string{ "id": "-10", } req = mux.SetURLVars(req, vars) rr := httptest.NewRecorder() handler := http.HandlerFunc(reviewHandler.GetReviewStatistics) handler.ServeHTTP(rr, req) assert.Equal(t, rr.Code, http.StatusBadRequest, "incorrect http code") }) t.Run("GetReviewStatistics_not_found_statistics", func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() reviewUCase := mock.NewMockUseCase(ctrl) reviewUCase. EXPECT(). GetStatisticsByProductId(productId). Return(&statistics, errors.ErrInternalError) reviewHandler := NewHandler(reviewUCase) ctx := context.WithValue(context.Background(), models.RequireIdKey, shortuuid.New()) req, _ := http.NewRequestWithContext(ctx, "GET", "/api/v1/review/product/{id:[0-9]+}", bytes.NewBuffer(nil)) vars := map[string]string{ "id": fmt.Sprintf("%d", productId), } req = mux.SetURLVars(req, vars) rr := httptest.NewRecorder() handler := http.HandlerFunc(reviewHandler.GetReviewStatistics) handler.ServeHTTP(rr, req) assert.Equal(t, rr.Code, http.StatusInternalServerError, "incorrect http code") }) }
explode_data.jsonl/71560
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 951 }
[ 2830, 3393, 19432, 3050, 13614, 19432, 38599, 1155, 353, 8840, 836, 8, 341, 197, 46166, 1669, 2622, 21, 19, 7, 19, 340, 197, 54120, 1669, 4119, 2817, 1050, 38599, 31483, 3244, 16708, 445, 1949, 19432, 38599, 18632, 497, 2915, 1155, 353,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestEvalStructFieldPointerExpressions(t *testing.T) { var data = make(VarMap) type structWithPointers struct { StringField *string IntField *int StructField *structWithPointers } stringVal := "test" intVal := 10 nestedStringVal := "nested" s := structWithPointers{ StringField: &stringVal, IntField: &intVal, StructField: &structWithPointers{ StringField: &nestedStringVal, }, } data.Set("structWithPointerFields", s) RunJetTest(t, data, nil, "PointerFields_1", `{{ structWithPointerFields.IntField }}`, "10") RunJetTest(t, data, nil, "PointerFields_2", `{{ structWithPointerFields.StructField.IntField }}`, "") RunJetTest(t, data, nil, "PointerFields_3", `{{ structWithPointerFields.StringField }}`, "test") RunJetTest(t, data, nil, "PointerFields_4", `{{ structWithPointerFields.StructField.StringField }}`, "nested") s2 := structWithPointers{ StringField: &stringVal, IntField: &intVal, } data.Set("structWithPointerFields2", s2) RunJetTest(t, data, nil, "PointerFields_5", `{{ structWithPointerFields2.IntField }}`, "10") RunJetTest(t, data, nil, "PointerFields_6", `{{ structWithPointerFields2.StringField }}`, "test") RunJetTest(t, data, nil, "PointerFields_7", `{{ structWithPointerFields2.StructField }}`, "") var set = NewSet(nil, "./testData") tt, err := set.parse("PointerFields_8", `{{ structWithPointerFields2.StructField.StringField }}`) if err != nil { t.Error(err) } buff := bytes.NewBuffer(nil) err = tt.Execute(buff, data, nil) if err == nil { t.Error("expected evaluating field of nil structto fail with a runtime error but got nil") } }
explode_data.jsonl/22903
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 615 }
[ 2830, 3393, 54469, 9422, 1877, 9084, 40315, 1155, 353, 8840, 836, 8, 341, 2405, 821, 284, 1281, 7, 3962, 2227, 692, 13158, 2036, 2354, 2609, 388, 2036, 341, 197, 4980, 1877, 353, 917, 198, 197, 57152, 1877, 262, 353, 396, 198, 197, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
3
func TestRSAMissingNULLParameters(t *testing.T) { block, _ := pem.Decode([]byte(certMissingRSANULL)) if _, err := ParseCertificate(block.Bytes); err == nil { t.Error("unexpected success when parsing certificate with missing RSA NULL parameter") } else if !strings.Contains(err.Error(), "missing NULL") { t.Errorf("unrecognised error when parsing certificate with missing RSA NULL parameter: %s", err) } }
explode_data.jsonl/68011
{ "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, 11451, 1402, 13577, 4576, 9706, 1155, 353, 8840, 836, 8, 341, 47996, 11, 716, 1669, 54184, 56372, 10556, 3782, 87793, 25080, 11451, 1093, 1426, 1171, 743, 8358, 1848, 1669, 14775, 33202, 18682, 36868, 1215, 1848, 621, 2092, 34...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
3
func TestContentTypeFieldArray(t *testing.T) { var err error assert := assert.New(t) handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(r.Method, "POST") assert.Equal(r.RequestURI, "/spaces/"+spaceID+"/content_types") checkHeaders(r, assert) var payload map[string]interface{} err := json.NewDecoder(r.Body).Decode(&payload) assert.Nil(err) fields := payload["fields"].([]interface{}) assert.Equal(1, len(fields)) field1 := fields[0].(map[string]interface{}) assert.Equal("Array", field1["type"].(string)) arrayItemSchema := field1["items"].(map[string]interface{}) assert.Equal("Text", arrayItemSchema["type"].(string)) arrayItemSchemaValidations := arrayItemSchema["validations"].([]interface{}) validation1 := arrayItemSchemaValidations[0].(map[string]interface{}) assert.Equal(true, validation1["unique"].(bool)) w.WriteHeader(201) fmt.Fprintln(w, string(readTestData("content_type.json"))) }) // test server server := httptest.NewServer(handler) defer server.Close() // cma client cma = NewCMA(CMAToken) cma.BaseURL = server.URL field1 := &Field{ ID: "field1", Name: "field1-name", Type: FieldTypeArray, Items: &FieldTypeArrayItem{ Type: FieldTypeText, Validations: []FieldValidation{ &FieldValidationUnique{ Unique: true, }, }, }, } ct := &ContentType{ Name: "ct-name", Description: "ct-description", Fields: []*Field{field1}, DisplayField: field1.ID, } err = cma.ContentTypes.Upsert("id1", ct) assert.Nil(err) }
explode_data.jsonl/66085
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 631 }
[ 2830, 3393, 29504, 1877, 1857, 1155, 353, 8840, 836, 8, 341, 2405, 1848, 1465, 198, 6948, 1669, 2060, 7121, 1155, 692, 53326, 1669, 1758, 89164, 18552, 3622, 1758, 37508, 11, 435, 353, 1254, 9659, 8, 341, 197, 6948, 12808, 2601, 20798, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestInMemoryIndexCache_AvoidsDeadlock(t *testing.T) { defer leaktest.CheckTimeout(t, 10*time.Second)() metrics := prometheus.NewRegistry() cache, err := NewInMemoryIndexCache(log.NewNopLogger(), metrics, Opts{ MaxItemSizeBytes: sliceHeaderSize + 5, MaxSizeBytes: sliceHeaderSize + 5, }) testutil.Ok(t, err) l, err := simplelru.NewLRU(math.MaxInt64, func(key, val interface{}) { // Hack LRU to simulate broken accounting: evictions do not reduce current size. size := cache.curSize cache.onEvict(key, val) cache.curSize = size }) testutil.Ok(t, err) cache.lru = l cache.StorePostings(ulid.MustNew(0, nil), labels.Label{Name: "test2", Value: "1"}, []byte{42, 33, 14, 67, 11}) testutil.Equals(t, uint64(sliceHeaderSize+5), cache.curSize) testutil.Equals(t, float64(cache.curSize), promtest.ToFloat64(cache.currentSize.WithLabelValues(cacheTypePostings))) testutil.Equals(t, float64(1), promtest.ToFloat64(cache.current.WithLabelValues(cacheTypePostings))) // This triggers deadlock logic. cache.StorePostings(ulid.MustNew(0, nil), labels.Label{Name: "test1", Value: "1"}, []byte{42}) testutil.Equals(t, uint64(sliceHeaderSize+1), cache.curSize) testutil.Equals(t, float64(cache.curSize), promtest.ToFloat64(cache.currentSize.WithLabelValues(cacheTypePostings))) testutil.Equals(t, float64(1), promtest.ToFloat64(cache.current.WithLabelValues(cacheTypePostings))) }
explode_data.jsonl/1715
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 513 }
[ 2830, 3393, 641, 10642, 1552, 8233, 1566, 1004, 82, 28320, 1023, 1155, 353, 8840, 836, 8, 341, 16867, 23352, 1944, 10600, 7636, 1155, 11, 220, 16, 15, 77053, 32435, 8, 2822, 2109, 13468, 1669, 2706, 39705, 7121, 15603, 741, 52680, 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 TestStatus(t *testing.T) { t.Parallel() type tcase struct { code int allow bool } cases := []tcase{ {200, true}, {400, true}, {401, true}, {403, true}, {404, true}, {500, false}, {502, false}, {503, false}, {504, false}, } for _, c := range cases { t.Run(strconv.Itoa(c.code), func(t *testing.T) { r, err := FromResponse(newHttpResponse(c.code, "")) require.NoError(t, err) expectAll(t, r, c.allow) r, err = FromStatusAndString(c.code, "") require.NoError(t, err) expectAll(t, r, c.allow) }) } }
explode_data.jsonl/51672
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 265 }
[ 2830, 3393, 2522, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 741, 13158, 259, 5638, 2036, 341, 197, 43343, 220, 526, 198, 197, 197, 7183, 1807, 198, 197, 532, 1444, 2264, 1669, 3056, 83, 5638, 515, 197, 197, 90, 17, 15, 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...
1
func TestOwnerRepoFromRepoURL(t *testing.T) { for _, url := range []string{ "https://github.com/org/repo.git", "https://USER:PASS@github.com/org/repo.git", "https://PASS:@github.com/org/repo.git", "https://:PASS@gitlab.com/org/repo", "http://USER:PASS@github.com/org/repo.git", "ssh://USER:PASS@github.com/org/repo.git", "git@github.com:org/repo.git", "github.com/org/repo.git", "bitbucket.org/org/repo", "gitlab.com/org/repo", } { ownerRepo, err := gitutil.OwnerRepoFromRepoURL(url) assert.NoError(t, err) assert.Equal(t, "org/repo", ownerRepo) } }
explode_data.jsonl/67879
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 271 }
[ 2830, 3393, 13801, 25243, 3830, 25243, 3144, 1155, 353, 8840, 836, 8, 341, 2023, 8358, 2515, 1669, 2088, 3056, 917, 515, 197, 197, 57557, 1110, 5204, 905, 41361, 10758, 5368, 32799, 756, 197, 197, 57557, 1110, 6448, 25, 49792, 31, 5204,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestPushLayerNoRetry(t *testing.T) { require := require.New(t) ctx, cleanup := context.BuildContextFixtureWithSampleImage() defer cleanup() p, err := PushClientFixture(ctx) require.NoError(err) p.config.Retries = 1 require.EqualError(p.PushLayer(image.NewEmptyDigest()), "push layer content : get layer file stat: file does not exist") }
explode_data.jsonl/63643
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 117 }
[ 2830, 3393, 16644, 9188, 2753, 51560, 1155, 353, 8840, 836, 8, 341, 17957, 1669, 1373, 7121, 1155, 340, 20985, 11, 21290, 1669, 2266, 25212, 1972, 18930, 2354, 17571, 1906, 741, 16867, 21290, 2822, 3223, 11, 1848, 1669, 22950, 2959, 18930...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestNamespacedCommands(t *testing.T) { const contextNS = "from-context" const flagNS = "from-flag" const allNS = "" testcases := []struct { name string cmd string wantNS string }{ {name: "get instances with flag namespace", cmd: "get instances --namespace " + flagNS, wantNS: flagNS}, {name: "get instances with context namespace", cmd: "get instances", wantNS: contextNS}, {name: "get all instances", cmd: "get instances --all-namespaces", wantNS: allNS}, {name: "describe instance with flag namespace", cmd: "describe instance NAME --namespace " + flagNS, wantNS: flagNS}, {name: "describe instance with context namespace", cmd: "describe instances NAME", wantNS: contextNS}, {name: "deprovision with flag namespace", cmd: "deprovision NAME --namespace " + flagNS, wantNS: flagNS}, {name: "deprovision with context namespace", cmd: "deprovision NAME", wantNS: contextNS}, {name: "bind with flag namespace", cmd: "bind NAME --namespace " + flagNS, wantNS: flagNS}, {name: "bind with context namespace", cmd: "bind NAME", wantNS: contextNS}, {name: "unbind with flag namespace", cmd: "unbind NAME --namespace " + flagNS, wantNS: flagNS}, {name: "unbind with context namespace", cmd: "unbind NAME", wantNS: contextNS}, {name: "get bindings with flag namespace", cmd: "get bindings --namespace " + flagNS, wantNS: flagNS}, {name: "get bindings with context namespace", cmd: "get bindings", wantNS: contextNS}, {name: "get all bindings", cmd: "get bindings --all-namespaces", wantNS: allNS}, {name: "describe binding with flag namespace", cmd: "describe binding NAME --namespace " + flagNS, wantNS: flagNS}, {name: "describe binding with context namespace", cmd: "describe binding NAME", wantNS: contextNS}, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { fakeClient := fake.NewSimpleClientset() cxt := newContext() cxt.App = &svcat.App{ CurrentNamespace: contextNS, SvcatClient: &servicecatalog.SDK{ServiceCatalogClient: fakeClient}, } cxt.Output = ioutil.Discard executeFakeCommand(t, tc.cmd, cxt, true) gotNamespace := fakeClient.Actions()[0].GetNamespace() if tc.wantNS != gotNamespace { t.Fatalf("the wrong namespace was used. WANT: %q, GOT: %q", tc.wantNS, gotNamespace) } }) } }
explode_data.jsonl/71177
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 787 }
[ 2830, 3393, 7980, 68552, 30479, 1155, 353, 8840, 836, 8, 341, 4777, 2266, 2448, 284, 330, 1499, 63633, 698, 4777, 5181, 2448, 284, 330, 1499, 77950, 698, 4777, 678, 2448, 284, 35829, 18185, 23910, 1669, 3056, 1235, 341, 197, 11609, 256,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestTimeType(t *testing.T) { var tt time.Time set := New() set.Register("default", func(ctx context.Context, t *Transformer, value reflect.Value, param string) error { value.Set(reflect.ValueOf(time.Now())) return nil }) err := set.Field(context.Background(), &tt, "default") Equal(t, err, nil) err = set.Field(context.Background(), &tt, "default,dive") NotEqual(t, err, nil) Equal(t, err.Error(), "Invalid dive tag configuration") }
explode_data.jsonl/43621
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 162 }
[ 2830, 3393, 1462, 929, 1155, 353, 8840, 836, 8, 1476, 2405, 17853, 882, 16299, 271, 8196, 1669, 1532, 741, 8196, 19983, 445, 2258, 497, 2915, 7502, 2266, 9328, 11, 259, 353, 46358, 11, 897, 8708, 6167, 11, 1685, 914, 8, 1465, 341, 1...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestString(t *testing.T) { { m, _ := ParseLoadMap("") s := m.String() test.S(t).ExpectEquals(s, "") } { loadList := "threads_running=20,threads_connected=10" m, _ := ParseLoadMap(loadList) s := m.String() test.S(t).ExpectEquals(s, "threads_connected=10,threads_running=20") } }
explode_data.jsonl/1134
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 141 }
[ 2830, 3393, 703, 1155, 353, 8840, 836, 8, 341, 197, 515, 197, 2109, 11, 716, 1669, 14775, 5879, 2227, 31764, 197, 1903, 1669, 296, 6431, 741, 197, 18185, 808, 1155, 568, 17536, 4315, 1141, 11, 14676, 197, 532, 197, 515, 197, 49386, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestGrpc(t *testing.T) { log.SetOutput(ioutil.Discard) corefile := `grpc://.:0 { whoami } ` g, err := CoreDNSServer(corefile) if err != nil { t.Fatalf("Could not get CoreDNS serving instance: %s", err) } _, tcp := CoreDNSServerPorts(g, 0) defer g.Stop() conn, err := grpc.Dial(tcp, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(5*time.Second)) if err != nil { t.Fatalf("Expected no error but got: %s", err) } defer conn.Close() client := pb.NewDnsServiceClient(conn) m := new(dns.Msg) m.SetQuestion("whoami.example.org.", dns.TypeA) msg, _ := m.Pack() reply, err := client.Query(context.TODO(), &pb.DnsPacket{Msg: msg}) if err != nil { t.Errorf("Expected no error but got: %s", err) } d := new(dns.Msg) err = d.Unpack(reply.Msg) if err != nil { t.Errorf("Expected no error but got: %s", err) } if d.Rcode != dns.RcodeSuccess { t.Errorf("Expected success but got %s", d.Rcode) } if len(d.Extra) != 2 { t.Errorf("Expected 2 RRs in additional section, but got %s", len(d.Extra)) } t.Logf("Message %v\n", d) }
explode_data.jsonl/28132
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 462 }
[ 2830, 3393, 6464, 3992, 1155, 353, 8840, 836, 8, 341, 6725, 4202, 5097, 1956, 30158, 909, 47560, 692, 71882, 1192, 1669, 1565, 56585, 1110, 18469, 15, 341, 197, 197, 14623, 10606, 198, 532, 3989, 3174, 11, 1848, 1669, 9518, 31264, 1220,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
7
func TestBadgerStorage(t *testing.T) { config := configuration.Config{ DeploymentMetadataStorage: t.TempDir(), Debug: true, } ctx, cancel := context.WithCancel(context.Background()) defer cancel() storage, err := NewStorage(ctx, config) if err != nil { t.Error(err) return } t.Run("test", MetadataTest(storage)) }
explode_data.jsonl/19088
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 139 }
[ 2830, 3393, 17082, 1389, 5793, 1155, 353, 8840, 836, 8, 341, 25873, 1669, 6546, 10753, 515, 197, 197, 75286, 14610, 5793, 25, 259, 65009, 6184, 3148, 197, 34424, 25, 3824, 830, 345, 197, 630, 20985, 11, 9121, 1669, 2266, 26124, 9269, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestQueue(t *testing.T) { pq := MakeQueue() assert.Equal(t, pq.Len(), 0) heap.Push(&pq, &Item{Value: "2", Priority: 2}) heap.Push(&pq, &Item{Value: "1", Priority: 1}) heap.Push(&pq, &Item{Value: "3", Priority: 3}) assert.Equal(t, pq.Len(), 3) item := heap.Pop(&pq).(*Item) assert.Equal(t, item.Value, "1") item = heap.Pop(&pq).(*Item) assert.Equal(t, item.Value, "2") item = heap.Pop(&pq).(*Item) assert.Equal(t, item.Value, "3") assert.Equal(t, pq.Len(), 0) }
explode_data.jsonl/49540
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 225 }
[ 2830, 3393, 7554, 1155, 353, 8840, 836, 8, 341, 3223, 80, 1669, 7405, 7554, 741, 6948, 12808, 1155, 11, 39639, 65819, 1507, 220, 15, 340, 197, 15961, 34981, 2099, 64016, 11, 609, 1234, 90, 1130, 25, 330, 17, 497, 31920, 25, 220, 17,...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestFixDeprecatedTaintKey(t *testing.T) { fakeNow := metav1.Date(2017, 1, 1, 12, 0, 0, 0, time.UTC) evictionTimeout := 10 * time.Minute fakeNodeHandler := &testutil.FakeNodeHandler{ Existing: []*v1.Node{ { ObjectMeta: metav1.ObjectMeta{ Name: "node0", CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), Labels: map[string]string{ kubeletapis.LabelZoneRegion: "region1", kubeletapis.LabelZoneFailureDomain: "zone1", }, }, }, }, Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0")}}), } nodeController, _ := newNodeLifecycleControllerFromClient( nil, fakeNodeHandler, evictionTimeout, testRateLimiterQPS, testRateLimiterQPS, testLargeClusterThreshold, testUnhealthyThreshold, testNodeMonitorGracePeriod, testNodeStartupGracePeriod, testNodeMonitorPeriod, true) nodeController.now = func() metav1.Time { return fakeNow } nodeController.recorder = testutil.NewFakeRecorder() deprecatedNotReadyTaint := &v1.Taint{ Key: algorithm.DeprecatedTaintNodeNotReady, Effect: v1.TaintEffectNoExecute, } nodeNotReadyTaint := &v1.Taint{ Key: algorithm.TaintNodeNotReady, Effect: v1.TaintEffectNoExecute, } deprecatedUnreachableTaint := &v1.Taint{ Key: algorithm.DeprecatedTaintNodeUnreachable, Effect: v1.TaintEffectNoExecute, } nodeUnreachableTaint := &v1.Taint{ Key: algorithm.TaintNodeUnreachable, Effect: v1.TaintEffectNoExecute, } tests := []struct { Name string Node *v1.Node ExpectedTaints []*v1.Taint }{ { Name: "Node with deprecated not-ready taint key", Node: &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "node0", CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), Labels: map[string]string{ kubeletapis.LabelZoneRegion: "region1", kubeletapis.LabelZoneFailureDomain: "zone1", }, }, Spec: v1.NodeSpec{ Taints: []v1.Taint{ *deprecatedNotReadyTaint, }, }, }, ExpectedTaints: []*v1.Taint{nodeNotReadyTaint}, }, { Name: "Node with deprecated unreachable taint key", Node: &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "node0", CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), Labels: map[string]string{ kubeletapis.LabelZoneRegion: "region1", kubeletapis.LabelZoneFailureDomain: "zone1", }, }, Spec: v1.NodeSpec{ Taints: []v1.Taint{ *deprecatedUnreachableTaint, }, }, }, ExpectedTaints: []*v1.Taint{nodeUnreachableTaint}, }, { Name: "Node with not-ready taint key", Node: &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "node0", CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), Labels: map[string]string{ kubeletapis.LabelZoneRegion: "region1", kubeletapis.LabelZoneFailureDomain: "zone1", }, }, Spec: v1.NodeSpec{ Taints: []v1.Taint{ *nodeNotReadyTaint, }, }, }, ExpectedTaints: []*v1.Taint{nodeNotReadyTaint}, }, { Name: "Node with unreachable taint key", Node: &v1.Node{ ObjectMeta: metav1.ObjectMeta{ Name: "node0", CreationTimestamp: metav1.Date(2012, 1, 1, 0, 0, 0, 0, time.UTC), Labels: map[string]string{ kubeletapis.LabelZoneRegion: "region1", kubeletapis.LabelZoneFailureDomain: "zone1", }, }, Spec: v1.NodeSpec{ Taints: []v1.Taint{ *nodeUnreachableTaint, }, }, }, ExpectedTaints: []*v1.Taint{nodeUnreachableTaint}, }, } for _, test := range tests { fakeNodeHandler.Update(test.Node) if err := nodeController.syncNodeStore(fakeNodeHandler); err != nil { t.Errorf("unexpected error: %v", err) } nodeController.doFixDeprecatedTaintKeyPass(test.Node) if err := nodeController.syncNodeStore(fakeNodeHandler); err != nil { t.Errorf("unexpected error: %v", err) } node, err := nodeController.nodeLister.Get(test.Node.GetName()) if err != nil { t.Errorf("Can't get current node...") return } if len(node.Spec.Taints) != len(test.ExpectedTaints) { t.Errorf("%s: Unexpected number of taints: expected %d, got %d", test.Name, len(test.ExpectedTaints), len(node.Spec.Taints)) } for _, taint := range test.ExpectedTaints { if !taintutils.TaintExists(node.Spec.Taints, taint) { t.Errorf("%s: Can't find taint %v in %v", test.Name, taint, node.Spec.Taints) } } } }
explode_data.jsonl/9619
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2171 }
[ 2830, 3393, 25958, 51344, 51, 1641, 1592, 1155, 353, 8840, 836, 8, 341, 1166, 726, 7039, 1669, 77520, 16, 8518, 7, 17, 15, 16, 22, 11, 220, 16, 11, 220, 16, 11, 220, 16, 17, 11, 220, 15, 11, 220, 15, 11, 220, 15, 11, 882, 87...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestSensorTotalIntegration(t *testing.T) { handleErr := func(err error) { if err != nil { t.Fatalf("Failed to setup test: %v", err) } } removeFileIfExists := func(filename string) { if _, err := os.Stat(filename); err == nil { os.Remove(filename) } } processResults := func(resultfile string, expected []string) bool { if _, err := os.Stat(resultfile); err == nil { file, err := os.Open(resultfile) if err != nil { return false } scanner := bufio.NewScanner(file) i := 0 for scanner.Scan() { if scanner.Text() != expected[i] { return false } i++ } if i != len(expected) { return false } if err := scanner.Err(); err != nil { return false } } else { return false } return true } // Remove previous results files if they exist // Defer to remove current test results files removeFileIfExists("/tmp/int-test-1-1-results.txt") defer removeFileIfExists("/tmp/int-test-1-1-results.txt") // Create executor script at /tmp/script-cm-rule-1.sh err := ioutil.WriteFile("/tmp/script-cm-rule-1.sh", []byte(executorScript), 0755) handleErr(err) defer os.Remove("/tmp/script-cm-rule-1.sh") // Setting up kubernetes namespace and required configmaps kubeConfig := utils.GetKubeAPIConfigOrDie("") ns := &v1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "eventsrunner", }, } // Setup test namespace and remove once test is done _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) handleErr(err) defer kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().Namespaces().Delete(context.Background(), ns.Name, metav1.DeleteOptions{}) // Setup test configmap, will be removed automatically when namespace is removed cm := &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "sensor-rules-1", Namespace: "eventsrunner", Labels: map[string]string{ "er-k8s-sensor-rules": "true", }, }, Data: map[string]string{ "rules": rulesConfigMap, }, } _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("eventsrunner").Create(context.Background(), cm, metav1.CreateOptions{}) handleErr(err) configObj, err := config.ParseConfigFromViper("", 1) handleErr(err) configObj.ExecutorType = "script" configObj.ScriptDir = "/tmp" configObj.ScriptPrefix = "script" // Setup Sensor sensorRuntime, err := SetupNewSensorRuntime(configObj) handleErr(err) go func() { err := sensorRuntime.StartSensorRuntime() if err != nil { panic(err) } }() go sensorRuntime.StopOnSignal() defer func() { syscall.Kill(syscall.Getpid(), syscall.SIGINT) }() // Make sure sensor is running before continuing // Try 2 seconds to check if the sensor is running if !retryFunc(func() bool { return sensorRuntime.sensor.GetSensorState() == RUNNING }, 2) { t.Fatal("Sensor is not running") } // Rudimentary test to check if the rule was added if _, ok := sensorRuntime.sensor.ruleInformers["cm-rule-1"]; !ok { t.Fatal("Sensor is not watching cm-rule-1") } // Making sure the sensor dint execute any executor scripts without // events or due to past or zombie events if retryFunc(func() bool { if _, err := os.Stat("/tmp/int-test-1-1-results.txt"); err == nil { return true } return false }, 2) { t.Fatal("Sensor executed for past or zombie events") } // Test event trigger when actual object is added // START testCm := &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "test-cm1", Namespace: "default", }, Data: map[string]string{ "test-key": "test-value", }, } _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("default").Create(context.Background(), testCm, metav1.CreateOptions{}) handleErr(err) defer kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("default").Delete(context.Background(), testCm.Name, metav1.DeleteOptions{}) if !retryFunc(func() bool { return processResults("/tmp/int-test-1-1-results.txt", []string{"added"}) }, 5) { t.Fatal("Sensor dint execute for added event") } // END // Test sensor rule update and check again if the sensor triggered the executor // again due to rule update // START cm.Data = map[string]string{ "rules": rulesUpdatedConfigMap, } _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("eventsrunner").Update(context.Background(), cm, metav1.UpdateOptions{}) handleErr(err) if !retryFunc(func() bool { return len(sensorRuntime.sensor.ruleInformers["cm-rule-1"].Rule.UpdatesOn) == 1 }, 5) { t.Fatal("Sensor should have updated rule") } if !retryFunc(func() bool { return processResults("/tmp/int-test-1-1-results.txt", []string{"added"}) }, 5) { t.Fatal("Sensor executed again on rule update") } // END // Test to make sure sensor dint execute for updates on part of the object // not mentioned in the updatedOn rule config field. // START testCm.ObjectMeta.Labels = map[string]string{ "test-label": "test-value", } _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("default").Update(context.Background(), testCm, metav1.UpdateOptions{}) handleErr(err) if retryFunc(func() bool { return processResults("/tmp/int-test-1-1-results.txt", []string{"added", "modified"}) }, 3) { t.Fatal("Sensor executed for updates on metadata") } // END // Test if sensor executed for correct update on data field of the object // START testCm.Data = map[string]string{ "test-key": "test-value-updated", } _, err = kubernetes.NewForConfigOrDie(kubeConfig).CoreV1().ConfigMaps("default").Update(context.Background(), testCm, metav1.UpdateOptions{}) handleErr(err) if !retryFunc(func() bool { return processResults("/tmp/int-test-1-1-results.txt", []string{"added", "modified"}) }, 5) { t.Fatal("/tmp/int-test-1-1-results.txt should added, modified event in order") } // END }
explode_data.jsonl/66715
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2206 }
[ 2830, 3393, 30752, 7595, 52464, 1155, 353, 8840, 836, 8, 341, 53822, 7747, 1669, 2915, 3964, 1465, 8, 341, 197, 743, 1848, 961, 2092, 341, 298, 3244, 30762, 445, 9408, 311, 6505, 1273, 25, 1018, 85, 497, 1848, 340, 197, 197, 532, 19...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestTPDUUDHI(t *testing.T) { // also tests tpdu.TPDU.SetUDH b := tpdu.TPDU{} udhi := b.UDHI() if udhi { t.Errorf("initial udhi should be false") } for _, p := range []tpdu.UserDataHeader{ nil, {tpdu.InformationElement{ID: 1, Data: []byte{5, 6, 7}}}, {tpdu.InformationElement{ID: 1, Data: []byte{1, 2, 3}}, tpdu.InformationElement{ID: 1, Data: []byte{5, 6, 7}}, }, nil, } { b.SetUDH(p) udhi = b.UDHI() if udhi != (len(p) != 0) { t.Errorf("for udh %v expected udhi %v, got %v", p, (len(p) != 0), udhi) } } }
explode_data.jsonl/28774
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 279 }
[ 2830, 3393, 4239, 21547, 4656, 23913, 1155, 353, 8840, 836, 8, 341, 197, 322, 1083, 7032, 18101, 1054, 836, 47, 21547, 4202, 4656, 39, 198, 2233, 1669, 18101, 1054, 836, 47, 21547, 16094, 197, 661, 6023, 1669, 293, 13, 4656, 23913, 74...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
4
func TestProtoForInstanceState(t *testing.T) { assert.Equal(t, ec2v1.Instance_UNKNOWN, protoForInstanceState("foo")) assert.Equal(t, ec2v1.Instance_UNKNOWN, protoForInstanceState("")) assert.Equal(t, ec2v1.Instance_RUNNING, protoForInstanceState("running")) assert.Equal(t, ec2v1.Instance_SHUTTING_DOWN, protoForInstanceState("shutting-down")) }
explode_data.jsonl/3403
{ "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, 31549, 2461, 8846, 1155, 353, 8840, 836, 8, 341, 6948, 12808, 1155, 11, 11942, 17, 85, 16, 12688, 31546, 11, 18433, 2461, 8846, 445, 7975, 5455, 6948, 12808, 1155, 11, 11942, 17, 85, 16, 12688, 31546, 11, 18433, 2461, 8846...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestIssue305(t *testing.T) { // If 'next' hits a breakpoint on the goroutine it's stepping through // the internal breakpoints aren't cleared preventing further use of // 'next' command protest.AllowRecording(t) withTestProcess("issue305", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 5) assertNoError(p.Continue(), t, "Continue()") assertNoError(p.Next(), t, "Next() 1") assertNoError(p.Next(), t, "Next() 2") assertNoError(p.Next(), t, "Next() 3") assertNoError(p.Next(), t, "Next() 4") assertNoError(p.Next(), t, "Next() 5") }) }
explode_data.jsonl/56236
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 219 }
[ 2830, 3393, 42006, 18, 15, 20, 1155, 353, 8840, 836, 8, 341, 197, 322, 1416, 364, 3600, 6, 12983, 264, 52745, 389, 279, 45198, 14159, 432, 594, 35467, 1526, 198, 197, 322, 279, 5306, 91530, 7629, 944, 22949, 26160, 4623, 990, 315, 1...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestBackupRestorePartitionedIncremental(t *testing.T) { defer leaktest.AfterTest(t)() const numAccounts = 10 const numBackups = 4 windowSize := int(numAccounts / 3) _, _, sqlDB, dir, cleanupFn := BackupRestoreTestSetup(t, MultiNode, 0, InitNone) defer cleanupFn() args := base.TestServerArgs{ExternalIODir: dir} rng, _ := randutil.NewPseudoRand() // Each incremental backup is written to two different subdirectories in // defaultDir and dc1Dir, respectively. const defaultDir = "nodelocal://0/default" const dc1Dir = "nodelocal://0/dc=dc1" var defaultBackupDirs []string var checksums []uint32 { for backupNum := 0; backupNum < numBackups; backupNum++ { // In the following, windowSize is `w` and offset is `o`. The first // mutation creates accounts with id [w,3w). Every mutation after // that deletes everything less than o, leaves [o, o+w) unchanged, // mutates [o+w,o+2w), and inserts [o+2w,o+3w). offset := windowSize * backupNum var buf bytes.Buffer fmt.Fprintf(&buf, `DELETE FROM data.bank WHERE id < %d; `, offset) buf.WriteString(`UPSERT INTO data.bank VALUES `) for j := 0; j < windowSize*2; j++ { if j != 0 { buf.WriteRune(',') } id := offset + windowSize + j payload := randutil.RandBytes(rng, backupRestoreRowPayloadSize) fmt.Fprintf(&buf, `(%d, %d, '%s')`, id, backupNum, payload) } sqlDB.Exec(t, buf.String()) checksums = append(checksums, checksumBankPayload(t, sqlDB)) defaultBackupDir := fmt.Sprintf("%s/%d", defaultDir, backupNum) dc1BackupDir := fmt.Sprintf("%s/%d", dc1Dir, backupNum) var from string if backupNum > 0 { from = fmt.Sprintf(` INCREMENTAL FROM %s`, strings.Join(defaultBackupDirs, `,`)) } sqlDB.Exec( t, fmt.Sprintf(`BACKUP TABLE data.bank TO ('%s?COCKROACH_LOCALITY=%s', '%s?COCKROACH_LOCALITY=%s') %s`, defaultBackupDir, url.QueryEscape("default"), dc1BackupDir, url.QueryEscape("dc=dc1"), from), ) defaultBackupDirs = append(defaultBackupDirs, fmt.Sprintf(`'%s'`, defaultBackupDir)) } } // Start a new cluster to restore into. { restoreTC := testcluster.StartTestCluster(t, singleNode, base.TestClusterArgs{ServerArgs: args}) defer restoreTC.Stopper().Stop(context.Background()) sqlDBRestore := sqlutils.MakeSQLRunner(restoreTC.Conns[0]) sqlDBRestore.Exec(t, `CREATE DATABASE data`) for i := len(defaultBackupDirs); i > 0; i-- { sqlDBRestore.Exec(t, `DROP TABLE IF EXISTS data.bank`) var from strings.Builder for backupNum := range defaultBackupDirs[:i] { if backupNum > 0 { from.WriteString(", ") } from.WriteString(fmt.Sprintf("('%s/%d', '%s/%d')", defaultDir, backupNum, dc1Dir, backupNum)) } sqlDBRestore.Exec(t, fmt.Sprintf(`RESTORE data.bank FROM %s`, from.String())) checksum := checksumBankPayload(t, sqlDBRestore) if checksum != checksums[i-1] { t.Fatalf("checksum mismatch at index %d: got %d expected %d", i-1, checksum, checksums[i]) } } } }
explode_data.jsonl/57591
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1236 }
[ 2830, 3393, 56245, 56284, 49978, 291, 38311, 278, 1155, 353, 8840, 836, 8, 341, 16867, 23352, 1944, 36892, 2271, 1155, 8, 2822, 4777, 1629, 41369, 284, 220, 16, 15, 198, 4777, 1629, 3707, 8602, 284, 220, 19, 198, 23545, 1695, 1669, 52...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestPlugin(t *testing.T) { th := Setup().InitBasic() defer th.TearDown() statesJson, _ := json.Marshal(th.App.Config().PluginSettings.PluginStates) states := map[string]*model.PluginState{} json.Unmarshal(statesJson, &states) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true *cfg.PluginSettings.EnableUploads = true *cfg.PluginSettings.AllowInsecureDownloadUrl = true }) path, _ := fileutils.FindDir("tests") tarData, err := ioutil.ReadFile(filepath.Join(path, "testplugin.tar.gz")) require.NoError(t, err) // Install from URL testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { res.WriteHeader(http.StatusOK) res.Write(tarData) })) defer func() { testServer.Close() }() url := testServer.URL manifest, resp := th.SystemAdminClient.InstallPluginFromUrl(url, false) CheckNoError(t, resp) assert.Equal(t, "testplugin", manifest.Id) _, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false) CheckBadRequestStatus(t, resp) manifest, resp = th.SystemAdminClient.InstallPluginFromUrl(url, true) CheckNoError(t, resp) assert.Equal(t, "testplugin", manifest.Id) ok, resp := th.SystemAdminClient.RemovePlugin(manifest.Id) CheckNoError(t, resp) require.True(t, ok) t.Run("install plugin from URL with slow response time", func(t *testing.T) { if testing.Short() { t.Skip("skipping test to install plugin from a slow response server") } // Install from URL - slow server to simulate longer bundle download times slowTestServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { time.Sleep(60 * time.Second) // Wait longer than the previous default 30 seconds timeout res.WriteHeader(http.StatusOK) res.Write(tarData) })) defer func() { slowTestServer.Close() }() manifest, resp = th.SystemAdminClient.InstallPluginFromUrl(slowTestServer.URL, true) CheckNoError(t, resp) assert.Equal(t, "testplugin", manifest.Id) }) // Stored in File Store: Install Plugin from URL case pluginStored, err := th.App.FileExists("./plugins/" + manifest.Id + ".tar.gz") assert.Nil(t, err) assert.True(t, pluginStored) th.App.RemovePlugin(manifest.Id) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false) CheckNotImplementedStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.InstallPluginFromUrl(url, false) CheckForbiddenStatus(t, resp) _, resp = th.SystemAdminClient.InstallPluginFromUrl("http://nodata", false) CheckBadRequestStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.AllowInsecureDownloadUrl = false }) _, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false) CheckBadRequestStatus(t, resp) // Successful upload manifest, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData)) CheckNoError(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true }) manifest, resp = th.SystemAdminClient.UploadPluginForced(bytes.NewReader(tarData)) defer os.RemoveAll("plugins/testplugin") CheckNoError(t, resp) assert.Equal(t, "testplugin", manifest.Id) // Stored in File Store: Upload Plugin case pluginStored, err = th.App.FileExists("./plugins/" + manifest.Id + ".tar.gz") assert.Nil(t, err) assert.True(t, pluginStored) // Upload error cases _, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader([]byte("badfile"))) CheckBadRequestStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData)) CheckNotImplementedStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true *cfg.PluginSettings.EnableUploads = false }) _, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData)) CheckNotImplementedStatus(t, resp) _, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false) CheckNotImplementedStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true }) _, resp = th.Client.UploadPlugin(bytes.NewReader(tarData)) CheckForbiddenStatus(t, resp) // Successful gets pluginsResp, resp := th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) found := false for _, m := range pluginsResp.Inactive { if m.Id == manifest.Id { found = true } } assert.True(t, found) found = false for _, m := range pluginsResp.Active { if m.Id == manifest.Id { found = true } } assert.False(t, found) // Successful activate ok, resp = th.SystemAdminClient.EnablePlugin(manifest.Id) CheckNoError(t, resp) assert.True(t, ok) pluginsResp, resp = th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) found = false for _, m := range pluginsResp.Active { if m.Id == manifest.Id { found = true } } assert.True(t, found) // Activate error case ok, resp = th.SystemAdminClient.EnablePlugin("junk") CheckNotFoundStatus(t, resp) assert.False(t, ok) ok, resp = th.SystemAdminClient.EnablePlugin("JUNK") CheckNotFoundStatus(t, resp) assert.False(t, ok) // Successful deactivate ok, resp = th.SystemAdminClient.DisablePlugin(manifest.Id) CheckNoError(t, resp) assert.True(t, ok) pluginsResp, resp = th.SystemAdminClient.GetPlugins() CheckNoError(t, resp) found = false for _, m := range pluginsResp.Inactive { if m.Id == manifest.Id { found = true } } assert.True(t, found) // Deactivate error case ok, resp = th.SystemAdminClient.DisablePlugin("junk") CheckNotFoundStatus(t, resp) assert.False(t, ok) // Get error cases th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.GetPlugins() CheckNotImplementedStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.GetPlugins() CheckForbiddenStatus(t, resp) // Successful webapp get _, resp = th.SystemAdminClient.EnablePlugin(manifest.Id) CheckNoError(t, resp) manifests, resp := th.Client.GetWebappPlugins() CheckNoError(t, resp) found = false for _, m := range manifests { if m.Id == manifest.Id { found = true } } assert.True(t, found) // Successful remove ok, resp = th.SystemAdminClient.RemovePlugin(manifest.Id) CheckNoError(t, resp) assert.True(t, ok) // Remove error cases ok, resp = th.SystemAdminClient.RemovePlugin(manifest.Id) CheckNotFoundStatus(t, resp) assert.False(t, ok) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = false }) _, resp = th.SystemAdminClient.RemovePlugin(manifest.Id) CheckNotImplementedStatus(t, resp) th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true }) _, resp = th.Client.RemovePlugin(manifest.Id) CheckForbiddenStatus(t, resp) _, resp = th.SystemAdminClient.RemovePlugin("bad.id") CheckNotFoundStatus(t, resp) }
explode_data.jsonl/27534
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 2493 }
[ 2830, 3393, 11546, 1155, 353, 8840, 836, 8, 341, 70479, 1669, 18626, 1005, 3803, 15944, 741, 16867, 270, 836, 682, 4454, 2822, 18388, 973, 5014, 11, 716, 1669, 2951, 37271, 24365, 5105, 10753, 1005, 11546, 6086, 64378, 23256, 340, 18388, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestFileOpenWrite(t *testing.T) { r := fstest.NewRun(t) defer r.Finalise() vfs, file, _ := fileCreate(t, r, vfscommon.CacheModeOff) fd, err := file.openWrite(os.O_WRONLY | os.O_TRUNC) require.NoError(t, err) newContents := []byte("this is some new contents") n, err := fd.Write(newContents) require.NoError(t, err) assert.Equal(t, len(newContents), n) require.NoError(t, fd.Close()) assert.Equal(t, int64(25), file.Size()) vfs.Opt.ReadOnly = true _, err = file.openWrite(os.O_WRONLY | os.O_TRUNC) assert.Equal(t, EROFS, err) }
explode_data.jsonl/9735
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 239 }
[ 2830, 3393, 1703, 5002, 7985, 1155, 353, 8840, 836, 8, 341, 7000, 1669, 48434, 477, 7121, 6727, 1155, 340, 16867, 435, 991, 977, 1064, 741, 5195, 3848, 11, 1034, 11, 716, 1669, 1034, 4021, 1155, 11, 435, 11, 92941, 5464, 46130, 3636, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestGoroutinesInfoLimit(t *testing.T) { withTestProcess("teststepconcurrent", t, func(p *proc.Target, fixture protest.Fixture) { setFileBreakpoint(p, t, fixture.Source, 37) assertNoError(p.Continue(), t, "Continue()") gcount := 0 nextg := 0 const goroutinesInfoLimit = 10 for nextg >= 0 { oldnextg := nextg var gs []*proc.G var err error gs, nextg, err = proc.GoroutinesInfo(p, nextg, goroutinesInfoLimit) assertNoError(err, t, fmt.Sprintf("GoroutinesInfo(%d, %d)", oldnextg, goroutinesInfoLimit)) gcount += len(gs) t.Logf("got %d goroutines\n", len(gs)) } t.Logf("number of goroutines: %d\n", gcount) gs, _, err := proc.GoroutinesInfo(p, 0, 0) assertNoError(err, t, "GoroutinesInfo(0, 0)") t.Logf("number of goroutines (full scan): %d\n", gcount) if len(gs) != gcount { t.Fatalf("mismatch in the number of goroutines %d %d\n", gcount, len(gs)) } }) }
explode_data.jsonl/56326
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 395 }
[ 2830, 3393, 38, 269, 28628, 1731, 16527, 1155, 353, 8840, 836, 8, 341, 46948, 2271, 7423, 445, 1944, 9520, 443, 3231, 497, 259, 11, 2915, 1295, 353, 15782, 35016, 11, 12507, 8665, 991, 12735, 8, 341, 197, 8196, 1703, 22524, 2768, 1295...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
3
func TestFileHelper_GetPathAndFileNameExt_01(t *testing.T) { fh := FileHelper{} commonDir := fh.AdjustPathSlash(".\\pathfilego\\003_filehelper\\common\\xt_dirmgr_01_test.go") expectedDir := fh.AdjustPathSlash(".\\pathfilego\\003_filehelper\\common") expectedFileNameExt := "xt_dirmgr_01_test.go" pathDir, fileNameExt, bothAreEmpty, err := fh.GetPathAndFileNameExt(commonDir) if err != nil { t.Errorf("Error returned from fh.GetPathAndFileNameExt(commonDir). commonDir='%v' "+ "Error='%v'", commonDir, err.Error()) } if false != bothAreEmpty { t.Errorf("Expected GetPathAndFileNameExt bothAreEmpty='%v'. Instead, bothAreEmpty='%v' ", false, bothAreEmpty) } if pathDir != expectedDir { t.Errorf("Expected GetPathAndFileNameExt to return path == '%v'. "+ "Instead, path== '%v' ", expectedDir, pathDir) } if fileNameExt != expectedFileNameExt { t.Errorf("Expected GetPathAndFileNameExt to return fileNameExt == '%v'. Instead, "+ "fileNameExt == '%v' ", expectedFileNameExt, fileNameExt) } }
explode_data.jsonl/14473
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 397 }
[ 2830, 3393, 1703, 5511, 13614, 1820, 3036, 10903, 6756, 62, 15, 16, 1155, 353, 8840, 836, 8, 1476, 220, 36075, 1669, 2887, 5511, 31483, 220, 4185, 6184, 1669, 36075, 17865, 4250, 1820, 88004, 5680, 3422, 2343, 1192, 3346, 3422, 15, 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...
5
func TestMapProxy_SetWithTtl(t *testing.T) { err := mp.SetWithTtl("testingKey1", "testingValue1", 0, time.Second) if err != nil { t.Error(err) } newValue, err := mp.Get("testingKey1") AssertEqualf(t, err, newValue, "testingValue1", "Map SetWithTtl failed.") mp.SetWithTtl("testingKey1", "testingValue2", 1, time.Millisecond) time.Sleep(5 * time.Second) newValue, err = mp.Get("testingKey1") AssertNilf(t, err, newValue, "Map SetWithTtl failed.") mp.Clear() }
explode_data.jsonl/57009
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 188 }
[ 2830, 3393, 2227, 16219, 14812, 2354, 51, 11544, 1155, 353, 8840, 836, 8, 341, 9859, 1669, 10490, 4202, 2354, 51, 11544, 445, 8840, 1592, 16, 497, 330, 8840, 1130, 16, 497, 220, 15, 11, 882, 32435, 340, 743, 1848, 961, 2092, 341, 19...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestCustomTags(t *testing.T) { tracer, apmtracer, recorder := newTestTracer() defer apmtracer.Close() outer := tracer.StartSpan("name", opentracing.Tag{Key: "foo", Value: "bar"}) inner := tracer.StartSpan("name", opentracing.Tag{Key: "baz", Value: "qux"}, opentracing.ChildOf(outer.Context())) inner.Finish() outer.Finish() apmtracer.Flush(nil) payloads := recorder.Payloads() require.Len(t, payloads.Transactions, 1) require.Len(t, payloads.Spans, 1) assert.Equal(t, model.IfaceMap{{Key: "foo", Value: "bar"}}, payloads.Transactions[0].Context.Tags) assert.Equal(t, model.IfaceMap{{Key: "baz", Value: "qux"}}, payloads.Spans[0].Context.Tags) }
explode_data.jsonl/28597
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 262 }
[ 2830, 3393, 10268, 15930, 1155, 353, 8840, 836, 8, 341, 25583, 9584, 11, 1443, 76, 94941, 11, 48835, 1669, 501, 2271, 1282, 9584, 741, 16867, 1443, 76, 94941, 10421, 2822, 197, 2676, 1669, 64306, 12101, 12485, 445, 606, 497, 1179, 23745...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestNormalizeSpiffeID(t *testing.T) { tests := []struct { name string in string out string }{ {name: "scheme and host are lowercased", in: "SpIfFe://HoSt", out: "spiffe://host"}, {name: "path casing is preserved", in: "SpIfFe://HoSt/PaTh", out: "spiffe://host/PaTh"}, } for _, test := range tests { test := test // alias loop variable as it is used in the closure t.Run(test.name, func(t *testing.T) { out, err := NormalizeSpiffeID(test.in, AllowAny()) assert.NoError(t, err) assert.Equal(t, test.out, out) }) } }
explode_data.jsonl/6134
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 223 }
[ 2830, 3393, 87824, 6406, 43414, 915, 1155, 353, 8840, 836, 8, 341, 78216, 1669, 3056, 1235, 341, 197, 11609, 914, 198, 197, 17430, 256, 914, 198, 197, 13967, 220, 914, 198, 197, 59403, 197, 197, 47006, 25, 330, 46141, 323, 3468, 525, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestHintAnnotations(t *testing.T) { t.Parallel() style := sampleStyle() tests := []struct { desc string give hint input string want []ui.TextAnnotation }{ { desc: "multiple matches", give: hint{ Label: "a", Text: "foo", Matches: []Range{ {0, 3}, {7, 10}, }, }, // [a]oo want: []ui.TextAnnotation{ ui.OverlayTextAnnotation{ Offset: 0, Overlay: "a", Style: style.HintLabel, }, ui.StyleTextAnnotation{ Offset: 1, Length: 2, Style: style.Match, }, ui.OverlayTextAnnotation{ Offset: 7, Overlay: "a", Style: style.HintLabel, }, ui.StyleTextAnnotation{ Offset: 8, Length: 2, Style: style.Match, }, }, }, { desc: "full input match", give: hint{ Label: "a", Text: "foo", Matches: []Range{ {0, 3}, }, }, input: "a", want: []ui.TextAnnotation{ ui.OverlayTextAnnotation{ Offset: 0, Overlay: "a", Style: style.HintLabelInput, }, ui.StyleTextAnnotation{ Offset: 1, Length: 2, Style: style.Match, }, }, }, { desc: "multi character label", give: hint{ Label: "ab", Text: "foobar", Matches: []Range{ {1, 7}, }, }, want: []ui.TextAnnotation{ ui.OverlayTextAnnotation{ Offset: 1, Overlay: "ab", Style: style.HintLabel, }, ui.StyleTextAnnotation{ Offset: 3, Length: 4, Style: style.Match, }, }, }, { desc: "multi character label/input match", give: hint{ Label: "ab", Text: "foobar", Matches: []Range{ {1, 7}, }, }, input: "a", want: []ui.TextAnnotation{ ui.OverlayTextAnnotation{ Offset: 1, Overlay: "a", Style: style.HintLabelInput, }, ui.OverlayTextAnnotation{ Offset: 2, Overlay: "b", Style: style.HintLabel, }, ui.StyleTextAnnotation{ Offset: 3, Length: 4, Style: style.Match, }, }, }, { desc: "multi character label/input mismatch", give: hint{ Label: "ab", Text: "foobar", Matches: []Range{ {1, 7}, }, }, input: "x", want: []ui.TextAnnotation{ ui.StyleTextAnnotation{ Offset: 1, Length: 6, Style: style.SkippedMatch, }, }, }, { desc: "long label", give: hint{ Label: "abcd", Text: "foo", Matches: []Range{ {0, 3}, }, }, want: []ui.TextAnnotation{ ui.OverlayTextAnnotation{ Offset: 0, Overlay: "abcd", Style: style.HintLabel, }, }, }, } for _, tt := range tests { tt := tt t.Run(tt.desc, func(t *testing.T) { t.Parallel() got := tt.give.Annotations(tt.input, style) assert.Equal(t, tt.want, got) }) } }
explode_data.jsonl/70477
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1529 }
[ 2830, 3393, 26987, 21418, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 2822, 42551, 1669, 6077, 2323, 2822, 78216, 1669, 3056, 1235, 341, 197, 41653, 220, 914, 198, 197, 3174, 533, 220, 13012, 198, 197, 22427, 914, 198, 197, 50780, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestCalculateNextReconcileUponError(t *testing.T) { now := metav1.Now() run := &v1alpha1.AnalysisRun{ Spec: v1alpha1.AnalysisRunSpec{ Metrics: []v1alpha1.Metric{{ Name: "success-rate", }}, }, Status: v1alpha1.AnalysisRunStatus{ Phase: v1alpha1.AnalysisPhaseRunning, MetricResults: []v1alpha1.MetricResult{{ Name: "success-rate", Phase: v1alpha1.AnalysisPhaseRunning, Error: 1, Measurements: []v1alpha1.Measurement{{ Value: "99", Phase: v1alpha1.AnalysisPhaseError, StartedAt: &now, FinishedAt: &now, }}, }}, }, } { run := run.DeepCopy() assert.Equal(t, now.Add(DefaultErrorRetryInterval), *calculateNextReconcileTime(run, run.Spec.Metrics)) } { run := run.DeepCopy() run.Spec.Metrics[0].Interval = "5m" assert.Equal(t, now.Add(DefaultErrorRetryInterval), *calculateNextReconcileTime(run, run.Spec.Metrics)) } }
explode_data.jsonl/75827
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 417 }
[ 2830, 3393, 47866, 5847, 693, 40446, 457, 49284, 1454, 1155, 353, 8840, 836, 8, 341, 80922, 1669, 77520, 16, 13244, 741, 56742, 1669, 609, 85, 16, 7141, 16, 8624, 9092, 6727, 515, 197, 7568, 992, 25, 348, 16, 7141, 16, 8624, 9092, 6...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestListSerialization(t *testing.T) { list := New() list.Add("a", "b", "c") var err error assert := func() { if actualValue, expectedValue := fmt.Sprintf("%s%s%s", list.Values()...), "abc"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if actualValue, expectedValue := list.Size(), 3; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if err != nil { t.Errorf("Got error %v", err) } } assert() json, err := list.ToJSON() assert() err = list.FromJSON(json) assert() }
explode_data.jsonl/18308
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 223 }
[ 2830, 3393, 852, 35865, 1155, 353, 8840, 836, 8, 341, 14440, 1669, 1532, 741, 14440, 1904, 445, 64, 497, 330, 65, 497, 330, 66, 5130, 2405, 1848, 1465, 198, 6948, 1669, 2915, 368, 341, 197, 743, 5042, 1130, 11, 3601, 1130, 1669, 887...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestWhile(t *testing.T) { input := `(while (> count 0) (set count (- count 1)))` lex := lexer.NewLexer(input) tokens, _ := lex.GetTokens() parser := NewParser(tokens) exprs, _ := parser.GetExpressions() ife, ok := exprs[0].(expr.While) if !ok { t.Fatalf("Conversion to While expression failed") } if ife.Cond.(expr.Seq).Exprs[0].(expr.Symbol).Name != ">" { t.Fatal("Condition wasn't right") } }
explode_data.jsonl/43725
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 168 }
[ 2830, 3393, 7983, 1155, 353, 8840, 836, 8, 341, 22427, 1669, 48651, 3472, 76852, 1760, 220, 15, 8, 320, 746, 1760, 10293, 1760, 220, 16, 7705, 3989, 197, 2571, 1669, 53259, 7121, 92847, 5384, 340, 3244, 9713, 11, 716, 1669, 22429, 223...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestNewInitData(t *testing.T) { // create temp directory tmpDir, err := ioutil.TempDir("", "kubeadm-init-test") if err != nil { t.Errorf("Unable to create temporary directory: %v", err) } defer os.RemoveAll(tmpDir) // create config file configFilePath := filepath.Join(tmpDir, "test-config-file") cfgFile, err := os.Create(configFilePath) if err != nil { t.Errorf("Unable to create file %q: %v", configFilePath, err) } defer cfgFile.Close() if _, err = cfgFile.WriteString(testInitConfig); err != nil { t.Fatalf("Unable to write file %q: %v", configFilePath, err) } testCases := []struct { name string args []string flags map[string]string validate func(*testing.T, *initData) expectError bool }{ // Init data passed using flags { name: "pass without any flag (use defaults)", }, { name: "fail if unknown feature gates flag are passed", flags: map[string]string{ options.FeatureGatesString: "unknown=true", }, expectError: true, }, { name: "fail if deprecetes feature gates are set", flags: map[string]string{ options.FeatureGatesString: fmt.Sprintf("%s=true", features.CoreDNS), }, expectError: true, }, { name: "fails if invalid preflight checks are provided", flags: map[string]string{ options.IgnorePreflightErrors: "all,something-else", }, expectError: true, }, // Init data passed using config file { name: "Pass with config from file", flags: map[string]string{ options.CfgPath: configFilePath, }, }, { name: "--cri-socket and --node-name flags override config from file", flags: map[string]string{ options.CfgPath: configFilePath, options.NodeCRISocket: "/var/run/crio/crio.sock", options.NodeName: "anotherName", }, validate: func(t *testing.T, data *initData) { // validate that cri-socket and node-name are overwritten if data.cfg.NodeRegistration.CRISocket != "/var/run/crio/crio.sock" { t.Errorf("Invalid NodeRegistration.CRISocket") } if data.cfg.NodeRegistration.Name != "anotherName" { t.Errorf("Invalid NodeRegistration.Name") } }, }, { name: "fail if mixedArguments are passed", flags: map[string]string{ options.CfgPath: configFilePath, options.APIServerAdvertiseAddress: "1.2.3.4", }, expectError: true, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { // initialize an external init option and inject it to the init cmd initOptions := newInitOptions() cmd := NewCmdInit(nil, initOptions) // sets cmd flags (that will be reflected on the init options) for f, v := range tc.flags { cmd.Flags().Set(f, v) } // test newInitData method data, err := newInitData(cmd, tc.args, initOptions, nil) if err != nil && !tc.expectError { t.Fatalf("newInitData returned unexpected error: %v", err) } if err == nil && tc.expectError { t.Fatalf("newInitData didn't return error when expected") } // exec additional validation on the returned value if tc.validate != nil { tc.validate(t, data) } }) } }
explode_data.jsonl/55393
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1281 }
[ 2830, 3393, 3564, 3803, 1043, 1155, 353, 8840, 836, 8, 341, 197, 322, 1855, 2730, 6220, 198, 20082, 6184, 11, 1848, 1669, 43144, 65009, 6184, 19814, 330, 74, 392, 3149, 76, 54773, 16839, 1138, 743, 1848, 961, 2092, 341, 197, 3244, 130...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestIsBulkOptimizable(t *testing.T) { var db statedb.VersionedDB = &VersionedDB{} _, ok := db.(statedb.BulkOptimizable) if !ok { t.Fatal("state couch db is expected to implement interface statedb.BulkOptimizable") } }
explode_data.jsonl/605
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 86 }
[ 2830, 3393, 3872, 88194, 21367, 318, 8335, 1155, 353, 8840, 836, 8, 341, 2405, 2927, 10982, 65, 35842, 291, 3506, 284, 609, 5637, 291, 3506, 16094, 197, 6878, 5394, 1669, 2927, 12832, 267, 657, 65, 1785, 21785, 21367, 318, 8335, 340, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
2
func TestInstallRelease_WrongTillerVersion(t *testing.T) { version.Version = "2.2.0" c := helm.NewContext() rs := rsFixture() // TODO: Refactor this into a mock. req := &services.InstallReleaseRequest{ Namespace: "spaced", Chart: &chart.Chart{ Metadata: &chart.Metadata{Name: "hello", TillerVersion: "<2.0.0"}, Templates: []*chart.Template{ {Name: "templates/hello", Data: []byte("hello: world")}, {Name: "templates/hooks", Data: []byte(manifestWithHook)}, }, }, } _, err := rs.InstallRelease(c, req) if err == nil { t.Fatalf("Expected to fail because of wrong version") } expect := "Chart incompatible with Tiller" if !strings.Contains(err.Error(), expect) { t.Errorf("Expected %q to contain %q", err.Error(), expect) } }
explode_data.jsonl/45608
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 295 }
[ 2830, 3393, 24690, 16077, 2763, 14347, 51, 15252, 5637, 1155, 353, 8840, 836, 8, 341, 74954, 35842, 284, 330, 17, 13, 17, 13, 15, 698, 1444, 1669, 33765, 7121, 1972, 741, 41231, 1669, 10036, 18930, 2822, 197, 322, 5343, 25, 8550, 5621...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestGenerateDirPaths(t *testing.T) { // EXERCISE actual := generateDirPaths("pname") // VERIFY expected := []string{ "pname/cmd/pname", "pname/configs", "pname/internal/app/pname", "pname/internal/pkg", "pname/pkg", "pname/scripts", } sort.Strings(actual) sort.Strings(expected) actualLength := len(actual) expectedLength := len(expected) if actualLength != expectedLength { t.Fatalf( "Dir slice length mismatch: actual %v vs expected %v", actualLength, expectedLength) } for i := 0; i < actualLength; i++ { eachActual := actual[i] eachExpected := expected[i] if eachActual != eachExpected { t.Errorf( "Mismatching dirs: actual %v vs expected %v", eachActual, eachExpected) } } }
explode_data.jsonl/54730
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 307 }
[ 2830, 3393, 31115, 6184, 26901, 1155, 353, 8840, 836, 8, 341, 197, 322, 4063, 27434, 9133, 198, 88814, 1669, 6923, 6184, 26901, 445, 82662, 5130, 197, 322, 78204, 198, 42400, 1669, 3056, 917, 515, 197, 197, 1, 82662, 83033, 4322, 606, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 TestGamma(t *testing.T) { cases := []struct { desc string gamma float64 value image.Image expected *image.RGBA }{ { desc: "1.0", gamma: 1.0, value: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF, }, }, expected: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF, }, }, }, { desc: "0", gamma: 0.0, value: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF, }, }, expected: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, }, }, }, { desc: "2.2", gamma: 2.2, value: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF, }, }, expected: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0xba, 0xba, 0xba, 0x80, 0xba, 0xba, 0xba, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xff, }, }, }, { desc: "0.5", gamma: 0.5, value: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0xFF, }, }, expected: &image.RGBA{ Rect: image.Rect(0, 0, 2, 2), Stride: 8, Pix: []uint8{ 0x40, 0x40, 0x40, 0x80, 0x40, 0x40, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xff, }, }, }, } for _, c := range cases { actual := Gamma(c.value, c.gamma) if !rgbaImageEqual(actual, c.expected) { t.Error(testFailMessage("Gamma "+c.desc, c.expected, actual)) } } }
explode_data.jsonl/5951
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 1381 }
[ 2830, 3393, 40457, 1155, 353, 8840, 836, 8, 341, 1444, 2264, 1669, 3056, 1235, 341, 197, 41653, 257, 914, 198, 197, 3174, 13099, 262, 2224, 21, 19, 198, 197, 16309, 262, 2168, 7528, 198, 197, 42400, 353, 1805, 80114, 32, 198, 197, 5...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
3
func TestPresentationMarshalFullJSON(t *testing.T) { var p Presentation assert.NoError(t, json.Unmarshal([]byte(`{ "clipped": true, "continuous": false, "fit": "cover", "orientation": "landscape", "overflow": "paginated", "spread": "both", "layout": "fixed" }`), &p)) assert.Equal(t, Presentation{ Clipped: newBool(true), Continuous: newBool(false), Fit: (*Fit)(newString("cover")), Orientation: (*Orientation)(newString("landscape")), Overflow: (*Overflow)(newString("paginated")), Spread: (*Spread)(newString("both")), Layout: (*EPUBLayout)(newString("fixed")), }, p, "Presentation should be equal to given JSON") }
explode_data.jsonl/79744
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 281 }
[ 2830, 3393, 55239, 55438, 9432, 5370, 1155, 353, 8840, 836, 8, 341, 2405, 281, 50868, 198, 6948, 35699, 1155, 11, 2951, 38097, 10556, 3782, 5809, 515, 197, 197, 1, 564, 6450, 788, 830, 345, 197, 197, 1, 78589, 788, 895, 345, 197, 19...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1
func TestHtlcIncomingResolverExitSettleHodl(t *testing.T) { t.Parallel() defer timeout(t)() ctx := newIncomingResolverTestContext(t, true) ctx.resolve() notifyData := <-ctx.registry.notifyChan notifyData.hodlChan <- invoices.NewSettleResolution( testResPreimage, testResCircuitKey, testAcceptHeight, invoices.ResultSettled, ) ctx.waitForResult(true) }
explode_data.jsonl/30615
{ "file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl", "token_count": 142 }
[ 2830, 3393, 39, 11544, 66, 97564, 18190, 15339, 1649, 11239, 39, 347, 75, 1155, 353, 8840, 836, 8, 341, 3244, 41288, 7957, 741, 16867, 9632, 1155, 8, 2822, 20985, 1669, 501, 97564, 18190, 2271, 1972, 1155, 11, 830, 340, 20985, 14691, ...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
1