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 TestIssue6(t *testing.T) {
data := `{
"code": 0,
"msg": "",
"data": {
"sz002024": {
"qfqday": [
[
"2014-01-02",
"8.93",
"9.03",
"9.17",
"8.88",
"621143.00"
],
[
"2014-01-03",
"9.03",
"9.30",
"9.47",
"8.98",
"1624438.00"
]
]
}
}
}`
var num []string
for _, v := range Get(data, "data.sz002024.qfqday.0").Array() {
num = append(num, v.String())
}
if fmt.Sprintf("%v", num) != "[2014-01-02 8.93 9.03 9.17 8.88 621143.00]" {
t.Fatalf("invalid result")
}
} | explode_data.jsonl/43436 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 513
} | [
2830,
3393,
42006,
21,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
1565,
515,
414,
330,
1851,
788,
220,
15,
345,
414,
330,
3236,
788,
8324,
414,
330,
691,
788,
341,
286,
330,
14357,
15,
15,
17,
15,
17,
19,
788,
341,
688,
330,
80,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateMountWithId(t *testing.T) {
mount, err := CreateMountWithId("bobolink")
assert.NoError(t, err)
assert.NotNil(t, mount)
defer func() { assert.NoError(t, mount.Release()) }()
err = mount.ReadDefaultConfigFile()
assert.NoError(t, err)
err = mount.Mount()
assert.NoError(t, err)
defer func() { assert.NoError(t, mount.Unmount()) }()
// verify the custom entity_id is visible in the 'session ls' output
// of mds.
cmd := []byte(`{"prefix": "session ls"}`)
buf, info, err := mount.MdsCommand(
testMdsName,
[][]byte{cmd})
assert.NoError(t, err)
assert.NotEqual(t, "", string(buf))
assert.Equal(t, "", string(info))
assert.Contains(t, string(buf), `"bobolink"`)
} | explode_data.jsonl/29513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 275
} | [
2830,
3393,
4021,
16284,
2354,
764,
1155,
353,
8840,
836,
8,
341,
2109,
629,
11,
1848,
1669,
4230,
16284,
2354,
764,
445,
47086,
337,
766,
1138,
6948,
35699,
1155,
11,
1848,
340,
6948,
93882,
1155,
11,
6470,
340,
16867,
2915,
368,
314... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestYouonWSpecial(t *testing.T) {
const want = "wa"
for _, v := range [2]string{"わぁ", "ワァ"} {
got, err := KanaToRomaji(v)
assert.Equal(t, want, got)
assert.Nil(t, err)
}
} | explode_data.jsonl/11339 | {
"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,
2610,
263,
7433,
2964,
1155,
353,
8840,
836,
8,
341,
4777,
1366,
284,
330,
9991,
1837,
2023,
8358,
348,
1669,
2088,
508,
17,
30953,
4913,
77083,
126025,
497,
330,
124556,
128046,
9207,
341,
197,
3174,
354,
11,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestEnumDeclConforms(t *testing.T) {
decl, ok := testSchema(t).lookupDeclByName("ExampleEnum", false)
if !ok {
t.Fatalf("lookupDeclByName failed")
}
enumDecl := decl.(*EnumDecl)
checkConforms(t,
context{},
enumDecl,
[]conformTest{
// Underlying type for ExampleEnum is uint8.
conformOk{uint64(0)},
conformOk{uint64(255)},
conformFail{uint64(256), "out of range"},
conformFail{int64(256), "out of range"},
conformFail{int64(-1), "out of range"},
conformFail{nil, "expecting int64 or uint64"},
conformFail{0, "expecting int64 or uint64"},
conformFail{uint(0), "expecting int64 or uint64"},
conformFail{int8(0), "expecting int64 or uint64"},
conformFail{uint8(0), "expecting int64 or uint64"},
conformFail{"foo", "expecting int64 or uint64"},
conformFail{1.5, "expecting int64 or uint64"},
},
)
} | explode_data.jsonl/21399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
10766,
21629,
1109,
9807,
1155,
353,
8840,
836,
8,
341,
197,
10005,
11,
5394,
1669,
1273,
8632,
1155,
568,
21020,
21629,
16898,
445,
13314,
10766,
497,
895,
340,
743,
753,
562,
341,
197,
3244,
30762,
445,
21020,
21629,
16898... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCatalog_Register_DeprecatedConnectProxy(t *testing.T) {
t.Parallel()
assert := assert.New(t)
dir1, s1 := testServer(t)
defer os.RemoveAll(dir1)
defer s1.Shutdown()
codec := rpcClient(t, s1)
defer codec.Close()
args := structs.TestRegisterRequestProxy(t)
args.Service.ProxyDestination = "legacy"
args.Service.Proxy = structs.ConnectProxyConfig{}
// Register
var out struct{}
assert.Nil(msgpackrpc.CallWithCodec(codec, "Catalog.Register", &args, &out))
// List
req := structs.ServiceSpecificRequest{
Datacenter: "dc1",
ServiceName: args.Service.Service,
}
var resp structs.IndexedServiceNodes
assert.Nil(msgpackrpc.CallWithCodec(codec, "Catalog.ServiceNodes", &req, &resp))
assert.Len(resp.ServiceNodes, 1)
v := resp.ServiceNodes[0]
assert.Equal(structs.ServiceKindConnectProxy, v.ServiceKind)
assert.Equal(args.Service.ProxyDestination, v.ServiceProxy.DestinationServiceName)
} | explode_data.jsonl/49213 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 338
} | [
2830,
3393,
41606,
73124,
90680,
38777,
14611,
16219,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
6948,
1669,
2060,
7121,
1155,
340,
48532,
16,
11,
274,
16,
1669,
1273,
5475,
1155,
340,
16867,
2643,
84427,
14161,
16,
340,
168... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckTokenString(t *testing.T) {
// the middleware to test
authMiddleware, _ := New(&GinJWTMiddleware{
Realm: "test zone",
Key: key,
Timeout: 1 * time.Second,
Authenticator: defaultAuthenticator,
Unauthorized: func(c *gin.Context, code int, message string) {
c.String(code, message)
},
PayloadFunc: func(data interface{}) MapClaims {
if v, ok := data.(MapClaims); ok {
return v
}
return nil
},
})
handler := ginHandler(authMiddleware)
r := gofight.New()
userToken, _, _ := authMiddleware.TokenGenerator(MapClaims{
"identity": "admin",
})
r.GET("/auth/hello").
SetHeader(gofight.H{
"Authorization": "Bearer " + userToken,
}).
Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
})
token, err := authMiddleware.ParseTokenString(userToken)
assert.NoError(t, err)
claims := ExtractClaimsFromToken(token)
assert.Equal(t, "admin", claims["identity"])
time.Sleep(2 * time.Second)
r.GET("/auth/hello").
SetHeader(gofight.H{
"Authorization": "Bearer " + userToken,
}).
Run(handler, func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, http.StatusUnauthorized, r.Code)
})
_, err = authMiddleware.ParseTokenString(userToken)
assert.Error(t, err)
assert.Equal(t, MapClaims{}, ExtractClaimsFromToken(nil))
} | explode_data.jsonl/64456 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 573
} | [
2830,
3393,
3973,
3323,
703,
1155,
353,
8840,
836,
8,
341,
197,
322,
279,
29679,
311,
1273,
198,
78011,
24684,
11,
716,
1669,
1532,
2099,
38,
258,
55172,
24684,
515,
197,
197,
64290,
25,
260,
330,
1944,
10143,
756,
197,
55242,
25,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnsupportedCommand(t *testing.T) {
c := NewParallelE2eCLI(t, binDir)
c.RunDockerCmd("context", "create", "example", "test-example")
res := c.RunDockerOrExitError("--context", "test-example", "images")
res.Assert(t, icmd.Expected{
ExitCode: 1,
Err: `Command "images" not available in current context (test-example), you can use the "default" context to run this command`,
})
} | explode_data.jsonl/5435 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
41884,
4062,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
16547,
36,
17,
68,
63959,
1155,
11,
9544,
6184,
692,
1444,
16708,
35,
13659,
15613,
445,
2147,
497,
330,
3182,
497,
330,
8687,
497,
330,
1944,
43430,
1138,
10202... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateAccessTokenVersion(t *testing.T) {
invalidToken, _ := randomHex(80)
newTokenResp, err := testClient.InvalidateAccessToken(invalidToken)
assert.NotNil(t, err)
assert.True(t, newTokenResp.NewAccessToken == "")
} | explode_data.jsonl/12575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
4289,
37649,
5637,
1155,
353,
8840,
836,
8,
341,
197,
11808,
3323,
11,
716,
1669,
4194,
20335,
7,
23,
15,
340,
8638,
3323,
36555,
11,
1848,
1669,
1273,
2959,
5337,
7067,
37649,
5900,
1891,
3323,
340,
6948,
93882,
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 |
func TestToECDSAErrors(t *testing.T) {
if _, err := HexToECDSA("0000000000000000000000000000000000000000000000000000000000000000"); err == nil {
t.Fatal("HexToECDSA should've returned error")
}
if _, err := HexToECDSA("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); err == nil {
t.Fatal("HexToECDSA should've returned error")
}
} | explode_data.jsonl/3756 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
1249,
7498,
72638,
13877,
1155,
353,
8840,
836,
8,
341,
743,
8358,
1848,
1669,
27228,
1249,
7498,
72638,
445,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestIndexGet(t *testing.T) {
gopClTest(t, `
a := [1, 3.4, 5]
b := a[1]
`, `package main
func main() {
a := []float64{1, 3.4, 5}
b := a[1]
}
`)
} | explode_data.jsonl/73656 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
1552,
1949,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
64,
1669,
508,
16,
11,
220,
18,
13,
19,
11,
220,
20,
921,
65,
1669,
264,
58,
16,
921,
7808,
1565,
1722,
1887,
271,
2830,
1887,
368,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSecretsController(t *testing.T) {
secrets := []runtime.Object{
genericCert,
genericMtlsCert,
genericMtlsCertSplit,
genericMtlsCertSplitCa,
tlsCert,
tlsMtlsCert,
tlsMtlsCertSplit,
tlsMtlsCertSplitCa,
}
client := kube.NewFakeClient(secrets...)
sc := NewSecretsController(client.KubeInformer().Core().V1().Secrets())
client.RunAndWait(make(chan struct{}))
cases := []struct {
name string
namespace string
cert string
key string
caCert string
}{
{"generic", "default", "generic-cert", "generic-key", ""},
{"generic-mtls", "default", "generic-mtls-cert", "generic-mtls-key", "generic-mtls-ca"},
{"generic-mtls-split", "default", "generic-mtls-split-cert", "generic-mtls-split-key", ""},
{"generic-mtls-split-cacert", "default", "", "", "generic-mtls-split-ca"},
{"tls", "default", "tls-cert", "tls-key", ""},
{"tls-mtls", "default", "tls-mtls-cert", "tls-mtls-key", "tls-mtls-ca"},
{"tls-mtls-split", "default", "tls-mtls-split-cert", "tls-mtls-split-key", ""},
{"tls-mtls-split-cacert", "default", "", "", "tls-mtls-split-ca"},
{"generic", "wrong-namespace", "", "", ""},
}
for _, tt := range cases {
t.Run(tt.name, func(t *testing.T) {
key, cert := sc.GetKeyAndCert(tt.name, tt.namespace)
if tt.key != string(key) {
t.Errorf("got key %q, wanted %q", string(key), tt.key)
}
if tt.cert != string(cert) {
t.Errorf("got cert %q, wanted %q", string(cert), tt.cert)
}
caCert := sc.GetCaCert(tt.name, tt.namespace)
if tt.caCert != string(caCert) {
t.Errorf("got caCert %q, wanted %q", string(caCert), tt.caCert)
}
})
}
} | explode_data.jsonl/66283 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 731
} | [
2830,
3393,
19773,
82,
2051,
1155,
353,
8840,
836,
8,
341,
84686,
52710,
1669,
3056,
22255,
8348,
515,
197,
3174,
3469,
36934,
345,
197,
3174,
3469,
44,
34488,
36934,
345,
197,
3174,
3469,
44,
34488,
36934,
20193,
345,
197,
3174,
3469,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStoreSafeReference(t *testing.T) {
st, closer := makeStore()
defer closer()
root, _ := st.CurrentRoot()
firstKey := []byte(`firstKey`)
firstValue := []byte(`firstValue`)
firstIndex, _ := st.Set(schema.KeyValue{Key: firstKey, Value: firstValue})
for n := uint64(0); n <= 64; n++ {
opts := schema.SafeReferenceOptions{
Ro: &schema.ReferenceOptions{
Reference: []byte(strconv.FormatUint(n, 10)),
Key: firstKey,
},
RootIndex: &schema.Index{
Index: root.Index,
},
}
proof, err := st.SafeReference(opts)
assert.NoError(t, err, "n=%d", n)
assert.NotNil(t, proof, "n=%d", n)
assert.Equal(t, n+1, proof.Index, "n=%d", n)
leaf := api.Digest(proof.Index, opts.Ro.Reference, opts.Ro.Key)
verified := proof.Verify(leaf[:], *root)
assert.True(t, verified, "n=%d", n)
root.Index = proof.At
root.Root = proof.Root
}
for n := uint64(0); n <= 64; n++ {
tag := []byte(strconv.FormatUint(n, 10))
item, err := st.Get(schema.Key{Key: tag})
assert.NoError(t, err, "n=%d", n)
assert.Equal(t, firstIndex.Index, item.Index, "n=%d", n)
assert.Equal(t, firstValue, item.Value, "n=%d", n)
assert.Equal(t, firstKey, item.Key, "n=%d", n)
}
} | explode_data.jsonl/77970 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 536
} | [
2830,
3393,
6093,
25663,
8856,
1155,
353,
8840,
836,
8,
341,
18388,
11,
12128,
1669,
1281,
6093,
741,
16867,
12128,
2822,
33698,
11,
716,
1669,
357,
11517,
8439,
2822,
42190,
1592,
1669,
3056,
3782,
5809,
3896,
1592,
24183,
42190,
1130,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestReadCheckpointMultipleSegments(t *testing.T) {
pageSize := 32 * 1024
const segments = 1
const seriesCount = 20
const samplesCount = 300
for _, compress := range []bool{false, true} {
t.Run(fmt.Sprintf("compress=%t", compress), func(t *testing.T) {
dir, err := ioutil.TempDir("", "readCheckpoint")
require.NoError(t, err)
defer func() {
require.NoError(t, os.RemoveAll(dir))
}()
wdir := path.Join(dir, "wal")
err = os.Mkdir(wdir, 0777)
require.NoError(t, err)
enc := record.Encoder{}
w, err := NewSize(nil, nil, wdir, pageSize, compress)
require.NoError(t, err)
// Write a bunch of data.
for i := 0; i < segments; i++ {
for j := 0; j < seriesCount; j++ {
ref := j + (i * 100)
series := enc.Series([]record.RefSeries{
{
Ref: uint64(ref),
Labels: labels.Labels{labels.Label{Name: "__name__", Value: fmt.Sprintf("metric_%d", j)}},
},
}, nil)
require.NoError(t, w.Log(series))
for k := 0; k < samplesCount; k++ {
inner := rand.Intn(ref + 1)
sample := enc.Samples([]record.RefSample{
{
Ref: uint64(inner),
T: int64(i),
V: float64(i),
},
}, nil)
require.NoError(t, w.Log(sample))
}
}
}
require.NoError(t, w.Close())
// At this point we should have at least 6 segments, lets create a checkpoint dir of the first 5.
checkpointDir := dir + "/wal/checkpoint.000004"
err = os.Mkdir(checkpointDir, 0777)
require.NoError(t, err)
for i := 0; i <= 4; i++ {
err := os.Rename(SegmentName(dir+"/wal", i), SegmentName(checkpointDir, i))
require.NoError(t, err)
}
wt := newWriteToMock()
watcher := NewWatcher(wMetrics, nil, nil, "", wt, dir, false)
watcher.MaxSegment = -1
// Set the Watcher's metrics so they're not nil pointers.
watcher.setMetrics()
lastCheckpoint, _, err := LastCheckpoint(watcher.walDir)
require.NoError(t, err)
err = watcher.readCheckpoint(lastCheckpoint)
require.NoError(t, err)
})
}
} | explode_data.jsonl/76539 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 929
} | [
2830,
3393,
4418,
92688,
32089,
64813,
1155,
353,
8840,
836,
8,
341,
35272,
1695,
1669,
220,
18,
17,
353,
220,
16,
15,
17,
19,
271,
4777,
20632,
284,
220,
16,
198,
4777,
4013,
2507,
284,
220,
17,
15,
198,
4777,
10469,
2507,
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,
1,
1... | 1 |
func TestTimeSorter(t *testing.T) {
tests := []struct {
in []time.Time
want []time.Time
}{
{
in: []time.Time{
time.Unix(1351228575, 0), // Fri Oct 26 05:16:15 UTC 2012 (Block #205000)
time.Unix(1351228575, 1), // Fri Oct 26 05:16:15 UTC 2012 (+1 nanosecond)
time.Unix(1348310759, 0), // Sat Sep 22 10:45:59 UTC 2012 (Block #200000)
time.Unix(1305758502, 0), // Wed May 18 22:41:42 UTC 2011 (Block #125000)
time.Unix(1347777156, 0), // Sun Sep 16 06:32:36 UTC 2012 (Block #199000)
time.Unix(1349492104, 0), // Sat Oct 6 02:55:04 UTC 2012 (Block #202000)
},
want: []time.Time{
time.Unix(1305758502, 0), // Wed May 18 22:41:42 UTC 2011 (Block #125000)
time.Unix(1347777156, 0), // Sun Sep 16 06:32:36 UTC 2012 (Block #199000)
time.Unix(1348310759, 0), // Sat Sep 22 10:45:59 UTC 2012 (Block #200000)
time.Unix(1349492104, 0), // Sat Oct 6 02:55:04 UTC 2012 (Block #202000)
time.Unix(1351228575, 0), // Fri Oct 26 05:16:15 UTC 2012 (Block #205000)
time.Unix(1351228575, 1), // Fri Oct 26 05:16:15 UTC 2012 (+1 nanosecond)
},
},
}
for i, test := range tests {
result := make([]time.Time, len(test.in))
copy(result, test.in)
sort.Sort(blockchain.TstTimeSorter(result))
if !reflect.DeepEqual(result, test.want) {
t.Errorf("timeSorter #%d got %v want %v", i, result,
test.want)
continue
}
}
} | explode_data.jsonl/13784 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
1462,
10231,
261,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
3056,
1678,
16299,
198,
197,
50780,
3056,
1678,
16299,
198,
197,
59403,
197,
197,
515,
298,
17430,
25,
3056,
1678,
16299,
515,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestNewException(t *testing.T) {
for _, test := range newExceptionTests {
actual := NewException(test.err, nil)
if actual.Value != test.Value {
t.Errorf("incorrect Value: got %s, want %s", actual.Value, test.Value)
}
if actual.Type != test.Type {
t.Errorf("incorrect Type: got %s, want %s", actual.Type, test.Type)
}
if actual.Module != test.Module {
t.Errorf("incorrect Module: got %s, want %s", actual.Module, test.Module)
}
}
} | explode_data.jsonl/30382 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
3564,
1354,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
501,
1354,
18200,
341,
197,
88814,
1669,
1532,
1354,
8623,
18441,
11,
2092,
340,
197,
743,
5042,
6167,
961,
1273,
6167,
341,
298,
3244,
13080,
445,
61... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReplicaRangefeedExpiringLeaseError(t *testing.T) {
defer leaktest.AfterTest(t)()
sc := kvserver.TestStoreConfig(nil)
kvserver.RangefeedEnabled.Override(&sc.Settings.SV, true)
mtc := &multiTestContext{
storeConfig: &sc,
// This test was written before the multiTestContext started creating many
// system ranges at startup, and hasn't been update to take that into
// account.
startWithSingleRange: true,
}
defer mtc.Stop()
mtc.Start(t, 1)
// Establish a rangefeed on the replica we plan to remove.
stream := newTestStream()
req := roachpb.RangeFeedRequest{
Header: roachpb.Header{
RangeID: 1,
},
Span: roachpb.Span{Key: roachpb.Key("a"), EndKey: roachpb.Key("z")},
}
// Cancel the stream's context so that RangeFeed would return
// immediately even if it didn't return the correct error.
stream.Cancel()
pErr := mtc.Store(0).RangeFeed(&req, stream)
const exp = "expiration-based leases are incompatible with rangefeeds"
if !testutils.IsPError(pErr, exp) {
t.Errorf("expected error %q, found %v", exp, pErr)
}
} | explode_data.jsonl/70685 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
18327,
15317,
49,
524,
823,
12051,
840,
78763,
2304,
519,
1454,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
29928,
1669,
16178,
4030,
8787,
6093,
2648,
27907,
340,
16463,
85,
4030,
2013,
524... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetComponentParams(t *testing.T) {
tests := []struct {
componentName string
jsonnet string
expected Params
}{
// Test getting the parameters where there is a single component
{
"foo",
`
{
global: {},
components: {
foo: {
name: "foo",
replicas: 1,
},
},
}`,
Params{"name": `"foo"`, "replicas": "1"},
},
// Test getting the parameters where there are multiple components
{
"foo",
`
{
global: {},
components: {
bar: {
replicas: 5
},
foo: {
name: "foo",
"replica-count": 1,
},
},
}`,
Params{"name": `"foo"`, "replica-count": "1"},
},
// Test getting the parameters for a component name with special characters
{
"foo-bar",
`
{
global: {},
components: {
"foo-bar": {
name: "foo-bar",
replicas: 1,
},
},
}`,
Params{"name": `"foo-bar"`, "replicas": "1"},
},
// Test case where one of the param values is a block string
{
"foo",
`
{
components: {
"foo": {
name: |||
name
is
foo
|||,
}
},
}`,
Params{"name": "|||\nname\nis\nfoo\n|||"},
},
}
errors := []struct {
componentName string
jsonnet string
}{
// Test case where component doesn't exist
{
"baz",
`
{
components: {
foo: {
name: "foo",
},
},
}`,
},
// Test case where components isn't a top level object
{
"baz",
`
{
global: {
// User-defined global parameters; accessible to all component and environments, Ex:
// replicas: 4,
components: {},
},
}`,
},
// Test case where one of the component names is a block string
{
"foo",
`
{
components: {
|||foo|||: {
name: "foo",
}
},
}`,
},
}
for _, s := range tests {
params, err := GetComponentParams(s.componentName, s.jsonnet)
if err != nil {
t.Errorf("Unexpected error\n input: %v\n error: %v", s.jsonnet, err)
}
if !reflect.DeepEqual(params, s.expected) {
t.Errorf("Wrong conversion\n expected:%v\n got:%v", s.expected, params)
}
}
for _, e := range errors {
params, err := GetComponentParams(e.componentName, e.jsonnet)
if err == nil {
t.Errorf("Expected error but not found\n input: %v got: %v", e, params)
}
}
} | explode_data.jsonl/36748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1019
} | [
2830,
3393,
25640,
4870,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
52228,
675,
914,
198,
197,
30847,
4711,
981,
914,
198,
197,
42400,
414,
34352,
198,
197,
59403,
197,
197,
322,
3393,
3709,
279,
5029,
1380,
1052... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestViaIntermediaryBadSignature(t *testing.T) {
r, cfg := setup(t)
s := NewService(cfg)
fr := &IntermediaryFactRequest{
SelfID: "1234567890",
Intermediary: "intermediary",
Expiry: time.Millisecond,
Facts: []Fact{
{
Fact: FactDateOfBirth,
Sources: []string{SourceDrivingLicense, SourcePassport},
Operator: "<=",
ExpectedValue: time.Now().Add(time.Hour * 183960).Format(time.RFC3339),
},
},
}
_, isk, err := ed25519.GenerateKey(rand.Reader)
require.Nil(t, err)
ipk, _, err := ed25519.GenerateKey(rand.Reader)
require.Nil(t, err)
r.addpk("intermediary", isk, ipk)
r.path = "/v1/apps/intermediary/devices"
r.payload = []byte(`["1", "2"]`)
r.secondaryPaths["/v1/apps/test"] = []byte(`{"paid_actions":true}`)
var called bool
r.responder = func(recipients []string, req []byte) (string, []byte, error) {
called = true
opts := &jose.SignerOptions{
ExtraHeaders: map[jose.HeaderKey]interface{}{
"kid": "1",
},
}
signer, err := jose.NewSigner(jose.SigningKey{Algorithm: jose.EdDSA, Key: isk}, opts)
require.Nil(t, err)
jws, err := jose.ParseSigned(string(req))
require.Nil(t, err)
payload, err := jws.Verify(s.sk.Public())
require.Nil(t, err)
var m standardresponse
err = json.Unmarshal(payload, &m)
require.Nil(t, err)
assert.NotEmpty(t, m.ID)
assert.NotEmpty(t, m.Conversation)
assert.NotZero(t, m.IssuedAt)
assert.NotZero(t, m.ExpiresAt)
assert.Equal(t, RequestInformation, m.Type)
assert.Equal(t, "test", m.Issuer)
assert.Equal(t, fr.SelfID, m.Subject)
assert.Equal(t, fr.Intermediary, m.Audience)
assert.Equal(t, fr.Description, m.Description)
require.Len(t, m.Facts, 1)
assert.Equal(t, FactDateOfBirth, m.Facts[0].Fact)
assert.Equal(t, []string{SourceDrivingLicense, SourcePassport}, m.Facts[0].Sources)
assert.Equal(t, "<=", m.Facts[0].Operator)
assert.Equal(t, fr.Facts[0].ExpectedValue, m.Facts[0].ExpectedValue)
m.Type = ResponseInformation
m.Issuer = fr.Intermediary
m.Audience = "test"
m.IssuedAt = ntp.TimeFunc()
m.ExpiresAt = ntp.TimeFunc().Add(time.Minute)
m.Status = "accepted"
m.Facts = fr.Facts
asrt, err := json.Marshal(map[string]interface{}{
"jti": uuid.New().String(),
"sub": "1234567890",
"aud": "test",
"iss": "intermediary",
"iat": ntp.TimeFunc().Format(time.RFC3339),
FactDateOfBirth: true,
})
require.Nil(t, err)
assertation, err := signer.Sign(asrt)
require.Nil(t, err)
m.Facts[0].Attestations = make([]json.RawMessage, 1)
m.Facts[0].Attestations[0] = json.RawMessage(assertation.FullSerialize())
resp, err := json.Marshal(m)
require.Nil(t, err)
response, err := signer.Sign(resp)
require.Nil(t, err)
return fr.Intermediary + ":1", []byte(response.FullSerialize()), nil
}
_, err = s.RequestViaIntermediary(fr)
require.NotNil(t, err)
assert.True(t, called)
} | explode_data.jsonl/25982 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1357
} | [
2830,
3393,
1900,
54428,
3306,
4404,
658,
17082,
25088,
1155,
353,
8840,
836,
8,
341,
7000,
11,
13286,
1669,
6505,
1155,
692,
1903,
1669,
1532,
1860,
28272,
692,
97714,
1669,
609,
3306,
4404,
658,
17417,
1900,
515,
197,
7568,
490,
915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_EraseData_immudb(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.EraseData("immudb")
assert.Nil(t, err)
} | explode_data.jsonl/57707 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
50,
7936,
2089,
10632,
1043,
71370,
661,
65,
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,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapOperatorAssignmentNan(t *testing.T) {
m := make(map[float64]int, 0)
nan := math.NaN()
// Test assignment operations.
m[nan] += 1
m[nan] += 2
m[nan] += 4
testMapNan(t, m)
} | explode_data.jsonl/19903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 85
} | [
2830,
3393,
2227,
18461,
41613,
45,
276,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1281,
9147,
95381,
21,
19,
63025,
11,
220,
15,
340,
9038,
276,
1669,
6888,
78706,
2822,
197,
322,
3393,
16319,
7525,
624,
2109,
7669,
276,
60,
1421,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenericBlock(t *testing.T) {
testInputs(t, `
?match$domain=foo.biz
/ads
/ads1$domain=foo.com
/ads2$domain=bar.com
||foo.org^
||bar.org^
@@||foo.com^$genericblock
@@||foo.org^$genericblock
@@||foo.biz^$genericblock
@@/reject
`,
[]TestInput{
// Generic match
{URL: "http://foo.com/ads", Matched: false, OriginDomain: "foo.com"},
{URL: "http://bar.com/ads", Matched: true, OriginDomain: "bar.com"},
// Domain specific match
{URL: "http://foo.com/ads1", Matched: true, OriginDomain: "foo.com"},
{URL: "http://bar.com/ads2", Matched: true, OriginDomain: "bar.com"},
{URL: "http://foo.org/ads3", Matched: true, OriginDomain: "foo.org"},
{URL: "http://bar.org/ads3", Matched: true, OriginDomain: "bar.org"},
// Exclude rules ignore genericblock bit
{URL: "http://foo.biz/reject?match", Matched: false, OriginDomain: "foo.biz"},
})
} | explode_data.jsonl/81620 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 352
} | [
2830,
3393,
19964,
4713,
1155,
353,
8840,
836,
8,
341,
18185,
31946,
1155,
11,
22074,
30,
6347,
3,
12204,
28,
7975,
52608,
198,
14,
7664,
198,
14,
7664,
16,
3,
12204,
28,
7975,
905,
198,
14,
7664,
17,
3,
12204,
28,
2257,
905,
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 TestSuiteWithSetupsAndTeardowns(t *testing.T) {
fixture := &Suite01{T: suite.New(t)}
suite.Run(fixture, suite.Options.IntegrationTests())
fixture.So(fixture.events, should.Equal, []string{
"SetupSuite",
"Setup",
"Test",
"Teardown",
"TeardownSuite",
})
} | explode_data.jsonl/7372 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
28000,
2354,
1649,
8602,
3036,
6639,
37496,
82,
1155,
353,
8840,
836,
8,
341,
1166,
12735,
1669,
609,
28000,
15,
16,
76025,
25,
16182,
7121,
1155,
73822,
96572,
16708,
94886,
11,
16182,
22179,
7371,
17376,
18200,
12367,
1166,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_PowerSetThreadSafe(t *testing.T) {
set := NewSet().PowerSet()
_, setIsThreadSafe := set.(*threadSafeSet)
if !setIsThreadSafe {
t.Error("result of PowerSet should be thread safe")
}
subset := set.Pop()
_, subsetIsThreadSafe := subset.(*threadSafeSet)
if !subsetIsThreadSafe {
t.Error("subsets in PowerSet result should be thread safe")
}
} | explode_data.jsonl/211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 127
} | [
2830,
3393,
1088,
1202,
1649,
6855,
25663,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
1532,
1649,
1005,
14986,
1649,
741,
197,
6878,
38398,
6855,
25663,
1669,
738,
41399,
4528,
25663,
1649,
340,
743,
753,
746,
3872,
6855,
25663,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestExecutorReadAllTransactions(t *testing.T) {
txe, tsv, db := newTestTxExecutor(t)
defer db.Close()
defer tsv.StopService()
db.AddQuery(txe.te.twoPC.readAllTransactions, &sqltypes.Result{
Fields: []*querypb.Field{
{Type: sqltypes.VarChar},
{Type: sqltypes.Int64},
{Type: sqltypes.Int64},
{Type: sqltypes.VarChar},
{Type: sqltypes.VarChar},
},
Rows: [][]sqltypes.Value{{
sqltypes.NewVarBinary("dtid0"),
sqltypes.NewInt64(int64(querypb.TransactionState_PREPARE)),
sqltypes.NewVarBinary("1"),
sqltypes.NewVarBinary("ks01"),
sqltypes.NewVarBinary("shard01"),
}},
})
got, _, _, err := txe.ReadTwopcInflight()
require.NoError(t, err)
want := []*tx.DistributedTx{{
Dtid: "dtid0",
State: "PREPARE",
Created: time.Unix(0, 1),
Participants: []querypb.Target{{
Keyspace: "ks01",
Shard: "shard01",
}},
}}
if !reflect.DeepEqual(got, want) {
t.Errorf("ReadAllTransactions:\n%s, want\n%s", jsonStr(got), jsonStr(want))
}
} | explode_data.jsonl/25176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 449
} | [
2830,
3393,
25255,
4418,
2403,
48761,
1155,
353,
8840,
836,
8,
341,
3244,
8371,
11,
259,
3492,
11,
2927,
1669,
501,
2271,
31584,
25255,
1155,
340,
16867,
2927,
10421,
741,
16867,
259,
3492,
30213,
1860,
2822,
20939,
1904,
2859,
1155,
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 TestSorted(t *testing.T) {
testCases := []struct {
name string
expected []string
sleepDuration time.Duration
}{
{
name: "run in alphabetical order",
expected: []string{"dev1", "dev2", "dev3", "dev4"},
sleepDuration: 1 * time.Millisecond,
},
}
testHosts := map[string]*gornir.Host{
"dev1": {Hostname: "dev1"},
"dev2": {Hostname: "dev2"},
"dev3": {Hostname: "dev3"},
"dev4": {Hostname: "dev4"},
}
for _, tc := range testCases {
tc := tc
results := make(chan *gornir.JobResult, len(testHosts))
t.Run(tc.name, func(t *testing.T) {
rnr := runner.Sorted()
if err := rnr.Run(
context.Background(),
NewNullLogger(),
&testTaskSleep{sleepDuration: tc.sleepDuration},
testHosts,
results,
); err != nil {
t.Fatal(err)
}
if err := rnr.Wait(); err != nil {
t.Fatal(err)
}
close(results)
// let's process the results and turn it into a list so we can
// compare with our expected value
got := make([]string, len(testHosts))
i := 0
for res := range results {
got[i] = res.Host().Hostname
i++
}
if !cmp.Equal(got, tc.expected) {
t.Error(cmp.Diff(got, tc.expected))
}
})
}
} | explode_data.jsonl/74948 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 561
} | [
2830,
3393,
51051,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
42400,
414,
3056,
917,
198,
197,
52533,
12945,
882,
33795,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
688,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRespondentCloseRx(t *testing.T) {
s := GetSocket(t, NewSocket)
var wg sync.WaitGroup
wg.Add(1)
pass := false
go func() {
defer wg.Done()
v, e := s.Recv()
MustBeError(t, e, mangos.ErrClosed)
MustBeNil(t, v)
pass = true
}()
time.Sleep(time.Millisecond * 10) // to allow go routine to run
MustSucceed(t, s.Close())
wg.Wait()
MustBeTrue(t, pass)
} | explode_data.jsonl/57396 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
65354,
306,
7925,
50639,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
2126,
10286,
1155,
11,
1532,
10286,
340,
2405,
63581,
12811,
28384,
2808,
198,
72079,
1904,
7,
16,
340,
41431,
1669,
895,
198,
30680,
2915,
368,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLoadConfiguration(t *testing.T) {
tests := map[string]struct {
Mode string
Network string
Port string
cfg *Configuration
err error
}{
"no envs set": {
err: errors.New("MODE must be populated"),
},
"only mode set": {
Mode: string(Online),
err: errors.New("NETWORK must be populated"),
},
"only mode and network set": {
Mode: string(Online),
Network: Mainnet,
err: errors.New("PORT must be populated"),
},
"all set (mainnet)": {
Mode: string(Online),
Network: Mainnet,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: verge.MainnetNetwork,
Blockchain: verge.Blockchain,
},
Params: verge.MainnetParams,
Currency: verge.MainnetCurrency,
GenesisBlockIdentifier: verge.MainnetGenesisBlockIdentifier,
Port: 1000,
RPCPort: mainnetRPCPort,
ConfigPath: mainnetConfigPath,
Pruning: &PruningConfiguration{
Frequency: pruneFrequency,
Depth: pruneDepth,
MinHeight: minPruneHeight,
},
Compressors: []*encoder.CompressorEntry{
{
Namespace: transactionNamespace,
DictionaryPath: mainnetTransactionDictionary,
},
},
},
},
"all set (testnet)": {
Mode: string(Online),
Network: Testnet,
Port: "1000",
cfg: &Configuration{
Mode: Online,
Network: &types.NetworkIdentifier{
Network: verge.TestnetNetwork,
Blockchain: verge.Blockchain,
},
Params: verge.TestnetParams,
Currency: verge.TestnetCurrency,
GenesisBlockIdentifier: verge.TestnetGenesisBlockIdentifier,
Port: 1000,
RPCPort: testnetRPCPort,
ConfigPath: testnetConfigPath,
Pruning: &PruningConfiguration{
Frequency: pruneFrequency,
Depth: pruneDepth,
MinHeight: minPruneHeight,
},
Compressors: []*encoder.CompressorEntry{
{
Namespace: transactionNamespace,
DictionaryPath: testnetTransactionDictionary,
},
},
},
},
"invalid mode": {
Mode: "bad mode",
Network: Testnet,
Port: "1000",
err: errors.New("bad mode is not a valid mode"),
},
"invalid network": {
Mode: string(Offline),
Network: "bad network",
Port: "1000",
err: errors.New("bad network is not a valid network"),
},
"invalid port": {
Mode: string(Offline),
Network: Testnet,
Port: "bad port",
err: errors.New("unable to parse port bad port"),
},
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
newDir, err := utils.CreateTempDir()
assert.NoError(t, err)
defer utils.RemoveTempDir(newDir)
os.Setenv(ModeEnv, test.Mode)
os.Setenv(NetworkEnv, test.Network)
os.Setenv(PortEnv, test.Port)
cfg, err := LoadConfiguration(newDir)
if test.err != nil {
assert.Nil(t, cfg)
assert.Contains(t, err.Error(), test.err.Error())
} else {
test.cfg.IndexerPath = path.Join(newDir, "indexer")
test.cfg.VergedPath = path.Join(newDir, "verged")
assert.Equal(t, test.cfg, cfg)
assert.NoError(t, err)
}
})
}
} | explode_data.jsonl/74032 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1534
} | [
2830,
3393,
5879,
7688,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
3636,
262,
914,
198,
197,
197,
12320,
914,
198,
197,
98459,
262,
914,
271,
197,
50286,
353,
7688,
198,
197,
9859,
1465,
198,
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 TestDownloadSingle(t *testing.T) {
var (
proxyURL = tutils.RandomProxyURL(t)
baseParams = tutils.BaseAPIParams(proxyURL)
objName = "object"
objNameSecond = "object-second"
// Links below don't contain protocols to test that no error occurs
// in case they are missing.
linkLarge = "storage.googleapis.com/nvdata-openimages/openimages-train-000001.tar"
linkSmall = "storage.googleapis.com/minikube/iso/minikube-v0.23.0.iso.sha256"
)
runProviderTests(t, func(t *testing.T, bck *cluster.Bck) {
m := ioContext{
t: t,
bck: bck.Bck,
}
m.initWithCleanup()
defer m.del()
clearDownloadList(t)
id, err := api.DownloadSingle(baseParams, generateDownloadDesc(), bck.Bck, objName, linkLarge)
tassert.CheckError(t, err)
time.Sleep(time.Second)
// Schedule second object.
idSecond, err := api.DownloadSingle(baseParams, generateDownloadDesc(), bck.Bck, objNameSecond, linkLarge)
tassert.CheckError(t, err)
// Cancel second object.
err = api.AbortDownload(baseParams, idSecond)
tassert.CheckError(t, err)
// Cancel first object.
abortDownload(t, id)
time.Sleep(time.Second)
// Check if the status is still available after some time.
if resp, err := api.DownloadStatus(baseParams, id); err != nil {
t.Errorf("got error when getting status for link that is not being downloaded: %v", err)
} else if !resp.Aborted {
t.Errorf("canceled link not marked: %v", resp)
}
err = api.AbortDownload(baseParams, id)
tassert.CheckError(t, err)
err = api.RemoveDownload(baseParams, id)
tassert.CheckError(t, err)
err = api.RemoveDownload(baseParams, id)
tassert.Errorf(t, err != nil, "expected error when removing non-existent task")
id, err = api.DownloadSingle(baseParams, generateDownloadDesc(), bck.Bck, objName, linkSmall)
tassert.CheckError(t, err)
waitForDownload(t, id, 30*time.Second)
checkDownloadedObjects(t, id, bck.Bck, []string{objName})
checkDownloadList(t, 2)
})
} | explode_data.jsonl/70376 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 757
} | [
2830,
3393,
11377,
10888,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
197,
22803,
3144,
414,
284,
259,
6031,
26709,
16219,
3144,
1155,
340,
197,
24195,
4870,
262,
284,
259,
6031,
13018,
7082,
4870,
65787,
3144,
340,
197,
22671,
675,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransportServerClosingUnexpectedly(t *testing.T) {
defer afterTest(t)
ts := httptest.NewServer(hostPortHandler)
defer ts.Close()
tr := &Transport{}
c := &Client{Transport: tr}
fetch := func(n, retries int) string {
condFatalf := func(format string, arg ...interface{}) {
if retries <= 0 {
t.Fatalf(format, arg...)
}
t.Logf("retrying shortly after expected error: "+format, arg...)
time.Sleep(time.Second / time.Duration(retries))
}
for retries >= 0 {
retries--
res, err := c.Get(ts.URL)
if err != nil {
condFatalf("error in req #%d, GET: %v", n, err)
continue
}
body, err := ioutil.ReadAll(res.Body)
if err != nil {
condFatalf("error in req #%d, ReadAll: %v", n, err)
continue
}
res.Body.Close()
return string(body)
}
panic("unreachable")
}
body1 := fetch(1, 0)
body2 := fetch(2, 0)
ts.CloseClientConnections() // surprise!
// This test has an expected race. Sleeping for 25 ms prevents
// it on most fast machines, causing the next fetch() call to
// succeed quickly. But if we do get errors, fetch() will retry 5
// times with some delays between.
time.Sleep(25 * time.Millisecond)
body3 := fetch(3, 5)
if body1 != body2 {
t.Errorf("expected body1 and body2 to be equal")
}
if body2 == body3 {
t.Errorf("expected body2 and body3 to be different")
}
} | explode_data.jsonl/4880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 535
} | [
2830,
3393,
27560,
5475,
36294,
29430,
398,
1155,
353,
8840,
836,
8,
341,
16867,
1283,
2271,
1155,
340,
57441,
1669,
54320,
70334,
7121,
5475,
19973,
7084,
3050,
340,
16867,
10591,
10421,
2822,
25583,
1669,
609,
27560,
16094,
1444,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSecondCurrency(t *testing.T) {
t.Parallel()
pair := NewCurrencyPair("BTC", "USD")
actual := pair.SecondCurrency
expected := CurrencyItem("USD")
if actual != expected {
t.Errorf(
"Test failed. GetSecondCurrency(): %s was not equal to expected value: %s",
actual, expected,
)
}
} | explode_data.jsonl/55828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 110
} | [
2830,
3393,
15666,
26321,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
3223,
1310,
1669,
1532,
26321,
12443,
445,
59118,
497,
330,
26749,
1138,
88814,
1669,
6716,
32435,
26321,
198,
42400,
1669,
28453,
1234,
445,
26749,
1138,
743... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackupRestoreEmptyDB(t *testing.T) {
defer leaktest.AfterTest(t)()
const numAccounts = 1
_, _, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, singleNode, numAccounts, InitNone)
defer cleanupFn()
sqlDB.Exec(t, `CREATE DATABASE empty`)
sqlDB.Exec(t, `BACKUP DATABASE empty TO $1`, LocalFoo)
sqlDB.Exec(t, `DROP DATABASE empty`)
sqlDB.Exec(t, `RESTORE DATABASE empty FROM $1`, LocalFoo)
sqlDB.CheckQueryResults(t, `USE empty; SHOW TABLES;`, [][]string{})
} | explode_data.jsonl/57619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
56245,
56284,
3522,
3506,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
1629,
41369,
284,
220,
16,
198,
197,
6878,
8358,
5704,
3506,
11,
8358,
21290,
24911,
1669,
43438,
56284,
2271,
218... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEachStr(t *testing.T) {
v := &Value{data: []string{string("hello"), string("hello"), string("hello"), string("hello"), string("hello")}}
count := 0
replacedVals := make([]string, 0)
assert.Equal(t, v, v.EachStr(func(i int, val string) bool {
count++
replacedVals = append(replacedVals, val)
// abort early
if i == 2 {
return false
}
return true
}))
assert.Equal(t, count, 3)
assert.Equal(t, replacedVals[0], v.MustStrSlice()[0])
assert.Equal(t, replacedVals[1], v.MustStrSlice()[1])
assert.Equal(t, replacedVals[2], v.MustStrSlice()[2])
} | explode_data.jsonl/23411 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
4854,
2580,
1155,
353,
8840,
836,
8,
1476,
5195,
1669,
609,
1130,
90,
691,
25,
3056,
917,
90,
917,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
3975,
914,
445,
14990,
899,
11248,
18032,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewHaGroupDeleteParamsWithTimeout(t *testing.T) {
p := NewHaGroupDeleteParamsWithTimeout(time.Minute * 5)
require.NotNil(t, p.timeout)
assert.Equal(t, time.Minute*5, p.timeout)
} | explode_data.jsonl/7748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 74
} | [
2830,
3393,
3564,
32942,
2808,
6435,
4870,
2354,
7636,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
1532,
32942,
2808,
6435,
4870,
2354,
7636,
9730,
75770,
353,
220,
20,
340,
17957,
93882,
1155,
11,
281,
36110,
340,
6948,
12808,
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 |
func TestEvaluateSubElem(t *testing.T) {
tstx := TstX{A: "foo", B: "bar"}
var inner struct {
S fmt.Stringer
}
inner.S = tstx
interfaceValue := reflect.ValueOf(&inner).Elem().Field(0)
for i, this := range []struct {
value reflect.Value
key string
expect interface{}
}{
{reflect.ValueOf(tstx), "A", "foo"},
{reflect.ValueOf(&tstx), "TstRp", "rfoo"},
{reflect.ValueOf(tstx), "TstRv", "rbar"},
//{reflect.ValueOf(map[int]string{1: "foo", 2: "bar"}), 1, "foo"},
{reflect.ValueOf(map[string]string{"key1": "foo", "key2": "bar"}), "key1", "foo"},
{interfaceValue, "String", "A: foo, B: bar"},
{reflect.Value{}, "foo", false},
//{reflect.ValueOf(map[int]string{1: "foo", 2: "bar"}), 1.2, false},
{reflect.ValueOf(tstx), "unexported", false},
{reflect.ValueOf(tstx), "unexportedMethod", false},
{reflect.ValueOf(tstx), "MethodWithArg", false},
{reflect.ValueOf(tstx), "MethodReturnNothing", false},
{reflect.ValueOf(tstx), "MethodReturnErrorOnly", false},
{reflect.ValueOf(tstx), "MethodReturnTwoValues", false},
{reflect.ValueOf(tstx), "MethodReturnValueWithError", false},
{reflect.ValueOf((*TstX)(nil)), "A", false},
{reflect.ValueOf(tstx), "C", false},
{reflect.ValueOf(map[int]string{1: "foo", 2: "bar"}), "1", false},
{reflect.ValueOf([]string{"foo", "bar"}), "1", false},
} {
result, err := evaluateSubElem(this.value, this.key)
if b, ok := this.expect.(bool); ok && !b {
if err == nil {
t.Errorf("[%d] evaluateSubElem didn't return an expected error", i)
}
} else {
if err != nil {
t.Errorf("[%d] failed: %s", i, err)
continue
}
if result.Kind() != reflect.String || result.String() != this.expect {
t.Errorf("[%d] evaluateSubElem with %v got %v but expected %v", i, this.key, result, this.expect)
}
}
}
} | explode_data.jsonl/9226 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 770
} | [
2830,
3393,
82345,
3136,
25586,
1155,
353,
8840,
836,
8,
341,
3244,
267,
87,
1669,
350,
267,
55,
90,
32,
25,
330,
7975,
497,
425,
25,
330,
2257,
16707,
2405,
9179,
2036,
341,
197,
7568,
8879,
6431,
261,
198,
197,
532,
197,
4382,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestSharder(t *testing.T) {
t.Run("constructing with bad count panics", func(t *testing.T) {
defer func() {
if x := recover(); x == nil {
t.Fatal("wanted New to panic when given bad count")
}
}()
New(0)
})
t.Run("only one shard", func(t *testing.T) {
s := New(1)
for i := 0; i < 100; i++ {
if idx := s.Index(uuid.New().String()); idx != 0 {
t.Fatalf("want index 0, got %d", idx)
}
}
})
t.Run("many shards", func(t *testing.T) {
s := New(10)
for i := 0; i < 100; i++ {
if idx := s.Index(uuid.New().String()); idx < 0 || idx >= 10 {
t.Fatalf("want index in range 0..10, got %d", idx)
}
}
})
} | explode_data.jsonl/64547 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 308
} | [
2830,
3393,
2016,
567,
261,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
7596,
287,
448,
3873,
1760,
7215,
1211,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
16867,
2915,
368,
341,
298,
743,
856,
1669,
11731,
2129,
856,
621,
209... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplyKeyStoreConfig(t *testing.T) {
slotNumber := 1
tempDir := t.TempDir()
worldReadablePinFilePath := filepath.Join(tempDir, "world-readable-pin-file")
err := os.WriteFile(worldReadablePinFilePath, []byte("world-readable-pin-file"), 0o644)
require.NoError(t, err)
securePinFilePath := filepath.Join(tempDir, "secure-pin-file")
err = os.WriteFile(securePinFilePath, []byte("secure-pin-file"), 0o600)
require.NoError(t, err)
worldWritablePKCS11LibPath := filepath.Join(tempDir, "world-writable-pkcs1")
err = os.WriteFile(worldWritablePKCS11LibPath, []byte("pkcs11"), 0o666)
require.NoError(t, err)
require.NoError(t, os.Chmod(worldWritablePKCS11LibPath, 0o666))
securePKCS11LibPath := filepath.Join(tempDir, "secure-pkcs11")
err = os.WriteFile(securePKCS11LibPath, []byte("pkcs11"), 0o600)
require.NoError(t, err)
tests := []struct {
name string
auth Auth
want keystore.Config
errMessage string
}{
{
name: "handle nil configuration",
auth: Auth{
CAKeyParams: nil,
},
want: service.MakeDefaultConfig().Auth.KeyStore,
},
{
name: "correct config",
auth: Auth{
CAKeyParams: &CAKeyParams{
PKCS11: PKCS11{
ModulePath: securePKCS11LibPath,
TokenLabel: "foo",
SlotNumber: &slotNumber,
Pin: "pin",
},
},
},
want: keystore.Config{
TokenLabel: "foo",
SlotNumber: &slotNumber,
Pin: "pin",
Path: securePKCS11LibPath,
},
},
{
name: "correct config with pin file",
auth: Auth{
CAKeyParams: &CAKeyParams{
PKCS11: PKCS11{
ModulePath: securePKCS11LibPath,
TokenLabel: "foo",
SlotNumber: &slotNumber,
PinPath: securePinFilePath,
},
},
},
want: keystore.Config{
TokenLabel: "foo",
SlotNumber: &slotNumber,
Pin: "secure-pin-file",
Path: securePKCS11LibPath,
},
},
{
name: "err when pin and pin path configured",
auth: Auth{
CAKeyParams: &CAKeyParams{
PKCS11: PKCS11{
Pin: "oops",
PinPath: securePinFilePath,
},
},
},
errMessage: "can not set both pin and pin_path",
},
{
name: "err when pkcs11 world writable",
auth: Auth{
CAKeyParams: &CAKeyParams{
PKCS11: PKCS11{
ModulePath: worldWritablePKCS11LibPath,
},
},
},
errMessage: fmt.Sprintf(
"PKCS11 library (%s) must not be world-writable",
worldWritablePKCS11LibPath,
),
},
{
name: "err when pin file world-readable",
auth: Auth{
CAKeyParams: &CAKeyParams{
PKCS11: PKCS11{
PinPath: worldReadablePinFilePath,
},
},
},
errMessage: fmt.Sprintf(
"HSM pin file (%s) must not be world-readable",
worldReadablePinFilePath,
),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := service.MakeDefaultConfig()
err := applyKeyStoreConfig(&FileConfig{
Auth: tt.auth,
}, cfg)
if tt.errMessage != "" {
require.EqualError(t, err, tt.errMessage)
} else {
require.NoError(t, err)
require.Equal(t, tt.want, cfg.Auth.KeyStore)
}
})
}
} | explode_data.jsonl/47184 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1452
} | [
2830,
3393,
28497,
1592,
6093,
2648,
1155,
353,
8840,
836,
8,
341,
61675,
2833,
1669,
220,
16,
271,
16280,
6184,
1669,
259,
65009,
6184,
2822,
76508,
57938,
19861,
19090,
1669,
26054,
22363,
9758,
6184,
11,
330,
14615,
83218,
74443,
14203... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetIdentifiers(t *testing.T) {
ctx := context.Background()
backend := &etcdTest{}
resp := new(client.Response)
configPath := new(client.Node)
node1 := createTestNode("check_names")
node2 := createTestNode("init_configs")
node3 := createTestNode("instances")
nodes := []*client.Node{node1, node2, node3}
configPath.Key = "/datadog/check_configs/"
nginx := &client.Node{
Key: "/datadog/check_configs/nginx",
Dir: true,
Nodes: nodes,
}
adTemplate := []*client.Node{nginx}
configPath.Nodes = adTemplate
resp.Node = configPath
backend.On("Get", context.Background(), "/datadog/check_configs", &client.GetOptions{Recursive: true}).Return(resp, nil).Times(1)
etcd := EtcdConfigProvider{Client: backend, templateDir: "/datadog/check_configs"}
array := etcd.getIdentifiers(ctx, "/datadog/check_configs")
assert.Len(t, array, 1)
assert.Equal(t, array, []string{"nginx"})
badConf := new(client.Node)
toofew := []*client.Node{node1, node2}
badConf.Key = "/datadog/check_configs/"
haproxy := &client.Node{
Key: "/datadog/check_configs/haproxy",
Dir: true,
Nodes: toofew,
}
adTemplate = []*client.Node{haproxy}
badConf.Nodes = adTemplate
resp.Node = badConf
backend.On("Get", context.Background(), "/datadog/check_configs", &client.GetOptions{Recursive: true}).Return(resp, nil)
errArray := etcd.getIdentifiers(ctx, "/datadog/check_configs")
assert.Len(t, errArray, 0)
assert.Equal(t, errArray, []string{})
backend.AssertExpectations(t)
} | explode_data.jsonl/53943 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 574
} | [
2830,
3393,
1949,
28301,
11836,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
197,
20942,
1669,
609,
295,
4385,
2271,
16094,
34653,
1669,
501,
12805,
12574,
340,
25873,
1820,
1669,
501,
12805,
21714,
340,
20831,
16,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestClient_PullIsMergeable(t *testing.T) {
cases := map[string]struct {
DiffStat string
ExpMergeable bool
}{
"mergeable": {
DiffStat: `{
"pagelen": 500,
"values": [
{
"status": "added",
"old": null,
"lines_removed": 0,
"lines_added": 2,
"new": {
"path": "parent/child/file1.txt",
"type": "commit_file",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/src/1ed8205eec00dab4f1c0a8c486a4492c98c51f8e/main.tf"
}
}
},
"type": "diffstat"
}
],
"page": 1,
"size": 1
}`,
ExpMergeable: true,
},
"merge conflict": {
DiffStat: `{
"pagelen": 500,
"values": [
{
"status": "merge conflict",
"old": {
"path": "main.tf",
"type": "commit_file",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/src/6d6a8026a788621b37a9ac422a7d0ebb1500e85f/main.tf"
}
}
},
"lines_removed": 1,
"lines_added": 0,
"new": {
"path": "main.tf",
"type": "commit_file",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/src/742e76108714365788f5681e99e4a64f45dce147/main.tf"
}
}
},
"type": "diffstat"
}
],
"page": 1,
"size": 1
}`,
ExpMergeable: false,
},
"merge conflict due to file deleted": {
DiffStat: `{
"pagelen": 500,
"values": [
{
"status": "local deleted",
"old": null,
"lines_removed": 0,
"lines_added": 3,
"new": {
"path": "main.tf",
"type": "commit_file",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/lkysow/atlantis-example/src/3539b9f51c9f91e8f6280e89c62e2673ddc51144/main.tf"
}
}
},
"type": "diffstat"
}
],
"page": 1,
"size": 1
}`,
ExpMergeable: false,
},
}
for name, c := range cases {
t.Run(name, func(t *testing.T) {
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.RequestURI {
case "/2.0/repositories/owner/repo/pullrequests/1/diffstat":
w.Write([]byte(c.DiffStat)) // nolint: errcheck
return
default:
t.Errorf("got unexpected request at %q", r.RequestURI)
http.Error(w, "not found", http.StatusNotFound)
return
}
}))
defer testServer.Close()
client := bitbucketcloud.NewClient(http.DefaultClient, "user", "pass", "runatlantis.io")
client.BaseURL = testServer.URL
actMergeable, err := client.PullIsMergeable(models.Repo{
FullName: "owner/repo",
Owner: "owner",
Name: "repo",
CloneURL: "",
SanitizedCloneURL: "",
VCSHost: models.VCSHost{
Type: models.BitbucketCloud,
Hostname: "bitbucket.org",
},
}, models.PullRequest{
Num: 1,
})
Ok(t, err)
Equals(t, c.ExpMergeable, actMergeable)
})
}
} | explode_data.jsonl/53235 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1668
} | [
2830,
3393,
2959,
1088,
617,
3872,
52096,
480,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
2415,
14032,
60,
1235,
341,
197,
10957,
3092,
15878,
257,
914,
198,
197,
197,
8033,
52096,
480,
1807,
198,
197,
59403,
197,
197,
1,
19052,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCache_ObjectReader(t *testing.T) {
cfg, repo, _ := testcfg.BuildWithRepo(t)
repoExecutor := newRepoExecutor(t, cfg, repo)
cache := newCache(time.Hour, 10, helper.NewManualTicker())
defer cache.Stop()
cache.cachedProcessDone = sync.NewCond(&sync.Mutex{})
t.Run("uncancellable", func(t *testing.T) {
ctx := testhelper.ContextWithoutCancel()
require.PanicsWithValue(t, "empty ctx.Done() in catfile.Batch.New()", func() {
_, _ = cache.ObjectReader(ctx, repoExecutor)
})
})
t.Run("uncacheable", func(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
// The context doesn't carry a session ID and is thus uncacheable.
// The process should never get returned to the cache and must be
// killed on context cancellation.
reader, err := cache.ObjectReader(ctx, repoExecutor)
require.NoError(t, err)
objectReaderImpl, ok := reader.(*objectReader)
require.True(t, ok, "expected object reader")
cancel()
// We're cheating a bit here to avoid creating a racy test by reaching into the
// process and trying to read from its stdout. If the cancel did kill the process as
// expected, then the stdout should be closed and we'll get an EOF.
output, err := io.ReadAll(objectReaderImpl.queue.stdout)
if err != nil {
require.True(t, errors.Is(err, os.ErrClosed))
} else {
require.NoError(t, err)
}
require.Empty(t, output)
require.True(t, reader.isClosed())
require.Empty(t, keys(t, &cache.objectReaders))
})
t.Run("cacheable", func(t *testing.T) {
defer cache.Evict()
ctx, cancel := testhelper.Context()
defer cancel()
ctx = correlation.ContextWithCorrelation(ctx, "1")
ctx = testhelper.MergeIncomingMetadata(ctx,
metadata.Pairs(SessionIDField, "1"),
)
reader, err := cache.ObjectReader(ctx, repoExecutor)
require.NoError(t, err)
// Cancel the context such that the process will be considered for return to the
// cache and wait for the cache to collect it.
cache.cachedProcessDone.L.Lock()
cancel()
defer cache.cachedProcessDone.L.Unlock()
cache.cachedProcessDone.Wait()
keys := keys(t, &cache.objectReaders)
require.Equal(t, []key{{
sessionID: "1",
repoStorage: repo.GetStorageName(),
repoRelPath: repo.GetRelativePath(),
}}, keys)
// Assert that we can still read from the cached process.
_, err = reader.Object(ctx, "refs/heads/master")
require.NoError(t, err)
})
t.Run("dirty process does not get cached", func(t *testing.T) {
defer cache.Evict()
ctx, cancel := testhelper.Context()
defer cancel()
ctx = testhelper.MergeIncomingMetadata(ctx,
metadata.Pairs(SessionIDField, "1"),
)
reader, err := cache.ObjectReader(ctx, repoExecutor)
require.NoError(t, err)
// While we request object data, we do not consume it at all. The reader is thus
// dirty and cannot be reused and shouldn't be returned to the cache.
object, err := reader.Object(ctx, "refs/heads/master")
require.NoError(t, err)
// Cancel the context such that the process will be considered for return to the
// cache and wait for the cache to collect it.
cache.cachedProcessDone.L.Lock()
cancel()
defer cache.cachedProcessDone.L.Unlock()
cache.cachedProcessDone.Wait()
require.Empty(t, keys(t, &cache.objectReaders))
// The process should be killed now, so reading the object must fail.
_, err = io.ReadAll(object)
require.True(t, errors.Is(err, os.ErrClosed))
})
t.Run("closed process does not get cached", func(t *testing.T) {
defer cache.Evict()
ctx, cancel := testhelper.Context()
defer cancel()
ctx = testhelper.MergeIncomingMetadata(ctx,
metadata.Pairs(SessionIDField, "1"),
)
reader, err := cache.ObjectReader(ctx, repoExecutor)
require.NoError(t, err)
// Closed processes naturally cannot be reused anymore and thus shouldn't ever get
// cached.
reader.close()
// Cancel the context such that the process will be considered for return to the
// cache and wait for the cache to collect it.
cache.cachedProcessDone.L.Lock()
cancel()
defer cache.cachedProcessDone.L.Unlock()
cache.cachedProcessDone.Wait()
require.Empty(t, keys(t, &cache.objectReaders))
})
} | explode_data.jsonl/81954 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1482
} | [
2830,
3393,
8233,
27839,
5062,
1155,
353,
8840,
836,
8,
341,
50286,
11,
15867,
11,
716,
1669,
1273,
14072,
25212,
2354,
25243,
1155,
340,
17200,
5368,
25255,
1669,
501,
25243,
25255,
1155,
11,
13286,
11,
15867,
692,
52680,
1669,
501,
82... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCookieSyncNoCookies(t *testing.T) {
rr := doPost(`{"bidders":["appnexus", "audienceNetwork", "random"]}`, nil, true, syncersForTest())
assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8")
assert.Equal(t, http.StatusOK, rr.Code)
assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork"}, parseSyncs(t, rr.Body.Bytes()))
assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes()))
} | explode_data.jsonl/21682 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
20616,
12154,
2753,
50672,
1155,
353,
8840,
836,
8,
341,
197,
634,
1669,
65156,
5809,
4913,
65,
99129,
36799,
676,
77,
23666,
497,
330,
7880,
1835,
12320,
497,
330,
11463,
1341,
28350,
2092,
11,
830,
11,
12811,
388,
2461,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMaxLength(t *testing.T) {
store := New(newDB(), []byte("secret"))
store.MaxLength(10)
r1 := req(func(w http.ResponseWriter, r *http.Request) {
session, err := store.Get(r, "session")
if err != nil {
panic(err)
}
session.Values["a"] = "aaaaaaaaaaaaaaaaaaaaaaaa"
if err := store.Save(r, w, session); err == nil {
t.Error("Expected too large error")
}
http.Error(w, "", http.StatusOK)
}, nil)
match(t, r1, 200, "")
} | explode_data.jsonl/71334 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
35601,
1155,
353,
8840,
836,
8,
341,
57279,
1669,
1532,
1755,
3506,
1507,
3056,
3782,
445,
20474,
5455,
57279,
70092,
7,
16,
15,
692,
7000,
16,
1669,
4232,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestSortedArray_NewSortedArrayFrom(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
a1 := []interface{}{"a", "f", "c"}
a2 := []interface{}{"h", "j", "i", "k"}
func1 := func(v1, v2 interface{}) int {
return strings.Compare(gconv.String(v1), gconv.String(v2))
}
func2 := func(v1, v2 interface{}) int {
return -1
}
array1 := garray.NewSortedArrayFrom(a1, func1)
array2 := garray.NewSortedArrayFrom(a2, func2)
t.Assert(array1.Len(), 3)
t.Assert(array1, []interface{}{"a", "c", "f"})
t.Assert(array2.Len(), 4)
t.Assert(array2, []interface{}{"k", "i", "j", "h"})
})
} | explode_data.jsonl/67004 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 285
} | [
2830,
3393,
51051,
1857,
39582,
51051,
1857,
3830,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
11323,
16,
1669,
3056,
4970,
6257,
4913,
64,
497,
330,
69,
497,
330,
66,
16707,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSliceMap(t *testing.T) {
tests := []struct {
name string
input []int
mapper func(int) int
want []int
}{
{
name: "case",
input: []int{1, 2, 1},
mapper: func(i int) int { return i * 2 },
want: []int{2, 4, 2},
},
{
name: "case",
input: []int{1, 2, 1},
mapper: func(i int) int { return i * 2 },
want: []int{2, 4, 2},
},
{
name: "empty",
input: []int{},
mapper: func(i int) int { return i * 2 },
want: []int{},
},
{
name: "nil",
input: nil,
mapper: func(i int) int { return i * 2 },
want: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := NewSlice(tt.input).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
got = NewSlice(tt.input).Parallel(2).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
got = NewSliceByComparable(tt.input).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
got = NewSliceByComparable(tt.input).Parallel(2).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
got = NewSliceByOrdered(tt.input).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
got = NewSliceByOrdered(tt.input).Parallel(2).Map(tt.mapper).ToSlice()
assert.Equal(t, tt.want, got)
})
}
tests = []struct {
name string
input []int
mapper func(int) int
want []int
}{
{
name: "case",
input: newArray(100),
mapper: func(i int) int { return i * 2 },
},
{
name: "case",
input: newArray(200),
mapper: func(i int) int { return i * 3 },
},
{
name: "case",
input: newArray(300),
mapper: func(i int) int { return i * 4 },
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t,
NewSliceByOrdered(tt.input).Parallel(10).Map(tt.mapper).ToSlice(),
NewSliceByOrdered(tt.input).Map(tt.mapper).ToSlice())
})
}
} | explode_data.jsonl/55753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 946
} | [
2830,
3393,
33236,
2227,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
256,
914,
198,
197,
22427,
220,
3056,
396,
198,
197,
2109,
3106,
2915,
1548,
8,
526,
198,
197,
50780,
256,
3056,
396,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIgnoringEINTR(t *testing.T) {
eintrs := 100
err := ignoringEINTR(func() error {
if eintrs == 0 {
return nil
}
eintrs--
return syscall.EINTR
})
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/55534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 98
} | [
2830,
3393,
87743,
36,
79079,
1155,
353,
8840,
836,
8,
341,
7727,
58788,
82,
1669,
220,
16,
15,
15,
198,
9859,
1669,
30903,
36,
79079,
18552,
368,
1465,
341,
197,
743,
4368,
85385,
621,
220,
15,
341,
298,
853,
2092,
198,
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... | 2 |
func TestStructLevel(t *testing.T) {
type Test struct {
String string
}
set := New()
set.RegisterStructLevel(func(ctx context.Context, t *Transformer, value reflect.Value) error {
s := value.Interface().(Test)
if s.String == "error" {
return errors.New("BAD VALUE")
}
s.String = "test"
value.Set(reflect.ValueOf(s))
return nil
}, Test{})
var tt Test
err := set.Struct(context.Background(), &tt)
Equal(t, err, nil)
Equal(t, tt.String, "test")
tt.String = "error"
err = set.Struct(context.Background(), &tt)
NotEqual(t, err, nil)
} | explode_data.jsonl/43620 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 221
} | [
2830,
3393,
9422,
4449,
1155,
353,
8840,
836,
8,
341,
13158,
3393,
2036,
341,
197,
4980,
914,
198,
197,
630,
8196,
1669,
1532,
741,
8196,
19983,
9422,
4449,
18552,
7502,
2266,
9328,
11,
259,
353,
46358,
11,
897,
8708,
6167,
8,
1465,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRouteCacheContents(t *testing.T) {
tests := map[string]struct {
contents map[string]*v2.RouteConfiguration
want []proto.Message
}{
"empty": {
contents: nil,
want: nil,
},
"simple": {
contents: map[string]*v2.RouteConfiguration{
"ingress_http": {
Name: "ingress_http",
},
"ingress_https": {
Name: "ingress_https",
},
},
want: []proto.Message{
&v2.RouteConfiguration{
Name: "ingress_http",
},
&v2.RouteConfiguration{
Name: "ingress_https",
},
},
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
var rc RouteCache
rc.Update(tc.contents)
got := rc.Contents()
assert.Equal(t, tc.want, got)
})
}
} | explode_data.jsonl/56949 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 353
} | [
2830,
3393,
4899,
8233,
14803,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
197,
17610,
2415,
14032,
8465,
85,
17,
58004,
7688,
198,
197,
50780,
257,
3056,
15110,
8472,
198,
197,
59403,
197,
197,
1,
3194... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestService_NewService(t *testing.T) {
data := struct {
address string
name string
args []string
}{
address: "10.0.1.66",
name: "cat",
args: []string{"testdata/sample_output.txt"},
}
cases := []struct {
svc *checkService
}{
{
&checkService{
address: data.address,
cmd: data.name,
cmdArgs: data.args,
},
},
}
for _, c := range cases {
svc := NewService(data.address, data.name, data.args)
if !reflect.DeepEqual(svc, c.svc) {
t.Errorf("expected %v to be %v", svc, c.svc)
}
}
} | explode_data.jsonl/1799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 258
} | [
2830,
3393,
1860,
39582,
1860,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
2036,
341,
197,
63202,
914,
198,
197,
11609,
262,
914,
198,
197,
31215,
262,
3056,
917,
198,
197,
59403,
197,
63202,
25,
330,
16,
15,
13,
15,
13,
16,
13,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBytes_ToBytes(t *testing.T) {
tests := []struct {
name string
e Bytes
want Bytes
}{
{name: "", e: Bytes{[]byte("abc")}, want: Bytes{[]byte("abc")}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := tt.e.ToBytes(); !got.Equal(tt.want) {
t.Errorf("Bytes.ToBytes() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/34772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 179
} | [
2830,
3393,
7078,
38346,
7078,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
7727,
262,
30024,
198,
197,
50780,
30024,
198,
197,
59403,
197,
197,
47006,
25,
7342,
384,
25,
30024,
90,
1294,
3782... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestReaderDict(t *testing.T) {
const (
dict = "hello world"
text = "hello again world"
)
var b bytes.Buffer
w, err := NewWriter(&b, 5)
if err != nil {
t.Fatalf("NewWriter: %v", err)
}
w.Write([]byte(dict))
w.Flush()
b.Reset()
w.Write([]byte(text))
w.Close()
r := NewReaderDict(&b, []byte(dict))
data, err := ioutil.ReadAll(r)
if err != nil {
t.Fatal(err)
}
if string(data) != "hello again world" {
t.Fatalf("read returned %q want %q", string(data), text)
}
} | explode_data.jsonl/81409 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
5062,
13448,
1155,
353,
8840,
836,
8,
341,
4777,
2399,
197,
2698,
849,
284,
330,
14990,
1879,
698,
197,
15425,
284,
330,
14990,
1549,
1879,
698,
197,
340,
2405,
293,
5820,
22622,
198,
6692,
11,
1848,
1669,
1532,
6492,
2099... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_Cache3(t *testing.T) {
var err error
var fn string
fn = ""
_, err = Read(fn)
if err == nil {
t.Fatalf("CachedFile Test 7 failed")
}
err = Write(fn, fn, false)
if err == nil {
t.Fatalf("CachedFile Test 8 failed")
}
} | explode_data.jsonl/63483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 102
} | [
2830,
3393,
920,
1777,
18,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
2405,
5168,
914,
198,
40095,
284,
35829,
197,
6878,
1848,
284,
4457,
24008,
340,
743,
1848,
621,
2092,
341,
197,
3244,
30762,
445,
70293,
1703,
3393,
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 TestFormatterForegroundForeground(test *testing.T) {
formatted, err := formatter.Format("{black | foreground | foreground}black{normal}")
assert.NoError(test, err)
assert.Equal(test, "\x1b[30mblack\x1b[0m", formatted)
} | explode_data.jsonl/39763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
14183,
25982,
25982,
8623,
353,
8840,
836,
8,
341,
37410,
12127,
11,
1848,
1669,
24814,
9978,
13976,
11453,
760,
39305,
760,
39305,
92,
11453,
90,
8252,
55266,
6948,
35699,
8623,
11,
1848,
340,
6948,
12808,
8623,
11,
2917,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestQuotedPrintable(t *testing.T) {
tests := []struct {
in, want string
err interface{}
}{
{in: "foo bar", want: "foo bar"},
{in: "foo bar=3D", want: "foo bar="},
{in: "foo bar=0", want: "foo bar", err: io.ErrUnexpectedEOF},
{in: "foo bar=ab", want: "foo bar", err: "multipart: invalid quoted-printable hex byte 0x61"},
{in: "foo bar=0D=0A", want: "foo bar\r\n"},
{in: "foo bar=\r\n baz", want: "foo bar baz"},
{in: "foo=\nbar", want: "foobar"},
{in: "foo\x00bar", want: "foo", err: "multipart: invalid unescaped byte 0x00 in quoted-printable body"},
{in: "foo bar\xff", want: "foo bar", err: "multipart: invalid unescaped byte 0xff in quoted-printable body"},
}
for _, tt := range tests {
var buf bytes.Buffer
_, err := io.Copy(&buf, newQuotedPrintableReader(strings.NewReader(tt.in)))
if got := buf.String(); got != tt.want {
t.Errorf("for %q, got %q; want %q", tt.in, got, tt.want)
}
switch verr := tt.err.(type) {
case nil:
if err != nil {
t.Errorf("for %q, got unexpected error: %v", tt.in, err)
}
case string:
if got := fmt.Sprint(err); got != verr {
t.Errorf("for %q, got error %q; want %q", tt.in, got, verr)
}
case error:
if err != verr {
t.Errorf("for %q, got error %q; want %q", tt.in, err, verr)
}
}
}
} | explode_data.jsonl/51801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 588
} | [
2830,
3393,
2183,
9253,
8994,
480,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
11,
1366,
914,
198,
197,
9859,
414,
3749,
16094,
197,
59403,
197,
197,
90,
258,
25,
330,
7975,
3619,
497,
1366,
25,
330,
7975... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 9 |
func TestApplicationList_fail(t *testing.T) {
ts := GateServerFail()
defer ts.Close()
meta := command.ApiMeta{}
args := []string{"--gate-endpoint", ts.URL}
cmd := ApplicationListCommand{
ApiMeta: meta,
}
ret := cmd.Run(args)
if ret == 0 { // Success is actually failure here, internal server error.
t.Fatalf("Command failed with: %d", ret)
}
} | explode_data.jsonl/18311 | {
"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,
4988,
852,
22121,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
29243,
5475,
19524,
741,
16867,
10591,
10421,
2822,
84004,
1669,
3210,
21044,
12175,
16094,
31215,
1669,
3056,
917,
4913,
313,
24601,
13068,
2768,
497,
10591,
20893,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconcileOnCancelledRunFinallyPipelineRun(t *testing.T) {
testCases := []struct {
name string
embeddedVal string
}{
{
name: "default embedded status",
embeddedVal: config.DefaultEmbeddedStatus,
},
{
name: "full embedded status",
embeddedVal: config.FullEmbeddedStatus,
},
{
name: "both embedded status",
embeddedVal: config.BothEmbeddedStatus,
},
{
name: "minimal embedded status",
embeddedVal: config.MinimalEmbeddedStatus,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
runTestReconcileOnCancelledRunFinallyPipelineRun(t, tc.embeddedVal)
})
}
} | explode_data.jsonl/27285 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 294
} | [
2830,
3393,
693,
40446,
457,
1925,
39473,
6727,
23949,
34656,
6727,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
197,
69864,
2208,
914,
198,
197,
59403,
197,
197,
515,
298,
11609,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIntDataPoint_CopyTo(t *testing.T) {
ms := NewIntDataPoint()
generateTestIntDataPoint().CopyTo(ms)
assert.EqualValues(t, generateTestIntDataPoint(), ms)
} | explode_data.jsonl/32711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 59
} | [
2830,
3393,
1072,
1043,
2609,
77637,
1249,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
1072,
1043,
2609,
741,
3174,
13220,
2271,
1072,
1043,
2609,
1005,
12106,
1249,
35680,
340,
6948,
12808,
6227,
1155,
11,
6923,
2271,
1072,
1043,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuildHeaders(t *testing.T) {
d := entity.Definition{}
assert.Equal(t, map[string]string{}, d.BuildHeaders())
d = entity.Definition{
Headers: []string{
"x-app:123",
"x-version:3",
},
}
assert.Equal(t, map[string]string{
"x-app": "123",
"x-version": "3",
}, d.BuildHeaders())
} | explode_data.jsonl/68889 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 142
} | [
2830,
3393,
11066,
10574,
1155,
353,
8840,
836,
8,
341,
2698,
1669,
5387,
49947,
4054,
31483,
6948,
12808,
1155,
11,
2415,
14032,
30953,
22655,
294,
25212,
10574,
12367,
2698,
284,
5387,
49947,
4054,
515,
197,
197,
10574,
25,
3056,
917,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseWithFuncsNoPtr(t *testing.T) {
type foo struct{}
err := env.ParseWithFuncs(foo{}, nil)
assert.Error(t, err)
assert.Equal(t, err, env.ErrNotAStructPtr)
} | explode_data.jsonl/7496 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
14463,
2354,
9626,
82,
2753,
5348,
1155,
353,
8840,
836,
8,
341,
13158,
15229,
2036,
16094,
9859,
1669,
6105,
8937,
2354,
9626,
82,
71880,
22655,
2092,
340,
6948,
6141,
1155,
11,
1848,
340,
6948,
12808,
1155,
11,
1848,
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 |
func TestAutoRetryBasicRerun(t *testing.T) {
t.Parallel()
out := new(bytes.Buffer)
rootPath := copyEnvironment(t, TEST_FIXTURE_AUTO_RETRY_RERUN)
modulePath := util.JoinPath(rootPath, TEST_FIXTURE_AUTO_RETRY_RERUN)
err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", modulePath), out, os.Stderr)
assert.Nil(t, err)
assert.Contains(t, out.String(), "Apply complete!")
} | explode_data.jsonl/10091 | {
"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,
13253,
51560,
15944,
49,
261,
359,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
13967,
1669,
501,
23158,
22622,
340,
33698,
1820,
1669,
2975,
12723,
1155,
11,
13602,
42635,
41486,
29013,
77924,
2568,
640,
1861,
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 TestTouchFromTime(t *testing.T) {
fileName := dirRoot + "/touch.txt"
now := time.Now().Local()
err := TouchFromTime(fileName, now, now)
if err != nil {
panic(err)
}
t.Cleanup(func() {
_ = RemoveWithRecur(dirRoot)
})
if !Exists(fileName) {
t.Error("TouchFromTime test failed!")
}
err = RemoveWithRecur(dirRoot)
if err != nil {
panic(err)
}
err = Touch(fileName)
if err != nil {
panic(err)
}
err = TouchFromTime(fileName, now, now)
if err != nil {
panic(err)
}
} | explode_data.jsonl/34172 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 211
} | [
2830,
3393,
11309,
3830,
1462,
1155,
353,
8840,
836,
8,
341,
17661,
675,
1669,
5419,
8439,
488,
3521,
22020,
3909,
1837,
80922,
1669,
882,
13244,
1005,
7319,
2822,
9859,
1669,
19338,
3830,
1462,
23014,
11,
1431,
11,
1431,
340,
743,
1848... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewPartyCoordinator(t *testing.T) {
ApplyDeadline = false
hosts := setupHosts(t, 4)
var pcs []*PartyCoordinator
var peers []string
timeout := time.Second * 4
for _, el := range hosts {
pcs = append(pcs, NewPartyCoordinator(el, timeout))
peers = append(peers, el.ID().String())
}
defer func() {
for _, el := range pcs {
el.Stop()
}
}()
msgID := conversion.RandStringBytesMask(64)
leader, err := LeaderNode(msgID, 10, peers)
assert.Nil(t, err)
// we sort the slice to ensure the leader is the first one easy for testing
for i, el := range pcs {
if el.host.ID().String() == leader {
if i == 0 {
break
}
temp := pcs[0]
pcs[0] = el
pcs[i] = temp
break
}
}
assert.Equal(t, pcs[0].host.ID().String(), leader)
// now we test the leader appears firstly and the the members
leaderAppersFirstTest(t, msgID, peers, pcs)
leaderAppearsLastTest(t, msgID, peers, pcs)
} | explode_data.jsonl/10308 | {
"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,
3564,
37361,
64304,
1155,
353,
8840,
836,
8,
341,
197,
28497,
83593,
284,
895,
198,
197,
44692,
1669,
6505,
9296,
82,
1155,
11,
220,
19,
340,
2405,
70299,
29838,
37361,
64304,
198,
2405,
25029,
3056,
917,
271,
78395,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestMkdir(t *testing.T) {
beforeTest(t)
conn := _getConnection(t)
defer conn.Close()
client := agaveproto.NewSftpRelayClient(conn)
// create a random directory name in our test dir
testDirectoryPath := fmt.Sprintf("%s/%s", CurrentBaseTestDirPath, uuid.New().String())
err := _updateLocalSharedTestDirOwnership()
if err != nil {
assert.FailNowf(t, err.Error(), "Unable to change permission on temp test dir: %s", err.Error())
}
// resolve it to the absolute path within our shared test directory on the remote system
remoteTestDirectoryPath := _resolveTestPath(testDirectoryPath, SFTP_SHARED_TEST_DIR)
req := &agaveproto.SrvMkdirRequest{
SystemConfig: _createRemoteSshKeySystemConfig(),
RemotePath: remoteTestDirectoryPath,
Recursive: false,
}
grpcResponse, err := client.Mkdir(context.Background(), req)
if err != nil {
assert.Nilf(t, err, "Error while invoking remote service: %v", err)
} else {
// get the test directory stat in the local shared directory
tmpTestDirInfo, err := os.Stat(_resolveTestPath(testDirectoryPath, LocalSharedTestDir))
if os.IsNotExist(err) {
assert.FailNowf(t, err.Error(), "Test directory was not created on remote host: %s", err.Error())
}
assert.Equal(t, "", grpcResponse.Error, "Mkdirs on valid remote should return empty Error")
if grpcResponse.Error == "" {
assert.True(t, tmpTestDirInfo.IsDir(), "Remote path should be a directory. File found instead.")
assert.Equal(t, remoteTestDirectoryPath, grpcResponse.RemoteFileInfo.Path, "Returned file name should match the name of the new directory")
assert.Equal(t, tmpTestDirInfo.Name(), grpcResponse.RemoteFileInfo.Name, "Returned file info name should match the name of the new directory")
assert.Equal(t, tmpTestDirInfo.Size(), grpcResponse.RemoteFileInfo.Size, "Returned file info size should match the size of the new directory")
assert.Equal(t, tmpTestDirInfo.ModTime().Unix(), grpcResponse.RemoteFileInfo.LastUpdated, "Returned file info last modified date should match the last modified date of the new directory")
assert.Equal(t, tmpTestDirInfo.Mode().String(), grpcResponse.RemoteFileInfo.Mode, "Returned file info mode should match the mode of the new directory")
assert.True(t, grpcResponse.RemoteFileInfo.IsDirectory, "Returned file info should report as a directory")
assert.False(t, grpcResponse.RemoteFileInfo.IsLink, "Returned file info should not report as a link")
}
}
afterTest(t)
} | explode_data.jsonl/32541 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 788
} | [
2830,
3393,
44,
12438,
1155,
353,
8840,
836,
8,
1476,
63234,
2271,
1155,
692,
32917,
1669,
716,
52414,
1155,
340,
16867,
4534,
10421,
2822,
197,
25291,
1669,
933,
523,
15110,
7121,
50,
25068,
6740,
352,
2959,
20571,
692,
197,
322,
1855,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncompatibilityExistence(t *testing.T) {
var existenceTest = []struct {
path string
}{
{"../examples/petstore/petstore.yaml"},
{"oas-examples/petstore.json"},
{"../examples/bookstore/bookstore.yaml"},
{"oas-examples/openapi.yaml"},
{"oas-examples/adsense.yaml"},
}
for _, trial := range existenceTest {
incompReport := createReport(t, trial.path)
baseNode := createNodeFromFile(incompReport.ReportIdentifier, t)
for _, incomp := range incompReport.GetIncompatibilities() {
t.Run(filepath.Base(trial.path)+"IncompExistence", func(tt *testing.T) {
searchForIncompatibiltiy(baseNode, incomp, t)
})
}
}
} | explode_data.jsonl/26490 | {
"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,
641,
18331,
3147,
25613,
763,
1155,
353,
8840,
836,
8,
1476,
2405,
13885,
2271,
284,
3056,
1235,
341,
197,
26781,
914,
198,
197,
59403,
197,
197,
4913,
1244,
51668,
4322,
295,
4314,
4322,
295,
4314,
33406,
7115,
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 TestWaitForCompletionSucceeded(t *testing.T) {
size := 2
done := make(chan bool, size)
done <- true
totalWaitTime = time.Second
assert.True(t, waitForCompletion(done))
totalWaitTime = 60 * time.Second
} | explode_data.jsonl/62012 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
14190,
2461,
33190,
50,
43805,
1155,
353,
8840,
836,
8,
341,
13832,
1669,
220,
17,
198,
40495,
1669,
1281,
35190,
1807,
11,
1379,
340,
40495,
9119,
830,
198,
34493,
14190,
1462,
284,
882,
32435,
198,
6948,
32443,
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 |
func TestTableRead(t *testing.T) {
t.Run("error reading file", func(t *testing.T) {
expected := "Error reading GPT from file"
f := &testhelper.FileImpl{
Reader: func(b []byte, offset int64) (int, error) {
return 0, fmt.Errorf(expected)
},
}
table, err := Read(f, 512, 512)
if table != nil {
t.Errorf("Returned table instead of nil")
}
if err == nil {
t.Errorf("Returned nil error instead of actual errors")
}
if !strings.HasPrefix(err.Error(), expected) {
t.Errorf("Error type %s instead of expected %s", err.Error(), expected)
}
})
t.Run("insufficient data read", func(t *testing.T) {
size := 100
expected := fmt.Sprintf("Read only %d bytes of GPT", size)
f := &testhelper.FileImpl{
Reader: func(b []byte, offset int64) (int, error) {
return size, nil
},
}
table, err := Read(f, 512, 512)
if table != nil {
t.Errorf("Returned table instead of nil")
}
if err == nil {
t.Errorf("Returned nil error instead of actual errors")
}
if !strings.HasPrefix(err.Error(), expected) {
t.Errorf("Error type %s instead of expected %s", err.Error(), expected)
}
})
t.Run("successful read", func(t *testing.T) {
f, err := os.Open(gptFile)
if err != nil {
t.Fatalf("Error opening file %s to read: %v", gptFile, err)
}
table, err := Read(f, 512, 512)
if table == nil {
t.Errorf("Returned nil instead of table")
}
if err != nil {
t.Errorf("Returned error %v instead of nil", err)
}
expected := GetValidTable()
if table == nil || !table.Equal(expected) {
t.Errorf("actual table was %v instead of expected %v", table, expected)
}
})
} | explode_data.jsonl/61026 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 654
} | [
2830,
3393,
2556,
4418,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
841,
5290,
1034,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
42400,
1669,
330,
1454,
5290,
479,
2828,
504,
1034,
698,
197,
1166,
1669,
609,
1944,
18764,
8576,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDockerVersionComparison(t *testing.T) {
v, err := newDockerVersion("1.10.3")
assert.NoError(t, err)
for i, test := range []struct {
version string
compare int
err bool
}{
{version: "1.9.2", compare: 1},
{version: "1.9.2-rc2", compare: 1},
{version: "1.10.3", compare: 0},
{version: "1.10.3-rc3", compare: 1},
{version: "1.10.4", compare: -1},
{version: "1.10.4-rc1", compare: -1},
{version: "1.11.1", compare: -1},
{version: "1.11.1-rc4", compare: -1},
{version: "invalid", err: true},
} {
testCase := fmt.Sprintf("test case #%d test version %q", i, test.version)
res, err := v.Compare(test.version)
assert.Equal(t, test.err, err != nil, testCase)
if !test.err {
assert.Equal(t, test.compare, res, testCase)
}
}
} | explode_data.jsonl/31196 | {
"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,
35,
13659,
5637,
33487,
1155,
353,
8840,
836,
8,
341,
5195,
11,
1848,
1669,
501,
35,
13659,
5637,
445,
16,
13,
16,
15,
13,
18,
1138,
6948,
35699,
1155,
11,
1848,
340,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
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... | 3 |
func TestFindMatch(t *testing.T) {
// testFind is the structure used to contain params pertinent to find related tests
type testFind struct {
pattern, filePath, flagName string
match bool
}
var basicTests = []testFind{
// Name match tests - success cases.
{"*.jpg", "carter.jpg", "name", true},
{"console", "pkg/console/console.go", "name", true},
{"console.go", "pkg/console/console.go", "name", true},
{"*XA==", "I/enjoy/morning/walks/XA==", "name ", true},
{"*parser", "/This/might/mess up./the/parser", "name", true},
{"*LTIxNDc0ODM2NDgvLTE=", "What/A/Naughty/String/LTIxNDc0ODM2NDgvLTE=", "name", true},
{"*", "/bla/bla/bla/ ", "name", true},
// Name match tests - failure cases.
{"*.jpg", "carter.jpeg", "name", false},
{"*/test/*", "/test/bob/likes/cake", "name", false},
{"*test/*", "bob/test/likes/cake", "name", false},
{"*test/*", "bob/likes/test/cake", "name", false},
{"*/test/*", "bob/likes/cake/test", "name", false},
{"*.jpg", ".jpg/elves/are/evil", "name", false},
{"wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi",
"An/Even/Bigger/String/wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", "name", false},
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/THE", "name", false},
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/The", "name", false},
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/𝓣𝓱𝓮", "name", false},
{"𝕿𝖍𝖊", "what/a/strange/turn/of/events/𝓣he", "name", false},
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/𝕿𝖍𝖊", "name", true},
// Path match tests - success cases.
{"*/test/*", "bob/test/likes/cake", "path", true},
{"*/test/*", "/test/bob/likes/cake", "path", true},
// Path match tests - failure cases.
{"*.jpg", ".jpg/elves/are/evil", "path", false},
{"*/test/*", "test1/test2/test3/test", "path", false},
{"*/ test /*", "test/test1/test2/test3/test", "path", false},
{"*/test/*", " test /I/have/Really/Long/hair", "path", false},
{"*XA==", "XA==/Height/is/a/social/construct", "path", false},
{"*W", "/Word//this/is a/trickyTest", "path", false},
{"LTIxNDc0ODM2NDgvLTE=", "LTIxNDc0ODM2NDgvLTE=/I/Am/One/Baaaaad/String", "path", false},
{"/", "funky/path/name", "path", false},
// Regexp based - success cases.
{"^[a-zA-Z][a-zA-Z0-9\\-]+[a-zA-Z0-9]$", "testbucket-1", "regex", true},
{`^(\d+\.){3}\d+$`, "192.168.1.1", "regex", true},
// Regexp based - failure cases.
{"^[a-zA-Z][a-zA-Z0-9\\-]+[a-zA-Z0-9]$", "testbucket.", "regex", false},
{`^(\d+\.){3}\d+$`, "192.168.x.x", "regex", false},
}
for _, test := range basicTests {
switch test.flagName {
case "name":
testMatch := nameMatch(test.pattern, test.filePath)
if testMatch != test.match {
t.Fatalf("Unexpected result %t, with pattern %s, flag %s and filepath %s \n",
!test.match, test.pattern, test.flagName, test.filePath)
}
case "path":
testMatch := pathMatch(test.pattern, test.filePath)
if testMatch != test.match {
t.Fatalf("Unexpected result %t, with pattern %s, flag %s and filepath %s \n",
!test.match, test.pattern, test.flagName, test.filePath)
}
case "regex":
testMatch := regexMatch(test.pattern, test.filePath)
if testMatch != test.match {
t.Fatalf("Unexpected result %t, with pattern %s, flag %s and filepath %s \n",
!test.match, test.pattern, test.flagName, test.filePath)
}
}
}
} | explode_data.jsonl/76927 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1571
} | [
2830,
3393,
9885,
8331,
1155,
353,
8840,
836,
8,
341,
197,
322,
1273,
9885,
374,
279,
5944,
1483,
311,
6644,
3628,
61523,
311,
1477,
5435,
7032,
198,
13158,
1273,
9885,
2036,
341,
197,
3223,
3227,
11,
22598,
11,
5181,
675,
914,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestServer_Request_Post_Body_ContentLength_TooLarge(t *testing.T) {
testBodyContentsFail(t, 3, "request declared a Content-Length of 3 but only wrote 2 bytes",
func(st *serverTester) {
st.writeHeaders(HeadersFrameParam{
StreamID: 1, // clients send odd numbers
BlockFragment: st.encodeHeader(
":method", "POST",
"content-length", "3",
),
EndStream: false, // to say DATA frames are coming
EndHeaders: true,
})
st.writeData(1, true, []byte("12"))
})
} | explode_data.jsonl/71612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
5475,
44024,
66726,
1668,
1076,
78383,
4373,
1139,
2624,
34253,
1155,
353,
8840,
836,
8,
341,
18185,
5444,
14803,
19524,
1155,
11,
220,
18,
11,
330,
2035,
14275,
264,
8883,
52493,
315,
220,
18,
714,
1172,
6139,
220,
17,
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... | 1 |
func TestProject(t *testing.T) {
t.Parallel()
t.Run("Init Project", func(t *testing.T) {
t.Parallel()
st, s, _ := setup()
pkey := tests.PrivKeys()[0]
init, err := s.Project.Init(st.ReaderWriter(), false, false, crypto.ECDSA_P256, crypto.SHA3_256, pkey)
assert.NoError(t, err)
sacc, err := init.EmulatorServiceAccount()
assert.NotNil(t, sacc)
assert.NoError(t, err)
assert.Equal(t, sacc.Name(), config.DefaultEmulatorServiceAccountName)
assert.Equal(t, sacc.Address().String(), "f8d6e0586b0a20c7")
p, err := sacc.Key().PrivateKey()
assert.NoError(t, err)
assert.Equal(t, (*p).String(), pkey.String())
init, err = s.Project.Init(st.ReaderWriter(), false, false, crypto.ECDSA_P256, crypto.SHA3_256, nil)
assert.NoError(t, err)
em, err := init.EmulatorServiceAccount()
assert.NoError(t, err)
k, err := em.Key().PrivateKey()
assert.NoError(t, err)
assert.NotNil(t, (*k).String())
})
t.Run("Deploy Project", func(t *testing.T) {
t.Parallel()
state, s, gw := setup()
c := config.Contract{
Name: "Hello",
Source: tests.ContractHelloString.Filename,
Network: "emulator",
}
state.Contracts().AddOrUpdate(c.Name, c)
n := config.Network{
Name: "emulator",
Host: "127.0.0.1:3569",
}
state.Networks().AddOrUpdate(n.Name, n)
a := tests.Alice()
state.Accounts().AddOrUpdate(a)
d := config.Deployment{
Network: n.Name,
Account: a.Name(),
Contracts: []config.ContractDeployment{{
Name: c.Name,
Args: nil,
}},
}
state.Deployments().AddOrUpdate(d)
gw.SendSignedTransaction.Run(func(args mock.Arguments) {
tx := args.Get(0).(*flowkit.Transaction)
assert.Equal(t, tx.FlowTransaction().Payer, a.Address())
assert.True(t, strings.Contains(string(tx.FlowTransaction().Script), "signer.contracts.add"))
gw.SendSignedTransaction.Return(tests.NewTransaction(), nil)
})
contracts, err := s.Project.Deploy("emulator", false)
assert.NoError(t, err)
assert.Equal(t, len(contracts), 1)
gw.Mock.AssertCalled(t, tests.GetLatestBlockFunc)
gw.Mock.AssertCalled(t, tests.GetAccountFunc, a.Address())
gw.Mock.AssertNumberOfCalls(t, tests.GetTransactionResultFunc, 1)
})
} | explode_data.jsonl/22580 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 917
} | [
2830,
3393,
7849,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
3244,
16708,
445,
3803,
5787,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3244,
41288,
7957,
2822,
197,
18388,
11,
274,
11,
716,
1669,
6505,
741,
197,
3223,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Basic1(t *testing.T) {
config := `
v1 = 1
v2 = "true"
v3 = "off"
v4 = "1.23"
array = [1,2,3]
[redis]
disk = "127.0.0.1:6379,0"
cache = "127.0.0.1:6379,1"
`
gtest.Case(t, func() {
path := gcfg.DEFAULT_CONFIG_FILE
err := gfile.PutContents(path, config)
gtest.Assert(err, nil)
defer func() {
_ = gfile.Remove(path)
}()
c := gcfg.New()
gtest.Assert(c.Get("v1"), 1)
gtest.AssertEQ(c.GetInt("v1"), 1)
gtest.AssertEQ(c.GetInt8("v1"), int8(1))
gtest.AssertEQ(c.GetInt16("v1"), int16(1))
gtest.AssertEQ(c.GetInt32("v1"), int32(1))
gtest.AssertEQ(c.GetInt64("v1"), int64(1))
gtest.AssertEQ(c.GetUint("v1"), uint(1))
gtest.AssertEQ(c.GetUint8("v1"), uint8(1))
gtest.AssertEQ(c.GetUint16("v1"), uint16(1))
gtest.AssertEQ(c.GetUint32("v1"), uint32(1))
gtest.AssertEQ(c.GetUint64("v1"), uint64(1))
gtest.AssertEQ(c.GetVar("v1").String(), "1")
gtest.AssertEQ(c.GetVar("v1").Bool(), true)
gtest.AssertEQ(c.GetVar("v2").String(), "true")
gtest.AssertEQ(c.GetVar("v2").Bool(), true)
gtest.AssertEQ(c.GetString("v1"), "1")
gtest.AssertEQ(c.GetFloat32("v4"), float32(1.23))
gtest.AssertEQ(c.GetFloat64("v4"), float64(1.23))
gtest.AssertEQ(c.GetString("v2"), "true")
gtest.AssertEQ(c.GetBool("v2"), true)
gtest.AssertEQ(c.GetBool("v3"), false)
gtest.AssertEQ(c.Contains("v1"), true)
gtest.AssertEQ(c.Contains("v2"), true)
gtest.AssertEQ(c.Contains("v3"), true)
gtest.AssertEQ(c.Contains("v4"), true)
gtest.AssertEQ(c.Contains("v5"), false)
gtest.AssertEQ(c.GetInts("array"), []int{1, 2, 3})
gtest.AssertEQ(c.GetStrings("array"), []string{"1", "2", "3"})
gtest.AssertEQ(c.GetArray("array"), []interface{}{1, 2, 3})
gtest.AssertEQ(c.GetInterfaces("array"), []interface{}{1, 2, 3})
gtest.AssertEQ(c.GetMap("redis"), map[string]interface{}{
"disk": "127.0.0.1:6379,0",
"cache": "127.0.0.1:6379,1",
})
gtest.AssertEQ(c.FilePath(), gfile.Pwd()+gfile.Separator+path)
})
} | explode_data.jsonl/24446 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1043
} | [
2830,
3393,
1668,
5971,
16,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
22074,
85,
16,
262,
284,
220,
16,
198,
85,
17,
262,
284,
330,
1866,
698,
85,
18,
262,
284,
330,
1847,
698,
85,
19,
262,
284,
330,
16,
13,
17,
18,
698,
1653... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamedWriter(t *testing.T) {
tests := []struct {
In string
In2 string
ExpectOutput string
}{
{In: "foobar", ExpectOutput: "[test] foobar"},
{In: "foobar\nbaz", ExpectOutput: "[test] foobar\n[test] baz"},
{In: "foobar\nbaz\n", ExpectOutput: "[test] foobar\n[test] baz\n"},
{In: "foobar\n", ExpectOutput: "[test] foobar\n"},
{In: "foobar", In2: "baz", ExpectOutput: "[test] foobarbaz"},
{In: "foobar\n", In2: "baz", ExpectOutput: "[test] foobar\n[test] baz"},
{In: "foobar\n", In2: "baz\n", ExpectOutput: "[test] foobar\n[test] baz\n"},
}
for _, tt := range tests {
t.Run(tt.In, func(t *testing.T) {
buf := new(bytes.Buffer)
w := NewNamedWriter(buf, "test")
n, err := io.WriteString(w, tt.In)
require.NoError(t, err)
assert.Equal(t, len(tt.In), n)
if tt.In2 != "" {
n, err = io.WriteString(w, tt.In2)
require.NoError(t, err)
assert.Equal(t, len(tt.In2), n)
}
assert.Equal(t, tt.ExpectOutput, buf.String())
})
}
} | explode_data.jsonl/8548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 486
} | [
2830,
3393,
15810,
6492,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
70167,
1843,
914,
198,
197,
70167,
17,
688,
914,
198,
197,
35911,
5097,
914,
198,
197,
59403,
197,
197,
90,
641,
25,
330,
50267,
497,
32085,
5... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNonLocalTimezone(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(2)
loc, err := time.LoadLocation("Atlantic/Cape_Verde")
if err != nil {
fmt.Printf("Failed to load time zone Atlantic/Cape_Verde: %+v", err)
t.Fail()
}
now := time.Now().In(loc)
// FIX: Issue #205
// This calculation doesn't work in seconds 58 or 59.
// Take the easy way out and sleep.
if now.Second() >= 58 {
time.Sleep(2 * time.Second)
now = time.Now().In(loc)
}
spec := fmt.Sprintf("%d,%d %d %d %d %d ?",
now.Second()+1, now.Second()+2, now.Minute(), now.Hour(), now.Day(), now.Month())
cron := New(WithLocation(loc), WithParser(secondParser))
cron.AddFunc(spec, func() { wg.Done() })
cron.Start()
defer cron.Stop()
select {
case <-time.After(OneSecond * 2):
t.Error("expected job fires 2 times")
case <-wait(wg):
}
} | explode_data.jsonl/8306 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 340
} | [
2830,
3393,
8121,
7319,
1462,
8684,
1155,
353,
8840,
836,
8,
341,
72079,
1669,
609,
12996,
28384,
2808,
16094,
72079,
1904,
7,
17,
692,
71128,
11,
1848,
1669,
882,
13969,
4707,
445,
77525,
11295,
2027,
2334,
86805,
1138,
743,
1848,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetTupleRecordMap(t *testing.T) {
messageChan := make(chan *entities.Message)
input := AggregationInput{
MessageChan: messageChan,
WorkerNum: 2,
CorrelateFields: fields,
}
aggregationProcess, _ := InitAggregationProcess(input)
assert.Equal(t, aggregationProcess.flowKeyRecordMap, aggregationProcess.flowKeyRecordMap)
} | explode_data.jsonl/8697 | {
"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,
1949,
28681,
6471,
2227,
1155,
353,
8840,
836,
8,
341,
24753,
46019,
1669,
1281,
35190,
353,
10499,
8472,
340,
22427,
1669,
4598,
34442,
2505,
515,
197,
46733,
46019,
25,
257,
1943,
46019,
345,
197,
197,
21936,
4651,
25,
981... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDaoTagByNames(t *testing.T) {
var (
c = context.TODO()
tnames = []string{"123", "456"}
)
convey.Convey("TagByNames", t, func(ctx convey.C) {
tags, tagMap, tagNameMap, err := d.TagByNames(c, tnames)
ctx.Convey("Then err should be nil.tags,tagMap,tagNameMap should not be nil.", func(ctx convey.C) {
ctx.So(err, convey.ShouldBeNil)
ctx.So(tagNameMap, convey.ShouldNotBeNil)
ctx.So(tagMap, convey.ShouldNotBeNil)
ctx.So(tags, convey.ShouldNotBeNil)
})
})
} | explode_data.jsonl/36687 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 217
} | [
2830,
3393,
12197,
5668,
1359,
7980,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
1444,
414,
284,
2266,
90988,
741,
197,
197,
1517,
971,
284,
3056,
917,
4913,
16,
17,
18,
497,
330,
19,
20,
21,
16707,
197,
340,
37203,
5617,
4801,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenreService_Count(t *testing.T) {
var tests = []struct {
name string
resp string
opts []Option
wantCount int
wantErr error
}{
{"Happy path", `{"count": 100}`, []Option{SetFilter("popularity", OpGreaterThan, "75")}, 100, nil},
{"Empty response", "", nil, 0, errInvalidJSON},
{"Invalid option", "", []Option{SetLimit(-100)}, 0, ErrOutOfRange},
{"No results", "[]", nil, 0, ErrNoResults},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
ts, c := testServerString(http.StatusOK, test.resp)
defer ts.Close()
count, err := c.Genres.Count(test.opts...)
if errors.Cause(err) != test.wantErr {
t.Errorf("got: <%v>, want: <%v>", errors.Cause(err), test.wantErr)
}
if count != test.wantCount {
t.Fatalf("got: <%v>, want: <%v>", count, test.wantCount)
}
})
}
} | explode_data.jsonl/41087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 368
} | [
2830,
3393,
37525,
1860,
50775,
1155,
353,
8840,
836,
8,
341,
2405,
7032,
284,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
34653,
414,
914,
198,
197,
64734,
414,
3056,
5341,
198,
197,
50780,
2507,
526,
198,
197,
50780,
7747,
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... | 3 |
func TestCommand_AllAssociatedValueDescriptors(t *testing.T) {
var testMap = make(map[string]string)
type args struct {
vdNames *map[string]string
}
tests := []struct {
name string
c *Command
args args
}{
{"get assoc val descs", &TestCommand, args{vdNames: &testMap}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.c.AllAssociatedValueDescriptors(tt.args.vdNames)
if len(*tt.args.vdNames) != 2 {
t.Error("Associated value descriptor size > than expected")
}
})
}
} | explode_data.jsonl/34915 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
4062,
53629,
52969,
1130,
58553,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
2227,
284,
1281,
9147,
14032,
30953,
340,
13158,
2827,
2036,
341,
197,
5195,
67,
7980,
353,
2186,
14032,
30953,
198,
197,
532,
78216,
1669,
3056,
123... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFlusherCond(t *testing.T) {
var mu sync.Mutex
var q syncQueue
var c flusherCond
var closed bool
c.init(&mu, &q)
var flusherWG sync.WaitGroup
flusherWG.Add(1)
go func() {
defer flusherWG.Done()
mu.Lock()
defer mu.Unlock()
for {
for {
if closed {
return
}
if !q.empty() {
break
}
c.Wait()
}
head, tail := q.load()
q.pop(head, tail, nil)
}
}()
var commitMu sync.Mutex
var doneWG sync.WaitGroup
// NB: we're testing with low concurrency here, because what we want to
// stress is that signalling of the flusherCond works
// correctly. Specifically, we want to make sure that a signal is "lost",
// causing the test to wedge.
for i := 0; i < 2; i++ {
doneWG.Add(1)
go func(i int) {
defer doneWG.Done()
for j := 0; j < 10000; j++ {
wg := &sync.WaitGroup{}
wg.Add(1)
// syncQueue is a single-producer, single-consumer queue. We need to
// provide mutual exclusion on the producer side.
commitMu.Lock()
q.push(wg, new(error))
commitMu.Unlock()
c.Signal()
wg.Wait()
}
}(i)
}
doneWG.Wait()
mu.Lock()
closed = true
c.Signal()
mu.Unlock()
flusherWG.Wait()
} | explode_data.jsonl/58754 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 534
} | [
2830,
3393,
46874,
261,
49696,
1155,
353,
8840,
836,
8,
341,
2405,
11834,
12811,
99014,
198,
2405,
2804,
12811,
7554,
198,
2405,
272,
18198,
261,
49696,
198,
2405,
7877,
1807,
271,
1444,
8271,
2099,
15128,
11,
609,
80,
692,
2405,
18198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVerifyCertificateWithDSASignature(t *testing.T) {
pemBlock, _ := pem.Decode([]byte(dsaCertPem))
cert, err := ParseCertificate(pemBlock.Bytes)
if err != nil {
t.Fatalf("Failed to parse certificate: %s", err)
}
// test cert is self-signed
if err = cert.CheckSignatureFrom(cert); err != nil {
t.Fatalf("DSA Certificate verification failed: %s", err)
}
} | explode_data.jsonl/56551 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
32627,
33202,
2354,
5936,
1911,
622,
1568,
1155,
353,
8840,
836,
8,
341,
3223,
336,
4713,
11,
716,
1669,
54184,
56372,
10556,
3782,
1500,
9081,
36934,
47,
336,
1171,
1444,
529,
11,
1848,
1669,
14775,
33202,
1295,
336,
4713,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergeProwConfig(t *testing.T) {
t.Parallel()
o := TestOptions{}
o.Setup()
prowConfig := &config.Config{}
prowConfig.LogLevel = "debug"
c, err := yaml.Marshal(prowConfig)
assert.NoError(t, err)
data := make(map[string]string)
data["config.yaml"] = string(c)
cm := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "config",
},
Data: data,
}
_, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Create(cm)
assert.NoError(t, err)
err = o.AddProwConfig()
assert.NoError(t, err)
cm, err = o.KubeClient.CoreV1().ConfigMaps(o.NS).Get("config", metav1.GetOptions{})
assert.NoError(t, err)
yaml.Unmarshal([]byte(cm.Data["config.yaml"]), &prowConfig)
assert.Equal(t, "debug", prowConfig.LogLevel)
assert.NotEmpty(t, prowConfig.Presubmits["test/repo"])
} | explode_data.jsonl/70865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 337
} | [
2830,
3393,
52096,
47,
651,
2648,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22229,
1669,
3393,
3798,
16094,
22229,
39820,
2822,
3223,
651,
2648,
1669,
609,
1676,
10753,
16094,
3223,
651,
2648,
5247,
4449,
284,
330,
8349,
183... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBackupRestoreIncrementalAddTable(t *testing.T) {
defer leaktest.AfterTest(t)()
const numAccounts = 1
_, _, sqlDB, _, cleanupFn := BackupRestoreTestSetup(t, singleNode, numAccounts, InitNone)
defer cleanupFn()
sqlDB.Exec(t, `CREATE DATABASE data2`)
sqlDB.Exec(t, `CREATE TABLE data.t (s string PRIMARY KEY)`)
full, inc := LocalFoo+"/full", LocalFoo+"/inc"
sqlDB.Exec(t, `INSERT INTO data.t VALUES ('before')`)
sqlDB.Exec(t, `BACKUP data.*, data2.* TO $1`, full)
sqlDB.Exec(t, `UPDATE data.t SET s = 'after'`)
sqlDB.Exec(t, `CREATE TABLE data2.t2 (i int)`)
sqlDB.Exec(t, "BACKUP data.*, data2.* TO $1 INCREMENTAL FROM $2", inc, full)
} | explode_data.jsonl/57610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
56245,
56284,
38311,
278,
2212,
2556,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
4777,
1629,
41369,
284,
220,
16,
198,
197,
6878,
8358,
5704,
3506,
11,
8358,
21290,
24911,
1669,
43438,
5628... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_VirtualNetworks_Spec_Properties_SubnetsARM_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of VirtualNetworks_Spec_Properties_SubnetsARM via JSON returns original",
prop.ForAll(RunJSONSerializationTestForVirtualNetworksSpecPropertiesSubnetsARM, VirtualNetworksSpecPropertiesSubnetsARMGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/2900 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
2334,
2901,
12320,
82,
1098,
992,
1088,
9249,
36359,
52861,
17911,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBasicIndexAndSearch(t *testing.T) {
q := search.NewTermQuery(index.NewTerm("foo", "bar"))
q.SetBoost(-42)
os.RemoveAll(".gltest")
directory, err := store.OpenFSDirectory(".gltest")
It(t).Should("has no error: %v", err).Assert(err == nil)
It(t).Should("has valid directory").Assert(directory != nil)
fmt.Println("Directory", directory)
defer directory.Close()
analyzer := std.NewStandardAnalyzer()
conf := index.NewIndexWriterConfig(util.VERSION_LATEST, analyzer)
writer, err := index.NewIndexWriter(directory, conf)
It(t).Should("has no error: %v", err).Assert(err == nil)
d := docu.NewDocument()
d.Add(docu.NewTextFieldFromString("foo", "bar", docu.STORE_YES))
err = writer.AddDocument(d.Fields())
It(t).Should("has no error: %v", err).Assert(err == nil)
err = writer.Close() // ensure index is written
It(t).Should("has no error: %v", err).Assert(err == nil)
reader, err := index.OpenDirectoryReader(directory)
It(t).Should("has no error: %v", err).Assert(err == nil)
defer reader.Close()
searcher := search.NewIndexSearcher(reader)
res, err := searcher.Search(q, nil, 1000)
It(t).Should("has no error: %v", err).Assert(err == nil)
hits := res.ScoreDocs
It(t).Should("expect 1 hits, but %v only.", len(hits)).Assert(len(hits) == 1)
It(t).Should("expect score to be negative (got %v)", hits[0].Score).Verify(hits[0].Score < 0)
explain, err := searcher.Explain(q, hits[0].Doc)
It(t).Should("has no error: %v", err).Assert(err == nil)
It(t).Should("score doesn't match explanation (%v vs %v)", hits[0].Score, explain.Value()).Verify(isSimilar(hits[0].Score, explain.Value(), 0.001))
It(t).Should("explain doesn't think doc is a match").Verify(explain.IsMatch())
} | explode_data.jsonl/50443 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 632
} | [
2830,
3393,
15944,
1552,
3036,
5890,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
2711,
7121,
17249,
2859,
7195,
7121,
17249,
445,
7975,
497,
330,
2257,
5455,
18534,
4202,
52363,
4080,
19,
17,
692,
25078,
84427,
5680,
6072,
1944,
5130,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFillObjectMetaSystemFields(t *testing.T) {
ctx := api.NewDefaultContext()
resource := api.ObjectMeta{}
api.FillObjectMetaSystemFields(ctx, &resource)
if resource.CreationTimestamp.Time.IsZero() {
t.Errorf("resource.CreationTimestamp is zero")
} else if len(resource.UID) == 0 {
t.Errorf("resource.UID missing")
}
} | explode_data.jsonl/75051 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
14449,
1190,
12175,
2320,
8941,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
6330,
7121,
3675,
1972,
741,
50346,
1669,
6330,
80222,
16094,
54299,
19495,
1190,
12175,
2320,
8941,
7502,
11,
609,
9233,
340,
743,
5101,
727,
26453,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetPool(t *testing.T) {
p1 := signal.GetPoolAllocator(10, 0, 512)
p2 := signal.GetPoolAllocator(10, 512, 512)
if p1 == p2 {
t.Fatal("p1 must be not equal to p2")
}
} | explode_data.jsonl/36810 | {
"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,
1949,
10551,
1155,
353,
8840,
836,
8,
341,
3223,
16,
1669,
8286,
2234,
10551,
42730,
7,
16,
15,
11,
220,
15,
11,
220,
20,
16,
17,
340,
3223,
17,
1669,
8286,
2234,
10551,
42730,
7,
16,
15,
11,
220,
20,
16,
17,
11,
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 TestAuthMethodRSAandDSA(t *testing.T) {
config := &ClientConfig{
User: "testuser",
Auth: []AuthMethod{
PublicKeys(testSigners["dsa"], testSigners["rsa"]),
},
HostKeyCallback: InsecureIgnoreHostKey(),
}
if err := tryAuth(t, config); err != nil {
t.Fatalf("client could not authenticate with rsa key: %v", err)
}
} | explode_data.jsonl/6938 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
5087,
3523,
73564,
437,
72638,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
609,
2959,
2648,
515,
197,
31672,
25,
330,
1944,
872,
756,
197,
197,
5087,
25,
3056,
5087,
3523,
515,
298,
73146,
8850,
8623,
7264,
388,
1183,
96780... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGlobsToBase(t *testing.T) {
Convey("Should return the correct base", t, func() {
So(globsToBase("."), ShouldEqual, ".")
So(globsToBase("foo/bar.baz"), ShouldEqual, "foo")
So(globsToBase("foo/*.baz"), ShouldEqual, "foo")
So(globsToBase("foo/bar/**/*.baz"), ShouldEqual, "foo/bar")
So(globsToBase(
"foo/bar/baz",
"foo/**/baz",
), ShouldEqual, "foo")
})
} | explode_data.jsonl/18040 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 172
} | [
2830,
3393,
38,
68164,
1249,
3978,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
14996,
470,
279,
4396,
2331,
497,
259,
11,
2915,
368,
341,
197,
76912,
3268,
68164,
1249,
3978,
73133,
701,
12260,
2993,
11,
5933,
1138,
197,
76912,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNegativeChannelCreateConfigUpdate(t *testing.T) {
config := genesisconfig.Load(genesisconfig.SampleDevModeSoloProfile)
channelConfig := genesisconfig.Load(genesisconfig.SampleSingleMSPChannelProfile)
group, err := NewChannelGroup(config)
assert.NoError(t, err)
assert.NotNil(t, group)
t.Run("NoGroups", func(t *testing.T) {
channelGroup := proto.Clone(group).(*cb.ConfigGroup)
channelGroup.Groups = nil
_, err := NewChannelCreateConfigUpdate("channel.id", &cb.ConfigGroup{}, channelConfig)
assert.Error(t, err)
assert.Regexp(t, "missing all channel groups", err.Error())
})
t.Run("NoConsortiumsGroup", func(t *testing.T) {
channelGroup := proto.Clone(group).(*cb.ConfigGroup)
delete(channelGroup.Groups, channelconfig.ConsortiumsGroupKey)
_, err := NewChannelCreateConfigUpdate("channel.id", channelGroup, channelConfig)
assert.Error(t, err)
assert.Regexp(t, "bad consortiums group", err.Error())
})
t.Run("NoConsortiums", func(t *testing.T) {
channelGroup := proto.Clone(group).(*cb.ConfigGroup)
delete(channelGroup.Groups[channelconfig.ConsortiumsGroupKey].Groups, genesisconfig.SampleConsortiumName)
_, err := NewChannelCreateConfigUpdate("channel.id", channelGroup, channelConfig)
assert.Error(t, err)
assert.Regexp(t, "bad consortium:", err.Error())
})
} | explode_data.jsonl/78127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 449
} | [
2830,
3393,
38489,
9629,
4021,
2648,
4289,
1155,
353,
8840,
836,
8,
341,
25873,
1669,
59366,
1676,
13969,
36884,
13774,
1676,
76266,
14592,
3636,
89299,
8526,
340,
71550,
2648,
1669,
59366,
1676,
13969,
36884,
13774,
1676,
76266,
10888,
44,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEncodeYAML(t *testing.T) {
f := newFixture(t)
defer f.TearDown()
f.File("Tiltfile", `
expected = '''key1: foo
key2:
key3: bar
key4: true
key5: 3
key6:
- foo
- 7
'''
observed = encode_yaml({
'key1': 'foo',
'key2': {
'key3': 'bar',
'key4': True
},
'key5': 3,
'key6': [
'foo',
7,
]
})
load('assert.tilt', 'assert')
assert.equals(expected, str(observed))
`)
_, err := f.ExecFile("Tiltfile")
if err != nil {
fmt.Println(f.PrintOutput())
}
require.NoError(t, err)
} | explode_data.jsonl/10617 | {
"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,
32535,
56,
31102,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
836,
682,
4454,
2822,
1166,
8576,
445,
51,
2963,
1192,
497,
22074,
7325,
284,
11456,
792,
16,
25,
15229,
198,
792,
17,
510,
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 TestClientDuration(t *testing.T) {
const delay = 500 * time.Millisecond
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("hello"))
w.(http.Flusher).Flush()
time.Sleep(delay)
w.Write([]byte("world"))
}))
defer server.Close()
_, spans, _ := apmtest.WithTransaction(func(ctx context.Context) {
// mustGET reads the body, so it should not return until the handler completes.
mustGET(ctx, server.URL)
})
require.Len(t, spans, 1)
span := spans[0]
assert.Equal(t, "GET "+server.Listener.Addr().String(), span.Name)
assert.InDelta(t, delay/time.Millisecond, span.Duration, 100)
} | explode_data.jsonl/49619 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 242
} | [
2830,
3393,
2959,
12945,
1155,
353,
8840,
836,
8,
341,
4777,
7626,
284,
220,
20,
15,
15,
353,
882,
71482,
198,
41057,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
4232,
353,
1254,
9659,
8,
341,
197,
6692... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetATotalLagOf20For2PartitionsOn100UnprocessedEvents(t *testing.T) {
lag := getTotalLagRelatedToPartitionAmount(100, 2, 10)
if lag != 20 {
t.Errorf("Expected a lag of 20 for 2 partitions, got %d", lag)
}
} | explode_data.jsonl/13472 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
1949,
828,
2370,
43,
351,
2124,
17,
15,
2461,
17,
5800,
5930,
1925,
16,
15,
15,
1806,
34022,
7900,
1155,
353,
8840,
836,
8,
341,
8810,
351,
1669,
74456,
43,
351,
11686,
1249,
49978,
10093,
7,
16,
15,
15,
11,
220,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestLogsExporter_WithSpan(t *testing.T) {
set := componenttest.NewNopExporterCreateSettings()
sr := new(tracetest.SpanRecorder)
set.TracerProvider = sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
otel.SetTracerProvider(set.TracerProvider)
defer otel.SetTracerProvider(trace.NewNoopTracerProvider())
le, err := NewLogsExporter(&fakeLogsExporterConfig, set, newPushLogsData(nil))
require.Nil(t, err)
require.NotNil(t, le)
checkWrapSpanForLogsExporter(t, sr, set.TracerProvider.Tracer("test"), le, nil, 1)
} | explode_data.jsonl/59610 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 202
} | [
2830,
3393,
51053,
88025,
62,
2354,
12485,
1155,
353,
8840,
836,
8,
341,
8196,
1669,
3692,
1944,
7121,
45,
453,
88025,
4021,
6086,
741,
1903,
81,
1669,
501,
7624,
580,
57824,
85309,
47023,
340,
8196,
8240,
9584,
5179,
284,
45402,
15067,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPusher(t *testing.T) {
var html = template.Must(template.New("https").Parse(`
<html>
<head>
<title>Https Test</title>
<script src="/assets/app.js"></script>
</head>
<body>
<h1 style="color:red;">Welcome, Ginner!</h1>
</body>
</html>
`))
router := New()
router.Static("./assets", "./assets")
router.SetHTMLTemplate(html)
go func() {
router.GET("/pusher", func(c *Context) {
if pusher := c.Writer.Pusher(); pusher != nil {
err := pusher.Push("/assets/app.js", nil)
assert.NoError(t, err)
}
c.String(http.StatusOK, "it worked")
})
assert.NoError(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
}()
// have to wait for the goroutine to start and run the server
// otherwise the main thread will complete
time.Sleep(5 * time.Millisecond)
assert.Error(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
testRequest(t, "https://localhost:8449/pusher")
} | explode_data.jsonl/1175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
16644,
261,
1155,
353,
8840,
836,
8,
341,
2405,
5272,
284,
3811,
50463,
29963,
7121,
445,
2428,
1827,
14463,
61528,
13745,
397,
16343,
397,
220,
366,
2102,
29,
92869,
3393,
522,
2102,
397,
220,
366,
2282,
2286,
5914,
5160,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOrderedCallsCorrect(t *testing.T) {
reporter, ctrl, subjectOne, subjectTwo := commonTestOrderedCalls(t)
ctrl.Call(subjectOne, "FooMethod", "1")
ctrl.Call(subjectTwo, "FooMethod", "2")
ctrl.Call(subjectTwo, "BarMethod", "3")
ctrl.Finish()
reporter.assertPass("After finish")
} | explode_data.jsonl/17288 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 107
} | [
2830,
3393,
54384,
55292,
33092,
1155,
353,
8840,
836,
8,
341,
69931,
261,
11,
23743,
11,
3832,
3966,
11,
3832,
11613,
1669,
4185,
2271,
54384,
55292,
1155,
692,
84381,
27017,
29128,
3966,
11,
330,
40923,
3523,
497,
330,
16,
1138,
84381... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCleanTempDirectory_ShouldThrowError(t *testing.T) {
cb := &v1alpha1.CodebaseBranch{
ObjectMeta: metav1.ObjectMeta{
Name: "stub-name",
Namespace: "stub-namespace",
},
Spec: v1alpha1.CodebaseBranchSpec{
CodebaseName: "stub-name",
BranchName: ".",
},
}
directory := CleanTempDirectory{}
err := directory.ServeRequest(cb)
assert.Error(t, err)
assert.Equal(t, v1alpha1.CleanData, cb.Status.Action)
} | explode_data.jsonl/14732 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
27529,
12151,
9310,
36578,
616,
23079,
1454,
1155,
353,
8840,
836,
8,
341,
63810,
1669,
609,
85,
16,
7141,
16,
20274,
3152,
18197,
515,
197,
23816,
12175,
25,
77520,
16,
80222,
515,
298,
21297,
25,
414,
330,
59398,
11494,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExtendedPath_Error(t *testing.T) {
t.Parallel()
baseUrl := "http://example.com"
cases := []struct {
name string
startingUrl string
path string
expectedPath adapters.ExtendedPath
expectedURL string
}{
{
"bad array input",
baseUrl,
`["one","two"`,
adapters.ExtendedPath{},
baseUrl,
},
}
for _, test := range cases {
t.Run(test.name, func(t *testing.T) {
ep := adapters.ExtendedPath{}
err := json.Unmarshal([]byte(test.path), &ep)
hga := adapters.HTTPGet{
URL: cltest.WebURL(t, test.startingUrl),
ExtendedPath: ep,
}
hpa := adapters.HTTPPost{
URL: cltest.WebURL(t, test.startingUrl),
ExtendedPath: ep,
}
requestGET, _ := hga.GetRequest()
assert.Equal(t, test.expectedURL, requestGET.URL.String())
assert.Equal(t, test.expectedPath, hga.ExtendedPath)
requestPOST, _ := hpa.GetRequest("")
assert.Equal(t, test.expectedURL, requestPOST.URL.String())
assert.Equal(t, test.expectedPath, hpa.ExtendedPath)
assert.NotNil(t, err)
})
}
} | explode_data.jsonl/36142 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 477
} | [
2830,
3393,
53190,
1820,
28651,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
24195,
2864,
1669,
330,
1254,
1110,
8687,
905,
1837,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
21375,
287,
2864,
220,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadImage(t *testing.T) {
img, err := trickOrTreat.readImage(nil)
if err != nil {
t.Errorf("Could not read candies from %#v: %v", trickOrTreat, err)
return
}
var found bool
for _, cand := range candiesImgs {
if want := fmt.Sprintf("", cand); want == img {
found = true
}
}
if !found {
t.Fatalf("Image %q not part of curated list of images", img)
}
} | explode_data.jsonl/3991 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 160
} | [
2830,
3393,
4418,
1906,
1155,
353,
8840,
836,
8,
341,
39162,
11,
1848,
1669,
14068,
2195,
51,
1222,
4125,
1906,
27907,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
12895,
537,
1349,
97397,
504,
52406,
85,
25,
1018,
85,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPeerRoutes(t *testing.T) {
pp := netaddr.MustParseIPPrefix
tests := []struct {
name string
peers []wgcfg.Peer
want []netaddr.IPPrefix
}{
{
name: "small_v4",
peers: []wgcfg.Peer{
{
AllowedIPs: []netaddr.IPPrefix{
pp("100.101.102.103/32"),
},
},
},
want: []netaddr.IPPrefix{
pp("100.101.102.103/32"),
},
},
{
name: "big_v4",
peers: []wgcfg.Peer{
{
AllowedIPs: []netaddr.IPPrefix{
pp("100.101.102.103/32"),
pp("100.101.102.104/32"),
pp("100.101.102.105/32"),
},
},
},
want: []netaddr.IPPrefix{
pp("100.64.0.0/10"),
},
},
{
name: "has_1_v6",
peers: []wgcfg.Peer{
{
AllowedIPs: []netaddr.IPPrefix{
pp("fd7a:115c:a1e0:ab12:4843:cd96:6258:b240/128"),
},
},
},
want: []netaddr.IPPrefix{
pp("fd7a:115c:a1e0::/48"),
},
},
{
name: "has_2_v6",
peers: []wgcfg.Peer{
{
AllowedIPs: []netaddr.IPPrefix{
pp("fd7a:115c:a1e0:ab12:4843:cd96:6258:b240/128"),
pp("fd7a:115c:a1e0:ab12:4843:cd96:6258:b241/128"),
},
},
},
want: []netaddr.IPPrefix{
pp("fd7a:115c:a1e0::/48"),
},
},
{
name: "big_v4_big_v6",
peers: []wgcfg.Peer{
{
AllowedIPs: []netaddr.IPPrefix{
pp("100.101.102.103/32"),
pp("100.101.102.104/32"),
pp("100.101.102.105/32"),
pp("fd7a:115c:a1e0:ab12:4843:cd96:6258:b240/128"),
pp("fd7a:115c:a1e0:ab12:4843:cd96:6258:b241/128"),
},
},
},
want: []netaddr.IPPrefix{
pp("fd7a:115c:a1e0::/48"),
pp("100.64.0.0/10"),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := peerRoutes(tt.peers, 2)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("got = %v; want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/1959 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1115
} | [
2830,
3393,
30888,
26653,
1155,
353,
8840,
836,
8,
341,
65729,
1669,
4179,
6214,
50463,
14463,
3298,
14335,
198,
78216,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
197,
375,
388,
3056,
45540,
14072,
1069,
34756,
198,
197,
507... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSaveVerCode(t *testing.T) {
t.Parallel()
db := NewTestDatabase(t)
maxAge := time.Hour
code := VerificationCode{
Code: "12345678",
TestType: "confirmed",
ExpiresAt: time.Now().Add(time.Hour),
}
if err := db.SaveVerificationCode(&code, maxAge); err != nil {
t.Fatalf("error creating verification code: %v", err)
}
got, err := db.FindVerificationCode(code.Code)
if err != nil {
t.Fatalf("error reading code from db: %v", err)
}
if diff := cmp.Diff(code, *got); diff != "" {
t.Fatalf("mismatch (-want, +got):\n%s", diff)
}
code.Claimed = true
if err := db.SaveVerificationCode(&code, maxAge); err != nil {
t.Fatalf("error claiming verification code: %v", err)
}
got, err = db.FindVerificationCode(code.Code)
if err != nil {
t.Fatalf("error reading code from db: %v", err)
}
if diff := cmp.Diff(code, *got); diff != "" {
t.Fatalf("mismatch (-want, +got):\n%s", diff)
}
} | explode_data.jsonl/22971 | {
"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,
8784,
10141,
2078,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
20939,
1669,
1532,
2271,
5988,
1155,
692,
22543,
16749,
1669,
882,
73550,
198,
43343,
1669,
55473,
2078,
515,
197,
90774,
25,
414,
330,
16,
17,
18,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestJson2Struct_slice_string(t *testing.T) {
ret, err := Json2Struct("auto_name", `["12","2","3","42"]`, GoStructType)
fmt.Printf("ret:\n %s, %v\n", ret, err)
} | explode_data.jsonl/72750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
5014,
17,
9422,
26488,
3904,
1155,
353,
8840,
836,
8,
341,
11262,
11,
1848,
1669,
8308,
17,
9422,
445,
3902,
1269,
497,
1565,
1183,
16,
17,
2198,
17,
2198,
18,
2198,
19,
17,
1341,
7808,
5994,
9422,
929,
340,
11009,
19367... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoleUndelete(t *testing.T) {
h := newHelper(t)
helpers.AllowMe(h, types.RoleRbacResource(0), "delete")
res := h.repoMakeRole()
h.apiInit().
Post(fmt.Sprintf("/roles/%d/undelete", res.ID)).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
res = h.lookupRoleByID(res.ID)
h.a.NotNil(res)
h.a.Nil(res.DeletedAt)
} | explode_data.jsonl/8345 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 173
} | [
2830,
3393,
9030,
19957,
68,
1617,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
5511,
1155,
340,
197,
21723,
29081,
7823,
3203,
11,
4494,
35955,
49,
55877,
4783,
7,
15,
701,
330,
4542,
5130,
10202,
1669,
305,
46169,
8078,
9030,
2822... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPersistApprovalOpFail(t *testing.T) {
em, cancel := newTestEventManager(t)
defer cancel()
mdi := em.database.(*databasemocks.Plugin)
approval := newApproval()
pool := &fftypes.TokenPool{
Namespace: "ns1",
}
mdi.On("GetTokenPoolByProtocolID", em.ctx, "erc1155", "F1").Return(pool, nil)
mdi.On("GetOperations", em.ctx, mock.Anything).Return(nil, nil, fmt.Errorf("pop"))
valid, err := em.persistTokenApproval(em.ctx, approval)
assert.False(t, valid)
assert.EqualError(t, err, "pop")
mdi.AssertExpectations(t)
} | explode_data.jsonl/15917 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 215
} | [
2830,
3393,
61267,
90107,
7125,
19524,
1155,
353,
8840,
836,
8,
341,
66204,
11,
9121,
1669,
501,
2271,
83694,
1155,
340,
16867,
9121,
2822,
2109,
8579,
1669,
976,
15062,
41399,
67,
2096,
300,
336,
25183,
64378,
692,
197,
54439,
1669,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.