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 Test_CreateSecurityGroupWithRPCrequestWithJSONWithNestingparametersWithPOST(t *testing.T) {
client, err := ecs.NewClientWithAccessKey(os.Getenv("REGION_ID"), os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
assert.Nil(t, err)
request := ecs.CreateCreateSecurityGroupRequest()
request.SetContentType("JSON")
tag := ecs.CreateSecurityGroupTag{
Key: "test",
Value: "test",
}
request.Tag = &[]ecs.CreateSecurityGroupTag{tag}
response, err := client.CreateSecurityGroup(request)
assert.Nil(t, err)
assert.True(t, response.IsSuccess())
assert.Equal(t, 36, len(response.RequestId))
assert.True(t, len(response.SecurityGroupId) > 0)
securityGroupId = response.SecurityGroupId
} | explode_data.jsonl/56870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
34325,
15352,
2808,
2354,
29528,
2035,
2354,
5370,
2354,
45,
59855,
13786,
2354,
2946,
1155,
353,
8840,
836,
8,
341,
25291,
11,
1848,
1669,
78422,
7121,
2959,
2354,
6054,
1592,
9638,
64883,
445,
77431,
3450,
3975,
2643,
64883,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerBoundHandshake_ParseServerAddress(t *testing.T) {
tt := []struct {
addr string
expectedAddr string
}{
{
addr: "",
expectedAddr: "",
},
{
addr: "example.com:25565",
expectedAddr: "example.com:25565",
},
{
addr: mc.ForgeSeparator,
expectedAddr: "",
},
{
addr: mc.RealIPSeparator,
expectedAddr: "",
},
{
addr: "example.com" + mc.ForgeSeparator,
expectedAddr: "example.com",
},
{
addr: "example.com" + mc.ForgeSeparator + "some data",
expectedAddr: "example.com",
},
{
addr: "example.com:25565" + mc.RealIPSeparator + "some data",
expectedAddr: "example.com:25565",
},
{
addr: "example.com:1234" + mc.ForgeSeparator + "some data" + mc.RealIPSeparator + "more",
expectedAddr: "example.com:1234",
},
}
for _, tc := range tt {
hs := mc.ServerBoundHandshake{ServerAddress: tc.addr}
if hs.ParseServerAddress() != tc.expectedAddr {
t.Errorf("got: %v; want: %v", hs.ParseServerAddress(), tc.expectedAddr)
}
}
} | explode_data.jsonl/45005 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 531
} | [
2830,
3393,
5475,
19568,
2314,
29661,
77337,
5475,
4286,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
53183,
260,
914,
198,
197,
42400,
13986,
914,
198,
197,
59403,
197,
197,
515,
298,
53183,
25,
260,
8324,
298,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFetch(t *testing.T) {
f := mbtest.NewReportingMetricSetV2Error(t, getConfig())
events, errs := mbtest.ReportingFetchV2Error(f)
assert.Empty(t, errs)
if !assert.NotEmpty(t, events) {
t.FailNow()
}
t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(),
events[0].BeatEvent("system", "uptime").Fields.StringToPrint())
} | explode_data.jsonl/5598 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 143
} | [
2830,
3393,
20714,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
10016,
1944,
7121,
70131,
54310,
1649,
53,
17,
1454,
1155,
11,
66763,
2398,
90873,
11,
70817,
1669,
10016,
1944,
43648,
20714,
53,
17,
1454,
955,
692,
6948,
11180,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetServerConfig(t *testing.T) {
//没有TLS的良好配置
viper.Set("peer.tls.enabled", false)
sc, _ := GetServerConfig()
assert.Equal(t, false, sc.SecOpts.UseTLS,
"ServerConfig.SecOpts.UseTLS should be false")
//保留选项
assert.Equal(t, comm.DefaultKeepaliveOptions, sc.KaOpts,
"ServerConfig.KaOpts should be set to default values")
viper.Set("peer.keepalive.minInterval", "2m")
sc, _ = GetServerConfig()
assert.Equal(t, time.Duration(2)*time.Minute, sc.KaOpts.ServerMinInterval,
"ServerConfig.KaOpts.ServerMinInterval should be set to 2 min")
//TLS配置良好
viper.Set("peer.tls.enabled", true)
viper.Set("peer.tls.cert.file", filepath.Join("testdata", "Org1-server1-cert.pem"))
viper.Set("peer.tls.key.file", filepath.Join("testdata", "Org1-server1-key.pem"))
viper.Set("peer.tls.rootcert.file", filepath.Join("testdata", "Org1-cert.pem"))
sc, _ = GetServerConfig()
assert.Equal(t, true, sc.SecOpts.UseTLS, "ServerConfig.SecOpts.UseTLS should be true")
assert.Equal(t, false, sc.SecOpts.RequireClientCert,
"ServerConfig.SecOpts.RequireClientCert should be false")
viper.Set("peer.tls.clientAuthRequired", true)
viper.Set("peer.tls.clientRootCAs.files",
[]string{filepath.Join("testdata", "Org1-cert.pem"),
filepath.Join("testdata", "Org2-cert.pem")})
sc, _ = GetServerConfig()
assert.Equal(t, true, sc.SecOpts.RequireClientCert,
"ServerConfig.SecOpts.RequireClientCert should be true")
assert.Equal(t, 2, len(sc.SecOpts.ClientRootCAs),
"ServerConfig.SecOpts.ClientRootCAs should contain 2 entries")
//TLS配置错误
viper.Set("peer.tls.rootcert.file", filepath.Join("testdata", "Org11-cert.pem"))
_, err := GetServerConfig()
assert.Error(t, err, "GetServerConfig should return error with bad root cert path")
viper.Set("peer.tls.cert.file", filepath.Join("testdata", "Org11-cert.pem"))
_, err = GetServerConfig()
assert.Error(t, err, "GetServerConfig should return error with bad tls cert path")
//禁用剩余测试的TLS
viper.Set("peer.tls.enabled", false)
viper.Set("peer.tls.clientAuthRequired", false)
} | explode_data.jsonl/62189 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 844
} | [
2830,
3393,
1949,
5475,
2648,
1155,
353,
8840,
836,
8,
1476,
322,
80443,
45439,
108672,
85767,
198,
5195,
12858,
4202,
445,
16537,
734,
4730,
22141,
497,
895,
340,
29928,
11,
716,
1669,
2126,
5475,
2648,
741,
6948,
12808,
1155,
11,
895,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCheckTiKVFormerPodStatus(t *testing.T) {
g := NewGomegaWithT(t)
type testcase struct {
stsReplicas int32
name string
targetOrdinal int32
deleteSlots []int32
permit bool
}
tests := []testcase{
{
stsReplicas: 5,
name: "last target ordinal",
targetOrdinal: 4,
deleteSlots: []int32{},
permit: true,
},
{
stsReplicas: 5,
name: "FirstTargetOrdinal",
targetOrdinal: 0,
deleteSlots: []int32{},
permit: true,
},
{
stsReplicas: 4,
name: "mid target ordinal, check success",
targetOrdinal: 1,
deleteSlots: []int32{0},
permit: true,
},
{
stsReplicas: 4,
name: "mid target ordinal, check success",
targetOrdinal: 1,
deleteSlots: []int32{2},
permit: true,
},
}
for _, test := range tests {
t.Log("test: ", test.name)
kubeCli, _ := newFakeComponent()
slots := sets.NewInt32(test.deleteSlots...)
tc := newTidbClusterForPodAdmissionControl(test.stsReplicas, test.stsReplicas)
sts := buildTargetStatefulSet(tc, v1alpha1.TiKVMemberType)
err := helper.SetDeleteSlots(sts, slots)
g.Expect(err).NotTo(HaveOccurred())
for i := range helper.GetPodOrdinals(test.stsReplicas, sts) {
pod := buildPod(tc, v1alpha1.TiKVMemberType, i)
pod.Labels[apps.ControllerRevisionHashLabelKey] = sts.Status.UpdateRevision
kubeCli.CoreV1().Pods(tc.Namespace).Create(pod)
}
desc := controllerDesc{
name: tc.Name,
namespace: tc.Namespace,
kind: tc.Kind,
}
err = checkFormerTiKVPodStatus(kubeCli, desc, test.targetOrdinal, tc.Spec.TiKV.Replicas, sts, buildStoresInfo(tc, sts))
if test.permit {
g.Expect(err).NotTo(HaveOccurred())
} else {
g.Expect(err).Should(HaveOccurred())
}
}
} | explode_data.jsonl/75799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 848
} | [
2830,
3393,
3973,
45351,
82707,
30845,
23527,
2522,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
1532,
38,
32696,
2354,
51,
1155,
340,
13158,
70080,
2036,
341,
197,
18388,
82,
18327,
52210,
256,
526,
18,
17,
198,
197,
11609,
688,
914,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDecodeCmdMessageDeleteStream(t *testing.T) {
bin := []byte{
// nil
0x05,
// number: 42
0x00, 0x40, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
r := bytes.NewReader(bin)
d := amf0.NewDecoder(r)
var v AMFConvertible
err := CmdBodyDecoderFor("deleteStream", 42)(r, d, &v)
assert.Nil(t, err)
assert.Equal(t, &NetStreamDeleteStream{
StreamID: 42,
}, v)
} | explode_data.jsonl/7724 | {
"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,
32564,
15613,
2052,
6435,
3027,
1155,
353,
8840,
836,
8,
341,
2233,
258,
1669,
3056,
3782,
515,
197,
197,
322,
2092,
198,
197,
197,
15,
87,
15,
20,
345,
197,
197,
322,
1372,
25,
220,
19,
17,
198,
197,
197,
15,
87,
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 TestListType(t *testing.T) {
assert.Equal(t, true, ListObjects.Objects())
assert.Equal(t, false, ListObjects.Dirs())
assert.Equal(t, false, ListDirs.Objects())
assert.Equal(t, true, ListDirs.Dirs())
assert.Equal(t, true, ListAll.Objects())
assert.Equal(t, true, ListAll.Dirs())
var (
a = mockobject.Object("a")
b = mockobject.Object("b")
dir = mockdir.New("dir")
adir = mockobject.Object("dir/a")
dir2 = mockdir.New("dir2")
origEntries = fs.DirEntries{
a, b, dir, adir, dir2,
}
dirEntries = fs.DirEntries{
dir, dir2,
}
objEntries = fs.DirEntries{
a, b, adir,
}
)
copyOrigEntries := func() (out fs.DirEntries) {
out = make(fs.DirEntries, len(origEntries))
copy(out, origEntries)
return out
}
got := copyOrigEntries()
ListAll.Filter(&got)
assert.Equal(t, origEntries, got)
got = copyOrigEntries()
ListObjects.Filter(&got)
assert.Equal(t, objEntries, got)
got = copyOrigEntries()
ListDirs.Filter(&got)
assert.Equal(t, dirEntries, got)
} | explode_data.jsonl/65767 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 478
} | [
2830,
3393,
852,
929,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
1155,
11,
830,
11,
1759,
11543,
40314,
2398,
6948,
12808,
1155,
11,
895,
11,
1759,
11543,
909,
16838,
2398,
6948,
12808,
1155,
11,
895,
11,
1759,
97384,
40314,
2398,
694... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSwitchSetEndpoints(t *testing.T) {
defer testutil.AfterTest(t)
clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 3})
defer clus.Terminate(t)
// get non partitioned members endpoints
eps := []string{clus.Members[1].GRPCAddr(), clus.Members[2].GRPCAddr()}
cli := clus.Client(0)
clus.Members[0].InjectPartition(t, clus.Members[1:]...)
cli.SetEndpoints(eps...)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if _, err := cli.Get(ctx, "foo"); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/30355 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 212
} | [
2830,
3393,
16837,
1649,
80786,
1155,
353,
8840,
836,
8,
341,
16867,
1273,
1314,
36892,
2271,
1155,
340,
197,
4163,
1669,
17590,
7121,
28678,
53,
18,
1155,
11,
609,
60168,
72883,
2648,
90,
1695,
25,
220,
18,
3518,
16867,
1185,
355,
83... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddPort(t *testing.T) {
az := getTestCloud()
svc := getTestService("servicea", v1.ProtocolTCP, 80)
clusterResources := getClusterResources(az, 1, 1)
svc.Spec.Ports = append(svc.Spec.Ports, v1.ServicePort{
Name: fmt.Sprintf("port-udp-%d", 1234),
Protocol: v1.ProtocolUDP,
Port: 1234,
NodePort: getBackendPort(1234),
})
lb, err := az.reconcileLoadBalancer(testClusterName, &svc, clusterResources.nodes, true /* wantLb */)
if err != nil {
t.Errorf("Unexpected error: %q", err)
}
// ensure we got a frontend ip configuration
if len(*lb.FrontendIPConfigurations) != 1 {
t.Error("Expected the loadbalancer to have a frontend ip configuration")
}
validateLoadBalancer(t, lb, svc)
} | explode_data.jsonl/50383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
2212,
7084,
1155,
353,
8840,
836,
8,
341,
197,
1370,
1669,
633,
2271,
16055,
741,
1903,
7362,
1669,
633,
2271,
1860,
445,
7936,
64,
497,
348,
16,
54096,
49896,
11,
220,
23,
15,
340,
197,
18855,
11277,
1669,
633,
28678,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOperandRegistry(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecsWithDefaultAndCustomReporters(t,
"OperandRegistry Controller Suite",
[]Reporter{printer.NewlineReporter{}})
} | explode_data.jsonl/900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
29940,
15603,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
692,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,
1155,
345,
197,
197,
1,
29940,
15603,
9771,
20977,
756,
197,
197,
1294,
52766,
90,
62956,
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 |
func TestNegativeStream(t *testing.T) {
session := createSession(t)
defer session.Close()
conn := getRandomConn(t, session)
const stream = -50
writer := frameWriterFunc(func(f *framer, streamID int) error {
f.writeHeader(0, opOptions, stream)
return f.finishWrite()
})
frame, err := conn.exec(context.Background(), writer, nil)
if err == nil {
t.Fatalf("expected to get an error on stream %d", stream)
} else if frame != nil {
t.Fatalf("expected to get nil frame got %+v", frame)
}
} | explode_data.jsonl/11182 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 178
} | [
2830,
3393,
38489,
3027,
1155,
353,
8840,
836,
8,
341,
25054,
1669,
1855,
5283,
1155,
340,
16867,
3797,
10421,
2822,
32917,
1669,
52436,
9701,
1155,
11,
3797,
692,
4777,
4269,
284,
481,
20,
15,
198,
38959,
1669,
4034,
6492,
9626,
18552,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLogAndMetrics(t *testing.T) {
tests := []struct {
logLevel string
quiet bool
}{
{logLevel: "", quiet: false},
{logLevel: "Info", quiet: false},
{logLevel: "Error", quiet: true},
}
for _, test := range tests {
t.Run(test.logLevel, func(t *testing.T) {
out := testLogAndMetrics(t, test.logLevel)
if test.quiet {
assert.Regexp(t, `^Running Firecracker v0\.\d+\.\d+`, out)
return
}
// By default, Firecracker's log level is Warn.
logLevel := "WARN"
if test.logLevel != "" {
logLevel = strings.ToUpper(test.logLevel)
}
assert.Contains(t, out, ":"+logLevel+"]")
})
}
} | explode_data.jsonl/70436 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 277
} | [
2830,
3393,
2201,
3036,
27328,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
6725,
4449,
914,
198,
197,
197,
43650,
262,
1807,
198,
197,
59403,
197,
197,
90,
839,
4449,
25,
7342,
11340,
25,
895,
1583,
197,
197,
90... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTokenAuth(t *testing.T) {
token, err := ioutil.ReadFile(tokenFilePath)
assert.NoError(t, err)
client, err := NewClient(ClientOptions{
URL: serviceURL,
Authentication: NewAuthenticationToken(string(token)),
})
assert.NoError(t, err)
producer, err := client.CreateProducer(ProducerOptions{
Topic: newAuthTopicName(),
})
assert.NoError(t, err)
assert.NotNil(t, producer)
client.Close()
} | explode_data.jsonl/69309 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 161
} | [
2830,
3393,
3323,
5087,
1155,
353,
8840,
836,
8,
341,
43947,
11,
1848,
1669,
43144,
78976,
13274,
19090,
340,
6948,
35699,
1155,
11,
1848,
692,
25291,
11,
1848,
1669,
1532,
2959,
46851,
3798,
515,
197,
79055,
25,
310,
2473,
3144,
345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestShardGetAndExist(t *testing.T) {
elements := []struct {
s *shard
ws *workers
n int
getFail int64
notExist int64
lifetime time.Duration
interval time.Duration
}{
{
s: &shard{elements: make(map[string]element), q: &queue{}},
ws: &workers{wn: 1, number: 256},
n: 128,
},
{
s: &shard{elements: make(map[string]element), q: &queue{}},
ws: &workers{wn: 4, number: 512},
n: 256,
},
{
s: &shard{elements: make(map[string]element), q: &queue{}},
ws: &workers{wn: 32, number: 1024},
n: 100,
},
{
s: &shard{elements: make(map[string]element), q: &queue{}},
ws: &workers{wn: 32, number: 1024},
n: 1024,
lifetime: 100 * time.Millisecond,
interval: 10 * time.Millisecond,
},
{
s: &shard{elements: make(map[string]element), q: &queue{}},
ws: &workers{wn: 32, number: 1024},
n: 330,
lifetime: 100 * time.Millisecond,
interval: 10 * time.Millisecond,
},
}
for _, e := range elements {
for i := 0; i < e.n; i++ {
k := fmt.Sprintf("%d", i)
assert.Equal(t, e.s.add(k, k, e.lifetime), nil)
}
e.ws.cb = func(w *worker, i int) error {
if e.interval != 0 {
time.Sleep(e.interval)
}
k := fmt.Sprintf("%d", i)
x := e.s.get(k)
if v, ok := x.(string); !ok || v != k {
atomic.AddInt64(&e.getFail, 1)
}
if !e.s.exist(k) {
atomic.AddInt64(&e.notExist, 1)
}
return nil
}
e.ws.initialize()
e.ws.run()
total := e.ws.wn * e.ws.number
t.Logf("total (%d) get-fail/not-exist (%d/%d) success (%d)",
total, e.getFail, e.notExist, total-int(e.getFail))
assert.Equal(t, e.getFail, e.notExist)
if e.lifetime == 0 {
assert.Equal(t, e.ws.number-int(e.getFail)/e.ws.wn, e.n)
} else {
assert.Equal(t, e.ws.number-int(e.getFail)/e.ws.wn < e.n, true)
}
}
} | explode_data.jsonl/5396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 966
} | [
2830,
3393,
2016,
567,
1949,
3036,
25613,
1155,
353,
8840,
836,
8,
341,
197,
21423,
1669,
3056,
1235,
341,
197,
1903,
286,
353,
927,
567,
198,
197,
6692,
82,
981,
353,
54958,
198,
197,
9038,
286,
526,
198,
197,
10366,
19524,
220,
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... | 5 |
func TestNumberOfRetryAttemptsIsZeroForNonExistentJob(t *testing.T) {
withRepository(func(r *RedisJobRepository) {
retries, err := r.GetNumberOfRetryAttempts("nonexistent-job-id")
assert.Nil(t, err)
assert.Zero(t, retries)
})
} | explode_data.jsonl/32063 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
40619,
51560,
81517,
3872,
17999,
2461,
8121,
840,
18128,
12245,
1155,
353,
8840,
836,
8,
341,
46948,
4624,
18552,
2601,
353,
48137,
12245,
4624,
8,
341,
197,
17200,
4543,
11,
1848,
1669,
435,
2234,
40619,
51560,
81517,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestRequestThatCameDuringReauthWaitsUntilItIsCompleted(t *testing.T) {
var info = struct {
numreauths int
failedAuths int
reauthCh chan struct{}
mut *sync.RWMutex
}{
0,
0,
make(chan struct{}),
new(sync.RWMutex),
}
numconc := 20
prereauthTok := client.TokenID
postreauthTok := "12345678"
p := new(gophercloud.ProviderClient)
p.UseTokenLock()
p.SetToken(prereauthTok)
p.ReauthFunc = func() error {
info.mut.RLock()
if info.numreauths == 0 {
info.mut.RUnlock()
close(info.reauthCh)
time.Sleep(1 * time.Second)
} else {
info.mut.RUnlock()
}
p.SetThrowaway(true)
p.AuthenticatedHeaders()
info.mut.Lock()
info.numreauths++
info.mut.Unlock()
p.TokenID = postreauthTok
p.SetThrowaway(false)
return nil
}
th.SetupHTTP()
defer th.TeardownHTTP()
th.Mux.HandleFunc("/route", func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Auth-Token") != postreauthTok {
info.mut.Lock()
info.failedAuths++
info.mut.Unlock()
w.WriteHeader(http.StatusUnauthorized)
return
}
info.mut.RLock()
hasReauthed := info.numreauths != 0
info.mut.RUnlock()
if hasReauthed {
th.CheckEquals(t, p.Token(), postreauthTok)
}
w.Header().Add("Content-Type", "application/json")
fmt.Fprintf(w, `{}`)
})
wg := new(sync.WaitGroup)
reqopts := new(gophercloud.RequestOpts)
reqopts.KeepResponseBody = true
reqopts.MoreHeaders = map[string]string{
"X-Auth-Token": prereauthTok,
}
for i := 0; i < numconc; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
if i != 0 {
<-info.reauthCh
}
resp, err := p.Request("GET", fmt.Sprintf("%s/route", th.Endpoint()), reqopts)
th.CheckNoErr(t, err)
if resp == nil {
t.Errorf("got a nil response")
return
}
if resp.Body == nil {
t.Errorf("response body was nil")
return
}
defer resp.Body.Close()
actual, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Errorf("error reading response body: %s", err)
return
}
th.CheckByteArrayEquals(t, []byte(`{}`), actual)
}(i)
}
wg.Wait()
th.AssertEquals(t, 1, info.numreauths)
th.AssertEquals(t, 1, info.failedAuths)
} | explode_data.jsonl/5891 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1011
} | [
2830,
3393,
1900,
4792,
34,
373,
16014,
693,
3242,
54,
56479,
24493,
2132,
3872,
22724,
1155,
353,
8840,
836,
8,
341,
2405,
3546,
284,
2036,
341,
197,
22431,
265,
3242,
82,
220,
526,
198,
197,
1166,
5687,
5087,
82,
526,
198,
197,
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... | 2 |
func TestClean(t *testing.T) {
tests := cleantests
if runtime.GOOS == "windows" {
for i := range tests {
tests[i].result = filepath.FromSlash(tests[i].result)
}
tests = append(tests, wincleantests...)
}
for _, test := range tests {
if s := filepath.Clean(test.path); s != test.result {
t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.result)
}
if s := filepath.Clean(test.result); s != test.result {
t.Errorf("Clean(%q) = %q, want %q", test.result, s, test.result)
}
}
if testing.Short() {
t.Skip("skipping malloc count in short mode")
}
if runtime.GOMAXPROCS(0) > 1 {
t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1")
return
}
for _, test := range tests {
allocs := testing.AllocsPerRun(100, func() { filepath.Clean(test.result) })
if allocs > 0 {
t.Errorf("Clean(%q): %v allocs, want zero", test.result, allocs)
}
}
} | explode_data.jsonl/1653 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 372
} | [
2830,
3393,
27529,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
11299,
517,
17966,
198,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
2023,
600,
1669,
2088,
7032,
341,
298,
78216,
989,
936,
1382,
284,
26054,
11439,
88004,
8623,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSupervisedPool_Exec(t *testing.T) {
ctx := context.Background()
p, err := Initialize(
ctx,
func() *exec.Cmd { return exec.Command("php", "../tests/memleak.php", "pipes") },
pipe.NewPipeFactory(),
cfgSupervised,
)
assert.NoError(t, err)
assert.NotNil(t, p)
time.Sleep(time.Second)
pidBefore := p.Workers()[0].Pid()
for i := 0; i < 100; i++ {
time.Sleep(time.Millisecond * 100)
_, err = p.Exec(&payload.Payload{
Context: []byte(""),
Body: []byte("foo"),
})
assert.NoError(t, err)
}
assert.NotEqual(t, pidBefore, p.Workers()[0].Pid())
p.Destroy(context.Background())
} | explode_data.jsonl/78511 | {
"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,
10048,
77990,
10551,
62,
10216,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
3223,
11,
1848,
1669,
9008,
1006,
197,
20985,
345,
197,
29244,
368,
353,
11748,
64512,
314,
470,
3883,
12714,
445,
1208,
497,
7005,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStateStore(t *testing.T) {
testCases := map[string]struct {
migrationErr error
inputDatabase map[fmt.Stringer]cbg.CBORMarshaler
test func(t *testing.T, stateStore versioned.StateStore)
}{
"Get, not ready": {
migrationErr: versioning.ErrMigrationsNotRun,
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
storedState := ss.Get(stringer("/apples"))
var out cbg.CborInt
require.EqualError(t, storedState.Get(&out), versioning.ErrMigrationsNotRun.Error())
},
},
"Get, ready": {
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
storedState := ss.Get(stringer("/apples"))
var out cbg.CborInt
err := storedState.Get(&out)
require.Equal(t, cbg.CborInt(54), out)
require.NoError(t, err)
},
},
"Begin, not ready": {
migrationErr: versioning.ErrMigrationsNotRun,
test: func(t *testing.T, ss versioned.StateStore) {
require.EqualError(t, ss.Begin(stringer("/apples"), newInt(54)), versioning.ErrMigrationsNotRun.Error())
},
},
"Beging, ready": {
test: func(t *testing.T, ss versioned.StateStore) {
err := ss.Begin(stringer("/apples"), newInt(54))
require.NoError(t, err)
storedState := ss.Get(stringer("/apples"))
var out cbg.CborInt
err = storedState.Get(&out)
require.Equal(t, cbg.CborInt(54), out)
require.NoError(t, err)
},
},
"List, not ready": {
migrationErr: versioning.ErrMigrationsNotRun,
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
var out []*cbg.CborInt
require.EqualError(t, ss.List(&out), versioning.ErrMigrationsNotRun.Error())
},
},
"List, ready": {
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
var out []cbg.CborInt
err := ss.List(&out)
require.Len(t, out, 1)
require.Equal(t, cbg.CborInt(54), out[0])
require.NoError(t, err)
},
},
"Has, not ready": {
migrationErr: versioning.ErrMigrationsNotRun,
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
has, err := ss.Has(stringer("/apples"))
require.False(t, has)
require.EqualError(t, err, versioning.ErrMigrationsNotRun.Error())
},
},
"Has, ready": {
inputDatabase: map[fmt.Stringer]cbg.CBORMarshaler{
stringer("/apples"): newInt(54),
},
test: func(t *testing.T, ss versioned.StateStore) {
has, err := ss.Has(stringer("/apples"))
require.True(t, has)
require.NoError(t, err)
},
},
}
for testCase, data := range testCases {
t.Run(testCase, func(t *testing.T) {
ds := datastore.NewMapDatastore()
ss := statestore.New(ds)
if data.inputDatabase != nil {
for key, value := range data.inputDatabase {
err := ss.Begin(key, value)
require.NoError(t, err)
}
}
ms := migrationState{data.migrationErr}
migratedSs := versioned.NewMigratedStateStore(ss, ms)
data.test(t, migratedSs)
})
}
} | explode_data.jsonl/1302 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1511
} | [
2830,
3393,
1397,
6093,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
2109,
5033,
7747,
220,
1465,
198,
197,
22427,
5988,
2415,
58,
12501,
6431,
261,
60,
7221,
70,
727,
33,
4365,
28423,
261,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRejectBadTransformer(t *testing.T) {
g := gomega.NewGomegaWithT(t)
kfsvc := makeTestKFService()
kfsvc.Spec.Default.Transformer = &TransformerSpec{}
g.Expect(kfsvc.ValidateCreate()).Should(gomega.MatchError(ExactlyOneTransformerViolatedError))
} | explode_data.jsonl/7105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
78413,
17082,
46358,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
38,
32696,
2354,
51,
1155,
340,
16463,
69,
58094,
1669,
1281,
2271,
65008,
1860,
741,
16463,
69,
58094,
36473,
13275,
11815,
34527,
284,
609,
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... | 1 |
func TestSplitTextWithOptions(t *testing.T) {
err := initTesting()
if err != nil {
t.Error(err)
return
}
pdf := setupDefaultA4PDF(t)
var splitTextTests = []struct {
name string
in string
opts *BreakOption
exp []string
}{
{
"strict breaks no separator",
"Lorem ipsum dolor sit amet, consetetur",
&DefaultBreakOption,
[]string{"Lorem ipsum dol", "or sit amet, conse", "tetur"},
},
{
"no options given",
"Lorem ipsum dolor sit amet, consetetur",
nil,
[]string{"Lorem ipsum dol", "or sit amet, conse", "tetur"},
},
{
"strict breaks with separator",
"Lorem ipsum dolor sit amet, consetetur",
&BreakOption{
Separator: "-",
Mode: BreakModeStrict,
},
[]string{"Lorem ipsum d-", "olor sit amet, c-", "onsetetur"},
},
{
"text with possible word-wrap",
"Lorem ipsum dolor sit amet, consetetur",
&BreakOption{
BreakIndicator: ' ',
Mode: BreakModeIndicatorSensitive,
},
[]string{"Lorem ipsum", "dolor sit amet,", "consetetur"},
},
{
"text without possible word-wrap",
"Loremipsumdolorsitamet,consetetur",
&BreakOption{
BreakIndicator: ' ',
Mode: BreakModeIndicatorSensitive,
},
[]string{"Loremipsumdolo", "rsitamet,consetet", "ur"},
},
{
"text with only empty spaces",
" ",
&BreakOption{
BreakIndicator: ' ',
Mode: BreakModeIndicatorSensitive,
},
[]string{" ", " "},
},
}
for _, tt := range splitTextTests {
t.Run(tt.name, func(t *testing.T) {
lines, err := pdf.SplitTextWithOption(tt.in, 100, tt.opts)
if err != nil {
t.Fatal(err)
}
if len(lines) != len(tt.exp) {
t.Fatalf("amount of expected and split lines invalid. Expected: %d, result: %d", len(tt.exp), len(lines))
}
for i, e := range tt.exp {
if e != lines[i] {
t.Fatalf("split text invalid. Expected: '%s', result: '%s'", e, lines[i])
}
}
})
}
} | explode_data.jsonl/60949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1003
} | [
2830,
3393,
20193,
1178,
74238,
1155,
353,
8840,
836,
8,
341,
9859,
1669,
2930,
16451,
741,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
853,
198,
197,
630,
3223,
2940,
1669,
6505,
3675,
32,
19,
23424,
1155,
692,
2405,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestTimePointerIfValid(t *testing.T) {
// invalid sql.NullTime should return nil
sqlNullTime := sql.NullTime{}
timePointer := timePointerIfValid(sqlNullTime)
require.Nil(t, timePointer)
// a valid sql.NullTime should return a time.Time pointer
desiredTime := time.Now()
sqlNullTime = sql.NullTime{
Valid: true,
Time: desiredTime,
}
timePointer = timePointerIfValid(sqlNullTime)
require.Equal(t, &desiredTime, timePointer)
} | explode_data.jsonl/7623 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 159
} | [
2830,
3393,
1462,
9084,
2679,
4088,
1155,
353,
8840,
836,
8,
341,
197,
322,
8318,
5704,
23979,
1462,
1265,
470,
2092,
198,
30633,
3280,
1462,
1669,
5704,
23979,
1462,
16094,
21957,
9084,
1669,
882,
9084,
2679,
4088,
13148,
3280,
1462,
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 TestReleaseExcludePrefixesNestedNetworks(t *testing.T) {
pool, err := prefixpool.New("10.20.4.1/22", "127.0.0.1/22")
require.Nil(t, err)
expectedPrefixes := []string{"10.20.0.0/16", "127.0.0.0/22"}
prefixesToRelease := []string{"10.20.0.1/21", "10.20.2.1/21", "10.20.2.1/16"}
err = pool.ReleaseExcludedPrefixes(prefixesToRelease)
require.Nil(t, err)
require.Equal(t, expectedPrefixes, pool.GetPrefixes())
err = pool.ReleaseExcludedPrefixes(prefixesToRelease)
require.Nil(t, err)
require.Equal(t, expectedPrefixes, pool.GetPrefixes())
} | explode_data.jsonl/45817 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
16077,
95239,
14335,
288,
71986,
12320,
82,
1155,
353,
8840,
836,
8,
341,
85273,
11,
1848,
1669,
9252,
10285,
7121,
445,
16,
15,
13,
17,
15,
13,
19,
13,
16,
14,
17,
17,
497,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAbortTask(t *testing.T) {
Convey("With a task and a build", t, func() {
require.NoError(t, db.ClearCollections(task.Collection, build.Collection, VersionCollection),
"Error clearing task, build, and version collections")
displayName := "testName"
userName := "testUser"
b := &build.Build{
Id: "buildtest",
}
testTask := &task.Task{
Id: "testone",
DisplayName: displayName,
Activated: false,
BuildId: b.Id,
Status: evergreen.TaskStarted,
}
finishedTask := &task.Task{
Id: "another",
DisplayName: displayName,
Activated: false,
BuildId: b.Id,
Status: evergreen.TaskFailed,
}
b.Tasks = []build.TaskCache{
{
Id: testTask.Id,
},
{
Id: finishedTask.Id,
},
{
Id: "dt",
},
}
So(b.Insert(), ShouldBeNil)
So(testTask.Insert(), ShouldBeNil)
So(finishedTask.Insert(), ShouldBeNil)
var err error
Convey("with a task that has started, aborting a task should work", func() {
So(AbortTask(testTask.Id, userName), ShouldBeNil)
testTask, err = task.FindOne(task.ById(testTask.Id))
So(err, ShouldBeNil)
So(testTask.Activated, ShouldEqual, false)
So(testTask.Aborted, ShouldEqual, true)
})
Convey("a task that is finished should error when aborting", func() {
So(AbortTask(finishedTask.Id, userName), ShouldNotBeNil)
})
Convey("a display task should abort its execution tasks", func() {
dt := task.Task{
Id: "dt",
DisplayOnly: true,
ExecutionTasks: []string{"et1", "et2"},
Status: evergreen.TaskStarted,
BuildId: b.Id,
}
So(dt.Insert(), ShouldBeNil)
et1 := task.Task{
Id: "et1",
Status: evergreen.TaskStarted,
BuildId: b.Id,
}
So(et1.Insert(), ShouldBeNil)
et2 := task.Task{
Id: "et2",
Status: evergreen.TaskFailed,
BuildId: b.Id,
}
So(et2.Insert(), ShouldBeNil)
So(AbortTask(dt.Id, userName), ShouldBeNil)
dbTask, err := task.FindOneId(dt.Id)
So(err, ShouldBeNil)
So(dbTask.Aborted, ShouldBeTrue)
dbTask, err = task.FindOneId(et1.Id)
So(err, ShouldBeNil)
So(dbTask.Aborted, ShouldBeTrue)
dbTask, err = task.FindOneId(et2.Id)
So(err, ShouldBeNil)
So(dbTask.Aborted, ShouldBeFalse)
})
})
} | explode_data.jsonl/60433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1065
} | [
2830,
3393,
85891,
6262,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
2354,
264,
3383,
323,
264,
1936,
497,
259,
11,
2915,
368,
341,
197,
17957,
35699,
1155,
11,
2927,
13524,
52730,
17483,
28629,
11,
1936,
28629,
11,
6079,
6482,
13... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteHostErrorDeletingVM(t *testing.T) {
RegisterMockDriver(t)
api := tests.NewMockAPI(t)
h, err := createHost(api, defaultMachineConfig)
if err != nil {
t.Errorf("createHost failed: %v", err)
}
d := &tests.MockDriver{RemoveError: true, T: t}
h.Driver = d
if err := DeleteHost(api); err == nil {
t.Fatal("Expected error deleting host.")
}
} | explode_data.jsonl/4188 | {
"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,
6435,
9296,
1454,
60475,
11187,
1155,
353,
8840,
836,
8,
341,
79096,
11571,
11349,
1155,
340,
54299,
1669,
7032,
7121,
11571,
7082,
1155,
340,
9598,
11,
1848,
1669,
1855,
9296,
24827,
11,
1638,
21605,
2648,
340,
743,
1848,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRollupPredictLinear(t *testing.T) {
f := func(sec, vExpected float64) {
t.Helper()
secs := []*timeseries{{
Values: []float64{sec},
Timestamps: []int64{123},
}}
var me metricsql.MetricExpr
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, secs}
testRollupFunc(t, "predict_linear", args, &me, vExpected)
}
f(0e-3, 30.382432471845043)
f(50e-3, 17.03950235614201)
f(100e-3, 3.696572240438975)
f(200e-3, -22.989287990967092)
} | explode_data.jsonl/23115 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
32355,
454,
53544,
31898,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
2915,
73104,
11,
348,
18896,
2224,
21,
19,
8,
341,
197,
3244,
69282,
741,
197,
197,
53281,
1669,
29838,
15136,
4699,
90,
515,
298,
197,
6227,
25,
257,
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 TestParseGrowth_PercentageGrowth(t *testing.T) {
// Valid linear growth
g, err := tester.ParseGrowth("%100.50")
require.NoError(t, err)
assert.IsType(t, new(tester.PercentageGrowth), g)
assert.Equal(t, 100.50, g.(*tester.PercentageGrowth).Increase)
// Invalid value
_, err = tester.ParseGrowth("%abcdef")
assert.EqualError(t, err, "strconv.ParseFloat: parsing \"abcdef\": invalid syntax")
} | explode_data.jsonl/66517 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
14463,
38,
19089,
53918,
16133,
38,
19089,
1155,
353,
8840,
836,
8,
341,
197,
322,
7818,
13482,
6513,
198,
3174,
11,
1848,
1669,
37111,
8937,
38,
19089,
4430,
16,
15,
15,
13,
20,
15,
1138,
17957,
35699,
1155,
11,
1848,
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 TestWriterNoTimestamp(t *testing.T) {
tests := []struct {
data string
name string
exp string
}{
{
data: "foo",
name: "name",
exp: "3 name\nfoo\n",
},
{
data: "foo\n",
name: "",
exp: "4\nfoo\n",
},
}
for _, test := range tests {
var buf bytes.Buffer
w := NewWriter(&buf)
w.NoTimestamp = true
var tm time.Time
_, err := w.Write([]byte(test.data), tm, test.name)
assert.Nil(t, err)
got := buf.String()
assert.Equal(t, test.exp, got)
rbuf := bufio.NewReader(bytes.NewBufferString(got))
r := NewReader(rbuf)
r.NoTimestamp = true
ok := r.ReadNextData()
assert.True(t, ok)
assert.Equal(t, string(r.Data), test.data)
assert.Equal(t, r.Name, test.name)
}
} | explode_data.jsonl/44793 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 342
} | [
2830,
3393,
6492,
2753,
20812,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
8924,
914,
198,
197,
11609,
914,
198,
197,
48558,
220,
914,
198,
197,
59403,
197,
197,
515,
298,
8924,
25,
330,
7975,
756,
298,
11609,
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 Test_randomString(t *testing.T) {
type args struct {
n int
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
{
name: "10 characters",
args: args{
n: 10,
},
},
{
name: "5 characters",
args: args{
n: 5,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
regexAlphaNumeric := regexp.MustCompile(fmt.Sprintf("^([0-9a-zA-Z]+){%d}", tt.args.n))
got := randomString(tt.args.n)
if !regexAlphaNumeric.MatchString(got) {
t.Fatalf("Expected %d character alpha numeric string, got '%s'", tt.args.n, got)
}
})
}
} | explode_data.jsonl/58085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 300
} | [
2830,
3393,
22644,
703,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
9038,
526,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
59403,
197,
197,
322,
5343,
25,
2691,
1273,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDivide(t *testing.T) {
s, err := parseFile("src/parse/asp/test_data/interpreter/divide.build")
assert.NoError(t, err)
assert.EqualValues(t, 0, s.Lookup("i"))
assert.EqualValues(t, 7, s.Lookup("j"))
assert.EqualValues(t, -2, s.Lookup("k"))
} | explode_data.jsonl/81091 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
12509,
577,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
4715,
1703,
445,
3548,
14,
6400,
14,
13367,
12697,
1769,
14,
90554,
22013,
577,
13239,
1138,
6948,
35699,
1155,
11,
1848,
340,
6948,
12808,
6227,
1155,
11,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIDService(t *testing.T) {
oldTTL := pstore.RecentlyConnectedAddrTTL
pstore.RecentlyConnectedAddrTTL = time.Second
defer func() {
pstore.RecentlyConnectedAddrTTL = oldTTL
}()
N := 3
for i := 0; i < N; i++ {
subtestIDService(t)
}
} | explode_data.jsonl/59577 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
915,
1860,
1155,
353,
8840,
836,
8,
341,
61828,
51,
13470,
1669,
281,
4314,
2817,
1168,
398,
21146,
13986,
51,
13470,
198,
3223,
4314,
2817,
1168,
398,
21146,
13986,
51,
13470,
284,
882,
32435,
198,
16867,
2915,
368,
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 |
func TestRebuildIndexAlwaysFull(t *testing.T) {
indexFull := repository.IndexFull
defer func() {
repository.IndexFull = indexFull
}()
repository.IndexFull = func(*repository.Index, bool) bool { return true }
testRebuildIndex(t, nil)
} | explode_data.jsonl/43565 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
693,
5834,
1552,
37095,
9432,
1155,
353,
8840,
836,
8,
341,
26327,
9432,
1669,
12542,
18338,
9432,
198,
16867,
2915,
368,
341,
197,
17200,
3099,
18338,
9432,
284,
1922,
9432,
198,
197,
69826,
17200,
3099,
18338,
9432,
284,
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 |
func TestGoutils(t *testing.T) {
tests := map[string]string{
`{{abbrev 5 "hello world"}}`: "he...",
`{{abbrevboth 5 10 "1234 5678 9123"}}`: "...5678...",
`{{nospace "h e l l o "}}`: "hello",
`{{untitle "First Try"}}`: "first try", //https://youtu.be/44-RsrF_V_w
`{{initials "First Try"}}`: "FT",
`{{wrap 5 "Hello World"}}`: "Hello\nWorld",
`{{wrapWith 5 "\t" "Hello World"}}`: "Hello\tWorld",
}
for k, v := range tests {
t.Log(k)
if err := runt(k, v); err != nil {
t.Errorf("Error on tpl %q: %s", k, err)
}
}
} | explode_data.jsonl/63883 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
38,
411,
8669,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
30953,
515,
197,
197,
63,
2979,
44272,
220,
20,
330,
14990,
1879,
30975,
44622,
1843,
330,
383,
72903,
197,
197,
63,
2979,
44272,
21028,
220,
20,
220,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestQuery(t *testing.T) {
api := &testGraphQLAPI{}
client := NewClient(api, WithSubscriberID(testDeviceID))
res, err := client.Post(graphql.PostRequest{
Query: "query ",
})
if err != nil {
t.Fatalf("Post error: %v", err)
}
if res == nil {
t.Fatal("Post returns nil")
}
if _, ok := api.GetPostedHeader()["x-amz-subscriber-id"]; ok {
t.Fatalf("GetPostedHeader error: %+v", api)
}
raw, ok := res.Data.(json.RawMessage)
if !ok {
t.Fatalf("Data error: %+v", res.Data)
}
if !bytes.Equal(raw, testData) {
t.Fatalf("Data error: %+v", res.Data)
}
if res.Errors != testResponse.Errors {
t.Fatalf("Errors error: %+v", *res.Errors)
}
if res.Extensions != testResponse.Extensions {
t.Fatalf("Extensions error: %+v", *res.Extensions)
}
} | explode_data.jsonl/26618 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 326
} | [
2830,
3393,
2859,
1155,
353,
8840,
836,
8,
341,
54299,
1669,
609,
1944,
88637,
7082,
16094,
25291,
1669,
1532,
2959,
24827,
11,
3085,
40236,
915,
8623,
6985,
915,
1171,
10202,
11,
1848,
1669,
2943,
23442,
24312,
1470,
23442,
1900,
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... | 8 |
func TestEncodeGeohash(t *testing.T) {
var tests = []encodeTest{
{39.55078125, -76.640625, "dr12zzzzzzzz"},
{39.5507, -76.6406, "dr18bpbp88fe"},
{39.55, -76.64, "dr18bpb7qw65"},
{39, -76, "dqcvyedrrwut"},
}
for _, test := range tests {
geohash := EncodeGeohash(test.lat, test.lng, 12)
if test.geohash != geohash {
t.Errorf("expectd %s, got %s", test.geohash, geohash)
}
}
for prec := range []int{3, 4, 5, 6, 7, 8} {
for _, test := range tests {
geohash := EncodeGeohash(test.lat, test.lng, prec)
if len(geohash) != prec {
t.Errorf("expected len %d, got %d", prec, len(geohash))
}
if test.geohash[0:prec] != geohash {
t.Errorf("expectd %s, got %s", test.geohash, geohash)
}
}
}
} | explode_data.jsonl/4143 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 370
} | [
2830,
3393,
32535,
9499,
2267,
988,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
6180,
2271,
515,
197,
197,
90,
18,
24,
13,
20,
20,
15,
22,
23,
16,
17,
20,
11,
481,
22,
21,
13,
21,
19,
15,
21,
17,
20,
11,
330,
3612,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestContainerStart(t *testing.T) {
expectedURL := "/containers/container_id/start"
client := &Client{
transport: newMockClient(nil, func(req *http.Request) (*http.Response, error) {
if !strings.HasPrefix(req.URL.Path, expectedURL) {
return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
}
// we're not expecting any payload, but if one is supplied, check it is valid.
if req.Header.Get("Content-Type") == "application/json" {
var startConfig interface{}
if err := json.NewDecoder(req.Body).Decode(&startConfig); err != nil {
return nil, fmt.Errorf("Unable to parse json: %s", err)
}
}
checkpoint := req.URL.Query().Get("checkpoint")
if checkpoint != "checkpoint_id" {
return nil, fmt.Errorf("checkpoint not set in URL query properly. Expected 'checkpoint_id', got %s", checkpoint)
}
return &http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(bytes.NewReader([]byte(""))),
}, nil
}),
}
err := client.ContainerStart(context.Background(), "container_id", types.ContainerStartOptions{CheckpointID: "checkpoint_id"})
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/70922 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 442
} | [
2830,
3393,
4502,
3479,
1155,
353,
8840,
836,
8,
341,
42400,
3144,
1669,
3521,
39399,
83897,
842,
69976,
698,
25291,
1669,
609,
2959,
515,
197,
197,
26445,
25,
501,
11571,
2959,
27907,
11,
2915,
6881,
353,
1254,
9659,
8,
4609,
1254,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLikeOperators(t *testing.T) {
defer leaktest.AfterTest(t)()
for _, tc := range []struct {
pattern string
negate bool
tups tuples
expected tuples
}{
{
pattern: "def",
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"def"}},
},
{
pattern: "def",
negate: true,
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"abc"}, {"ghi"}},
},
{
pattern: "de%",
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"def"}},
},
{
pattern: "de%",
negate: true,
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"abc"}, {"ghi"}},
},
{
pattern: "%ef",
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"def"}},
},
{
pattern: "%ef",
negate: true,
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"abc"}, {"ghi"}},
},
{
pattern: "_e_",
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"def"}},
},
{
pattern: "_e_",
negate: true,
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"abc"}, {"ghi"}},
},
{
pattern: "%e%",
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"def"}},
},
{
pattern: "%e%",
negate: true,
tups: tuples{{"abc"}, {"def"}, {"ghi"}},
expected: tuples{{"abc"}, {"ghi"}},
},
} {
runTests(
t, []tuples{tc.tups}, tc.expected, orderedVerifier,
func(input []Operator) (Operator, error) {
ctx := tree.MakeTestingEvalContext(cluster.MakeTestingClusterSettings())
return GetLikeOperator(&ctx, input[0], 0, tc.pattern, tc.negate)
})
}
} | explode_data.jsonl/28118 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 826
} | [
2830,
3393,
12949,
77760,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
2023,
8358,
17130,
1669,
2088,
3056,
1235,
341,
197,
3223,
3227,
220,
914,
198,
197,
9038,
791,
349,
256,
1807,
198,
197,
3244,
860... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransportIgnores408(t *testing.T) {
// Not parallel. Relies on mutating the log package's global Output.
defer log.SetOutput(log.Writer())
var logout bytes.Buffer
log.SetOutput(&logout)
defer afterTest(t)
const target = "backend:443"
cst := newClientServerTest(t, h1Mode, HandlerFunc(func(w ResponseWriter, r *Request) {
nc, _, err := w.(Hijacker).Hijack()
if err != nil {
t.Error(err)
return
}
defer nc.Close()
nc.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok"))
nc.Write([]byte("HTTP/1.1 408 bye\r\n")) // changing 408 to 409 makes test fail
}))
defer cst.close()
req, err := NewRequest("GET", cst.ts.URL, nil)
if err != nil {
t.Fatal(err)
}
res, err := cst.c.Do(req)
if err != nil {
t.Fatal(err)
}
slurp, err := ioutil.ReadAll(res.Body)
if err != nil {
t.Fatal(err)
}
if err != nil {
t.Fatal(err)
}
if string(slurp) != "ok" {
t.Fatalf("got %q; want ok", slurp)
}
t0 := time.Now()
for i := 0; i < 50; i++ {
time.Sleep(time.Duration(i) * 5 * time.Millisecond)
if cst.tr.IdleConnKeyCountForTesting() == 0 {
if got := logout.String(); got != "" {
t.Fatalf("expected no log output; got: %s", got)
}
return
}
}
t.Fatalf("timeout after %v waiting for Transport connections to die off", time.Since(t0))
} | explode_data.jsonl/14184 | {
"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,
27560,
40,
70,
2152,
416,
19,
15,
23,
1155,
353,
8840,
836,
8,
341,
197,
322,
2806,
15279,
13,
6512,
550,
389,
96518,
279,
1487,
6328,
594,
3644,
9258,
624,
16867,
1487,
4202,
5097,
12531,
47838,
12367,
2405,
22359,
5820,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindSubmatchIndex(t *testing.T) {
for _, test := range findTests {
testFindSubmatchIndex(&test, MustCompile(test.pat).FindSubmatchIndex([]byte(test.text)), t)
}
} | explode_data.jsonl/55093 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
9885,
3136,
6347,
1552,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
1477,
18200,
341,
197,
18185,
9885,
3136,
6347,
1552,
2099,
1944,
11,
15465,
46126,
8623,
96534,
568,
9885,
3136,
6347,
1552,
10556,
3782,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) {
var args = Arguments([]interface{}{"string", AnythingOfType("string"), true})
var count int
var diff string
diff, count = args.Diff([]interface{}{"string", 123, true})
assert.Equal(t, 1, count)
assert.Contains(t, diff, `string != type int - %!s(int=123)`)
} | explode_data.jsonl/8619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
87581,
2831,
1557,
3092,
62,
2354,
77303,
34696,
9171,
1400,
14277,
1155,
353,
8840,
836,
8,
8022,
2405,
2827,
284,
27702,
10556,
4970,
6257,
4913,
917,
497,
40933,
34696,
445,
917,
3975,
830,
35099,
2405,
1760,
526,
319,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWSSubscriptionHandling(t *testing.T) {
t.Parallel()
pressXToJSON := []byte(`{
"method": "SUBSCRIBE",
"params": [
"btcusdt@aggTrade",
"btcusdt@depth"
],
"id": 1
}`)
err := b.wsHandleData(pressXToJSON)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76681 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
54,
1220,
392,
12124,
38606,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
1873,
55,
1249,
5370,
1669,
3056,
3782,
5809,
515,
220,
330,
4393,
788,
330,
29038,
64640,
756,
220,
330,
3519,
788,
2278,
262,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPodFailedSchedulingMultipleTimesDoesNotBlockNewerPod(t *testing.T) {
c := clock.NewFakeClock(time.Now())
q := NewTestQueue(context.Background(), newDefaultQueueSort(), WithClock(c))
// Add an unschedulable pod to a priority queue.
// This makes a situation that the pod was tried to schedule
// and had been determined unschedulable so far
unschedulablePod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test-pod-unscheduled",
Namespace: "ns1",
UID: "tp001",
},
Spec: v1.PodSpec{
Priority: &highPriority,
},
Status: v1.PodStatus{
NominatedNodeName: "node1",
},
}
// Update pod condition to unschedulable.
podutil.UpdatePodCondition(&unschedulablePod.Status, &v1.PodCondition{
Type: v1.PodScheduled,
Status: v1.ConditionFalse,
Reason: v1.PodReasonUnschedulable,
Message: "fake scheduling failure",
})
// Put in the unschedulable queue
q.AddUnschedulableIfNotPresent(newQueuedPodInfoForLookup(&unschedulablePod), q.SchedulingCycle())
// Move clock to make the unschedulable pods complete backoff.
c.Step(DefaultPodInitialBackoffDuration + time.Second)
// Move all unschedulable pods to the active queue.
q.MoveAllToActiveOrBackoffQueue(UnschedulableTimeout, nil)
// Simulate a pod being popped by the scheduler,
// At this time, unschedulable pod should be popped.
p1, err := q.Pop()
if err != nil {
t.Errorf("Error while popping the head of the queue: %v", err)
}
if p1.Pod != &unschedulablePod {
t.Errorf("Expected that test-pod-unscheduled was popped, got %v", p1.Pod.Name)
}
// Assume newer pod was added just after unschedulable pod
// being popped and before being pushed back to the queue.
newerPod := v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "test-newer-pod",
Namespace: "ns1",
UID: "tp002",
CreationTimestamp: metav1.Now(),
},
Spec: v1.PodSpec{
Priority: &highPriority,
},
Status: v1.PodStatus{
NominatedNodeName: "node1",
},
}
q.Add(&newerPod)
// And then unschedulablePodInfo was determined as unschedulable AGAIN.
podutil.UpdatePodCondition(&unschedulablePod.Status, &v1.PodCondition{
Type: v1.PodScheduled,
Status: v1.ConditionFalse,
Reason: v1.PodReasonUnschedulable,
Message: "fake scheduling failure",
})
// And then, put unschedulable pod to the unschedulable queue
q.AddUnschedulableIfNotPresent(newQueuedPodInfoForLookup(&unschedulablePod), q.SchedulingCycle())
// Move clock to make the unschedulable pods complete backoff.
c.Step(DefaultPodInitialBackoffDuration + time.Second)
// Move all unschedulable pods to the active queue.
q.MoveAllToActiveOrBackoffQueue(UnschedulableTimeout, nil)
// At this time, newerPod should be popped
// because it is the oldest tried pod.
p2, err2 := q.Pop()
if err2 != nil {
t.Errorf("Error while popping the head of the queue: %v", err2)
}
if p2.Pod != &newerPod {
t.Errorf("Expected that test-newer-pod was popped, got %v", p2.Pod.Name)
}
} | explode_data.jsonl/68199 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1140
} | [
2830,
3393,
23527,
9408,
50,
44356,
32089,
18889,
21468,
2623,
4713,
3564,
261,
23527,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
8866,
7121,
52317,
26104,
9730,
13244,
2398,
18534,
1669,
1532,
2271,
7554,
5378,
19047,
1507,
501,
3675,
755... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAnd(t *testing.T) {
t.Parallel()
for i, c := range []struct {
stmt stmt.Statement
sql string
sqlIndent string
values []interface{}
}{
// 0
{
stmt.NewAnd(
stmt.NewColumn("foo").NotEq(stmt.NewVal(100)),
),
`"foo" != ?`,
`> "foo" != ?
`,
[]interface{}{
100,
},
},
// 1
{
stmt.NewAnd(
stmt.NewColumn("foo").NotEq(stmt.NewVal(100)),
stmt.NewColumn("bar").Eq(stmt.NewVal(200)),
),
`"foo" != ? AND "bar" = ?`,
`> "foo" != ?
> AND "bar" = ?
`,
[]interface{}{
100,
200,
},
},
// 2
{
stmt.NewAnd(
stmt.NewColumn("foo").NotEq(stmt.NewVal(100)),
stmt.NewColumn("bar").Eq(stmt.NewVal(200)),
stmt.NewColumn("baz").Like(stmt.NewVal("abc")),
),
`"foo" != ? AND "bar" = ? AND "baz" LIKE ?`,
`> "foo" != ?
> AND "bar" = ?
> AND "baz" LIKE ?
`,
[]interface{}{
100,
200,
"abc",
},
},
// 3
{
stmt.NewAnd(
stmt.NewAnd(
stmt.NewColumn("foo").NotEq(stmt.NewVal(100)),
stmt.NewColumn("bar").Eq(stmt.NewVal(200)),
stmt.NewColumn("baz").Like(stmt.NewVal("abc")),
),
stmt.NewColumn("foo").Between(
stmt.NewVal(300),
stmt.NewVal(400),
),
),
`("foo" != ? AND "bar" = ? AND "baz" LIKE ?) AND "foo" BETWEEN ? AND ?`,
`> (
> "foo" != ?
> AND "bar" = ?
> AND "baz" LIKE ?
> )
> AND "foo" BETWEEN ? AND ?
`,
[]interface{}{
100,
200,
"abc",
300,
400,
},
},
} {
c := c
t.Run(fmt.Sprintf("%d Build", i), func(t *testing.T) {
t.Parallel()
sql, values := b.Build(c.stmt)
if sql != c.sql {
t.Error(diff.SQL(sql, c.sql))
}
if !reflect.DeepEqual(values, c.values) {
t.Error(diff.Values(values, c.values))
}
})
t.Run(fmt.Sprintf("%d BuildIndent", i), func(t *testing.T) {
t.Parallel()
sql, values := bi.Build(c.stmt)
if sql != c.sqlIndent {
t.Error(diff.SQL(sql, c.sqlIndent))
}
if !reflect.DeepEqual(values, c.values) {
t.Error(diff.Values(values, c.values))
}
})
}
} | explode_data.jsonl/370 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1106
} | [
2830,
3393,
3036,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2023,
600,
11,
272,
1669,
2088,
3056,
1235,
341,
197,
55822,
414,
20020,
70215,
198,
197,
30633,
981,
914,
198,
197,
30633,
42729,
914,
198,
197,
45939,
262,
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... | 3 |
func TestSettingsFlag(t *testing.T) {
tests := []struct {
in []string
expected map[string]interface{}
}{
{nil, nil},
{[]string{"a=1"}, map[string]interface{}{"a": uint64(1)}},
{[]string{"a=1", "b=false"}, map[string]interface{}{"a": uint64(1), "b": false}},
{[]string{"a=1", "b"}, map[string]interface{}{"a": uint64(1), "b": true}},
{[]string{"a=1", "c=${a}"}, map[string]interface{}{"a": uint64(1), "c": uint64(1)}},
}
for _, test := range tests {
test := test
name := strings.Join(test.in, ",")
t.Run(name, func(t *testing.T) {
config := NewConfig()
f := NewSettingsFlag(config)
fs := flag.NewFlagSet("test", flag.ContinueOnError)
fs.Var(f, "s", "message")
goflagUsage, _ := withStderr(fs.PrintDefaults)
goflagExpectedUsage := " -s value\n \tmessage\n"
cmd := cobra.Command{}
cmd.PersistentFlags().AddGoFlag(fs.Lookup("s"))
cobraUsage := cmd.LocalFlags().FlagUsages()
cobraExpectedUsage := " -s, --s setting=value message\n"
for _, in := range test.in {
err := f.Set(in)
if err != nil {
t.Error(err)
}
}
var result map[string]interface{}
err := config.Unpack(&result)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, goflagExpectedUsage, goflagUsage)
assert.Equal(t, cobraExpectedUsage, cobraUsage)
assert.Equal(t, test.expected, result)
})
}
} | explode_data.jsonl/32977 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 611
} | [
2830,
3393,
6086,
12135,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
981,
3056,
917,
198,
197,
42400,
2415,
14032,
31344,
16094,
197,
59403,
197,
197,
90,
8385,
11,
2092,
1583,
197,
197,
90,
1294,
917,
4913... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDeleteVolume(t *testing.T) {
tests := map[string]*struct {
volumeName string
namespace string
fakeHandler utiltesting.FakeHandler
err error
addr string
}{
"StatusOK": {
volumeName: "qwewretrytu",
fakeHandler: utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: "Volume 'qwewretrytu' deleted Successfully",
T: t,
},
err: nil,
addr: "MAPI_ADDR",
},
"VolumeNameMissing": {
volumeName: "",
fakeHandler: utiltesting.FakeHandler{
StatusCode: 400,
ResponseBody: "Volume name is missing",
T: t,
},
err: fmt.Errorf("Server status error: %v", http.StatusText(400)),
addr: "MAPI_ADDR",
},
"VolumeNotPresent": {
volumeName: "volume",
fakeHandler: utiltesting.FakeHandler{
StatusCode: 404,
ResponseBody: "Volume 'volume' not found",
T: t,
},
err: fmt.Errorf("Server status error: %v", http.StatusText(404)),
addr: "MAPI_ADDR",
},
"DeleteAppNameSpaceVolume": {
volumeName: "testvol",
namespace: "app",
fakeHandler: utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: "Volume 'testvol' deleted Successfully",
T: t,
},
err: nil,
addr: "MAPI_ADDR",
},
"DeleteWrongNameSpaceVolume": {
volumeName: "testvol",
namespace: "",
fakeHandler: utiltesting.FakeHandler{
StatusCode: 404,
ResponseBody: string("Volume 'testvol' not found"),
T: t,
},
err: fmt.Errorf("Server status error: %v", http.StatusText(404)),
addr: "MAPI_ADDR",
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
server := httptest.NewServer(&tt.fakeHandler)
os.Setenv(tt.addr, server.URL)
defer os.Unsetenv(tt.addr)
defer server.Close()
got := DeleteVolume(tt.volumeName, tt.namespace)
if !reflect.DeepEqual(got, tt.err) {
t.Fatalf("DeleteVolume(%v) => got %v, want %v ", tt.volumeName, got, tt.err)
}
})
}
} | explode_data.jsonl/78174 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 912
} | [
2830,
3393,
6435,
18902,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
8465,
1235,
341,
197,
5195,
4661,
675,
220,
914,
198,
197,
56623,
256,
914,
198,
197,
1166,
726,
3050,
4094,
8840,
991,
726,
3050,
198,
197,
9859,
260,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileRevisionTargetDoesNotExist(t *testing.T) {
var reconciler *Reconciler
ctx, _, _, _, cancel := newTestSetup(t, func(r *Reconciler) {
reconciler = r
})
defer cancel()
r := Route("test-ns", "test-route", WithRouteLabel(map[string]string{"route": "test-route"}))
rev := newTestRevision(r.Namespace, "revision")
tcInvalidRev := traffic.Config{Targets: map[string]traffic.RevisionTargets{
traffic.DefaultTarget: {{
TrafficTarget: v1.TrafficTarget{
RevisionName: "invalid-revision",
Percent: ptr.Int64(100),
},
Active: true,
}}}}
ctx = config.ToContext(ctx, &config.Config{
GC: &gc.Config{
StaleRevisionLastpinnedDebounce: time.Minute,
},
})
fakeservingclient.Get(ctx).ServingV1().Revisions(r.Namespace).Create(rev)
fakerevisioninformer.Get(ctx).Informer().GetIndexer().Add(rev)
// Try reconciling target revisions for a revision that does not exist. No err should be returned
if err := reconciler.reconcileTargetRevisions(ctx, &tcInvalidRev, r); err != nil {
t.Fatal("Error reconciling target revisions:", err)
}
} | explode_data.jsonl/64525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 408
} | [
2830,
3393,
693,
40446,
457,
33602,
6397,
21468,
45535,
1155,
353,
8840,
836,
8,
341,
2405,
31445,
5769,
353,
693,
40446,
5769,
198,
20985,
11,
8358,
8358,
8358,
9121,
1669,
501,
2271,
21821,
1155,
11,
2915,
2601,
353,
693,
40446,
5769,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAsyncAPIUnpairApplicationWithAppWebhook(stdT *testing.T) {
t := testingx.NewT(stdT)
t.Run("TestAsyncAPIUnpairApplicationWithAppWebhook", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
appName := fmt.Sprintf("app-async-unpair-%s", time.Now().Format("060102150405"))
appInput := graphql.ApplicationRegisterInput{
Name: appName,
ProviderName: ptr.String("compass"),
Webhooks: []*graphql.WebhookInput{testPkg.BuildMockedWebhook(testConfig.ExternalServicesMockBaseURL, graphql.WebhookTypeUnpairApplication)},
}
t.Log(fmt.Sprintf("Registering application: %s", appName))
appInputGQL, err := testctx.Tc.Graphqlizer.ApplicationRegisterInputToGQL(appInput)
require.NoError(t, err)
registerRequest := fixtures.FixRegisterApplicationRequest(appInputGQL)
app := graphql.ApplicationExt{}
err = testctx.Tc.RunOperationWithCustomTenant(ctx, certSecuredGraphQLClient, testConfig.DefaultTestTenant, registerRequest, &app)
defer fixtures.CleanupApplication(t, ctx, certSecuredGraphQLClient, testConfig.DefaultTestTenant, &app)
require.NoError(t, err)
require.Equal(t, app.Status.Condition, graphql.ApplicationStatusConditionInitial)
require.Len(t, app.Webhooks, 1)
nearCreationTime := time.Now().Add(-1 * time.Second)
triggerAsyncUnpair(t, ctx, app, nearCreationTime, app.Webhooks[0].ID, certSecuredGraphQLClient)
})
} | explode_data.jsonl/57892 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 502
} | [
2830,
3393,
6525,
7082,
1806,
12670,
4988,
2354,
2164,
5981,
20873,
5194,
51,
353,
8840,
836,
8,
341,
3244,
1669,
7497,
87,
7121,
51,
5194,
51,
340,
3244,
16708,
445,
2271,
6525,
7082,
1806,
12670,
4988,
2354,
2164,
5981,
20873,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSame(t *testing.T) {
t.Parallel()
s1 := []float64{1, 2, 3, 4}
s2 := []float64{1, 2, 3, 4}
if !Same(s1, s2) {
t.Errorf("Equal slices returned as unequal")
}
s2 = []float64{1, 2, 3, 4 + 1e-14}
if Same(s1, s2) {
t.Errorf("Unequal slices returned as equal")
}
if Same(s1, []float64{}) {
t.Errorf("Unequal slice lengths returned as equal")
}
s1 = []float64{1, 2, math.NaN(), 4}
s2 = []float64{1, 2, math.NaN(), 4}
if !Same(s1, s2) {
t.Errorf("Slices with matching NaN values returned as unequal")
}
s1 = []float64{1, 2, math.NaN(), 4}
s2 = []float64{1, math.NaN(), 3, 4}
if Same(s1, s2) {
t.Errorf("Slices with unmatching NaN values returned as equal")
}
} | explode_data.jsonl/1237 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
19198,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
16,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
532,
1903,
17,
1669,
3056,
3649,
21,
19,
90,
16,
11,
220,
17,
11,
220,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestOpen_FileTooSmall(t *testing.T) {
path := tempfile()
defer os.RemoveAll(path)
db, err := bolt.Open(path, 0666, nil)
if err != nil {
t.Fatal(err)
}
pageSize := int64(db.Info().PageSize)
if err = db.Close(); err != nil {
t.Fatal(err)
}
// corrupt the database
if err = os.Truncate(path, pageSize); err != nil {
t.Fatal(err)
}
db, err = bolt.Open(path, 0666, nil)
if err == nil || err.Error() != "file size too small" {
t.Fatalf("unexpected error: %s", err)
}
} | explode_data.jsonl/27467 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
5002,
34061,
31246,
25307,
1155,
353,
8840,
836,
8,
341,
26781,
1669,
54819,
741,
16867,
2643,
84427,
5581,
692,
20939,
11,
1848,
1669,
31842,
12953,
5581,
11,
220,
15,
21,
21,
21,
11,
2092,
340,
743,
1848,
961,
2092,
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... | 6 |
func TestPrecompiledModExpOOG(t *testing.T) {
modexpTests, err := loadJson("modexp")
if err != nil {
t.Fatal(err)
}
for _, test := range modexpTests {
testPrecompiledOOG("05", test, t)
}
} | explode_data.jsonl/53910 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
4703,
50845,
4459,
8033,
46,
12223,
1155,
353,
8840,
836,
8,
341,
42228,
4580,
18200,
11,
1848,
1669,
2795,
5014,
445,
2593,
4580,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
2023,
8358,
1273,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestCtxInit(t *testing.T) {
var ctx RequestCtx
var logger customLogger
globalConnID = 0x123456
ctx.Init(&ctx.Request, zeroTCPAddr, &logger)
ip := ctx.RemoteIP()
if !ip.IsUnspecified() {
t.Fatalf("unexpected ip for bare RequestCtx: %q. Expected 0.0.0.0", ip)
}
ctx.Logger().Printf("foo bar %d", 10)
expectedLog := "#0012345700000000 - 0.0.0.0:0<->0.0.0.0:0 - GET http:/// - foo bar 10\n"
if logger.out != expectedLog {
t.Fatalf("Unexpected log output: %q. Expected %q", logger.out, expectedLog)
}
} | explode_data.jsonl/73297 | {
"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,
1900,
23684,
3803,
1155,
353,
8840,
836,
8,
341,
2405,
5635,
6145,
23684,
198,
2405,
5925,
2526,
7395,
198,
18842,
9701,
915,
284,
220,
15,
87,
16,
17,
18,
19,
20,
21,
198,
20985,
26849,
2099,
3773,
9659,
11,
7168,
49896... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFuzzAuthorization(t *testing.T) {
framework.NewTest(t).
Features("security.fuzz.authorization").
Run(func(t framework.TestContext) {
ns := "fuzz-authz"
namespace.ClaimOrFail(t, t, ns)
t.ConfigIstio().YAML(ns, authzDenyPolicy).ApplyOrFail(t)
t.Logf("authorization policy applied")
deploy(t, dotdotpwn, ns, "fuzzers/dotdotpwn/dotdotpwn.yaml")
t.ConfigIstio().File(ns, "fuzzers/wfuzz/wordlist.yaml").ApplyOrFail(t)
deploy(t, wfuzz, ns, "fuzzers/wfuzz/wfuzz.yaml")
deploy(t, apacheServer, ns, "backends/apache/apache.yaml")
deploy(t, nginxServer, ns, "backends/nginx/nginx.yaml")
deploy(t, tomcatServer, ns, "backends/tomcat/tomcat.yaml")
waitService(t, apacheServer, ns)
waitService(t, nginxServer, ns)
waitService(t, tomcatServer, ns)
for _, fuzzer := range []string{dotdotpwn, wfuzz} {
t.NewSubTest(fuzzer).Run(func(t framework.TestContext) {
for _, target := range []string{apacheServer, nginxServer, tomcatServer} {
t.NewSubTest(target).Run(func(t framework.TestContext) {
runFuzzer(t, fuzzer, ns, target)
})
}
})
}
})
} | explode_data.jsonl/66766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
37,
8889,
18124,
1155,
353,
8840,
836,
8,
341,
1166,
5794,
7121,
2271,
1155,
4292,
197,
197,
21336,
445,
17039,
833,
8889,
63988,
38609,
197,
85952,
18552,
1155,
12626,
8787,
1972,
8,
341,
298,
84041,
1669,
330,
69,
8889,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExamples(t *testing.T) {
tests := []test{
{
name: "HelloWorld",
args: exampleToArgs(t, exampleHelloWorld),
out: "Hello, world! 3.141592653589793\n",
},
{
name: "Average",
args: exampleToArgs(t, exampleAverage),
in: "a b 400\nc d 200\ne f 200\ng h 200",
out: "250\n",
},
{
name: "Milliseconds",
args: exampleToArgs(t, exampleMilliseconds),
in: "1 GET 3.14159\n2 HEAD 4.0\n3 GET 1.0\n4 GET 100.23\n",
out: "3142ms\n4000ms\n1000ms\n100230ms\n",
},
{
name: "Frequencies",
args: exampleToArgs(t, exampleFrequencies),
in: "The foo bar foo bar\nthe the the\nend.\n",
out: "the 4\nfoo 2\nbar 2\nend. 1\n",
},
}
runTests(t, tests)
} | explode_data.jsonl/46852 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
40381,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1944,
515,
197,
197,
515,
298,
11609,
25,
330,
9707,
10134,
756,
298,
31215,
25,
3110,
1249,
4117,
1155,
11,
3110,
9707,
10134,
1326,
298,
13967,
25,
220,
330,
9707,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEmptyMdStatProcFile1(t *testing.T) {
filename := makeFakeMDStatFile([]byte(mdStatFileEmpty))
defer os.Remove(filename)
k := MdstatConf{
FileName: filename,
}
acc := testutil.Accumulator{}
err := k.Gather(&acc)
assert.NoError(t, err)
} | explode_data.jsonl/73539 | {
"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,
3522,
72529,
15878,
24508,
1703,
16,
1155,
353,
8840,
836,
8,
341,
66434,
1669,
1281,
52317,
6076,
15878,
1703,
10556,
3782,
48645,
15878,
1703,
3522,
1171,
16867,
2643,
13270,
10961,
692,
16463,
1669,
53110,
9878,
15578,
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 TestIDPIDPInitiatedNewSession(t *testing.T) {
test := NewIdentifyProviderTest(t)
test.IDP.SessionProvider = &mockSessionProvider{
GetSessionFunc: func(w http.ResponseWriter, r *http.Request, req *IdpAuthnRequest) *Session {
fmt.Fprintf(w, "RelayState: %s", req.RelayState)
return nil
},
}
w := httptest.NewRecorder()
r, _ := http.NewRequest("GET", "https://idp.example.com/services/sp/whoami", nil)
test.IDP.ServeIDPInitiated(w, r, test.SP.MetadataURL.String(), "ThisIsTheRelayState")
assert.Check(t, is.Equal(200, w.Code))
assert.Check(t, is.Equal("RelayState: ThisIsTheRelayState", string(w.Body.Bytes())))
} | explode_data.jsonl/19833 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
915,
33751,
47,
3803,
10029,
3564,
5283,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
1532,
28301,
1437,
5179,
2271,
1155,
340,
18185,
9910,
47,
20674,
5179,
284,
609,
16712,
5283,
5179,
515,
197,
37654,
5283,
9626,
25,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTriggerAnnotateUserInfo(t *testing.T) {
const (
u1 = "oveja@knative.dev"
u2 = "cabra@knative.dev"
u3 = "vaca@knative.dev"
)
withUserAnns := func(creator, updater string, t *Trigger) *Trigger {
a := t.GetAnnotations()
if a == nil {
a = map[string]string{}
defer t.SetAnnotations(a)
}
a[eventing.CreatorAnnotation] = creator
a[eventing.UpdaterAnnotation] = updater
return t
}
tests := []struct {
name string
user string
this *Trigger
prev *Trigger
wantedAnns map[string]string
}{
{
name: "create new trigger",
user: u1,
this: &Trigger{},
prev: nil,
wantedAnns: map[string]string{
eventing.CreatorAnnotation: u1,
eventing.UpdaterAnnotation: u1,
},
}, {
name: "update trigger which has no annotations without diff",
user: u1,
this: &Trigger{Spec: TriggerSpec{Broker: defaultBroker, Filter: defaultTriggerFilter}},
prev: &Trigger{Spec: TriggerSpec{Broker: defaultBroker, Filter: defaultTriggerFilter}},
wantedAnns: map[string]string{},
}, {
name: "update trigger which has annotations without diff",
user: u2,
this: withUserAnns(u1, u1, &Trigger{Spec: TriggerSpec{Broker: defaultBroker, Filter: defaultTriggerFilter}}),
prev: withUserAnns(u1, u1, &Trigger{Spec: TriggerSpec{Broker: defaultBroker, Filter: defaultTriggerFilter}}),
wantedAnns: map[string]string{
eventing.CreatorAnnotation: u1,
eventing.UpdaterAnnotation: u1,
},
}, {
name: "update trigger which has no annotations with diff",
user: u2,
this: &Trigger{Spec: TriggerSpec{Broker: defaultBroker}},
prev: &Trigger{Spec: TriggerSpec{Broker: otherBroker}},
wantedAnns: map[string]string{
eventing.UpdaterAnnotation: u2,
},
}, {
name: "update trigger which has annotations with diff",
user: u3,
this: withUserAnns(u1, u2, &Trigger{Spec: TriggerSpec{Broker: otherBroker}}),
prev: withUserAnns(u1, u2, &Trigger{Spec: TriggerSpec{Broker: defaultBroker}}),
wantedAnns: map[string]string{
eventing.CreatorAnnotation: u1,
eventing.UpdaterAnnotation: u3,
},
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
ctx := apis.WithUserInfo(context.Background(), &authv1.UserInfo{
Username: test.user,
})
if test.prev != nil {
ctx = apis.WithinUpdate(ctx, test.prev)
}
test.this.SetDefaults(ctx)
if got, want := test.this.GetAnnotations(), test.wantedAnns; !cmp.Equal(got, want) {
t.Errorf("Annotations = %v, want: %v, diff (-got, +want): %s", got, want, cmp.Diff(got, want))
}
})
}
} | explode_data.jsonl/54996 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1125
} | [
2830,
3393,
17939,
2082,
1921,
349,
36158,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
10676,
16,
284,
330,
994,
5580,
31,
19095,
1388,
21523,
698,
197,
10676,
17,
284,
330,
66,
43932,
31,
19095,
1388,
21523,
698,
197,
10676,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFilesetStructuralValidatorNoContainedAssertion(t *testing.T) {
json := datautils.JSONObject{
"@type": datautils.FilesetType,
"structural": map[string]interface{}{}}
fileset := datautils.NewResource(json)
validator := NewFilesetStructuralValidator(newMockRepository(nil))
err := validator.ValidateResource(fileset)
assert.NotNil(t, err)
} | explode_data.jsonl/16718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
1703,
746,
9422,
4176,
14256,
2753,
68799,
68639,
1155,
353,
8840,
836,
8,
341,
30847,
1669,
821,
6031,
40555,
515,
197,
197,
96270,
1313,
788,
414,
821,
6031,
8576,
70341,
345,
197,
197,
80575,
4176,
788,
2415,
14032,
31344... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStop(t *testing.T) {
t.Run(
"no error, 2 closers",
func(t *testing.T) {
var c = New(DefaultConfig())
var testCloser = &TestCloser{}
c.RegisterCloser(testCloser)
c.cfg.NoExitOnError = true
c.stop()
require.Equal(t, true, testCloser.closed)
},
)
t.Run(
"no error, 2 closers",
func(t *testing.T) {
var c = New(DefaultConfig())
var testCloser = &TestCloser{
err: errors.New("foo"),
}
c.RegisterCloser(testCloser)
c.cfg.NoExitOnError = true
c.stop()
require.Equal(t, true, testCloser.closed)
},
)
reset()
} | explode_data.jsonl/35311 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 270
} | [
2830,
3393,
10674,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
1006,
197,
197,
1,
2152,
1465,
11,
220,
17,
4496,
388,
756,
197,
29244,
1155,
353,
8840,
836,
8,
341,
298,
2405,
272,
284,
1532,
87874,
2648,
2398,
298,
2405,
1273,
51236... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdates(t *testing.T) {
t.Parallel()
aws_region := "ap-south-1"
var PATH_EXPRESSION = os.Getenv("PATH_EXPRESSION")
vars := map[string]interface{}{
"create_collector": true,
"sumologic_organization_id": common.SumologicOrganizationId,
"create_trail": true,
"collector_details": map[string]interface{}{
"collector_name": "Test Updates Cloudtrail Module",
"description": "thsisia",
"fields": map[string]interface{}{},
},
}
options, count := SetUpTest(t, vars, aws_region)
// Assert count of Expected resources.
test_structure.RunTestStage(t, "AssertCount", func() {
common.AssertResourceCounts(t, count, 11, 0, 0)
})
// Updating the Collector Name, description and fields only
vars = map[string]interface{}{
"create_collector": true,
"sumologic_organization_id": common.SumologicOrganizationId,
"create_trail": true,
"collector_details": map[string]interface{}{
"collector_name": "Test Updated Cloudtrail Module One",
"description": "This is a new description.",
"fields": map[string]interface{}{
"TestCollector": "MyValue",
},
},
}
count = UpdateTerraform(t, vars, options)
// Assert count of Expected resources.
test_structure.RunTestStage(t, "UpdateFirst", func() {
common.AssertResourceCounts(t, count, 0, 1, 0)
})
// use existing cloudtrail and bucket with existing IAM iam_role_arn
vars = map[string]interface{}{
"create_collector": true,
"sumologic_organization_id": common.SumologicOrganizationId,
"create_trail": false,
"wait_for_seconds": 1,
"collector_details": map[string]interface{}{
"collector_name": "Test Updated Cloudtrail Module One",
"description": "This is a new description.",
"fields": map[string]interface{}{
"TestCollector": "MyValue",
},
},
"source_details": map[string]interface{}{
"source_name": "My Test Source Another",
"source_category": "Labs/test/cloudtrail",
"description": "This source is ceated a.",
"bucket_details": map[string]interface{}{
"create_bucket": false,
"bucket_name": BUCKET_NAME,
"path_expression": PATH_EXPRESSION,
// This does not have any impact as terraform does not manage existing bucket.
"force_destroy_bucket": true,
},
"paused": false,
"scan_interval": 60000,
"cutoff_relative_time": "-1d",
"fields": map[string]interface{}{},
"sumo_account_id": "926226587429",
"collector_id": "",
"iam_details": map[string]interface{}{
"create_iam_role": false,
"iam_role_arn": IAM_ROLE,
},
"sns_topic_details": map[string]interface{}{
"create_sns_topic": true,
"sns_topic_arn": nil,
},
},
}
count = UpdateTerraform(t, vars, options)
// Assert count of Expected resources.
test_structure.RunTestStage(t, "UpdateFirst", func() {
common.AssertResourceCounts(t, count, 0, 3, 5)
})
// update fields to source
vars = map[string]interface{}{
"create_collector": true,
"sumologic_organization_id": common.SumologicOrganizationId,
"create_trail": false,
"wait_for_seconds": 1,
"collector_details": map[string]interface{}{
"collector_name": "Test Updated Cloudtrail Module One",
"description": "This is a new description.",
"fields": map[string]interface{}{
"TestCollector": "MyValue",
},
},
"source_details": map[string]interface{}{
"source_name": "My Test Source Another",
"source_category": "Labs/test/cloudtrail",
"description": "This source is ceated a.",
"bucket_details": map[string]interface{}{
"create_bucket": false,
"bucket_name": BUCKET_NAME,
"path_expression": PATH_EXPRESSION,
// This does not have any impact as terraform does not manage existing bucket.
"force_destroy_bucket": true,
},
"paused": false,
"scan_interval": 60000,
"cutoff_relative_time": "-1d",
"fields": map[string]interface{}{
"TestCollector": "MyValue",
},
"sumo_account_id": "926226587429",
"collector_id": "",
"iam_details": map[string]interface{}{
"create_iam_role": false,
"iam_role_arn": IAM_ROLE,
},
"sns_topic_details": map[string]interface{}{
"create_sns_topic": true,
"sns_topic_arn": nil,
},
},
}
count = UpdateTerraform(t, vars, options)
// Assert count of Expected resources.
test_structure.RunTestStage(t, "UpdateFirst", func() {
common.AssertResourceCounts(t, count, 0, 1, 0)
})
} | explode_data.jsonl/36177 | {
"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,
37091,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
8635,
20627,
1669,
330,
391,
1331,
2898,
12,
16,
698,
2405,
26773,
98345,
284,
2643,
64883,
445,
13593,
98345,
1138,
2405,
82,
1669,
2415,
14032,
31344,
67066... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccAWSDBInstanceNoSnapshot(t *testing.T) {
var snap rds.DBInstance
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceNoSnapshot,
Steps: []resource.TestStep{
{
Config: testAccSnapshotInstanceConfig(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists("aws_db_instance.snapshot", &snap),
),
},
},
})
} | explode_data.jsonl/33923 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 187
} | [
2830,
3393,
14603,
36136,
3506,
2523,
2753,
15009,
1155,
353,
8840,
836,
8,
341,
2405,
10658,
435,
5356,
22537,
2523,
271,
50346,
8787,
1155,
11,
5101,
31363,
515,
197,
197,
4703,
3973,
25,
257,
2915,
368,
314,
1273,
14603,
4703,
3973,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewGetStateResponseParsingPayloadChannelsError(t *testing.T) {
assert := assert.New(t)
jsonBytes := []byte(`{"status": 200, "message": "OK", "payload": {"channels": "a"}, "uuid": "my-custom-uuid", "service": "Presence"}`)
_, _, err := newGetStateResponse(jsonBytes, fakeResponseState)
assert.Equal("Response parsing channels", err.Error())
} | explode_data.jsonl/32504 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
3564,
1949,
1397,
2582,
68839,
29683,
35925,
1454,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
340,
30847,
7078,
1669,
3056,
3782,
5809,
4913,
2829,
788,
220,
17,
15,
15,
11,
330,
1994,
788,
330,
3925,
497,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSingleUnconfirmedChannel(t *testing.T) {
t.Parallel()
var fundingBroadcastHeight = uint32(1234)
// Let's create an open channel shell that contains all the information
// we need to create a static channel backup but simulate an
// unconfirmed channel by setting the block height to 0.
channel, err := genRandomOpenChannelShell()
if err != nil {
t.Fatalf("unable to gen open channel: %v", err)
}
channel.ShortChannelID.BlockHeight = 0
channel.FundingBroadcastHeight = fundingBroadcastHeight
singleChanBackup := NewSingle(channel, []net.Addr{addr1, addr2})
keyRing := &mockKeyRing{}
// Pack it and then unpack it again to make sure everything is written
// correctly, then check that the block height of the unpacked
// is the funding broadcast height we set before.
var b bytes.Buffer
if err := singleChanBackup.PackToWriter(&b, keyRing); err != nil {
t.Fatalf("unable to pack single: %v", err)
}
var unpackedSingle Single
err = unpackedSingle.UnpackFromReader(&b, keyRing)
if err != nil {
t.Fatalf("unable to unpack single: %v", err)
}
if unpackedSingle.ShortChannelID.BlockHeight != fundingBroadcastHeight {
t.Fatalf("invalid block height. got %d expected %d.",
unpackedSingle.ShortChannelID.BlockHeight,
fundingBroadcastHeight)
}
} | explode_data.jsonl/64337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
10888,
1806,
41028,
9629,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
10773,
43362,
3640,
284,
2622,
18,
17,
7,
16,
17,
18,
19,
692,
197,
322,
6771,
594,
1855,
458,
1787,
5496,
12528,
429,
5610,
678,
279... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestState_UpdateRplTopic(t *testing.T) {
t.Parallel()
st := setupNewState()
ev := &irc.Event{
Name: irc.RPL_TOPIC,
Sender: network,
Args: []string{st.selfUser.Nick(), channels[0], "topic topic"},
}
st.addChannel(channels[0])
ch, _ := st.Channel(channels[0])
if got, exp := ch.Topic, ""; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
st.Update(ev)
ch, _ = st.Channel(channels[0])
if got, exp := ch.Topic, "topic topic"; exp != got {
t.Errorf("Expected: %v, got: %v", exp, got)
}
} | explode_data.jsonl/32104 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
1397,
47393,
49,
500,
26406,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
18388,
1669,
6505,
3564,
1397,
2822,
74837,
1669,
609,
2437,
6904,
515,
197,
21297,
25,
256,
79923,
2013,
2916,
74077,
345,
197,
7568,
1659,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnmarshaler(t *testing.T) {
u := badUnmarshaler{}
format.RegisterDataFormat("format", u)
f := format.ByName("format")
if f == format.InvalidUnmarshaler {
t.Fatal("cannot find the registered formatter")
}
_, _ = f.Unmarshal([]byte{})
} | explode_data.jsonl/82021 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 99
} | [
2830,
3393,
1806,
27121,
261,
1155,
353,
8840,
836,
8,
341,
10676,
1669,
3873,
1806,
27121,
261,
16094,
59416,
19983,
1043,
4061,
445,
2243,
497,
575,
692,
1166,
1669,
3561,
13,
16898,
445,
2243,
1138,
743,
282,
621,
3561,
48144,
1806,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAlertForwarding(t *testing.T) {
c, s := net.Pipe()
go func() {
Client(c, testConfig).sendAlert(alertUnknownCA)
c.Close()
}()
err := Server(s, testConfig).Handshake()
s.Close()
if e, ok := err.(*net.OpError); !ok || e.Err != error(alertUnknownCA) {
t.Errorf("Got error: %s; expected: %s", err, error(alertUnknownCA))
}
} | explode_data.jsonl/80549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
9676,
25925,
287,
1155,
353,
8840,
836,
8,
341,
1444,
11,
274,
1669,
4179,
1069,
3444,
741,
30680,
2915,
368,
341,
197,
71724,
1337,
11,
1273,
2648,
568,
6681,
9676,
53437,
13790,
5049,
340,
197,
1444,
10421,
741,
197,
668... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTribonacci(t *testing.T) {
tests := []struct {
n int
want int
}{
{0, 0},
{1, 1},
{2, 1},
{3, 2},
{4, 4},
{25, 1389537},
}
for i, tt := range tests {
got := tribonacci(tt.n)
if got != tt.want {
t.Fatalf("#%d. got %v, want %v", i, got, tt.want)
}
}
} | explode_data.jsonl/73953 | {
"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,
51,
1897,
39345,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
9038,
262,
526,
198,
197,
50780,
526,
198,
197,
59403,
197,
197,
90,
15,
11,
220,
15,
1583,
197,
197,
90,
16,
11,
220,
16,
1583,
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 TestCreatePipelineVersion_ComplexPipelineVersion(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
// Create a pipeline.
createdPipeline, err := manager.CreatePipeline("pipeline", "", []byte(strings.TrimSpace(complexPipeline)))
assert.Nil(t, err)
// Create a version under the above pipeline.
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(
&api.PipelineVersion{
Name: "pipeline_version",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
Id: DefaultFakeUUID,
Type: api.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
},
},
},
[]byte(strings.TrimSpace(complexPipeline)), true)
assert.Nil(t, err)
_, err = manager.GetPipeline(createdPipeline.UUID)
assert.Nil(t, err)
_, err = manager.GetPipelineVersion(version.UUID)
assert.Nil(t, err)
} | explode_data.jsonl/77071 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 437
} | [
2830,
3393,
4021,
34656,
5637,
16946,
9111,
34656,
5637,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
1532,
52317,
2959,
2043,
2195,
62396,
67811,
7121,
52317,
1462,
2461,
44338,
2398,
16867,
3553,
10421,
741,
92272,
1669,
1532,
32498,
31200,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBucketReconciler_reconcileStorage(t *testing.T) {
tests := []struct {
name string
beforeFunc func(obj *sourcev1.Bucket, storage *Storage) error
want sreconcile.Result
wantErr bool
assertArtifact *sourcev1.Artifact
assertConditions []metav1.Condition
assertPaths []string
}{
{
name: "garbage collects",
beforeFunc: func(obj *sourcev1.Bucket, storage *Storage) error {
revisions := []string{"a", "b", "c", "d"}
for n := range revisions {
v := revisions[n]
obj.Status.Artifact = &sourcev1.Artifact{
Path: fmt.Sprintf("/reconcile-storage/%s.txt", v),
Revision: v,
}
if err := testStorage.MkdirAll(*obj.Status.Artifact); err != nil {
return err
}
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader(v), 0o640); err != nil {
return err
}
if n != len(revisions)-1 {
time.Sleep(time.Second * 1)
}
}
testStorage.SetArtifactURL(obj.Status.Artifact)
return nil
},
assertArtifact: &sourcev1.Artifact{
Path: "/reconcile-storage/d.txt",
Revision: "d",
Checksum: "18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4",
URL: testStorage.Hostname + "/reconcile-storage/d.txt",
Size: int64p(int64(len("d"))),
},
assertPaths: []string{
"/reconcile-storage/d.txt",
"/reconcile-storage/c.txt",
"!/reconcile-storage/b.txt",
"!/reconcile-storage/a.txt",
},
want: sreconcile.ResultSuccess,
},
{
name: "notices missing artifact in storage",
beforeFunc: func(obj *sourcev1.Bucket, storage *Storage) error {
obj.Status.Artifact = &sourcev1.Artifact{
Path: fmt.Sprintf("/reconcile-storage/invalid.txt"),
Revision: "d",
}
testStorage.SetArtifactURL(obj.Status.Artifact)
return nil
},
want: sreconcile.ResultSuccess,
assertPaths: []string{
"!/reconcile-storage/invalid.txt",
},
assertConditions: []metav1.Condition{
*conditions.TrueCondition(meta.ReconcilingCondition, "NoArtifact", "no artifact for resource in storage"),
},
},
{
name: "updates hostname on diff from current",
beforeFunc: func(obj *sourcev1.Bucket, storage *Storage) error {
obj.Status.Artifact = &sourcev1.Artifact{
Path: fmt.Sprintf("/reconcile-storage/hostname.txt"),
Revision: "f",
Checksum: "3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
URL: "http://outdated.com/reconcile-storage/hostname.txt",
}
if err := testStorage.MkdirAll(*obj.Status.Artifact); err != nil {
return err
}
if err := testStorage.AtomicWriteFile(obj.Status.Artifact, strings.NewReader("file"), 0o640); err != nil {
return err
}
return nil
},
want: sreconcile.ResultSuccess,
assertPaths: []string{
"/reconcile-storage/hostname.txt",
},
assertArtifact: &sourcev1.Artifact{
Path: "/reconcile-storage/hostname.txt",
Revision: "f",
Checksum: "3b9c358f36f0a31b6ad3e14f309c7cf198ac9246e8316f9ce543d5b19ac02b80",
URL: testStorage.Hostname + "/reconcile-storage/hostname.txt",
Size: int64p(int64(len("file"))),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
defer func() {
g.Expect(os.RemoveAll(filepath.Join(testStorage.BasePath, "/reconcile-storage"))).To(Succeed())
}()
r := &BucketReconciler{
EventRecorder: record.NewFakeRecorder(32),
Storage: testStorage,
}
obj := &sourcev1.Bucket{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-",
},
}
if tt.beforeFunc != nil {
g.Expect(tt.beforeFunc(obj, testStorage)).To(Succeed())
}
index := newEtagIndex()
got, err := r.reconcileStorage(context.TODO(), obj, index, "")
g.Expect(err != nil).To(Equal(tt.wantErr))
g.Expect(got).To(Equal(tt.want))
g.Expect(obj.Status.Artifact).To(MatchArtifact(tt.assertArtifact))
if tt.assertArtifact != nil && tt.assertArtifact.URL != "" {
g.Expect(obj.Status.Artifact.URL).To(Equal(tt.assertArtifact.URL))
}
g.Expect(obj.Status.Conditions).To(conditions.MatchConditions(tt.assertConditions))
for _, p := range tt.assertPaths {
absoluteP := filepath.Join(testStorage.BasePath, p)
if !strings.HasPrefix(p, "!") {
g.Expect(absoluteP).To(BeAnExistingFile())
continue
}
g.Expect(absoluteP).NotTo(BeAnExistingFile())
}
})
}
} | explode_data.jsonl/80415 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2116
} | [
2830,
3393,
36018,
693,
40446,
5769,
1288,
40446,
457,
5793,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
1797,
914,
198,
197,
63234,
9626,
981,
2915,
6779,
353,
2427,
85,
16,
1785,
11152,
11,
5819,
353,
579... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func Test_getEnvVarsForTask(t *testing.T) {
ctx := context.Background()
id := &mocks.TaskExecutionID{}
id.OnGetGeneratedName().Return("Job_Name")
id.OnGetID().Return(core.TaskExecutionIdentifier{})
assert.NoError(t, flyteK8sConfig.SetK8sPluginConfig(&flyteK8sConfig.K8sPluginConfig{
DefaultEnvVars: map[string]string{
"MyKey": "BadVal",
},
}))
envVars := getEnvVarsForTask(ctx, id, nil, map[string]string{
"MyKey": "MyVal",
})
assert.Equal(t, []v12.EnvVar{
{
Name: "MyKey",
Value: "MyVal",
},
}, envVars)
} | explode_data.jsonl/20423 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
3062,
14359,
28305,
2461,
6262,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
15710,
1669,
609,
16712,
82,
28258,
20294,
915,
16094,
15710,
8071,
1949,
15741,
675,
1005,
5598,
445,
12245,
19015,
1138,
15710,
807... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderListMetafields(t *testing.T) {
setup()
defer teardown()
httpmock.RegisterResponder("GET", fmt.Sprintf("https://fooshop.myshopify.com/%s/orders/1/metafields.json", client.pathPrefix),
httpmock.NewStringResponder(200, `{"metafields": [{"id":1},{"id":2}]}`))
metafields, err := client.Order.ListMetafields(1, nil)
if err != nil {
t.Errorf("Order.ListMetafields() returned error: %v", err)
}
expected := []Metafield{{ID: 1}, {ID: 2}}
if !reflect.DeepEqual(metafields, expected) {
t.Errorf("Order.ListMetafields() returned %+v, expected %+v", metafields, expected)
}
} | explode_data.jsonl/17992 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
4431,
852,
12175,
9007,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
28080,
16712,
19983,
30884,
445,
3806,
497,
8879,
17305,
445,
2428,
1110,
824,
9267,
453,
12618,
8675,
1437,
905,
12627,
82,
82818,
14,
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... | 3 |
func TestNewMasterState(t *testing.T) {
f, err := os.Open("../fixtures/master_state.json")
assert.Nil(t, err, "Unexpected error")
defer f.Close()
s, err := NewMasterState(f)
assert.Nil(t, err, "Unexpected error")
assert.NotNil(t, s, "Expected state")
assert.Equal(t, 1, len(s.Slaves), "Expected 1 slave")
slv := s.Slaves[0]
assert.Equal(t, "http://10.141.141.10:5051/slave(1)/state.json", slv.GetStateUrl(), "slave state url")
} | explode_data.jsonl/82162 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 183
} | [
2830,
3393,
3564,
18041,
1397,
1155,
353,
8840,
836,
8,
341,
1166,
11,
1848,
1669,
2643,
12953,
17409,
45247,
23303,
4387,
4323,
1138,
6948,
59678,
1155,
11,
1848,
11,
330,
29430,
1465,
1138,
16867,
282,
10421,
2822,
1903,
11,
1848,
166... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetChecksResult(t *testing.T) {
db := helpers.SetupTestDatabase(t)
mockAra := new(araMocks.AraService)
rList := &ara.RecordList{
Count: 3,
Results: []*ara.RecordListResult{
&ara.RecordListResult{
ID: 3,
Playbook: 1,
Key: "results",
Type: "json",
},
&ara.RecordListResult{
ID: 2,
Playbook: 1,
Key: "results",
Type: "json",
},
&ara.RecordListResult{
ID: 1,
Playbook: 1,
Key: "results",
Type: "json",
},
},
}
mockAra.On("GetRecordList", "key=trento-results&order=-id").Return(
rList, nil,
)
mockAra.On("GetRecord", 3).Return(
araResultRecord(), nil,
)
checksService := NewChecksService(mockAra, db)
c, err := checksService.GetChecksResult()
expectedResults := map[string]*models.Results{
"myClusterId": &models.Results{
Checks: map[string]*models.ChecksByHost{
"1.1.1": &models.ChecksByHost{
Hosts: map[string]*models.Check{
"host1": &models.Check{
Result: models.CheckPassing,
},
"host2": &models.Check{
Result: models.CheckPassing,
},
},
},
"1.1.2": &models.ChecksByHost{
Hosts: map[string]*models.Check{
"host1": &models.Check{
Result: models.CheckWarning,
},
"host2": &models.Check{
Result: models.CheckCritical,
},
},
},
"1.1.3": &models.ChecksByHost{
Hosts: map[string]*models.Check{
"host1": &models.Check{
Result: models.CheckPassing,
},
"host2": &models.Check{
Result: models.CheckWarning,
},
},
},
"1.1.4": &models.ChecksByHost{
Hosts: map[string]*models.Check{
"host1": &models.Check{
Result: models.CheckSkipped,
},
"host2": &models.Check{
Result: models.CheckSkipped,
},
},
},
},
},
}
assert.NoError(t, err)
assert.Equal(t, expectedResults, c)
mockAra.AssertExpectations(t)
} | explode_data.jsonl/67829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1011
} | [
2830,
3393,
1949,
49820,
2077,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
30187,
39820,
2271,
5988,
1155,
692,
77333,
32,
956,
1669,
501,
7,
5059,
72577,
875,
956,
1860,
692,
7000,
852,
1669,
609,
5059,
49959,
852,
515,
197,
197,
2507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSservice_GetExecutable(t *testing.T) {
op := Option{}
mpss := make([]immudb.ManpageService, 2)
mpss[0] = immudbcmdtest.ManpageServiceMock{}
mpss[1] = immudbcmdtest.ManpageServiceMock{}
ss := sservice{osMock, &servicetest.ConfigServiceMock{}, mpss, op}
_, err := ss.GetExecutable("immudb", "immudb")
assert.Nil(t, err)
} | explode_data.jsonl/57708 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
50,
7936,
13614,
94772,
1155,
353,
8840,
836,
8,
341,
39703,
1669,
6959,
16094,
53230,
778,
1669,
1281,
10556,
12543,
661,
65,
29902,
2893,
1860,
11,
220,
17,
340,
53230,
778,
58,
15,
60,
284,
4893,
661,
65,
8710,
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 TestPointerAndOmitEmpty(t *testing.T) {
validate := New()
type Test struct {
MyInt *int `validate:"omitempty,gte=2,lte=255"`
}
val1 := 0
val2 := 256
t1 := Test{MyInt: &val1} // This should fail validation on gte because value is 0
t2 := Test{MyInt: &val2} // This should fail validate on lte because value is 256
t3 := Test{MyInt: nil} // This should succeed validation because pointer is nil
errs := validate.Struct(t1)
NotEqual(t, errs, nil)
AssertError(t, errs, "Test.MyInt", "Test.MyInt", "MyInt", "MyInt", "gte")
errs = validate.Struct(t2)
NotEqual(t, errs, nil)
AssertError(t, errs, "Test.MyInt", "Test.MyInt", "MyInt", "MyInt", "lte")
errs = validate.Struct(t3)
Equal(t, errs, nil)
type TestIface struct {
MyInt interface{} `validate:"omitempty,gte=2,lte=255"`
}
ti1 := TestIface{MyInt: &val1} // This should fail validation on gte because value is 0
ti2 := TestIface{MyInt: &val2} // This should fail validate on lte because value is 256
ti3 := TestIface{MyInt: nil} // This should succeed validation because pointer is nil
errs = validate.Struct(ti1)
NotEqual(t, errs, nil)
AssertError(t, errs, "TestIface.MyInt", "TestIface.MyInt", "MyInt", "MyInt", "gte")
errs = validate.Struct(ti2)
NotEqual(t, errs, nil)
AssertError(t, errs, "TestIface.MyInt", "TestIface.MyInt", "MyInt", "MyInt", "lte")
errs = validate.Struct(ti3)
Equal(t, errs, nil)
} | explode_data.jsonl/77338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 562
} | [
2830,
3393,
9084,
3036,
46,
1763,
3522,
1155,
353,
8840,
836,
8,
1476,
197,
7067,
1669,
1532,
2822,
13158,
3393,
2036,
341,
197,
78469,
1072,
353,
396,
1565,
7067,
2974,
19967,
21644,
665,
28,
17,
22206,
665,
28,
17,
20,
20,
8805,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIssue20046(t *testing.T) {
skipSpecialPlatforms(t)
// This package only handles gc export data.
if runtime.Compiler != "gc" {
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
}
// On windows, we have to set the -D option for the compiler to avoid having a drive
// letter and an illegal ':' in the import path - just skip it (see also issue #3483).
if runtime.GOOS == "windows" {
t.Skip("avoid dealing with relative paths/drive letters on windows")
}
// "./issue20046".V.M must exist
pkg := compileAndImportPkg(t, "issue20046")
obj := lookupObj(t, pkg.Scope(), "V")
if m, index, indirect := types.LookupFieldOrMethod(obj.Type(), false, nil, "M"); m == nil {
t.Fatalf("V.M not found (index = %v, indirect = %v)", index, indirect)
}
} | explode_data.jsonl/30570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 268
} | [
2830,
3393,
42006,
17,
15,
15,
19,
21,
1155,
353,
8840,
836,
8,
341,
1903,
13389,
20366,
87268,
1155,
692,
197,
322,
1096,
6328,
1172,
13469,
22122,
7485,
821,
624,
743,
15592,
35952,
961,
330,
20669,
1,
341,
197,
3244,
57776,
69,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDeletePVCDoesNotDeletePVCOnFailedWorkflow(t *testing.T) {
assert := assert.New(t)
wf := unmarshalWF(workflowWithPVCAndFailingStep)
cancel, controller := newController(wf)
defer cancel()
woc := newWorkflowOperationCtx(wf, controller)
assert.Len(woc.wf.Status.PersistentVolumeClaims, 1, "1 PVC before operating")
ctx := context.Background()
woc.operate(ctx)
node1 := woc.wf.GetNodeByName("wf-with-pvc(0)[0].succeed")
node2 := woc.wf.GetNodeByName("wf-with-pvc(0)[1].failure")
// Node 1 Succeeded
assert.Equal(node1.Phase, wfv1.NodeSucceeded)
// Node 2 Failed
assert.Equal(node2.Phase, wfv1.NodeFailed)
// Hence, PVCs should stick around
assert.Len(woc.wf.Status.PersistentVolumeClaims, 1, "PVCs not deleted")
} | explode_data.jsonl/71004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
6435,
47,
11287,
21468,
2623,
6435,
47,
11287,
1925,
9408,
62768,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
6692,
69,
1669,
650,
27121,
32131,
31470,
4965,
2354,
47,
11287,
3036,
37,
14277,
8304,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetAccount(t *testing.T) {
b.SetDefaults()
TestSetup(t)
_, err := b.GetAccountBalance()
if areTestAPIKeysSet() && err != nil {
t.Errorf("Could not get account balance: %s", err)
} else if !areTestAPIKeysSet() && err == nil {
t.Error("Expecting an error when no keys are set")
}
} | explode_data.jsonl/14537 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 111
} | [
2830,
3393,
1949,
7365,
1155,
353,
8840,
836,
8,
341,
2233,
4202,
16273,
741,
73866,
21821,
1155,
692,
197,
6878,
1848,
1669,
293,
2234,
7365,
21190,
741,
743,
525,
2271,
7082,
8850,
1649,
368,
1009,
1848,
961,
2092,
341,
197,
3244,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestDebugFunctions(t *testing.T) {
//Test printCompositeKeys
// initialize a key list
loadKeys := []*statedb.CompositeKey{}
//create a composite key and add to the key list
compositeKey := statedb.CompositeKey{Namespace: "ns", Key: "key3"}
loadKeys = append(loadKeys, &compositeKey)
compositeKey = statedb.CompositeKey{Namespace: "ns", Key: "key4"}
loadKeys = append(loadKeys, &compositeKey)
testutil.AssertEquals(t, printCompositeKeys(loadKeys), "[ns,key4],[ns,key4]")
} | explode_data.jsonl/601 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 180
} | [
2830,
3393,
7939,
25207,
1155,
353,
8840,
836,
8,
1476,
197,
322,
2271,
1173,
41685,
8850,
198,
197,
322,
9468,
264,
1376,
1140,
198,
49386,
8850,
1669,
29838,
267,
657,
65,
2961,
13607,
1592,
16094,
197,
322,
3182,
264,
27714,
1376,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_getBeginFromCheckpoint(t *testing.T) {
now := time.Now().UTC()
type args struct {
vcTime time.Time
cp checkpoint
maxAge time.Duration
}
tests := []struct {
name string
args args
want time.Time
}{
{
name: "empty checkpoint (use vcTime)",
args: args{
vcTime: now,
cp: checkpoint{},
maxAge: CheckpointDefaultAge,
},
want: now,
},
{
name: "checkpoint too old (use CheckpointDefaultAge)",
args: args{
vcTime: now,
cp: checkpoint{
LastEventKey: 1234,
LastEventKeyTimestamp: now.Add(time.Hour * -1),
},
maxAge: CheckpointDefaultAge,
},
want: now.Add(CheckpointDefaultAge * -1),
},
{
name: "valid checkpoint within custom CheckpointConfig maxAge",
args: args{
vcTime: now,
cp: checkpoint{
LastEventKey: 1234,
LastEventKeyTimestamp: now.Add(time.Hour * -1),
},
maxAge: time.Hour * 2,
},
want: now.Add(time.Hour * -1),
},
}
for _, tt := range tests {
ctx := context.TODO()
t.Run(tt.name, func(t *testing.T) {
if got := getBeginFromCheckpoint(ctx, tt.args.vcTime, tt.args.cp, tt.args.maxAge); !reflect.DeepEqual(got, tt.want) {
t.Errorf("getBeginFromCheckpoint() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/66110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 590
} | [
2830,
3393,
3062,
11135,
3830,
92688,
1155,
353,
8840,
836,
8,
341,
80922,
1669,
882,
13244,
1005,
21183,
2822,
13158,
2827,
2036,
341,
197,
5195,
66,
1462,
882,
16299,
198,
197,
52018,
257,
29295,
198,
197,
22543,
16749,
882,
33795,
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 TestHgFileExistsByCommit(t *testing.T) {
assert := assert.New(t)
repo, client := helpers.CreateHgRepo(t, "hg-repo")
defer helpers.CleanupHgRepo(t, client)
commitID := helpers.SeedHgRepo(t, repo, client)
bookmarkCommitID := helpers.SeedHgBookmark(t, repo, client)
fileExists, err := repo.FileExistsByCommit(commitID, "AUTHORS")
assert.Nil(err)
assert.False(fileExists, "File 'AUTHORS' should not exist at first commit.")
fileExists, err = repo.FileExistsByCommit(bookmarkCommitID, "AUTHORS")
assert.Nil(err)
assert.True(fileExists, "File 'AUTHORS' should exist at bookmark.")
} | explode_data.jsonl/57188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 231
} | [
2830,
3393,
39,
70,
1703,
15575,
1359,
33441,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
17200,
5368,
11,
2943,
1669,
30187,
7251,
39,
70,
25243,
1155,
11,
330,
66602,
5504,
5368,
1138,
16867,
30187,
727,
60639,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMediaErrHandling(t *testing.T) {
handler := &myHandler{}
server := httptest.NewServer(handler)
defer server.Close()
client := &http.Client{}
s, err := storage.New(client)
if err != nil {
t.Fatalf("unable to create service: %v", err)
}
s.BasePath = server.URL
const body = "fake media data"
f := strings.NewReader(body)
// The combination of TimeoutReader and OneByteReader causes the first byte to
// be successfully delivered, but then a timeout error is reported.
r := iotest.TimeoutReader(iotest.OneByteReader(f))
o := &storage.Object{
Bucket: "mybucket",
Name: "filename",
ContentType: "plain/text",
ContentEncoding: "utf-8",
ContentLanguage: "en",
}
_, err = s.Objects.Insert("mybucket", o).Media(r).Do()
if err == nil || !strings.Contains(err.Error(), "timeout") {
t.Errorf("expected timeout error, got %v", err)
}
if handler.err != nil {
t.Errorf("handler err = %v, want nil", handler.err)
}
} | explode_data.jsonl/56690 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 369
} | [
2830,
3393,
12661,
7747,
38606,
1155,
353,
8840,
836,
8,
341,
53326,
1669,
609,
2408,
3050,
16094,
41057,
1669,
54320,
70334,
7121,
5475,
36514,
340,
16867,
3538,
10421,
2822,
25291,
1669,
609,
1254,
11716,
16094,
1903,
11,
1848,
1669,
58... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNonEmptyString(t *testing.T) {
t.Run("empty", func(t *testing.T) {
str := ""
_, errors := NonEmptyString(str, "")
assert.Equal(t, 1, len(errors))
})
t.Run("valid", func(t *testing.T) {
str := "str"
_, errors := NonEmptyString(str, "")
assert.Equal(t, 0, len(errors))
})
} | explode_data.jsonl/22689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
8121,
3522,
703,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3194,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
11355,
1669,
8389,
197,
197,
6878,
5975,
1669,
11581,
3522,
703,
4199,
11,
14676,
197,
6948,
12808,
1155,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_fakeNamespaceInformer(t *testing.T) {
// nothing real to test here. just to make coverage happy
c, err := newFakeAPIClientset(k8sconfig.APIConfig{})
assert.NoError(t, err)
i := NewFakeNamespaceInformer(c)
i.AddEventHandlerWithResyncPeriod(cache.ResourceEventHandlerFuncs{}, time.Second)
i.HasSynced()
i.LastSyncResourceVersion()
store := i.GetStore()
store.Add(api_v1.Namespace{})
} | explode_data.jsonl/41510 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
56881,
22699,
641,
34527,
1155,
353,
8840,
836,
8,
341,
197,
322,
4302,
1931,
311,
1273,
1588,
13,
1101,
311,
1281,
10191,
6247,
198,
1444,
11,
1848,
1669,
501,
52317,
2537,
98900,
746,
5969,
23,
82,
1676,
24922,
2648,
377... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVerifyRootErrors(t *testing.T) {
// Test setup
key, err := pem.UnmarshalPrivateKey(testonly.DemoPrivateKey, testonly.DemoPrivateKeyPass)
if err != nil {
t.Fatalf("Failed to open test key, err=%v", err)
}
signer := tcrypto.NewSHA256Signer(key)
pk, err := pem.UnmarshalPublicKey(testonly.DemoPublicKey)
if err != nil {
t.Fatalf("Failed to load public key, err=%v", err)
}
signedRoot := trillian.SignedLogRoot{}
hash, err := tcrypto.HashLogRoot(signedRoot)
if err != nil {
t.Fatalf("HashLogRoot(): %v", err)
}
signature, err := signer.Sign(hash)
if err != nil {
t.Fatal("Failed to create test signature")
}
signedRoot.Signature = signature
// Test execution
tests := []struct {
desc string
trusted, newRoot *trillian.SignedLogRoot
}{
{desc: "newRootNil", trusted: &signedRoot, newRoot: nil},
{desc: "trustedNil", trusted: nil, newRoot: &signedRoot},
}
for _, test := range tests {
logVerifier := NewLogVerifier(rfc6962.DefaultHasher, pk)
// This also makes sure that no nil pointer dereference errors occur (as this would cause a panic).
if err := logVerifier.VerifyRoot(test.trusted, test.newRoot, nil); err == nil {
t.Errorf("%v: VerifyRoot() error expected, but got nil", test.desc)
}
}
} | explode_data.jsonl/24266 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 485
} | [
2830,
3393,
32627,
8439,
13877,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
6505,
198,
23634,
11,
1848,
1669,
54184,
38097,
75981,
8623,
3243,
909,
6726,
75981,
11,
1273,
3243,
909,
6726,
75981,
12187,
340,
743,
1848,
961,
2092,
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... | 7 |
func TestHTMLTemplateWatcher_BadDirectory(t *testing.T) {
TranslationsPreInit()
watcher, err := NewHTMLTemplateWatcher("notarealdirectory")
assert.Nil(t, watcher)
assert.Error(t, err)
} | explode_data.jsonl/53383 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
5835,
7275,
47248,
1668,
329,
9310,
1155,
353,
8840,
836,
8,
341,
197,
95807,
4703,
3803,
741,
6692,
28058,
11,
1848,
1669,
1532,
5835,
7275,
47248,
445,
1921,
546,
4747,
4758,
1138,
6948,
59678,
1155,
11,
55727,
340,
6948,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestSegmentMerging(t *testing.T) {
tests := []struct {
name string
stop func(tcpip.Endpoint)
resume func(tcpip.Endpoint)
}{
{
"stop work",
func(ep tcpip.Endpoint) {
ep.(interface{ StopWork() }).StopWork()
},
func(ep tcpip.Endpoint) {
ep.(interface{ ResumeWork() }).ResumeWork()
},
},
{
"cork",
func(ep tcpip.Endpoint) {
ep.SocketOptions().SetCorkOption(true)
},
func(ep tcpip.Endpoint) {
ep.SocketOptions().SetCorkOption(false)
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.CreateConnected(context.TestInitialSequenceNumber, 30000, -1 /* epRcvBuf */)
// Send tcp.InitialCwnd number of segments to fill up
// InitialWindow but don't ACK. That should prevent
// anymore packets from going out.
var r bytes.Reader
for i := 0; i < tcp.InitialCwnd; i++ {
r.Reset([]byte{0})
if _, err := c.EP.Write(&r, tcpip.WriteOptions{}); err != nil {
t.Fatalf("Write #%d failed: %s", i+1, err)
}
}
// Now send the segments that should get merged as the congestion
// window is full and we won't be able to send any more packets.
var allData []byte
for i, data := range [][]byte{{1, 2, 3, 4}, {5, 6, 7}, {8, 9}, {10}, {11}} {
allData = append(allData, data...)
r.Reset(data)
if _, err := c.EP.Write(&r, tcpip.WriteOptions{}); err != nil {
t.Fatalf("Write #%d failed: %s", i+1, err)
}
}
// Check that we get tcp.InitialCwnd packets.
iss := seqnum.Value(context.TestInitialSequenceNumber).Add(1)
for i := 0; i < tcp.InitialCwnd; i++ {
b := c.GetPacket()
checker.IPv4(t, b,
checker.PayloadLen(header.TCPMinimumSize+1),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+uint32(i)+1),
checker.TCPAckNum(uint32(iss)),
checker.TCPFlagsMatch(header.TCPFlagAck, ^header.TCPFlagPsh),
),
)
}
// Acknowledge the data.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss,
AckNum: c.IRS.Add(1 + 10), // 10 for the 10 bytes of payload.
RcvWnd: 30000,
})
// Check that data is received.
b := c.GetPacket()
checker.IPv4(t, b,
checker.PayloadLen(len(allData)+header.TCPMinimumSize),
checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPSeqNum(uint32(c.IRS)+11),
checker.TCPAckNum(uint32(iss)),
checker.TCPFlagsMatch(header.TCPFlagAck, ^header.TCPFlagPsh),
),
)
if got := b[header.IPv4MinimumSize+header.TCPMinimumSize:]; !bytes.Equal(got, allData) {
t.Fatalf("got data = %v, want = %v", got, allData)
}
// Acknowledge the data.
c.SendPacket(nil, &context.Headers{
SrcPort: context.TestPort,
DstPort: c.Port,
Flags: header.TCPFlagAck,
SeqNum: iss,
AckNum: c.IRS.Add(11 + seqnum.Size(len(allData))),
RcvWnd: 30000,
})
})
}
} | explode_data.jsonl/75963 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1432
} | [
2830,
3393,
21086,
44,
95296,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
62644,
256,
2915,
98203,
573,
90409,
340,
197,
10202,
3885,
2915,
98203,
573,
90409,
340,
197,
59403,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNonStringImage(t *testing.T) {
_, err := loadYAML(`
version: "3"
services:
foo:
image: ["busybox", "latest"]
`)
assert.Error(t, err)
assert.Contains(t, err.Error(), "services.foo.image must be a string")
} | explode_data.jsonl/16387 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
8121,
703,
1906,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
2795,
56,
31102,
61528,
4366,
25,
330,
18,
698,
12779,
510,
220,
15229,
510,
262,
2168,
25,
4383,
78467,
2011,
497,
330,
19350,
7026,
24183,
6948,
6141,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKpt_GetApplyDir(t *testing.T) {
tests := []struct {
description string
live latestV1.KptLive
expected string
commands util.Command
shouldErr bool
}{
{
description: "specified an invalid applyDir",
live: latestV1.KptLive{
Apply: latestV1.KptApplyInventory{
Dir: "invalid_path",
},
},
shouldErr: true,
},
{
description: "specified a valid applyDir",
live: latestV1.KptLive{
Apply: latestV1.KptApplyInventory{
Dir: "valid_path",
},
},
expected: "valid_path",
},
{
description: "unspecified applyDir",
expected: ".kpt-hydrated",
commands: testutil.CmdRunOut("kpt live init .kpt-hydrated --context kubecontext --namespace testNamespace", ""),
},
{
description: "unspecified applyDir with specified inventory-id and namespace",
live: latestV1.KptLive{
Apply: latestV1.KptApplyInventory{
InventoryID: "1a23bcde-4f56-7891-a2bc-de34fabcde5f6",
InventoryNamespace: "foo",
},
},
expected: ".kpt-hydrated",
commands: testutil.CmdRunOut("kpt live init .kpt-hydrated --inventory-id 1a23bcde-4f56-7891-a2bc-de34fabcde5f6 --context kubecontext --namespace foo", ""),
},
{
description: "existing template resource in .kpt-hydrated",
expected: ".kpt-hydrated",
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&util.DefaultExecCommand, test.commands)
tmpDir := t.NewTempDir().Chdir()
if test.live.Apply.Dir == test.expected {
// 0755 is a permission setting where the owner can read, write, and execute.
// Others can read and execute but not modify the directory.
t.CheckNoError(os.Mkdir(test.live.Apply.Dir, 0755))
}
if test.description == "existing template resource in .kpt-hydrated" {
tmpDir.Touch(".kpt-hydrated/inventory-template.yaml")
}
k := NewDeployer(&kptConfig{
workingDir: ".",
}, nil, deploy.NoopComponentProvider, &latestV1.KptDeploy{
Live: test.live,
})
applyDir, err := k.getApplyDir(context.Background())
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expected, applyDir)
})
}
} | explode_data.jsonl/9526 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 911
} | [
2830,
3393,
42,
417,
13614,
28497,
6184,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
914,
198,
197,
8810,
533,
286,
5535,
53,
16,
11352,
417,
20324,
198,
197,
42400,
262,
914,
198,
197,
197,
24270,
262,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSubject(t *testing.T) {
cl := &GerritCL{}
if w, e := cl.Subject(), ""; w != e {
t.Errorf("cl.Subject() = %q; want %q", w, e)
}
testcases := []struct{ msg, subject string }{
{"maintner: slurp up all the things", "maintner: slurp up all the things"},
{"cmd/go: build stuff\n\nand do other stuff, too.", "cmd/go: build stuff"},
}
for _, tc := range testcases {
cl = &GerritCL{Commit: &GitCommit{Msg: tc.msg}}
if cl.Subject() != tc.subject {
t.Errorf("cl.Subject() = %q; want %q", cl.Subject(), tc.subject)
}
}
} | explode_data.jsonl/66160 | {
"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,
13019,
1155,
353,
8840,
836,
8,
341,
39407,
1669,
609,
38,
615,
275,
3140,
16094,
743,
289,
11,
384,
1669,
1185,
57388,
1507,
35466,
289,
961,
384,
341,
197,
3244,
13080,
445,
564,
57388,
368,
284,
1018,
80,
26,
1366,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestNewSimpleApplicationEvent(t *testing.T) {
tests := []struct {
name string
appID string
event events.ApplicationEventType
wantID string
wantEvent events.ApplicationEventType
}{
{TestCreateName, "testAppId001", events.SubmitApplication, "testAppId001", events.SubmitApplication},
}
for _, tt := range tests {
instance := NewSimpleApplicationEvent(tt.appID, tt.event)
t.Run(tt.name, func(t *testing.T) {
if instance.applicationID != tt.wantID || instance.event != tt.wantEvent {
t.Errorf("want %s %s, got %s %s",
tt.wantID, tt.wantEvent,
instance.applicationID, instance.event)
}
})
}
} | explode_data.jsonl/9769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 254
} | [
2830,
3393,
3564,
16374,
4988,
1556,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
28236,
915,
257,
914,
198,
197,
28302,
257,
4357,
17521,
47906,
198,
197,
50780,
915,
262,
914,
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 TestDefaultVPCIsMissing(t *testing.T) {
driver := NewDriver("machineFoo", "path")
driver.clientFactory = func() Ec2Client {
return &fakeEC2WithDescribe{
output: &ec2.DescribeAccountAttributesOutput{
AccountAttributes: []*ec2.AccountAttribute{},
},
}
}
vpc, err := driver.getDefaultVPCId()
assert.EqualError(t, err, "No default-vpc attribute")
assert.Empty(t, vpc)
} | explode_data.jsonl/7414 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
3675,
53,
4872,
3872,
25080,
1155,
353,
8840,
836,
8,
341,
33652,
1669,
1532,
11349,
445,
32056,
40923,
497,
330,
2343,
1138,
33652,
6581,
4153,
284,
2915,
368,
36111,
17,
2959,
341,
197,
853,
609,
30570,
7498,
17,
2354,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLang_English_Season(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-05", "Winter"},
{"2020-02-05", "Winter"},
{"2020-03-05", "Spring"},
{"2020-04-05", "Spring"},
{"2020-05-05", "Spring"},
{"2020-06-05", "Summer"},
{"2020-07-05", "Summer"},
{"2020-08-05", "Summer"},
{"2020-09-05", "Autumn"},
{"2020-10-05", "Autumn"},
{"2020-11-05", "Autumn"},
{"2020-12-05", "Winter"},
}
for index, test := range tests {
c := SetTimezone(PRC).Parse(test.input).SetLocale(english)
assert.Nil(c.Error)
assert.Equal(test.expected, c.Season(), "test index id is "+strconv.Itoa(index))
}
} | explode_data.jsonl/29472 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
26223,
2089,
968,
1672,
26920,
1497,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
78216,
1669,
3056,
1235,
341,
197,
22427,
262,
914,
442,
69058,
25511,
198,
197,
42400,
914,
442,
220,
106076,
25511,
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 TestDefaultUnparseable(t *testing.T) {
var args struct {
A int `default:"x"`
}
err := parse("", &args)
assert.EqualError(t, err, `error processing default value for --a: strconv.ParseInt: parsing "x": invalid syntax`)
} | explode_data.jsonl/13080 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
3675,
1806,
6400,
480,
1155,
353,
8840,
836,
8,
341,
2405,
2827,
2036,
341,
197,
22985,
526,
1565,
2258,
2974,
87,
8805,
197,
630,
9859,
1669,
4715,
19814,
609,
2116,
340,
6948,
12808,
1454,
1155,
11,
1848,
11,
1565,
841,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateCIDR(t *testing.T) {
testCases := map[string]struct {
inputCIDR string
wantError error
}{
"good case": {
inputCIDR: "10.10.10.10/24",
wantError: nil,
},
"bad case": {
inputCIDR: "10.10.10.10",
wantError: errValueNotAnIPNet,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
got := validateCIDR(tc.inputCIDR)
if tc.wantError != nil {
require.EqualError(t, got, tc.wantError.Error())
} else {
require.Nil(t, got)
}
})
}
} | explode_data.jsonl/34551 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 249
} | [
2830,
3393,
17926,
54146,
49,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
22427,
54146,
49,
914,
198,
197,
50780,
1454,
1465,
198,
197,
59403,
197,
197,
1,
18536,
1142,
788,
341,
298,
22427,
5414... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncodeDecodeVarint(t *testing.T) {
b := [8]byte{}
n, err := encodeVarint(b[:], 42)
if err != nil {
t.Fatal(err)
}
v, n2, err := decodeVarint(b[:n])
if err != nil {
t.Fatal(err)
}
if v != 42 {
t.Errorf("decoded value mismatch: want %d, got %d", 42, v)
}
if n2 != n {
t.Errorf("decoded byte count mismatch: want %d, got %d", n, n2)
}
} | explode_data.jsonl/52775 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 175
} | [
2830,
3393,
32535,
32564,
3962,
396,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
508,
23,
90184,
31483,
9038,
11,
1848,
1669,
16164,
3962,
396,
1883,
3447,
1125,
220,
19,
17,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestBasicAuth(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
auth := strings.SplitN(r.Header["Authorization"][0], " ", 2)
if len(auth) != 2 || auth[0] != "Basic" {
t.Error("bad syntax")
}
payload, _ := base64.StdEncoding.DecodeString(auth[1])
pair := strings.SplitN(string(payload), ":", 2)
if pair[0] != "myusername" || pair[1] != "mypassword" {
t.Error("Wrong username/password")
}
}))
defer ts.Close()
New().Post(ts.URL).
SetBasicAuth("myusername", "mypassword").
End()
} | explode_data.jsonl/25478 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
15944,
5087,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
78011,
1669,
9069,
19823,
45,
2601,
15753,
1183,
18124,
18121,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 Test_informerListFuncWithSelectors(t *testing.T) {
ls, fs, err := selectorsFromFilters(Filters{
Fields: []FieldFilter{
{
Key: "kk1",
Value: "kv1",
Op: selection.Equals,
},
},
Labels: []FieldFilter{
{
Key: "lk1",
Value: "lv1",
Op: selection.NotEquals,
},
},
})
assert.NoError(t, err)
c, err := newFakeAPIClientset(k8sconfig.APIConfig{})
assert.NoError(t, err)
listFunc := informerListFuncWithSelectors(c, "test-ns", ls, fs)
opts := metav1.ListOptions{}
obj, err := listFunc(opts)
assert.NoError(t, err)
assert.NotNil(t, obj)
} | explode_data.jsonl/41505 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 292
} | [
2830,
3393,
1243,
34527,
852,
9626,
2354,
96995,
1155,
353,
8840,
836,
8,
341,
197,
4730,
11,
8619,
11,
1848,
1669,
56037,
3830,
28351,
7832,
8612,
515,
197,
197,
8941,
25,
3056,
1877,
5632,
515,
298,
197,
515,
571,
55242,
25,
256,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestResources_SyncDroplets(t *testing.T) {
tests := []struct {
name string
dropletsSvc godo.DropletsService
expectedResources *resources
err error
}{
{
name: "happy path",
dropletsSvc: &fakeDropletService{
listFunc: func(ctx context.Context, opt *godo.ListOptions) ([]godo.Droplet, *godo.Response, error) {
return []godo.Droplet{{ID: 2, Name: "two"}}, newFakeOKResponse(), nil
},
},
expectedResources: &resources{
dropletIDMap: map[int]*godo.Droplet{2: {ID: 2, Name: "two"}},
dropletNameMap: map[string]*godo.Droplet{"two": {ID: 2, Name: "two"}},
},
err: nil,
},
{
name: "droplets svc failure",
dropletsSvc: &fakeDropletService{
listFunc: func(ctx context.Context, opt *godo.ListOptions) ([]godo.Droplet, *godo.Response, error) {
return nil, newFakeNotOKResponse(), errors.New("droplets svc fail")
},
},
expectedResources: &resources{
dropletIDMap: map[int]*godo.Droplet{1: {ID: 1, Name: "one"}},
dropletNameMap: map[string]*godo.Droplet{"one": {ID: 1, Name: "one"}},
},
err: errors.New("droplets svc fail"),
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
client := &godo.Client{
Droplets: test.dropletsSvc,
}
fakeResources := newResources("", "", client)
fakeResources.UpdateDroplets([]godo.Droplet{
{ID: 1, Name: "one"},
})
err := fakeResources.SyncDroplets(context.Background())
if test.err != nil {
if !reflect.DeepEqual(err, test.err) {
t.Errorf("incorrect err\nwant: %#v\n got: %#v", test.err, err)
}
return
}
if err != nil {
t.Errorf("did not expect err but got: %s", err)
return
}
if want, got := test.expectedResources.dropletIDMap, fakeResources.dropletIDMap; !reflect.DeepEqual(want, got) {
t.Errorf("incorrect droplet id map\nwant: %#v\n got: %#v", want, got)
}
if want, got := test.expectedResources.dropletNameMap, fakeResources.dropletNameMap; !reflect.DeepEqual(want, got) {
t.Errorf("incorrect droplet name map\nwant: %#v\n got: %#v", want, got)
}
})
}
} | explode_data.jsonl/28026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 952
} | [
2830,
3393,
11277,
1098,
1721,
35,
299,
89492,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
1060,
914,
198,
197,
2698,
299,
89492,
92766,
981,
342,
6004,
909,
299,
89492,
1860,
198,
197,
42400,
11277,
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... | 1 |
func Test_Stream_Global_Index(t *testing.T) {
tester := assert.New(t)
s, deferFunc := setup(t)
defer deferFunc()
_ = setupQueryData(t, "global_index.json", s)
tests := []struct {
name string
traceID string
wantTraceSegmentNum int
wantErr bool
}{
{
name: "trace id is 1",
traceID: "1",
wantTraceSegmentNum: 2,
},
{
name: "trace id is 2",
traceID: "2",
wantTraceSegmentNum: 3,
},
{
name: "unknown trace id",
traceID: "foo",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
shards, errShards := s.Shards(nil)
tester.NoError(errShards)
err := func() error {
for _, shard := range shards {
itemIDs, err := shard.Index().Seek(index.Field{
Key: index.FieldKey{
//trace_id
IndexRuleID: 10,
},
Term: []byte(tt.traceID),
})
if err != nil {
return errors.WithStack(err)
}
if len(itemIDs) < 1 {
continue
}
if err != nil {
return errors.WithStack(err)
}
tester.Equal(tt.wantTraceSegmentNum, len(itemIDs))
for _, itemID := range itemIDs {
segShard, err := s.Shard(itemID.ShardID)
if err != nil {
return errors.WithStack(err)
}
series, err := segShard.Series().GetByID(itemID.SeriesID)
if err != nil {
return errors.WithStack(err)
}
err = func() error {
item, closer, errInner := series.Get(itemID)
defer func(closer io.Closer) {
_ = closer.Close()
}(closer)
if errInner != nil {
return errors.WithStack(errInner)
}
tagFamily, errInner := s.ParseTagFamily("searchable", item)
if errInner != nil {
return errors.WithStack(errInner)
}
for _, tag := range tagFamily.GetTags() {
if tag.GetKey() == "trace_id" {
tester.Equal(tt.traceID, tag.GetValue().GetStr().GetValue())
}
}
return nil
}()
if err != nil {
return errors.WithStack(err)
}
}
}
return nil
}()
if tt.wantErr {
tester.Error(err)
return
}
tester.NoError(err)
})
}
} | explode_data.jsonl/17755 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1192
} | [
2830,
3393,
80631,
93132,
50361,
1155,
353,
8840,
836,
8,
341,
18185,
261,
1669,
2060,
7121,
1155,
340,
1903,
11,
17956,
9626,
1669,
6505,
1155,
340,
16867,
17956,
9626,
741,
197,
62,
284,
6505,
2859,
1043,
1155,
11,
330,
9752,
3560,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpgradeCmdEndorseFail(t *testing.T) {
InitMSP()
signer, err := common.GetDefaultSigner()
if err != nil {
t.Fatalf("Get default signer error: %v", err)
}
errCode := int32(500)
errMsg := "upgrade error"
mockResponse := &pb.ProposalResponse{Response: &pb.Response{Status: errCode, Message: errMsg}}
mockEndorerClient := common.GetMockEndorserClient(mockResponse, nil)
mockBroadcastClient := common.GetMockBroadcastClient(nil)
mockCF := &ChaincodeCmdFactory{
EndorserClient: mockEndorerClient,
Signer: signer,
BroadcastClient: mockBroadcastClient,
}
cmd := upgradeCmd(mockCF)
addFlags(cmd)
args := []string{"-C", "mychannel", "-n", "example02", "-p", "github.com/hyperledger/mchain/examples/chaincode/go/chaincode_example02",
"-v", "anotherversion", "-c", "{\"Function\":\"init\",\"Args\": [\"param\",\"1\"]}"}
cmd.SetArgs(args)
expectErrMsg := fmt.Sprintf("Could not assemble transaction, err Proposal response was not successful, error code %d, msg %s", errCode, errMsg)
if err := cmd.Execute(); err == nil {
t.Errorf("Run chaincode upgrade cmd error:%v", err)
} else {
if err.Error() != expectErrMsg {
t.Errorf("Run chaincode upgrade cmd get unexpected error: %s", err.Error())
}
}
} | explode_data.jsonl/63160 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 453
} | [
2830,
3393,
43861,
15613,
3727,
10836,
19524,
1155,
353,
8840,
836,
8,
341,
98762,
44,
4592,
2822,
69054,
261,
11,
1848,
1669,
4185,
2234,
3675,
7264,
261,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1949,
1638,
70039,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.