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 TestTextSearchMissingQuery(t *testing.T) {
c, _ := NewClient(WithAPIKey(apiKey))
r := &TextSearchRequest{}
_, err := c.TextSearch(context.Background(), r)
if "maps: Query and PageToken both missing" != err.Error() {
t.Errorf("Wrong error returned \"%v\"", err)
}
} | explode_data.jsonl/76294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
1178,
5890,
25080,
2859,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
1532,
2959,
7,
2354,
7082,
1592,
24827,
1592,
1171,
7000,
1669,
609,
1178,
5890,
1900,
16094,
197,
6878,
1848,
1669,
272,
1979,
5890,
5378,
19047,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRefresh(t *testing.T) {
t.Parallel()
storageConfig := CreateStorageConfig("Refresh")
var err error
svc := createDynamoDB()
storage := New(svc, storageConfig)
err = storage.CreateSchema()
assert.Nil(t, err, "%s", err)
defer storage.DropSchema()
client := &osin.DefaultClient{
Id: "1234",
Secret: "aabbccdd",
}
err = storage.CreateClient(client)
assert.Nil(t, err, "%s", err)
accessData := &osin.AccessData{
Client: client,
AccessToken: "1",
RefreshToken: "r9999",
ExpiresIn: 3600,
CreatedAt: time.Now(),
}
got, err := storage.LoadRefresh(accessData.RefreshToken)
assert.Equal(t, ErrRefreshNotFound, err)
assert.Nil(t, got)
err = storage.SaveRefresh(accessData)
assert.Nil(t, err, "%s", err)
got, err = storage.LoadRefresh(accessData.RefreshToken)
// We need to convert it to json as pointers inside structs are different
// and assert library doesn't provide recursive value comparison for structs
assert.Nil(t, err, "%s", err)
gotJSON, err := json.Marshal(got)
assert.Nil(t, err, "%s", err)
expectedJSON, err := json.Marshal(accessData)
assert.Nil(t, err, "%s", err)
assert.JSONEq(t, string(expectedJSON), string(gotJSON))
err = storage.RemoveRefresh(accessData.RefreshToken)
assert.Nil(t, err, "%s", err)
got, err = storage.LoadRefresh(accessData.RefreshToken)
assert.Equal(t, ErrRefreshNotFound, err)
assert.Nil(t, got)
// let's try with expired token
accessData.CreatedAt = accessData.CreatedAt.Add(-time.Duration(accessData.ExpiresIn) * time.Second)
err = storage.SaveRefresh(accessData)
assert.Nil(t, err, "%s", err)
// refresh token doesn't expire
got, err = storage.LoadRefresh(accessData.RefreshToken)
assert.Nil(t, err, "%s", err)
gotJSON, err = json.Marshal(got)
assert.Nil(t, err, "%s", err)
expectedJSON, err = json.Marshal(accessData)
assert.Nil(t, err, "%s", err)
assert.JSONEq(t, string(expectedJSON), string(gotJSON))
} | explode_data.jsonl/78081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 735
} | [
2830,
3393,
14567,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
16172,
2648,
1669,
4230,
5793,
2648,
445,
14567,
1138,
2405,
1848,
1465,
198,
1903,
7362,
1669,
1855,
35,
85608,
3506,
741,
197,
16172,
1669,
1532,
1141,
7362... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDoubleAddImport(t *testing.T) {
file := parse(t, "doubleimport", "package main\n")
AddImport(fset, file, "os")
AddImport(fset, file, "bytes")
want := `package main
import (
"bytes"
"os"
)
`
if got := print(t, "doubleimport", file); got != want {
t.Errorf("got: %s\nwant: %s", got, want)
}
} | explode_data.jsonl/5960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
7378,
2212,
11511,
1155,
353,
8840,
836,
8,
341,
17661,
1669,
4715,
1155,
11,
330,
4331,
474,
497,
330,
1722,
1887,
1699,
1138,
37972,
11511,
955,
746,
11,
1034,
11,
330,
436,
1138,
37972,
11511,
955,
746,
11,
1034,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCompressionTruncation(t *testing.T) {
deftlvl := logrus.GetLevel();
logrus.SetLevel(0);
rand.Seed(0)
testData := []byte(RandStringRunes(4000))
testSuffix := "[truncate]"
outputPlugin := OutputPlugin{
PluginID: 10,
stream: "MyStream",
}
var compressedOutput, err = compressThenTruncate(gzipCompress, testData, 200, []byte(testSuffix), outputPlugin)
assert.Nil(t, err)
assert.GreaterOrEqual(t, len(compressedOutput), 150)
assert.LessOrEqual(t, len(compressedOutput), 200)
logrus.SetLevel(deftlvl)
} | explode_data.jsonl/74105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 200
} | [
2830,
3393,
81411,
1282,
1347,
367,
1155,
353,
8840,
836,
8,
341,
58351,
723,
58160,
1669,
1487,
20341,
2234,
4449,
543,
90822,
4202,
4449,
7,
15,
626,
7000,
437,
5732,
291,
7,
15,
340,
18185,
1043,
1669,
3056,
3782,
2785,
437,
703,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_DirectedWithDuplicateEdge(t *testing.T) {
gb := NewGraphBuilder(BuilderOptions{AllowDuplicateEdges: false, IsDirected: true})
gb.AddNode(1)
gb.AddNode(2)
gb.AddEdge(1, 2)
gb.AddEdge(1, 2)
_, err := gb.Build()
assert.ErrorIs(t, err, duplicateEdgeError{fromID: 1, toID: 2})
gb = NewGraphBuilder(BuilderOptions{AllowDuplicateEdges: true, IsDirected: true})
gb.AddNode(1)
gb.AddNode(2)
gb.AddEdge(1, 2)
gb.AddEdge(1, 2)
actual_graph, err := gb.Build()
assert.NoError(t, err)
expected_graph := rawDirectedGraph{
Nodes: map[NodeID]*rawDirectedNode{
1: {
ID: 1, Incoming: []NodeID{}, Outgoing: []NodeID{2},
},
2: {
ID: 2, Incoming: []NodeID{1}, Outgoing: []NodeID{},
},
},
FromToEdges: map[NodeID]map[NodeID]*rawDirectedEdge{
1: {
2: &rawDirectedEdge{From: 1, To: 2},
},
},
}
AssertGraphEquals(t, expected_graph, actual_graph)
} | explode_data.jsonl/81789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
1557,
74612,
2354,
53979,
11656,
1155,
353,
8840,
836,
8,
341,
3174,
65,
1669,
1532,
11212,
3297,
7,
3297,
3798,
90,
18605,
53979,
41122,
25,
895,
11,
2160,
92669,
25,
830,
3518,
3174,
65,
1904,
1955,
7,
16,
340,
3174,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_downloadFilesNeverCalledForTextMessages(t *testing.T) {
msgs := []bot.Message{
{
From: bot.User{
Username: "username",
DisplayName: "First Last",
},
Sent: time.Unix(1578627415, 0),
Text: "Message",
},
}
fileRecipient := new(fileRecipientMock)
storage := new(storageMock)
e, err := setup(fileRecipient, storage)
assert.NoError(t, err)
defer teardown()
err = createFile(e.InputRoot+"/20200111.log", msgs)
assert.NoError(t, err)
defer os.Remove(e.InputRoot + "/20200111.log")
e.Export(684, 20200111)
fileRecipient.AssertExpectations(t)
storage.AssertExpectations(t)
} | explode_data.jsonl/37340 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
35939,
10809,
26155,
20960,
2461,
1178,
15820,
1155,
353,
8840,
836,
8,
341,
21169,
82,
1669,
3056,
6331,
8472,
515,
197,
197,
515,
298,
197,
3830,
25,
10924,
7344,
515,
571,
197,
11115,
25,
262,
330,
5113,
756,
571,
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 TestClientSetClientHBForNonExistentClient(t *testing.T) {
cs := createClientStore()
ch := make(chan struct{})
cs.setClientHB("me", time.Millisecond, func() { ch <- struct{}{} })
// function should not be invoked
select {
case <-ch:
t.Fatal("Timer should not have fired!")
case <-time.After(25 * time.Millisecond):
// ok
}
} | explode_data.jsonl/37763 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
2959,
1649,
2959,
30725,
2461,
8121,
840,
18128,
2959,
1155,
353,
8840,
836,
8,
341,
71899,
1669,
1855,
2959,
6093,
2822,
23049,
1669,
1281,
35190,
2036,
37790,
71899,
980,
2959,
30725,
445,
2660,
497,
882,
71482,
11,
2915,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCheckEnvVarsError(t *testing.T) {
result, err := checkEnvVars([]string{"ABCd=def", "GHI=jkl"})
if err == nil {
t.Errorf("Expected to be an error but was nil")
}
if result != nil {
t.Errorf("Expected result to be nil, but was %s", result)
}
} | explode_data.jsonl/53757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
3973,
14359,
28305,
1454,
1155,
353,
8840,
836,
8,
341,
9559,
11,
1848,
1669,
1779,
14359,
28305,
10556,
917,
4913,
25411,
67,
28,
750,
497,
330,
38,
23913,
45612,
10561,
1,
8824,
743,
1848,
621,
2092,
341,
197,
3244,
1308... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateCmd(t *testing.T) {
// setup root and subcommands
rootCmd := &cobra.Command{
Use: "root",
}
queryCmd := &cobra.Command{
Use: "query",
}
rootCmd.AddCommand(queryCmd)
// command being tested
distCmd := &cobra.Command{
Use: "distr",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}
queryCmd.AddCommand(distCmd)
commissionCmd := &cobra.Command{
Use: "commission",
}
distCmd.AddCommand(commissionCmd)
tests := []struct {
reason string
args []string
wantErr bool
}{
{"misspelled command", []string{"comission"}, true},
{"no command provided", []string{}, false},
{"help flag", []string{"comission", "--help"}, false},
{"shorthand help flag", []string{"comission", "-h"}, false},
}
for _, tt := range tests {
err := client.ValidateCmd(distCmd, tt.args)
require.Equal(t, tt.wantErr, err != nil, tt.reason)
}
} | explode_data.jsonl/49166 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 375
} | [
2830,
3393,
17926,
15613,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
3704,
323,
1186,
24270,
198,
33698,
15613,
1669,
609,
59410,
12714,
515,
197,
95023,
25,
330,
2888,
756,
197,
532,
27274,
15613,
1669,
609,
59410,
12714,
515,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestKnativeServing_Acceptance(t *testing.T) {
domainName := MustGetenv(t, "DOMAIN_NAME")
target := MustGetenv(t, "TARGET")
testServiceURL := fmt.Sprintf("https://test-service.knative-serving.%s", domainName)
ingressClient, err := ingressgateway.FromEnv().Client()
if err != nil {
t.Fatalf("Unexpected error when creating ingressgateway client: %s", err)
}
kubeConfig := loadKubeConfigOrDie()
serviceClient := serving.NewForConfigOrDie(kubeConfig).Services("knative-serving")
service, err := serviceClient.Create(&serving_api.Service{
ObjectMeta: meta.ObjectMeta{
Name: "test-service",
},
Spec: serving_api.ServiceSpec{
RunLatest: &serving_api.RunLatestType{
Configuration: serving_api.ConfigurationSpec{
RevisionTemplate: serving_api.RevisionTemplateSpec{
Spec: serving_api.RevisionSpec{
Container: core_api.Container{
Image: "gcr.io/knative-samples/helloworld-go",
Env: []core_api.EnvVar{
{
Name: "TARGET",
Value: target,
},
},
Resources: core_api.ResourceRequirements{
Requests: core_api.ResourceList{
core_api.ResourceCPU: resource.MustParse(cpuLimits),
},
},
},
},
},
},
},
},
})
if err != nil {
t.Fatalf("Cannot create test service: %v", err)
}
defer deleteService(serviceClient, service)
err = retry.Do(func() error {
log.Printf("Calling: %s", testServiceURL)
resp, err := ingressClient.Get(testServiceURL)
if err != nil {
return err
}
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
msg := strings.TrimSpace(string(bytes))
expectedMsg := fmt.Sprintf("Hello %s!", target)
log.Printf("Received %v: '%s'", resp.StatusCode, msg)
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("unexpected status code: %v", resp.StatusCode)
}
if msg != expectedMsg {
return fmt.Errorf("unexpected response: '%s'", msg)
}
return nil
}, retry.OnRetry(func(n uint, err error) {
log.Printf("[%v] try failed: %s", n, err)
}), retry.Attempts(20),
)
if err != nil {
t.Fatalf("cannot get test service response: %s", err)
}
} | explode_data.jsonl/70249 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 913
} | [
2830,
3393,
42,
29738,
50,
19505,
1566,
66,
1484,
681,
1155,
353,
8840,
836,
8,
341,
2698,
3121,
675,
1669,
15465,
1949,
3160,
1155,
11,
330,
57125,
4708,
1138,
28861,
1669,
15465,
1949,
3160,
1155,
11,
330,
45583,
5130,
18185,
1860,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMSSQLQueryStop(t *testing.T) {
MSSQLQuery, ok := NewSqlserverSQLQuery(sMSSQLQuery)
if ok != nil {
t.Fail()
}
if MSSQLQuery.Stop() != nil {
t.Fail()
}
} | explode_data.jsonl/22807 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
44,
1220,
3588,
2859,
10674,
1155,
353,
8840,
836,
8,
341,
9209,
1220,
3588,
2859,
11,
5394,
1669,
1532,
8269,
4030,
6688,
2859,
1141,
44,
1220,
3588,
2859,
340,
743,
5394,
961,
2092,
341,
197,
3244,
57243,
741,
197,
630,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 3 |
func TestTSEnumConstantFolding(t *testing.T) {
expectPrintedTS(t, `
enum Foo {
add = 1 + 2,
sub = -1 - 2,
mul = 10 * 20,
div_pos_inf = 1 / 0,
div_neg_inf = 1 / -0,
div_nan = 0 / 0,
div_neg_zero = 1 / (1 / -0),
div0 = 10 / 20,
div1 = 10 / -20,
div2 = -10 / 20,
div3 = -10 / -20,
mod0 = 123 % 100,
mod1 = 123 % -100,
mod2 = -123 % 100,
mod3 = -123 % -100,
fmod0 = 1.375 % 0.75,
fmod1 = 1.375 % -0.75,
fmod2 = -1.375 % 0.75,
fmod3 = -1.375 % -0.75,
pow0 = 2.25 ** 3,
pow1 = 2.25 ** -3,
pow2 = (-2.25) ** 3,
pow3 = (-2.25) ** -3,
}
`, `var Foo;
(function(Foo) {
Foo[Foo["add"] = 3] = "add";
Foo[Foo["sub"] = -3] = "sub";
Foo[Foo["mul"] = 200] = "mul";
Foo[Foo["div_pos_inf"] = Infinity] = "div_pos_inf";
Foo[Foo["div_neg_inf"] = -Infinity] = "div_neg_inf";
Foo[Foo["div_nan"] = NaN] = "div_nan";
Foo[Foo["div_neg_zero"] = -0] = "div_neg_zero";
Foo[Foo["div0"] = 0.5] = "div0";
Foo[Foo["div1"] = -0.5] = "div1";
Foo[Foo["div2"] = -0.5] = "div2";
Foo[Foo["div3"] = 0.5] = "div3";
Foo[Foo["mod0"] = 23] = "mod0";
Foo[Foo["mod1"] = 23] = "mod1";
Foo[Foo["mod2"] = -23] = "mod2";
Foo[Foo["mod3"] = -23] = "mod3";
Foo[Foo["fmod0"] = 0.625] = "fmod0";
Foo[Foo["fmod1"] = 0.625] = "fmod1";
Foo[Foo["fmod2"] = -0.625] = "fmod2";
Foo[Foo["fmod3"] = -0.625] = "fmod3";
Foo[Foo["pow0"] = 11.390625] = "pow0";
Foo[Foo["pow1"] = 0.0877914951989026] = "pow1";
Foo[Foo["pow2"] = -11.390625] = "pow2";
Foo[Foo["pow3"] = -0.0877914951989026] = "pow3";
})(Foo || (Foo = {}));
`)
expectPrintedTS(t, `
enum Foo {
shl0 = 987654321 << 2,
shl1 = 987654321 << 31,
shl2 = 987654321 << 34,
shr0 = -987654321 >> 2,
shr1 = -987654321 >> 31,
shr2 = -987654321 >> 34,
ushr0 = -987654321 >>> 2,
ushr1 = -987654321 >>> 31,
ushr2 = -987654321 >>> 34,
bitand = 0xDEADF00D & 0xBADCAFE,
bitor = 0xDEADF00D | 0xBADCAFE,
bitxor = 0xDEADF00D ^ 0xBADCAFE,
}
`, `var Foo;
(function(Foo) {
Foo[Foo["shl0"] = -344350012] = "shl0";
Foo[Foo["shl1"] = -2147483648] = "shl1";
Foo[Foo["shl2"] = -344350012] = "shl2";
Foo[Foo["shr0"] = -246913581] = "shr0";
Foo[Foo["shr1"] = -1] = "shr1";
Foo[Foo["shr2"] = -246913581] = "shr2";
Foo[Foo["ushr0"] = 826828243] = "ushr0";
Foo[Foo["ushr1"] = 1] = "ushr1";
Foo[Foo["ushr2"] = 826828243] = "ushr2";
Foo[Foo["bitand"] = 179159052] = "bitand";
Foo[Foo["bitor"] = -542246145] = "bitor";
Foo[Foo["bitxor"] = -721405197] = "bitxor";
})(Foo || (Foo = {}));
`)
} | explode_data.jsonl/82321 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1413
} | [
2830,
3393,
51,
925,
2413,
15472,
37,
14995,
1155,
353,
8840,
836,
8,
341,
24952,
8994,
291,
9951,
1155,
11,
22074,
197,
37777,
33428,
341,
298,
12718,
284,
220,
16,
488,
220,
17,
345,
298,
28624,
284,
481,
16,
481,
220,
17,
345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStatus_NotSyncing(t *testing.T) {
mockJSONRPC := &mocks.JSONRPC{}
mockGraphQL := &mocks.GraphQL{}
c := &Client{
c: mockJSONRPC,
g: mockGraphQL,
traceSemaphore: semaphore.NewWeighted(100),
}
ctx := context.Background()
mockJSONRPC.On(
"CallContext",
ctx,
mock.Anything,
"eth_getBlockByNumber",
"latest",
false,
).Return(
nil,
).Run(
func(args mock.Arguments) {
header := args.Get(1).(**types.Header)
file, err := ioutil.ReadFile("testdata/basic_header.json")
assert.NoError(t, err)
*header = new(types.Header)
assert.NoError(t, (*header).UnmarshalJSON(file))
},
).Once()
block, timestamp, syncStatus, peers, err := c.Status(ctx)
assert.Equal(t, &RosettaTypes.BlockIdentifier{
Hash: "0x48269a339ce1489cff6bab70eff432289c4f490b81dbd00ff1f81c68de06b842",
Index: 8916656,
}, block)
assert.Equal(t, int64(1603225195000), timestamp)
assert.Equal(t, &RosettaTypes.SyncStatus{
CurrentIndex: RosettaTypes.Int64(8916656),
TargetIndex: RosettaTypes.Int64(8916656),
}, syncStatus)
assert.Nil(t, peers)
assert.NoError(t, err)
mockJSONRPC.AssertExpectations(t)
mockGraphQL.AssertExpectations(t)
} | explode_data.jsonl/55485 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 537
} | [
2830,
3393,
2522,
60816,
12154,
287,
1155,
353,
8840,
836,
8,
341,
77333,
5370,
29528,
1669,
609,
16712,
82,
18009,
29528,
16094,
77333,
88637,
1669,
609,
16712,
82,
40237,
3588,
31483,
1444,
1669,
609,
2959,
515,
197,
1444,
25,
1060,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSyncer_applyChunks_RejectSenders(t *testing.T) {
// Banning chunks senders via ban_chunk_senders should work the same for all results
testcases := map[string]struct {
result abci.ResponseApplySnapshotChunk_Result
}{
"accept": {abci.ResponseApplySnapshotChunk_ACCEPT},
"abort": {abci.ResponseApplySnapshotChunk_ABORT},
"retry": {abci.ResponseApplySnapshotChunk_RETRY},
"retry_snapshot": {abci.ResponseApplySnapshotChunk_RETRY_SNAPSHOT},
"reject_snapshot": {abci.ResponseApplySnapshotChunk_REJECT_SNAPSHOT},
}
for name, tc := range testcases {
tc := tc
t.Run(name, func(t *testing.T) {
connQuery := &proxymocks.AppConnQuery{}
connSnapshot := &proxymocks.AppConnSnapshot{}
stateProvider := &mocks.StateProvider{}
stateProvider.On("AppHash", mock.Anything).Return([]byte("app_hash"), nil)
syncer := newSyncer(log.NewNopLogger(), connSnapshot, connQuery, stateProvider, "")
// Set up three peers across two snapshots, and ask for one of them to be banned.
// It should be banned from all snapshots.
peerA := simplePeer("a")
peerB := simplePeer("b")
peerC := simplePeer("c")
s1 := &snapshot{Height: 1, Format: 1, Chunks: 3}
s2 := &snapshot{Height: 2, Format: 1, Chunks: 3}
_, err := syncer.AddSnapshot(peerA, s1)
require.NoError(t, err)
_, err = syncer.AddSnapshot(peerA, s2)
require.NoError(t, err)
_, err = syncer.AddSnapshot(peerB, s1)
require.NoError(t, err)
_, err = syncer.AddSnapshot(peerB, s2)
require.NoError(t, err)
_, err = syncer.AddSnapshot(peerC, s1)
require.NoError(t, err)
_, err = syncer.AddSnapshot(peerC, s2)
require.NoError(t, err)
chunks, err := newChunkQueue(s1, "")
require.NoError(t, err)
added, err := chunks.Add(&chunk{Height: 1, Format: 1, Index: 0, Chunk: []byte{0}, Sender: peerA.ID()})
require.True(t, added)
require.NoError(t, err)
added, err = chunks.Add(&chunk{Height: 1, Format: 1, Index: 1, Chunk: []byte{1}, Sender: peerB.ID()})
require.True(t, added)
require.NoError(t, err)
added, err = chunks.Add(&chunk{Height: 1, Format: 1, Index: 2, Chunk: []byte{2}, Sender: peerC.ID()})
require.True(t, added)
require.NoError(t, err)
// The first two chunks are accepted, before the last one asks for b sender to be rejected
connSnapshot.On("ApplySnapshotChunkSync", abci.RequestApplySnapshotChunk{
Index: 0, Chunk: []byte{0}, Sender: "a",
}).Once().Return(&abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ACCEPT}, nil)
connSnapshot.On("ApplySnapshotChunkSync", abci.RequestApplySnapshotChunk{
Index: 1, Chunk: []byte{1}, Sender: "b",
}).Once().Return(&abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ACCEPT}, nil)
connSnapshot.On("ApplySnapshotChunkSync", abci.RequestApplySnapshotChunk{
Index: 2, Chunk: []byte{2}, Sender: "c",
}).Once().Return(&abci.ResponseApplySnapshotChunk{
Result: tc.result,
RejectSenders: []string{string(peerB.ID())},
}, nil)
// On retry, the last chunk will be tried again, so we just accept it then.
if tc.result == abci.ResponseApplySnapshotChunk_RETRY {
connSnapshot.On("ApplySnapshotChunkSync", abci.RequestApplySnapshotChunk{
Index: 2, Chunk: []byte{2}, Sender: "c",
}).Once().Return(&abci.ResponseApplySnapshotChunk{Result: abci.ResponseApplySnapshotChunk_ACCEPT}, nil)
}
// We don't really care about the result of applyChunks, since it has separate test.
// However, it will block on e.g. retry result, so we spawn a goroutine that will
// be shut down when the chunk queue closes.
go func() {
syncer.applyChunks(chunks) //nolint:errcheck // purposefully ignore error
}()
time.Sleep(50 * time.Millisecond)
s1peers := syncer.snapshots.GetPeers(s1)
assert.Len(t, s1peers, 2)
assert.EqualValues(t, "a", s1peers[0].ID())
assert.EqualValues(t, "c", s1peers[1].ID())
syncer.snapshots.GetPeers(s1)
assert.Len(t, s1peers, 2)
assert.EqualValues(t, "a", s1peers[0].ID())
assert.EqualValues(t, "c", s1peers[1].ID())
err = chunks.Close()
require.NoError(t, err)
})
}
} | explode_data.jsonl/46294 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1714
} | [
2830,
3393,
12154,
261,
36551,
89681,
50693,
583,
11505,
388,
1155,
353,
8840,
836,
8,
341,
197,
322,
425,
5947,
26757,
3624,
388,
4566,
8943,
30539,
13565,
388,
1265,
975,
279,
1852,
369,
678,
3059,
198,
18185,
23910,
1669,
2415,
14032... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateMatcher(t *testing.T) {
cases := []struct {
m *pb.Matcher
err string
}{
{
m: &pb.Matcher{
Name: "a",
Pattern: "b",
Type: pb.Matcher_EQUAL,
},
err: "",
}, {
m: &pb.Matcher{
Name: "00",
Pattern: "a",
Type: pb.Matcher_EQUAL,
},
err: "invalid label name",
}, {
m: &pb.Matcher{
Name: "a",
Pattern: "((",
Type: pb.Matcher_REGEXP,
},
err: "invalid regular expression",
}, {
m: &pb.Matcher{
Name: "a",
Pattern: "\xff",
Type: pb.Matcher_EQUAL,
},
err: "invalid label value",
}, {
m: &pb.Matcher{
Name: "a",
Pattern: "b",
Type: 333,
},
err: "unknown matcher type",
},
}
for _, c := range cases {
err := validateMatcher(c.m)
if err == nil {
if c.err != "" {
t.Errorf("expected error containing %q but got none", c.err)
}
continue
}
if err != nil && c.err == "" {
t.Errorf("unexpected error %q", err)
continue
}
if !strings.Contains(err.Error(), c.err) {
t.Errorf("expected error to contain %q but got %q", c.err, err)
}
}
} | explode_data.jsonl/2693 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 591
} | [
2830,
3393,
17926,
37554,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
2109,
256,
353,
16650,
76452,
198,
197,
9859,
914,
198,
197,
59403,
197,
197,
515,
298,
2109,
25,
609,
16650,
76452,
515,
571,
21297,
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... | 7 |
func TestNewlineData(t *testing.T) {
data := []byte("a\nb\ncdef\n")
buffer := NewSyslogBuffer()
buffer.Append(data)
result := buffer.NextLine()
assert.NotEqual(t, nil, result)
assert.Equal(t, "a", string(result))
assert.Equal(t, "b\ncdef\n", string(buffer.Buffer))
result = buffer.NextLine()
assert.NotEqual(t, nil, result)
assert.Equal(t, "b", string(result))
result = buffer.NextLine()
assert.NotEqual(t, nil, result)
assert.Equal(t, "cdef", string(result))
} | explode_data.jsonl/18085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
3564,
1056,
1043,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
445,
64,
1699,
65,
59,
1016,
750,
1699,
5130,
31122,
1669,
1532,
32792,
839,
4095,
741,
31122,
8982,
2592,
692,
9559,
1669,
4147,
18501,
2460,
741,
69... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIterGrowAndDelete(t *testing.T) {
m := make(map[int]int, 4)
for i := 0; i < 100; i++ {
m[i] = i
}
growflag := true
for k := range m {
if growflag {
// grow the table
for i := 100; i < 1000; i++ {
m[i] = i
}
// delete all odd keys
for i := 1; i < 1000; i += 2 {
delete(m, i)
}
growflag = false
} else {
if k&1 == 1 {
t.Error("odd value returned")
}
}
}
} | explode_data.jsonl/19909 | {
"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,
8537,
56788,
3036,
6435,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
1281,
9147,
18640,
63025,
11,
220,
19,
340,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
341,
197,
2109,
989,
60,
284,
600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestKsonnetApp(t *testing.T) {
Given(t).
Path("ksonnet").
Env("prod").
// Null out dest server to verify that destination is inferred from ksonnet app
Parameter("guestbook-ui=image=gcr.io/heptio-images/ks-guestbook-demo:0.1").
DestServer("").
When().
Create().
Sync().
Then().
And(func(app *Application) {
closer, client, err := ArgoCDClientset.NewRepoClient()
assert.NoError(t, err)
defer io.Close(closer)
details, err := client.GetAppDetails(context.Background(), &repositorypkg.RepoAppDetailsQuery{
Source: &app.Spec.Source,
})
assert.NoError(t, err)
serviceType := ""
for _, param := range details.Ksonnet.Parameters {
if param.Name == "type" && param.Component == "guestbook-ui" {
serviceType = param.Value
}
}
assert.Equal(t, serviceType, "LoadBalancer")
})
} | explode_data.jsonl/66683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
42,
930,
4711,
2164,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
445,
74,
930,
4711,
38609,
197,
197,
14359,
445,
19748,
38609,
197,
197,
322,
18084,
700,
3201,
3538,
311,
10146,
429,
9106,
374,
67595... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
tests := []struct {
testName string
svc *corev1.Service
wantError bool
wantValue []elbv2.TargetGroupAttribute
}{
{
testName: "Default values",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
},
wantError: false,
wantValue: []elbv2.TargetGroupAttribute{
{
Key: tgAttrsProxyProtocolV2Enabled,
Value: "false",
},
},
},
{
testName: "Proxy V2 enabled",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
},
},
},
wantError: false,
wantValue: []elbv2.TargetGroupAttribute{
{
Key: tgAttrsProxyProtocolV2Enabled,
Value: "true",
},
},
},
{
testName: "Invalid value",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "v2",
},
},
},
wantError: true,
},
{
testName: "target group attributes",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-target-group-attributes": "target.group-attr-1=80, t2.enabled=false, preserve_client_ip.enabled=true",
},
},
},
wantValue: []elbv2.TargetGroupAttribute{
{
Key: tgAttrsProxyProtocolV2Enabled,
Value: "false",
},
{
Key: tgAttrsPreserveClientIPEnabled,
Value: "true",
},
{
Key: "target.group-attr-1",
Value: "80",
},
{
Key: "t2.enabled",
Value: "false",
},
},
wantError: false,
},
{
testName: "target group proxy v2 override",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-target-group-attributes": tgAttrsProxyProtocolV2Enabled + "=false",
"service.beta.kubernetes.io/aws-load-balancer-proxy-protocol": "*",
},
},
},
wantValue: []elbv2.TargetGroupAttribute{
{
Key: tgAttrsProxyProtocolV2Enabled,
Value: "true",
},
},
},
{
testName: "target group attr parse error",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-target-group-attributes": "k1=v1, malformed",
},
},
},
wantError: true,
},
{
testName: "IP enabled attribute parse error",
svc: &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"service.beta.kubernetes.io/aws-load-balancer-target-group-attributes": tgAttrsPreserveClientIPEnabled + "= FalSe",
},
},
},
wantError: true,
},
}
for _, tt := range tests {
t.Run(tt.testName, func(t *testing.T) {
parser := annotations.NewSuffixAnnotationParser("service.beta.kubernetes.io")
builder := &defaultModelBuildTask{
service: tt.svc,
annotationParser: parser,
}
tgAttrs, err := builder.buildTargetGroupAttributes(context.Background())
if tt.wantError {
assert.Error(t, err)
} else {
sort.Slice(tt.wantValue, func(i, j int) bool {
return tt.wantValue[i].Key < tt.wantValue[j].Key
})
sort.Slice(tgAttrs, func(i, j int) bool {
return tgAttrs[i].Key < tgAttrs[j].Key
})
assert.Equal(t, tt.wantValue, tgAttrs)
}
})
}
} | explode_data.jsonl/40056 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1713
} | [
2830,
3393,
9993,
1712,
3297,
6262,
11123,
2808,
53671,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
18185,
675,
220,
914,
198,
197,
1903,
7362,
981,
353,
98645,
16,
13860,
198,
197,
50780,
1454,
1807,
198,
197,
50... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_ServerPersist_Queue_Success(t *testing.T) {
sc, _ := getNewSC(getDefaultTestConfig())
defer sc.clean()
ch, _ := sc.client.Channel()
ch.QueueDeclare(t.Name(), true, false, false, false, emptyTable)
sc.server.Stop()
sc, _ = getNewSC(getDefaultTestConfig())
ch, _ = sc.client.Channel()
if _, err := ch.QueueDeclarePassive(t.Name(), false, false, false, false, emptyTable); err != nil {
t.Error("Expected queue exists after server restart", err)
}
} | explode_data.jsonl/44902 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 167
} | [
2830,
3393,
62320,
61267,
62,
7554,
87161,
1155,
353,
8840,
836,
8,
341,
29928,
11,
716,
1669,
633,
3564,
3540,
5433,
3675,
2271,
2648,
2398,
16867,
1136,
25237,
741,
23049,
11,
716,
1669,
1136,
6581,
38716,
2822,
23049,
50251,
78455,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSupervisor_MultipleServices(t *testing.T) {
cfg := &Config{
Logger: testr.NewTestLogger(t),
}
const numServices = 10
serviceChan := make(chan struct{})
for i := 0; i < numServices; i++ {
cfg.Services = append(cfg.Services, NewService(fmt.Sprintf("service%d", i), func(ctx context.Context) error {
serviceChan <- struct{}{}
<-ctx.Done()
return nil
}))
}
_, done := newTestFixture(t, cfg)
defer done()
for i := 0; i < numServices; i++ {
select {
case <-serviceChan:
case <-time.After(time.Second):
t.Fatalf("timed out waiting for service %d to run", i)
}
}
} | explode_data.jsonl/9761 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 240
} | [
2830,
3393,
10048,
31396,
1245,
12229,
11025,
1155,
353,
8840,
836,
8,
341,
50286,
1669,
609,
2648,
515,
197,
55861,
25,
1273,
81,
7121,
2271,
7395,
1155,
1326,
197,
532,
4777,
1629,
11025,
284,
220,
16,
15,
198,
52934,
46019,
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... | 1 |
func TestReadPaypalCsv(t *testing.T) {
r := strings.NewReader(kPaypalCsv)
var loader autoimport.Loader
loader = csv.CsvLoader{make(storeType)}
batch, err := loader.Load(3, "", r, date_util.YMD(2015, 9, 3))
if err != nil {
t.Errorf("Got error %v", err)
return
}
entries := batch.Entries()
expectedEntries := []*fin.Entry{
{
Date: date_util.YMD(2015, 12, 6),
Name: "TrackR, Inc",
CatPayment: fin.NewCatPayment(fin.Expense, 8700, true, 3)},
{
Date: date_util.YMD(2015, 9, 5),
Name: "Starbucks Coffee Company",
CatPayment: fin.NewCatPayment(fin.Expense, 4810, true, 3)},
{
Date: date_util.YMD(2015, 9, 3),
Name: "Disney Online",
CatPayment: fin.NewCatPayment(fin.Expense, 4641, true, 3)}}
if !reflect.DeepEqual(expectedEntries, entries) {
t.Errorf("Expected %v, got %v", expectedEntries, entries)
}
} | explode_data.jsonl/33812 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 402
} | [
2830,
3393,
4418,
20595,
19308,
94826,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
9069,
68587,
5969,
20595,
19308,
94826,
340,
2405,
16047,
3233,
474,
82987,
198,
197,
8355,
284,
13147,
727,
3492,
9181,
90,
6927,
31200,
929,
10569,
2233,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsKubeadmPrereleaseVersion(t *testing.T) {
validVersionInfo := &apimachineryversion.Info{Major: "1", GitVersion: "v1.23.0-alpha.1"}
tests := []struct {
name string
versionInfo *apimachineryversion.Info
k8sVersion *version.Version
mcpVersion *version.Version
expectedResult bool
}{
{
name: "invalid versionInfo",
versionInfo: &apimachineryversion.Info{},
expectedResult: false,
},
{
name: "kubeadm is not a prerelease version",
versionInfo: &apimachineryversion.Info{Major: "1", GitVersion: "v1.23.0"},
expectedResult: false,
},
{
name: "mcpVersion is equal to k8sVersion",
versionInfo: validVersionInfo,
k8sVersion: version.MustParseSemantic("v1.21.0"),
mcpVersion: version.MustParseSemantic("v1.21.0"),
expectedResult: true,
},
{
name: "k8sVersion is 1 MINOR version older than mcpVersion",
versionInfo: validVersionInfo,
k8sVersion: version.MustParseSemantic("v1.21.0"),
mcpVersion: version.MustParseSemantic("v1.22.0"),
expectedResult: true,
},
{
name: "k8sVersion is 2 MINOR versions older than mcpVersion",
versionInfo: validVersionInfo,
k8sVersion: version.MustParseSemantic("v1.21.0"),
mcpVersion: version.MustParseSemantic("v1.23.0"),
expectedResult: false,
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
result := isKubeadmPrereleaseVersion(tc.versionInfo, tc.k8sVersion, tc.mcpVersion)
if result != tc.expectedResult {
t.Errorf("expected result: %v, got %v", tc.expectedResult, result)
}
})
}
} | explode_data.jsonl/10229 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 737
} | [
2830,
3393,
3872,
42,
392,
3149,
76,
3533,
485,
1623,
5637,
1155,
353,
8840,
836,
8,
341,
56322,
5637,
1731,
1669,
609,
391,
70355,
4366,
20132,
90,
34475,
25,
330,
16,
497,
21120,
5637,
25,
330,
85,
16,
13,
17,
18,
13,
15,
64538,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapProxy_ContainsKey(t *testing.T) {
testKey := "testingKey1"
testValue := "testingValue"
mp.Put(testKey, testValue)
found, err := mp.ContainsKey(testKey)
AssertEqualf(t, err, found, true, "containsKey returned a wrong result")
found, err = mp.ContainsKey("testingKey2")
AssertEqualf(t, err, found, false, "containsKey returned a wrong result")
mp.Clear()
} | explode_data.jsonl/56976 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 134
} | [
2830,
3393,
2227,
16219,
62,
23805,
1592,
1155,
353,
8840,
836,
8,
341,
18185,
1592,
1669,
330,
8840,
1592,
16,
698,
18185,
1130,
1669,
330,
8840,
1130,
698,
53230,
39825,
8623,
1592,
11,
1273,
1130,
340,
58102,
11,
1848,
1669,
10490,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValuesFloat32(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec(`drop table if exists t;`)
tk.MustExec(`create table t (i int key, j float);`)
tk.MustExec(`insert into t values (1, 0.01);`)
tk.MustQuery(`select * from t;`).Check(testkit.Rows(`1 0.01`))
tk.MustExec(`insert into t values (1, 0.02) on duplicate key update j = values (j);`)
tk.MustQuery(`select * from t;`).Check(testkit.Rows(`1 0.02`))
} | explode_data.jsonl/65475 | {
"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,
6227,
5442,
18,
17,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1273,
8226,
7251,
11571,
6093,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
340,
3244,
74,
50463,
1021... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPoliciesPathSlashes(t *testing.T) {
f := newFixture(t)
if err := f.v1(http.MethodPut, "/policies/a/b/c.rego", testMod, 200, ""); err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if err := f.v1(http.MethodGet, "/policies/a/b/c.rego", testMod, 200, ""); err != nil {
t.Fatalf("Unexpected error: %v", err)
}
} | explode_data.jsonl/79015 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
47,
42038,
1820,
7442,
14051,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
743,
1848,
1669,
282,
3133,
16,
19886,
20798,
19103,
11,
3521,
79,
42038,
14186,
3470,
2899,
1327,
3346,
497,
1273,
4459,
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... | 3 |
func TestAdmissionBroker(t *testing.T) {
// Anonymous struct fields:
// name: short description of the testing
// broker: a fake broker object
// allowed: flag for whether or not the broker should be admitted
cases := []struct {
name string
broker *servicecatalog.ClusterServiceBroker
userInfo *user.DefaultInfo
allowed bool
}{
{
name: "broker with no auth",
broker: &servicecatalog.ClusterServiceBroker{
ObjectMeta: metav1.ObjectMeta{
Name: "test-broker",
},
Spec: servicecatalog.ClusterServiceBrokerSpec{
URL: "http://example.com",
},
},
userInfo: &user.DefaultInfo{
Name: "system:serviceaccount:test-ns:catalog",
Groups: []string{"system:serviceaccount", "system:serviceaccounts:test-ns"},
},
allowed: true,
},
{
name: "broker with basic auth, user authenticated",
broker: &servicecatalog.ClusterServiceBroker{
ObjectMeta: metav1.ObjectMeta{
Name: "test-broker",
},
Spec: servicecatalog.ClusterServiceBrokerSpec{
URL: "http://example.com",
AuthInfo: &servicecatalog.ServiceBrokerAuthInfo{
Basic: &servicecatalog.BasicAuthConfig{
SecretRef: &servicecatalog.ObjectReference{
Namespace: "test-ns",
Name: "test-secret",
},
},
},
},
},
userInfo: &user.DefaultInfo{
Name: "system:serviceaccount:test-ns:catalog",
Groups: []string{"system:serviceaccount", "system:serviceaccounts:test-ns"},
},
allowed: true,
},
{
name: "broker with bearer token, user authenticated",
broker: &servicecatalog.ClusterServiceBroker{
ObjectMeta: metav1.ObjectMeta{
Name: "test-broker",
},
Spec: servicecatalog.ClusterServiceBrokerSpec{
URL: "http://example.com",
AuthInfo: &servicecatalog.ServiceBrokerAuthInfo{
Bearer: &servicecatalog.BearerTokenAuthConfig{
SecretRef: &servicecatalog.ObjectReference{
Namespace: "test-ns",
Name: "test-secret",
},
},
},
},
},
userInfo: &user.DefaultInfo{
Name: "system:serviceaccount:test-ns:catalog",
Groups: []string{"system:serviceaccount", "system:serviceaccounts:test-ns"},
},
allowed: true,
},
{
name: "broker with bearer token, unauthenticated user",
broker: &servicecatalog.ClusterServiceBroker{
ObjectMeta: metav1.ObjectMeta{
Name: "test-broker",
},
Spec: servicecatalog.ClusterServiceBrokerSpec{
URL: "http://example.com",
AuthInfo: &servicecatalog.ServiceBrokerAuthInfo{
Bearer: &servicecatalog.BearerTokenAuthConfig{
SecretRef: &servicecatalog.ObjectReference{
Namespace: "test-ns",
Name: "test-secret",
},
},
},
},
},
userInfo: &user.DefaultInfo{
Name: "system:serviceaccount:test-ns:forbidden",
Groups: []string{"system:serviceaccount", "system:serviceaccounts:test-ns"},
},
allowed: false,
},
}
for _, tc := range cases {
mockKubeClient := newMockKubeClientForTest(tc.userInfo)
handler, kubeInformerFactory, err := newHandlerForTest(mockKubeClient)
if err != nil {
t.Errorf("unexpected error initializing handler: %v", err)
}
kubeInformerFactory.Start(wait.NeverStop)
err = handler.Admit(admission.NewAttributesRecord(tc.broker, nil, servicecatalog.Kind("ClusterServiceBroker").WithVersion("version"), tc.broker.Namespace, tc.broker.Name, servicecatalog.Resource("clusterservicebrokers").WithVersion("version"), "", admission.Create, tc.userInfo))
if err != nil && tc.allowed || err == nil && !tc.allowed {
t.Errorf("Create test '%s' reports: Unexpected error returned from admission handler: %v", tc.name, err)
}
}
} | explode_data.jsonl/9268 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1511
} | [
2830,
3393,
2589,
2728,
65545,
1155,
353,
8840,
836,
8,
341,
197,
322,
30437,
2036,
5043,
510,
197,
322,
829,
25,
2805,
4008,
315,
279,
7497,
198,
197,
322,
22316,
25,
264,
12418,
22316,
1633,
198,
197,
322,
5420,
25,
5181,
369,
342... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMiddleware_Allowlist(t *testing.T) {
// setup types
got := []string{""}
want := []string{"foobar"}
// setup context
gin.SetMode(gin.TestMode)
resp := httptest.NewRecorder()
context, engine := gin.CreateTestContext(resp)
context.Request, _ = http.NewRequest(http.MethodGet, "/health", nil)
// setup mock server
engine.Use(Allowlist(want))
engine.GET("/health", func(c *gin.Context) {
got = c.Value("allowlist").([]string)
c.Status(http.StatusOK)
})
// run test
engine.ServeHTTP(context.Writer, context.Request)
if resp.Code != http.StatusOK {
t.Errorf("Secret returned %v, want %v", resp.Code, http.StatusOK)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Secret is %v, want %v", got, want)
}
} | explode_data.jsonl/6606 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 273
} | [
2830,
3393,
24684,
53629,
363,
1607,
1155,
353,
8840,
836,
8,
341,
197,
322,
6505,
4494,
198,
3174,
354,
1669,
3056,
917,
90,
3014,
532,
50780,
1669,
3056,
917,
4913,
50267,
63159,
197,
322,
6505,
2266,
198,
3174,
258,
4202,
3636,
326... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGatherExchangeMarketPairs(t *testing.T) {
GatherExchangeMarketPairs(&types.Options{
Slug: "binance",
}, "ETH", gocron.Every(10).Seconds())
gocron.Start()
time.Sleep(15 * time.Second)
} | explode_data.jsonl/15047 | {
"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,
38,
1856,
31564,
38822,
54228,
1155,
353,
8840,
836,
8,
341,
9600,
1856,
31564,
38822,
54228,
2099,
9242,
22179,
515,
197,
197,
54968,
25,
330,
6863,
681,
756,
197,
2137,
330,
7625,
497,
342,
509,
2248,
5142,
1204,
7,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func Test_trafficFilterRuleHash(t *testing.T) {
type args struct {
v interface{}
}
tests := []struct {
name string
args args
want int
}{
{
name: "hash a rule without description",
args: args{v: map[string]interface{}{
"source": "8.8.8.8/24",
}},
want: 1202035824,
},
{
name: "hash a rule with description",
args: args{v: map[string]interface{}{
"source": "8.8.8.8/24",
"description": "google dns",
}},
want: 1579348650,
},
{
name: "hash a rule different without description",
args: args{v: map[string]interface{}{
"source": "8.8.4.4/24",
}},
want: 2058478515,
},
{
name: "hash a rule different with description",
args: args{v: map[string]interface{}{
"source": "8.8.4.4/24",
"description": "alternate google dns",
}},
want: 766352945,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := trafficFilterRuleHash(tt.args.v); got != tt.want {
t.Errorf("trafficFilterRuleHash() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/26853 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 500
} | [
2830,
3393,
90012,
5632,
11337,
6370,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
5195,
3749,
16094,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
526,
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... | 2 |
func TestPriorityQueue_NominatedPodDeleted(t *testing.T) {
tests := []struct {
name string
podInfo *framework.PodInfo
deletePod bool
want bool
}{
{
name: "alive pod gets added into PodNominator",
podInfo: medPriorityPodInfo,
want: true,
},
{
name: "deleted pod shouldn't be added into PodNominator",
podInfo: highPriNominatedPodInfo,
deletePod: true,
want: false,
},
{
name: "pod without .status.nominatedPodName specified shouldn't be added into PodNominator",
podInfo: highPriorityPodInfo,
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cs := fake.NewSimpleClientset(tt.podInfo.Pod)
informerFactory := informers.NewSharedInformerFactory(cs, 0)
podLister := informerFactory.Core().V1().Pods().Lister()
// Build a PriorityQueue.
q := NewPriorityQueue(newDefaultQueueSort(), informerFactory, WithPodNominator(NewPodNominator(podLister)))
ctx := context.Background()
informerFactory.Start(ctx.Done())
informerFactory.WaitForCacheSync(ctx.Done())
if tt.deletePod {
// Simulate that the test pod gets deleted physically.
informerFactory.Core().V1().Pods().Informer().GetStore().Delete(tt.podInfo.Pod)
}
q.AddNominatedPod(tt.podInfo, tt.podInfo.Pod.Status.NominatedNodeName)
if got := len(q.NominatedPodsForNode(tt.podInfo.Pod.Status.NominatedNodeName)) == 1; got != tt.want {
t.Errorf("Want %v, but got %v", tt.want, got)
}
})
}
} | explode_data.jsonl/68192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 617
} | [
2830,
3393,
20555,
7554,
1604,
49515,
23527,
26039,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
414,
914,
198,
197,
3223,
347,
1731,
256,
353,
3794,
88823,
1731,
198,
197,
15618,
23527,
1807,
198,
197,
50780,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestLengthFilter(t *testing.T) {
var filters = []ResponseFilter{
LengthFilter(100),
LengthFilter(1000),
LengthFilter(0),
}
var tests = []struct {
length int64
shouldCompress [3]bool
}{
{20, [3]bool{false, false, false}},
{50, [3]bool{false, false, false}},
{100, [3]bool{true, false, false}},
{500, [3]bool{true, false, false}},
{1000, [3]bool{true, true, false}},
{1500, [3]bool{true, true, false}},
}
for i, ts := range tests {
for j, filter := range filters {
r := httptest.NewRecorder()
r.Header().Set("Content-Length", fmt.Sprint(ts.length))
wWriter := NewResponseFilterWriter([]ResponseFilter{filter}, &gzipResponseWriter{gzip.NewWriter(r), &httpserver.ResponseWriterWrapper{ResponseWriter: r}, false})
if filter.ShouldCompress(wWriter) != ts.shouldCompress[j] {
t.Errorf("Test %v: Expected %v found %v", i, ts.shouldCompress[j], filter.ShouldCompress(r))
}
}
}
} | explode_data.jsonl/15901 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 378
} | [
2830,
3393,
4373,
5632,
1155,
353,
8840,
836,
8,
341,
2405,
13406,
284,
3056,
2582,
5632,
515,
197,
197,
4373,
5632,
7,
16,
15,
15,
1326,
197,
197,
4373,
5632,
7,
16,
15,
15,
15,
1326,
197,
197,
4373,
5632,
7,
15,
1326,
197,
630... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStoreGCThreshold(t *testing.T) {
defer leaktest.AfterTest(t)()
tc := testContext{}
stopper := stop.NewStopper()
defer stopper.Stop(context.Background())
tc.Start(t, stopper)
store := tc.store
assertThreshold := func(ts hlc.Timestamp) {
repl, err := store.GetReplica(1)
if err != nil {
t.Fatal(err)
}
repl.mu.Lock()
gcThreshold := *repl.mu.state.GCThreshold
pgcThreshold, err := repl.mu.stateLoader.LoadGCThreshold(context.Background(), store.Engine())
repl.mu.Unlock()
if err != nil {
t.Fatal(err)
}
if gcThreshold != *pgcThreshold {
t.Fatalf("persisted != in-memory threshold: %s vs %s", pgcThreshold, gcThreshold)
}
if *pgcThreshold != ts {
t.Fatalf("expected timestamp %s, got %s", ts, pgcThreshold)
}
}
// Threshold should start at zero.
assertThreshold(hlc.Timestamp{})
threshold := hlc.Timestamp{
WallTime: 2e9,
}
gcr := roachpb.GCRequest{
// Bogus span to make it a valid request.
RequestHeader: roachpb.RequestHeader{
Key: roachpb.Key("a"),
EndKey: roachpb.Key("b"),
},
Threshold: threshold,
}
if _, pErr := tc.SendWrappedWith(roachpb.Header{RangeID: 1}, &gcr); pErr != nil {
t.Fatal(pErr)
}
assertThreshold(threshold)
} | explode_data.jsonl/112 | {
"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,
6093,
22863,
37841,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
78255,
1669,
1273,
1972,
16094,
62644,
712,
1669,
2936,
7121,
10674,
712,
741,
16867,
2936,
712,
30213,
5378,
19047,
2398,
78255,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrepareSearchQuery(t *testing.T) {
type args struct {
table string
searchRequest SearchRequest
}
type res struct {
count uint64
wantErr bool
errFunc func(err error) bool
}
tests := []struct {
name string
db *dbMock
args args
res res
}{
{
"search with no params",
mockDB(t).
expectGetSearchRequestNoParams("TESTTABLE", 1, 1),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{},
},
res{
count: 1,
wantErr: false,
},
},
{
"search with limit",
mockDB(t).
expectGetSearchRequestWithLimit("TESTTABLE", 2, 2, 5),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{limit: 2},
},
res{
count: 5,
wantErr: false,
},
},
{
"search with offset",
mockDB(t).
expectGetSearchRequestWithOffset("TESTTABLE", 2, 2, 2),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{offset: 2},
},
res{
count: 2,
wantErr: false,
},
},
{
"search with sorting asc",
mockDB(t).
expectGetSearchRequestWithSorting("TESTTABLE", "ASC", TestSearchKey_ID, 2, 2),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{sortingColumn: TestSearchKey_ID, asc: true},
},
res{
count: 2,
wantErr: false,
},
},
{
"search with sorting asc",
mockDB(t).
expectGetSearchRequestWithSorting("TESTTABLE", "DESC", TestSearchKey_ID, 2, 2),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{sortingColumn: TestSearchKey_ID},
},
res{
count: 2,
wantErr: false,
},
},
{
"search with search query",
mockDB(t).
expectGetSearchRequestWithSearchQuery("TESTTABLE", TestSearchKey_ID.ToColumnName(), "=", "AggregateID", 2, 2),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{queries: []SearchQuery{TestSearchQuery{key: TestSearchKey_ID, method: domain.SearchMethodEqualsIgnoreCase, value: "AggregateID"}}},
},
res{
count: 2,
wantErr: false,
},
},
{
"search with all params",
mockDB(t).
expectGetSearchRequestWithAllParams("TESTTABLE", TestSearchKey_ID.ToColumnName(), "=", "AggregateID", "ASC", TestSearchKey_ID, 2, 2, 2, 5),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{limit: 2, offset: 2, sortingColumn: TestSearchKey_ID, asc: true, queries: []SearchQuery{TestSearchQuery{key: TestSearchKey_ID, method: domain.SearchMethodEqualsIgnoreCase, value: "AggregateID"}}},
},
res{
count: 5,
wantErr: false,
},
},
{
"search db error",
mockDB(t).
expectGetSearchRequestErr("TESTTABLE", 1, 1, gorm.ErrUnaddressable),
args{
table: "TESTTABLE",
searchRequest: TestSearchRequest{},
},
res{
count: 1,
wantErr: true,
errFunc: caos_errs.IsInternal,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
res := &Test{}
getQuery := PrepareSearchQuery(tt.args.table, tt.args.searchRequest)
count, err := getQuery(tt.db.db, res)
if !tt.res.wantErr && err != nil {
t.Errorf("got wrong err should be nil: %v ", err)
}
if !tt.res.wantErr && count != tt.res.count {
t.Errorf("got wrong count: %v ", err)
}
if tt.res.wantErr && !tt.res.errFunc(err) {
t.Errorf("got wrong err: %v ", err)
}
if err := tt.db.mock.ExpectationsWereMet(); !tt.res.wantErr && err != nil {
t.Errorf("there were unfulfilled expectations: %s", err)
}
tt.db.close()
})
}
} | explode_data.jsonl/64354 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1661
} | [
2830,
3393,
50590,
5890,
2859,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
26481,
260,
914,
198,
197,
45573,
1900,
7542,
1900,
198,
197,
532,
13158,
592,
2036,
341,
197,
18032,
256,
2622,
21,
19,
198,
197,
50780,
7747,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandshakeClientAES128CBCSHA256(t *testing.T) {
test := &clientTest{
name: "AES128-SHA256",
args: []string{"-cipher", "AES128-SHA256"},
}
runClientTestTLS12(t, test)
} | explode_data.jsonl/27697 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
2314,
29661,
2959,
69168,
16,
17,
23,
69972,
33145,
17,
20,
21,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
609,
2972,
2271,
515,
197,
11609,
25,
330,
69168,
16,
17,
23,
6222,
17020,
17,
20,
21,
756,
197,
31215,
25,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_normalHex(t *testing.T) {
tests := []struct {
in string
want string
}{
{},
{"abc", "abc"},
{"7E:12:49:9C:EC:EC:22:DE:53:78:71:79:BF:28:D4:51:2D:66:23:96", "7e12499cecec22de53787179bf28d4512d662396"},
{"7E12499CECEC22DE53787179BF28D4512D662396", "7e12499cecec22de53787179bf28d4512d662396"},
{"7e12499cecec22de53787179bf28d4512d662396", "7e12499cecec22de53787179bf28d4512d662396"},
}
for _, tt := range tests {
t.Run(tt.in, func(t *testing.T) {
if got := normalHex(tt.in); got != tt.want {
t.Errorf("normalHex() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/78643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
13973,
20335,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
17430,
256,
914,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
38837,
197,
197,
4913,
13683,
497,
330,
13683,
7115,
197,
197,
4913,
22,
36,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInsert(t *testing.T) {
settings := &Settings{Username: "Administrator", Password: "password", BucketName: "test", BucketPassword: "", Server: "http://localhost:8091"}
iCtx := test.NewActivityInitContext(settings, nil)
act, err := New(iCtx)
assert.Nil(t, err)
tc := test.NewActivityContext(act.Metadata())
tc.SetInput("key", 1234567889)
tc.SetInput("data", `{"name":"foo"}`)
tc.SetInput("method", `Insert`)
tc.SetInput("expiry", 0)
_, insertError := act.Eval(tc)
assert.Nil(t, insertError)
log.Println("TestInsert successful")
} | explode_data.jsonl/38802 | {
"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,
13780,
1155,
353,
8840,
836,
8,
341,
62930,
1669,
609,
6086,
90,
11115,
25,
330,
62376,
497,
12362,
25,
330,
3833,
497,
47768,
675,
25,
330,
1944,
497,
47768,
4876,
25,
7342,
8422,
25,
330,
1254,
1110,
8301,
25,
23,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNewEncryptionKey(t *testing.T) {
t.Parallel()
keyA := NewEncryptionKey()
keyB := NewEncryptionKey()
if keyA == keyB {
t.Fatalf("Key %s should not equal %s\n", keyA, keyB)
}
if len(keyA) != 32 {
t.Fatalf("Keys should be 32 bytes long, KeyA is %d bytes\n", len(keyA))
}
} | explode_data.jsonl/54121 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
3564,
79239,
1592,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
23634,
32,
1669,
1532,
79239,
1592,
741,
23634,
33,
1669,
1532,
79239,
1592,
2822,
743,
1376,
32,
621,
1376,
33,
341,
197,
3244,
30762,
445,
1592,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRemoveFlagElement(t *testing.T) {
defer initFlag(TestTx.Flags)
ctx := context.Background()
scope := NewReferenceScope(TestTx)
for _, v := range removeFlagElementTests {
initFlag(TestTx.Flags)
v.Init(TestTx.Flags)
err := RemoveFlagElement(ctx, scope, v.Expr)
if err != nil {
if len(v.Error) < 1 {
t.Errorf("%s: unexpected error %q", v.Name, err)
} else if err.Error() != v.Error {
t.Errorf("%s: error %q, want error %q", v.Name, err.Error(), v.Error)
}
continue
}
if 0 < len(v.Error) {
t.Errorf("%s: no error, want error %q", v.Name, v.Error)
continue
}
expect := v.Expect()
if !reflect.DeepEqual(TestTx.Flags, expect) {
t.Errorf("%s: result = %v, want %v", v.Name, TestTx.Flags, expect)
}
}
} | explode_data.jsonl/50844 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 330
} | [
2830,
3393,
13021,
12135,
1691,
1155,
353,
8840,
836,
8,
341,
16867,
2930,
12135,
31159,
31584,
51887,
692,
20985,
1669,
2266,
19047,
741,
66836,
1669,
1532,
8856,
10803,
31159,
31584,
692,
2023,
8358,
348,
1669,
2088,
4057,
12135,
1691,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSet_ContainsError(t *testing.T) {
t.Run("ok", func(t *testing.T) {
bag := NewValidateErrorBag()
errMsg := errors.New("error")
bag.SetError("test", "test summary", errMsg)
assert.True(t, bag.ContainsError("test", errMsg))
assert.False(t, bag.ContainsError("not in", errMsg))
})
} | explode_data.jsonl/9300 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
1649,
62,
23805,
1454,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
562,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
2233,
351,
1669,
1532,
17926,
1454,
12933,
741,
197,
9859,
6611,
1669,
5975,
7121,
445,
841,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMetricDescriptor_Type(t *testing.T) {
ms := NewMetricDescriptor()
ms.InitEmpty()
assert.EqualValues(t, MetricTypeUnspecified, ms.Type())
testValType := MetricTypeGaugeInt64
ms.SetType(testValType)
assert.EqualValues(t, testValType, ms.Type())
} | explode_data.jsonl/19521 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
54310,
11709,
13729,
1155,
353,
8840,
836,
8,
341,
47691,
1669,
1532,
54310,
11709,
741,
47691,
26849,
3522,
741,
6948,
12808,
6227,
1155,
11,
52458,
929,
1806,
53434,
11,
9829,
10184,
2398,
18185,
2208,
929,
1669,
52458,
929,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUPNP_DDWRT(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skipf("disabled to avoid firewall prompt")
}
dev := &fakeIGD{
t: t,
ssdpResp: "HTTP/1.1 200 OK\r\n" +
"Cache-Control: max-age=300\r\n" +
"Date: Sun, 10 May 2015 10:05:33 GMT\r\n" +
"Ext: \r\n" +
"Location: http://{{listenAddr}}/InternetGatewayDevice.xml\r\n" +
"Server: POSIX UPnP/1.0 DD-WRT Linux/V24\r\n" +
"ST: urn:schemas-upnp-org:device:WANConnectionDevice:1\r\n" +
"USN: uuid:CB2471CC-CF2E-9795-8D9C-E87B34C16800::urn:schemas-upnp-org:device:WANConnectionDevice:1\r\n" +
"\r\n",
httpResps: map[string]string{
"GET /InternetGatewayDevice.xml": `
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<friendlyName>Asus RT-N16:DD-WRT</friendlyName>
<modelName>Asus RT-N16</modelName>
<modelNumber>V24</modelNumber>
<serialNumber>0000001</serialNumber>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:A13AB4C3-3A14-E386-DE6A-EFEA923A06FE</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
<SCPDURL>/x_layer3forwarding.xml</SCPDURL>
<controlURL>/control?Layer3Forwarding</controlURL>
<eventSubURL>/event?Layer3Forwarding</eventSubURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
<friendlyName>WANDevice</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:48FD569B-F9A9-96AE-4EE6-EB403D3DB91A</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
<SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
<controlURL>/control?WANCommonInterfaceConfig</controlURL>
<eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
<friendlyName>WAN Connection Device</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:CB2471CC-CF2E-9795-8D9C-E87B34C16800</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
<SCPDURL>/x_wanipconnection.xml</SCPDURL>
<controlURL>/control?WANIPConnection</controlURL>
<eventSubURL>/event?WANIPConnection</eventSubURL>
</service>
</serviceList>
</device>
</deviceList>
</device>
<device>
<deviceType>urn:schemas-upnp-org:device:LANDevice:1</deviceType>
<friendlyName>LANDevice</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:04021998-3B35-2BDB-7B3C-99DA4435DA09</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:LANHostConfigManagement:1</serviceType>
<serviceId>urn:upnp-org:serviceId:LANHostCfg1</serviceId>
<SCPDURL>/x_lanhostconfigmanagement.xml</SCPDURL>
<controlURL>/control?LANHostConfigManagement</controlURL>
<eventSubURL>/event?LANHostConfigManagement</eventSubURL>
</service>
</serviceList>
</device>
</deviceList>
<presentationURL>http://{{listenAddr}}</presentationURL>
</device>
</root>
`,
// The response to our GetNATRSIPStatus call. This
// particular implementation has a bug where the elements
// inside u:GetNATRSIPStatusResponse are not properly
// namespaced.
"POST /control?WANIPConnection": `
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetNATRSIPStatusResponse xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRSIPAvailable>0</NewRSIPAvailable>
<NewNATEnabled>1</NewNATEnabled>
</u:GetNATRSIPStatusResponse>
</s:Body>
</s:Envelope>
`,
},
}
if err := dev.listen(); err != nil {
t.Skipf("cannot listen: %v", err)
}
dev.serve()
defer dev.close()
// Attempt to discover the fake device.
discovered := discoverUPnP()
if discovered == nil {
t.Fatalf("not discovered")
}
upnp, _ := discovered.(*upnp)
if upnp.service != "IGDv1-IP1" {
t.Errorf("upnp.service mismatch: got %q, want %q", upnp.service, "IGDv1-IP1")
}
wantURL := "http://" + dev.listener.Addr().String() + "/InternetGatewayDevice.xml"
if upnp.dev.URLBaseStr != wantURL {
t.Errorf("upnp.dev.URLBaseStr mismatch: got %q, want %q", upnp.dev.URLBaseStr, wantURL)
}
} | explode_data.jsonl/70749 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2848
} | [
2830,
3393,
3124,
26227,
1557,
54219,
5350,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
69,
445,
11978,
311,
5648,
49877,
9934,
1138,
197,
630,
27302,
1669,
609,
30570,
1914,
35,
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... | 6 |
func TestBackendSvcDesc_String(t *testing.T) {
testCases := map[string]struct {
wantedHumanString string
wantedJSONString string
}{
"correct output": {
wantedHumanString: `About
Application my-app
Name my-svc
Type Backend Service
Configurations
Environment Tasks CPU (vCPU) Memory (MiB) Port
----------- ----- ---------- ------------ ----
test 1 0.25 512 80
prod 3 0.5 1024 5000
Service Discovery
Environment Namespace
----------- ---------
test http://my-svc.test.my-app.local:5000
prod http://my-svc.prod.my-app.local:5000
Variables
Name Container Environment Value
---- --------- ----------- -----
COPILOT_ENVIRONMENT_NAME container prod prod
" " test test
Secrets
Name Container Environment Value From
---- --------- ----------- ----------
GITHUB_WEBHOOK_SECRET container test parameter/GH_WEBHOOK_SECRET
SOME_OTHER_SECRET " prod parameter/SHHHHH
Resources
test
AWS::EC2::SecurityGroup sg-0758ed6b233743530
prod
AWS::EC2::SecurityGroupIngress ContainerSecurityGroupIngressFromPublicALB
`,
wantedJSONString: "{\"service\":\"my-svc\",\"type\":\"Backend Service\",\"application\":\"my-app\",\"configurations\":[{\"environment\":\"test\",\"port\":\"80\",\"cpu\":\"256\",\"memory\":\"512\",\"tasks\":\"1\"},{\"environment\":\"prod\",\"port\":\"5000\",\"cpu\":\"512\",\"memory\":\"1024\",\"tasks\":\"3\"}],\"serviceDiscovery\":[{\"environment\":[\"test\"],\"namespace\":\"http://my-svc.test.my-app.local:5000\"},{\"environment\":[\"prod\"],\"namespace\":\"http://my-svc.prod.my-app.local:5000\"}],\"variables\":[{\"environment\":\"prod\",\"name\":\"COPILOT_ENVIRONMENT_NAME\",\"value\":\"prod\",\"container\":\"container\"},{\"environment\":\"test\",\"name\":\"COPILOT_ENVIRONMENT_NAME\",\"value\":\"test\",\"container\":\"container\"}],\"secrets\":[{\"name\":\"GITHUB_WEBHOOK_SECRET\",\"container\":\"container\",\"environment\":\"test\",\"valueFrom\":\"GH_WEBHOOK_SECRET\"},{\"name\":\"SOME_OTHER_SECRET\",\"container\":\"container\",\"environment\":\"prod\",\"valueFrom\":\"SHHHHH\"}],\"resources\":{\"prod\":[{\"type\":\"AWS::EC2::SecurityGroupIngress\",\"physicalID\":\"ContainerSecurityGroupIngressFromPublicALB\"}],\"test\":[{\"type\":\"AWS::EC2::SecurityGroup\",\"physicalID\":\"sg-0758ed6b233743530\"}]}}\n",
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
config := []*ECSServiceConfig{
{
ServiceConfig: &ServiceConfig{
CPU: "256",
Environment: "test",
Memory: "512",
Port: "80",
},
Tasks: "1",
},
{
ServiceConfig: &ServiceConfig{
CPU: "512",
Environment: "prod",
Memory: "1024",
Port: "5000",
},
Tasks: "3",
},
}
envVars := []*containerEnvVar{
{
envVar: &envVar{
Environment: "prod",
Name: "COPILOT_ENVIRONMENT_NAME",
Value: "prod",
},
Container: "container",
},
{
envVar: &envVar{
Environment: "test",
Name: "COPILOT_ENVIRONMENT_NAME",
Value: "test",
},
Container: "container",
},
}
secrets := []*secret{
{
Name: "GITHUB_WEBHOOK_SECRET",
Container: "container",
Environment: "test",
ValueFrom: "GH_WEBHOOK_SECRET",
},
{
Name: "SOME_OTHER_SECRET",
Container: "container",
Environment: "prod",
ValueFrom: "SHHHHH",
},
}
sds := []*ServiceDiscovery{
{
Environment: []string{"test"},
Namespace: "http://my-svc.test.my-app.local:5000",
},
{
Environment: []string{"prod"},
Namespace: "http://my-svc.prod.my-app.local:5000",
},
}
resources := map[string][]*stack.Resource{
"test": {
{
PhysicalID: "sg-0758ed6b233743530",
Type: "AWS::EC2::SecurityGroup",
},
},
"prod": {
{
Type: "AWS::EC2::SecurityGroupIngress",
PhysicalID: "ContainerSecurityGroupIngressFromPublicALB",
},
},
}
backendSvc := &backendSvcDesc{
Service: "my-svc",
Type: "Backend Service",
Configurations: config,
App: "my-app",
Variables: envVars,
Secrets: secrets,
ServiceDiscovery: sds,
Resources: resources,
environments: []string{"test", "prod"},
}
human := backendSvc.HumanString()
json, _ := backendSvc.JSONString()
require.Equal(t, tc.wantedHumanString, human)
require.Equal(t, tc.wantedJSONString, json)
})
}
} | explode_data.jsonl/78107 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2598
} | [
2830,
3393,
29699,
92766,
11065,
31777,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
6692,
7566,
33975,
703,
914,
198,
197,
6692,
7566,
5370,
703,
220,
914,
198,
197,
59403,
197,
197,
1,
19928,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCMakeNoComments(t *testing.T) {
reader := strings.NewReader("install(TARGETS main.x DESTINATION appcelerator/ingot)")
result, err := dialect.Examine("CMake", "foo.cmake", reader, nil)
if err != nil {
t.Fatal(err)
}
if result == nil {
t.Fatal("result was nil")
}
if result.Loc != 1 {
t.Fatalf("result.Loc should have been 1, was %d", result.Loc)
}
if result.Sloc != 1 {
t.Fatalf("result.Sloc should have been 1, was %d", result.Sloc)
}
if result.Comments != 0 {
t.Fatalf("result.Comments should have been 0, was %d", result.Comments)
}
if result.Blanks != 0 {
t.Fatalf("result.Blanks should have been 0, was %d", result.Blanks)
}
} | explode_data.jsonl/74596 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 261
} | [
2830,
3393,
34,
8078,
2753,
17373,
1155,
353,
8840,
836,
8,
341,
61477,
1669,
9069,
68587,
445,
12248,
4140,
16474,
50,
1887,
1993,
71990,
51860,
906,
3672,
39522,
14,
287,
354,
19107,
9559,
11,
1848,
1669,
42279,
5121,
19991,
445,
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... | 7 |
func TestDeltaValues(t *testing.T) {
deltaValues(nil)
values := []float64{123}
deltaValues(values)
valuesExpected := []float64{0}
testRowsEqual(t, values, testTimestamps[:1], valuesExpected, testTimestamps[:1])
values = append([]float64{}, testValues...)
deltaValues(values)
valuesExpected = []float64{-89, 10, -23, 33, -20, 65, -87, 32, -12, 2, 0, 0}
testRowsEqual(t, values, testTimestamps, valuesExpected, testTimestamps)
// remove counter resets
values = append([]float64{}, testValues...)
removeCounterResets(values)
deltaValues(values)
valuesExpected = []float64{34, 10, 21, 33, 34, 65, 12, 32, 32, 2, 0, 0}
testRowsEqual(t, values, testTimestamps, valuesExpected, testTimestamps)
} | explode_data.jsonl/23112 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 269
} | [
2830,
3393,
20277,
6227,
1155,
353,
8840,
836,
8,
341,
85435,
6227,
27907,
692,
45939,
1669,
3056,
3649,
21,
19,
90,
16,
17,
18,
532,
85435,
6227,
20103,
340,
45939,
18896,
1669,
3056,
3649,
21,
19,
90,
15,
532,
18185,
9024,
2993,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterAddCrossProtocol(t *testing.T) {
data := []byte{0x01, 0x02}
msg := wire.NewMsgFilterAdd(data)
if !bytes.Equal(msg.Data, data) {
t.Errorf("should get same data back out")
}
// Encode with latest protocol version.
var buf bytes.Buffer
err := msg.BtcEncode(&buf, wire.ProtocolVersion)
if err != nil {
t.Errorf("encode of MsgFilterAdd failed %v err <%v>", msg, err)
}
// Decode with old protocol version.
var readmsg wire.MsgFilterAdd
err = readmsg.BtcDecode(&buf, wire.BIP0031Version)
if err == nil {
t.Errorf("decode of MsgFilterAdd succeeded when it shouldn't "+
"have %v", msg)
}
// Since one of the protocol versions doesn't support the filteradd
// message, make sure the data didn't get encoded and decoded back out.
if bytes.Equal(msg.Data, readmsg.Data) {
t.Error("should not get same data for cross protocol")
}
} | explode_data.jsonl/14208 | {
"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,
5632,
2212,
28501,
20689,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
90,
15,
87,
15,
16,
11,
220,
15,
87,
15,
17,
532,
21169,
1669,
9067,
7121,
6611,
5632,
2212,
2592,
340,
743,
753,
9651,
12808,
8119,
3336,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVppArpTerminationTableEntryError(t *testing.T) {
ctx, bdHandler, _ := bdTestSetup(t)
defer ctx.TeardownTestCtx()
ctx.MockVpp.MockReply(&l2ba.BdIPMacAddDelReply{
Retval: 1,
})
err := bdHandler.AddArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "192.168.4.4")
Expect(err).Should(HaveOccurred())
ctx.MockVpp.MockReply(&l2ba.BridgeDomainAddDelReply{})
err = bdHandler.RemoveArpTerminationTableEntry(4, "FF:FF:FF:FF:FF:FF", "192.168.4.4")
Expect(err).Should(HaveOccurred())
} | explode_data.jsonl/39719 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 218
} | [
2830,
3393,
53,
602,
6953,
79,
21209,
32096,
2556,
5874,
1454,
1155,
353,
8840,
836,
8,
341,
20985,
11,
21486,
3050,
11,
716,
1669,
21486,
2271,
21821,
1155,
340,
16867,
5635,
94849,
37496,
2271,
23684,
2822,
20985,
24664,
53,
602,
2466... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewServer(t *testing.T) {
testCases := []struct {
cfg *Config
headers map[string]string
method string
expectedCode int
}{
{
cfg: &Config{},
headers: map[string]string{
"Access-Control-Request-Headers": "something",
"Access-Control-Request-Method": "something",
"Authorization": "Bearer token",
"Origin": "localhost",
},
method: http.MethodOptions,
expectedCode: http.StatusMethodNotAllowed,
},
{
cfg: &Config{},
headers: map[string]string{
"Authorization": "Bearer token",
"Origin": "localhost",
},
method: http.MethodOptions,
expectedCode: http.StatusBadRequest,
},
{
cfg: &Config{},
headers: map[string]string{
"Access-Control-Request-Headers": "something",
"Authorization": "Bearer token",
},
method: http.MethodDelete,
expectedCode: http.StatusOK,
},
}
for _, testCase := range testCases {
router := mux.NewRouter()
router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
})
server := NewServer(router, testCase.cfg)
rec := httptest.NewRecorder()
req, err := http.NewRequest(testCase.method, "/", nil)
if err != nil {
t.Errorf("create request %v", err)
}
for k, v := range testCase.headers {
req.Header.Set(k, v)
}
// Allow localhost as an origin
origins := handlers.AllowedOrigins([]string{"*"})
server.server.Handler = handlers.CORS(origins)(server.server.Handler)
server.server.Handler.ServeHTTP(rec, req)
if rec.Code != testCase.expectedCode {
t.Errorf("unexpected response code expected %d actual %d",
testCase.expectedCode, rec.Code)
}
}
} | explode_data.jsonl/1924 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 746
} | [
2830,
3393,
3564,
5475,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
50286,
688,
353,
2648,
198,
197,
67378,
414,
2415,
14032,
30953,
198,
197,
42257,
981,
914,
198,
197,
42400,
2078,
526,
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... | 1 |
func TestJobsController_Show_InvalidID(t *testing.T) {
client, cleanup, _, _, _, _ := setupJobSpecsControllerTestsWithJobs(t)
defer cleanup()
response, cleanup := client.Get("/v2/jobs/uuidLikeString")
defer cleanup()
cltest.AssertServerResponse(t, response, http.StatusUnprocessableEntity)
} | explode_data.jsonl/1627 | {
"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,
40667,
2051,
79665,
62,
7928,
915,
1155,
353,
8840,
836,
8,
341,
25291,
11,
21290,
11,
8358,
8358,
8358,
716,
1669,
6505,
12245,
8327,
82,
2051,
2271,
16056,
40667,
1155,
340,
16867,
21290,
2822,
21735,
11,
21290,
1669,
2943... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFiles_Subtitles(t *testing.T) {
setup()
defer teardown()
fixture := `
{
"default": "key0",
"status": "OK",
"subtitles": [
{
"key": "key0",
"language": "Turkish",
"language_code": "tur",
"name": "Big Buck Bunny",
"source": "opensubtitles"
},
{
"key": "key1",
"language": "English",
"language_code": "eng",
"name": "Big Buck Bunny",
"source": "opensubtitles"
}
]
}
`
mux.HandleFunc("/v2/files/1/subtitles", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintln(w, fixture)
})
ctx := context.Background()
subtitles, err := client.Files.Subtitles(ctx, 1)
if err != nil {
t.Error(err)
}
if len(subtitles) != 2 {
t.Errorf("got: %v, want: %v", len(subtitles), 2)
}
if subtitles[0].Key != "key0" {
t.Errorf("got: %v, want: %v", subtitles[0].Key, "key0")
}
// negative id
_, err = client.Files.Subtitles(ctx, -1)
if err == nil {
t.Errorf("negative file ID accepted")
}
} | explode_data.jsonl/48328 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 446
} | [
2830,
3393,
10809,
36359,
34523,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
1166,
12735,
1669,
22074,
515,
197,
86191,
788,
330,
792,
15,
756,
197,
1,
2829,
788,
330,
3925,
756,
197,
1,
1966,
34523,
788,
2278,
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 TestTideQuery(t *testing.T) {
q := " " + testQuery.Query() + " "
checkTok := func(tok string) {
if !strings.Contains(q, " "+tok+" ") {
t.Errorf("Expected query to contain \"%s\", got \"%s\"", tok, q)
}
}
checkTok("is:pr")
checkTok("state:open")
checkTok("archived:false")
checkTok("org:\"org\"")
checkTok("repo:\"k/k\"")
checkTok("repo:\"k/t-i\"")
checkTok("label:\"lgtm\"")
checkTok("label:\"approved\"")
checkTok("-label:\"foo\"")
checkTok("author:\"batman\"")
checkTok("milestone:\"milestone\"")
checkTok("review:approved")
} | explode_data.jsonl/53853 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
51,
577,
2859,
1155,
353,
8840,
836,
8,
341,
18534,
1669,
330,
330,
488,
1273,
2859,
15685,
368,
488,
330,
6228,
25157,
52854,
1669,
2915,
66853,
914,
8,
341,
197,
743,
753,
18594,
11545,
10583,
11,
330,
6630,
29594,
5172,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUrootCmdline(t *testing.T) {
samplef, err := ioutil.TempFile("", "u-root-sample-")
if err != nil {
t.Fatal(err)
}
samplef.Close()
defer os.RemoveAll(samplef.Name())
for _, tt := range []struct {
name string
env []string
args []string
err error
validators []itest.ArchiveValidator
}{
{
name: "include one extra file",
args: []string{"-nocmd", "-files=/bin/bash"},
err: nil,
validators: []itest.ArchiveValidator{
itest.HasFile{"bin/bash"},
},
},
{
name: "uinitcmd",
args: []string{"-build=bb", "-uinitcmd=echo foobar fuzz", "-defaultsh=", "./cmds/core/init", "./cmds/core/echo"},
err: nil,
validators: []itest.ArchiveValidator{
itest.HasRecord{cpio.Symlink("bin/uinit", "../bbin/echo")},
itest.HasContent{
Path: "etc/uinit.flags",
Content: "\"foobar\"\n\"fuzz\"",
},
},
},
{
name: "fix usage of an absolute path",
args: []string{"-nocmd", "-files=/bin:/bin"},
err: nil,
validators: []itest.ArchiveValidator{
itest.HasFile{"bin/bash"},
},
},
{
name: "include multiple extra files",
args: []string{"-nocmd", "-files=/bin/bash", "-files=/bin/ls", fmt.Sprintf("-files=%s", samplef.Name())},
validators: []itest.ArchiveValidator{
itest.HasFile{"bin/bash"},
itest.HasFile{"bin/ls"},
itest.HasFile{samplef.Name()},
},
},
{
name: "include one extra file with rename",
args: []string{"-nocmd", "-files=/bin/bash:bin/bush"},
validators: []itest.ArchiveValidator{
itest.HasFile{"bin/bush"},
},
},
{
name: "hosted source mode",
args: append([]string{"-build=source", "-base=/dev/null", "-defaultsh=", "-initcmd="}, srcmds...),
},
{
name: "hosted bb mode",
args: append([]string{"-build=bb", "-base=/dev/null", "-defaultsh=", "-initcmd="}, twocmds...),
},
{
name: "AMD64 bb build",
env: []string{"GOARCH=amd64"},
args: []string{"-build=bb", "all"},
},
{
name: "AMD64 source build",
env: []string{"GOARCH=amd64"},
args: []string{"-build=source", "all"},
validators: []itest.ArchiveValidator{
buildSourceValidator{
goroot: "/go",
gopath: ".",
env: []string{"GOARCH=amd64"},
},
},
},
{
name: "MIPS bb build",
env: []string{"GOARCH=mips"},
args: []string{"-build=bb", "all"},
},
{
name: "MIPSLE bb build",
env: []string{"GOARCH=mipsle"},
args: []string{"-build=bb", "all"},
},
{
name: "MIPS64 bb build",
env: []string{"GOARCH=mips64"},
args: []string{"-build=bb", "all"},
},
{
name: "MIPS64LE bb build",
env: []string{"GOARCH=mips64le"},
args: []string{"-build=bb", "all"},
},
{
name: "ARM7 bb build",
env: []string{"GOARCH=arm", "GOARM=7"},
args: []string{"-build=bb", "all"},
},
{
name: "ARM64 bb build",
env: []string{"GOARCH=arm64"},
args: []string{"-build=bb", "all"},
},
{
name: "386 (32 bit) bb build",
env: []string{"GOARCH=386"},
args: []string{"-build=bb", "all"},
},
{
name: "Power 64bit bb build",
env: []string{"GOARCH=ppc64le"},
args: []string{"-build=bb", "all"},
},
} {
t.Run(tt.name, func(t *testing.T) {
delFiles := true
f, sum1 := buildIt(t, tt.args, tt.env, tt.err)
defer func() {
if delFiles {
os.RemoveAll(f.Name())
}
}()
a, err := itest.ReadArchive(f.Name())
if err != nil {
t.Fatal(err)
}
for _, v := range tt.validators {
if err := v.Validate(a); err != nil {
t.Errorf("validator failed: %v / archive:\n%s", err, a)
}
}
f2, sum2 := buildIt(t, tt.args, tt.env, tt.err)
defer func() {
if delFiles {
os.RemoveAll(f2.Name())
}
}()
if !bytes.Equal(sum1, sum2) {
delFiles = false
t.Errorf("not reproducible, hashes don't match")
t.Errorf("env: %v args: %v", tt.env, tt.args)
t.Errorf("file1: %v file2: %v", f.Name(), f2.Name())
}
})
}
} | explode_data.jsonl/26064 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1902
} | [
2830,
3393,
52,
2888,
15613,
1056,
1155,
353,
8840,
836,
8,
341,
1903,
1516,
69,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
84,
39214,
83879,
12,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
1903,
1516,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTxnRetryErrMsg(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk1 := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk1.MustExec("use test")
tk1.MustExec("create table no_retry (id int)")
tk1.MustExec("insert into no_retry values (1)")
tk1.MustExec("begin")
tk2.MustExec("use test")
tk2.MustExec("update no_retry set id = id + 1")
tk1.MustExec("update no_retry set id = id + 1")
require.NoError(t, failpoint.Enable("tikvclient/mockRetryableErrorResp", `return(true)`))
_, err := tk1.Session().Execute(context.Background(), "commit")
require.NoError(t, failpoint.Disable("tikvclient/mockRetryableErrorResp"))
require.Error(t, err)
require.True(t, kv.ErrTxnRetryable.Equal(err), "error: %s", err)
require.True(t, strings.Contains(err.Error(), "mock retryable error"), "error: %s", err)
require.True(t, strings.Contains(err.Error(), kv.TxnRetryableMark), "error: %s", err)
} | explode_data.jsonl/5739 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 381
} | [
2830,
3393,
31584,
77,
51560,
75449,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
741,
3244,
74,
16,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnmarshalAssociativeArray(t *testing.T) {
tests := map[string]struct {
input []byte
output map[interface{}]interface{}
expectedError error
}{
"map[interface{}]interface{}: {'foo': 10, 'bar': 20}": {
[]byte("a:2:{s:3:\"bar\";i:20;s:3:\"foo\";i:10;}"),
map[interface{}]interface{}{"foo": int64(10), "bar": int64(20)},
nil,
},
"map[interface{}]interface{}: {1: 10, 2: 'foo'}": {
[]byte("a:2:{i:1;i:10;i:2;s:3:\"foo\";}"),
map[interface{}]interface{}{int64(1): int64(10), int64(2): "foo"},
nil,
},
"map[interface{}]interface{}: {'foo': 10, 'bar': 20, 'foobar': {'foo': 10, 'bar': 20}}": {
[]byte(`a:3:{s:3:"foo";i:10;s:3:"bar";i:20;s:6:"foobar";a:2:{s:3:"foo";i:10;s:3:"bar";i:20;}}`),
map[interface{}]interface{}{"foo": int64(10), "bar": int64(20), "foobar": map[interface{}]interface{}{"foo": int64(10), "bar": int64(20)}},
nil,
},
"map[interface{}]interface{}: {'foo': 10, 'bar': 20, 'foobar': {'foo': 10, 'bar': 20}, 'foobar1': {'foo': 10, 'bar': 20}}": {
[]byte(`a:4:{s:3:"foo";i:10;s:3:"bar";i:20;s:6:"foobar";a:2:{s:3:"foo";i:10;s:3:"bar";i:20;}s:7:"foobar1";a:2:{s:3:"foo";i:10;s:3:"bar";i:20;}}`),
map[interface{}]interface{}{"foo": int64(10), "bar": int64(20), "foobar": map[interface{}]interface{}{"foo": int64(10), "bar": int64(20)}, "foobar1": map[interface{}]interface{}{"foo": int64(10), "bar": int64(20)}},
nil,
},
"not an array": {
[]byte("N;"),
map[interface{}]interface{}{},
errors.New("not an array"),
},
}
for testName, test := range tests {
t.Run(testName, func(t *testing.T) {
result := make(map[interface{}]interface{})
err := phpserialize.Unmarshal(test.input, &result)
if test.expectedError == nil {
expectErrorToNotHaveOccurred(t, err)
if !reflect.DeepEqual(result, test.output) {
t.Errorf("Expected %v, got %v", result, test.output)
}
} else {
expectErrorToEqual(t, err, test.expectedError)
}
})
}
} | explode_data.jsonl/27022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 949
} | [
2830,
3393,
1806,
27121,
29815,
1388,
1857,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
22427,
260,
3056,
3782,
198,
197,
21170,
286,
2415,
58,
4970,
78134,
4970,
16094,
197,
42400,
1454,
1465,
198,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPodMatchesEvent(t *testing.T) {
tests := []struct {
name string
podInfo *framework.QueuedPodInfo
event framework.ClusterEvent
clusterEventMap map[framework.ClusterEvent]sets.String
want bool
}{
{
name: "event not registered",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}),
event: EmptyEvent,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("foo"),
},
want: false,
},
{
name: "pod's failed plugin matches but event does not match",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "bar"),
event: AssignedPodAdd,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("foo", "bar"),
},
want: false,
},
{
name: "wildcard event wins regardless of event matching",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "bar"),
event: WildCardEvent,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("foo"),
},
want: true,
},
{
name: "pod's failed plugin and event both match",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "bar"),
event: NodeTaintChange,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("foo", "bar"),
},
want: true,
},
{
name: "pod's failed plugin registers fine-grained event",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "bar"),
event: NodeTaintChange,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("foo"),
NodeTaintChange: sets.NewString("bar"),
},
want: true,
},
{
name: "if pod failed by multiple plugins, a single match gets a final match",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "foo", "bar"),
event: NodeAdd,
clusterEventMap: map[framework.ClusterEvent]sets.String{
NodeAllEvent: sets.NewString("bar"),
},
want: true,
},
{
name: "plugin returns WildCardEvent and plugin name matches",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "foo"),
event: PvAdd,
clusterEventMap: map[framework.ClusterEvent]sets.String{
WildCardEvent: sets.NewString("foo"),
},
want: true,
},
{
name: "plugin returns WildCardEvent but plugin name not match",
podInfo: newQueuedPodInfoForLookup(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "p"}}, "foo"),
event: PvAdd,
clusterEventMap: map[framework.ClusterEvent]sets.String{
WildCardEvent: sets.NewString("bar"),
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
q := NewTestQueue(context.Background(), newDefaultQueueSort())
q.clusterEventMap = tt.clusterEventMap
if got := q.podMatchesEvent(tt.podInfo, tt.event); got != tt.want {
t.Errorf("Want %v, but got %v", tt.want, got)
}
})
}
} | explode_data.jsonl/68207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1321
} | [
2830,
3393,
23527,
42470,
1556,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
310,
914,
198,
197,
3223,
347,
1731,
260,
353,
3794,
10003,
361,
3260,
23527,
1731,
198,
197,
28302,
1843,
12626,
72883,
1556,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestFilterByReplicationLagOneTabletMin(t *testing.T) {
// Use at least 1 tablets if possible
testSetMinNumTablets(1)
// lags of (1s, 100m) - return only healthy tablet if that is all that is available.
ts1 := &TabletStats{
Tablet: topo.NewTablet(1, "cell", "host1"),
Serving: true,
Stats: &querypb.RealtimeStats{SecondsBehindMaster: 1},
}
ts2 := &TabletStats{
Tablet: topo.NewTablet(2, "cell", "host2"),
Serving: true,
Stats: &querypb.RealtimeStats{SecondsBehindMaster: 100 * 60},
}
got := FilterByReplicationLag([]*TabletStats{ts1, ts2})
if len(got) != 1 || !got[0].DeepEqual(ts1) {
t.Errorf("FilterByReplicationLag([1s, 100m]) = %+v, want [1s]", got)
}
// lags of (1m, 100m) - return only healthy tablet if that is all that is healthy enough.
ts1 = &TabletStats{
Tablet: topo.NewTablet(1, "cell", "host1"),
Serving: true,
Stats: &querypb.RealtimeStats{SecondsBehindMaster: 1 * 60},
}
ts2 = &TabletStats{
Tablet: topo.NewTablet(2, "cell", "host2"),
Serving: true,
Stats: &querypb.RealtimeStats{SecondsBehindMaster: 100 * 60},
}
got = FilterByReplicationLag([]*TabletStats{ts1, ts2})
if len(got) != 1 || !got[0].DeepEqual(ts1) {
t.Errorf("FilterByReplicationLag([1m, 100m]) = %+v, want [1m]", got)
}
// Reset to the default
testSetMinNumTablets(2)
} | explode_data.jsonl/263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 550
} | [
2830,
3393,
5632,
1359,
18327,
1693,
43,
351,
3966,
2556,
83,
6217,
1155,
353,
8840,
836,
8,
341,
197,
322,
5443,
518,
3245,
220,
16,
28579,
421,
3204,
198,
18185,
1649,
6217,
4651,
2556,
2576,
7,
16,
340,
197,
322,
326,
2032,
315,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestHandlePacket(t *testing.T) {
pullAckData := []byte{2, 235, 169, 4}
err := HandlePacket(pullAckData)
if err != nil {
t.Fatal("Something,went,wrong,while,handling,packet")
}
pushAckData := []byte{2, 165, 210, 1}
err = HandlePacket(pushAckData)
if err != nil {
t.Fatal("Something,went,wrong,while,handling,packet")
}
pullRespData := []byte{2, 0, 0, 3, 123, 34, 116, 120, 112, 107, 34, 58, 123, 34, 105, 109, 109, 101, 34, 58, 102, 97, 108, 115, 101, 44, 34, 116, 109, 115, 116, 34, 58, 49, 49, 50, 51, 52, 53, 54, 44, 34, 102, 114, 101, 113, 34, 58, 56, 54, 54, 46, 51, 52, 57, 56, 49, 50, 44, 34, 114, 102, 99, 104, 34, 58, 48, 44, 34, 112, 111, 119, 101, 34, 58, 49, 52, 44, 34, 109, 111, 100, 117, 34, 58, 34, 76, 79, 82, 65, 34, 44, 34, 100, 97, 116, 114, 34, 58, 34, 83, 70, 55, 66, 87, 49, 50, 53, 34, 44, 34, 99, 111, 100, 114, 34, 58, 34, 52, 47, 54, 34, 44, 34, 105, 112, 111, 108, 34, 58, 116, 114, 117, 101, 44, 34, 115, 105, 122, 101, 34, 58, 49, 50, 44, 34, 100, 97, 116, 97, 34, 58, 34, 89, 76, 72, 107, 89, 86, 48, 103, 65, 65, 67, 100, 103, 55, 118, 122, 34, 125, 125}
err = HandlePacket(pullRespData)
if err != nil {
t.Fatal("Something,went,wrong,while,handling,packet")
}
pullAckData = []byte{0, 0, 0, 4}
err = HandlePacket(pullAckData)
if err == nil {
t.Fatal("An error should have been thrown for non-valid data array")
}
pushAckData = []byte{0, 0, 0, 1}
err = HandlePacket(pushAckData)
if err == nil {
t.Fatal("An error should have been thrown for non-valid data array")
}
pullRespData = []byte{2, 0, 0, 3, 123}
err = HandlePacket(pullRespData)
if err == nil {
t.Fatal("An error should have been thrown for non-valid data array")
}
} | explode_data.jsonl/39069 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
6999,
16679,
1155,
353,
8840,
836,
8,
341,
3223,
617,
55559,
1043,
1669,
3056,
3782,
90,
17,
11,
220,
17,
18,
20,
11,
220,
16,
21,
24,
11,
220,
19,
630,
9859,
1669,
13760,
16679,
1295,
617,
55559,
1043,
692,
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... | 7 |
func TestSqlite3_SQLType(t *testing.T) {
a := assert.New(t, false)
var data = []*sqlTypeTester{
{ // col == nil
err: true,
},
{ // col.PrimitiveType == nil
col: &core.Column{PrimitiveType: core.Auto},
err: true,
},
{
col: &core.Column{PrimitiveType: core.Int},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Bool},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Bool},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Bytes},
SQLType: "BLOB NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Int64},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Float64},
SQLType: "REAL NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.String},
SQLType: "TEXT NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Decimal},
SQLType: "NUMERIC NOT NULL",
},
{
col: &core.Column{
PrimitiveType: core.String,
Nullable: true,
},
SQLType: "TEXT",
},
{
col: &core.Column{
PrimitiveType: core.String,
Default: "123",
},
SQLType: "TEXT NOT NULL",
},
{
col: &core.Column{
PrimitiveType: core.String,
Default: "123",
HasDefault: true,
},
SQLType: "TEXT NOT NULL DEFAULT '123'",
},
{
col: &core.Column{
PrimitiveType: core.Int,
Length: []int{5, 6},
},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{
PrimitiveType: core.Int,
AI: true,
},
SQLType: "INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.String},
SQLType: "TEXT NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Float64},
SQLType: "REAL NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Int64},
SQLType: "INTEGER NOT NULL",
},
{
col: &core.Column{PrimitiveType: core.Time},
SQLType: "TIMESTAMP NOT NULL",
},
}
testSQLType(a, dialect.Sqlite3("sqlite3_driver", ""), data)
} | explode_data.jsonl/11880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1037
} | [
2830,
3393,
8269,
632,
18,
46625,
929,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
2060,
7121,
1155,
11,
895,
692,
2405,
821,
284,
29838,
3544,
929,
58699,
515,
197,
197,
90,
442,
1375,
621,
2092,
198,
298,
9859,
25,
830,
345,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHook_Error(t *testing.T) {
hook := NewHook(nil, nil)
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
hook.Err(errors.New("test"))
if strings.Count(hook.Error().Error(), "test") != 5 {
t.Error("get error err")
}
} | explode_data.jsonl/40946 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
31679,
28651,
1155,
353,
8840,
836,
8,
341,
9598,
1941,
1669,
1532,
31679,
27907,
11,
2092,
340,
9598,
1941,
27862,
38881,
7121,
445,
1944,
5455,
9598,
1941,
27862,
38881,
7121,
445,
1944,
5455,
9598,
1941,
27862,
38881,
7121,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFetchIntoObjectPool_Failure(t *testing.T) {
cfgBuilder := testcfg.NewGitalyCfgBuilder()
cfg, repos := cfgBuilder.BuildWithRepoAt(t, t.Name())
locator := config.NewLocator(cfg)
gitCmdFactory := git.NewExecCommandFactory(cfg)
server := NewServer(cfg, locator, gitCmdFactory, catfile.NewCache(cfg))
ctx, cancel := testhelper.Context()
defer cancel()
pool, err := objectpool.NewObjectPool(cfg, locator, gitCmdFactory, nil, repos[0].StorageName, gittest.NewObjectPoolName(t))
require.NoError(t, err)
defer func() {
require.NoError(t, pool.Remove(ctx))
}()
poolWithDifferentStorage := pool.ToProto()
poolWithDifferentStorage.Repository.StorageName = "some other storage"
testCases := []struct {
description string
request *gitalypb.FetchIntoObjectPoolRequest
code codes.Code
errMsg string
}{
{
description: "empty origin",
request: &gitalypb.FetchIntoObjectPoolRequest{
ObjectPool: pool.ToProto(),
},
code: codes.InvalidArgument,
errMsg: "origin is empty",
},
{
description: "empty pool",
request: &gitalypb.FetchIntoObjectPoolRequest{
Origin: repos[0],
},
code: codes.InvalidArgument,
errMsg: "object pool is empty",
},
{
description: "origin and pool do not share the same storage",
request: &gitalypb.FetchIntoObjectPoolRequest{
Origin: repos[0],
ObjectPool: poolWithDifferentStorage,
},
code: codes.InvalidArgument,
errMsg: "origin has different storage than object pool",
},
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
_, err := server.FetchIntoObjectPool(ctx, tc.request)
require.Error(t, err)
testhelper.RequireGrpcError(t, err, tc.code)
assert.Contains(t, err.Error(), tc.errMsg)
})
}
} | explode_data.jsonl/1519 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 697
} | [
2830,
3393,
20714,
26591,
1190,
10551,
1400,
9373,
1155,
353,
8840,
836,
8,
341,
50286,
3297,
1669,
1273,
14072,
7121,
38,
2174,
88,
42467,
3297,
741,
50286,
11,
45774,
1669,
13286,
3297,
25212,
2354,
25243,
1655,
1155,
11,
259,
2967,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostMedias_Validate(t *testing.T) {
tests := []struct {
postMedia types.PostMedias
expErr string
}{
{
postMedia: types.PostMedias{
types.PostMedia{
URI: "",
MimeType: "text/plain",
},
},
expErr: "uri must be specified and cannot be empty",
},
{
postMedia: types.PostMedias{
types.PostMedia{
URI: "htt://example.com",
MimeType: "text/plain",
},
},
expErr: "invalid uri provided",
},
{
postMedia: types.PostMedias{
types.PostMedia{
URI: "https://example.com",
MimeType: "",
},
},
expErr: "mime type must be specified and cannot be empty",
},
}
for _, test := range tests {
test := test
t.Run(test.expErr, func(t *testing.T) {
if len(test.expErr) != 0 {
require.Equal(t, test.expErr, test.postMedia.Validate().Error())
} else {
require.Nil(t, test.postMedia.Validate())
}
})
}
} | explode_data.jsonl/47670 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 448
} | [
2830,
3393,
4133,
13310,
3473,
62,
17926,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
51172,
12661,
4494,
23442,
13310,
3473,
198,
197,
48558,
7747,
262,
914,
198,
197,
59403,
197,
197,
515,
298,
51172,
12661,
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... | 2 |
func TestRuleColumnWithCharset(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := [][]string{
// 正面的例子
{
"CREATE TABLE `tb2` ( `id` int(11) DEFAULT NULL, `col` char(10) CHARACTER SET utf8 DEFAULT NULL)",
"alter table tb2 change col col char(10) CHARACTER SET utf8 DEFAULT NULL;",
},
// 反面的例子
{
"CREATE TABLE `tb` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `c` char(120) NOT NULL DEFAULT '', PRIMARY KEY (`id`))",
},
}
for _, sql := range sqls[0] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleColumnWithCharset()
if rule.Item != "COL.014" {
t.Error("Rule not match:", rule.Item, "Expect : COL.014")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
for _, sql := range sqls[1] {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleColumnWithCharset()
if rule.Item != "OK" {
t.Error("Rule not match:", rule.Item, "Expect : OK")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76836 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 498
} | [
2830,
3393,
11337,
2933,
2354,
78172,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
52931,
917,
515,
197,
197,
322,
71928,
96,
27091,
111564,
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... | 7 |
func TestOrgStats_String(t *testing.T) {
v := OrgStats{
TotalOrgs: Int(0),
DisabledOrgs: Int(0),
TotalTeams: Int(0),
TotalTeamMembers: Int(0),
}
want := `github.OrgStats{TotalOrgs:0, DisabledOrgs:0, TotalTeams:0, TotalTeamMembers:0}`
if got := v.String(); got != want {
t.Errorf("OrgStats.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33263 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
42437,
16635,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
33706,
16635,
515,
197,
197,
7595,
42437,
82,
25,
286,
1333,
7,
15,
1326,
197,
197,
25907,
42437,
82,
25,
257,
1333,
7,
15,
1326,
197,
197,
7595,
60669,
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... | 2 |
func TestMixedMoment(t *testing.T) {
for i, test := range []struct {
x, y, weights []float64
r, s float64
ans float64
}{
{
x: []float64{10, 2, 1, 8, 5},
y: []float64{8, 15, 1, 6, 3},
r: 1,
s: 1,
ans: 0.48,
},
{
x: []float64{10, 2, 1, 8, 5},
y: []float64{8, 15, 1, 6, 3},
weights: []float64{1, 1, 1, 1, 1},
r: 1,
s: 1,
ans: 0.48,
},
{
x: []float64{10, 2, 1, 8, 5},
y: []float64{8, 15, 1, 6, 3},
weights: []float64{2, 3, 0.2, 8, 4},
r: 1,
s: 1,
ans: -4.786371011357490,
},
{
x: []float64{10, 2, 1, 8, 5},
y: []float64{8, 15, 1, 6, 3},
weights: []float64{2, 3, 0.2, 8, 4},
r: 2,
s: 3,
ans: 1.598600579313326e+03,
},
} {
m := BivariateMoment(test.r, test.s, test.x, test.y, test.weights)
if math.Abs(test.ans-m) > 1e-14 {
t.Errorf("Moment mismatch case %d. Expected %v, found %v", i, test.ans, m)
}
}
if !panics(func() { BivariateMoment(1, 1, make([]float64, 3), make([]float64, 2), nil) }) {
t.Errorf("Moment did not panic with x, y length mismatch")
}
if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 3), nil) }) {
t.Errorf("Moment did not panic with x, y length mismatch")
}
if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 1)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
} | explode_data.jsonl/1777 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 895
} | [
2830,
3393,
86433,
83817,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
11,
379,
11,
14324,
3056,
3649,
21,
19,
198,
197,
7000,
11,
274,
688,
2224,
21,
19,
198,
197,
43579,
1843,
2224,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestToAST(t *testing.T) {
const prelude = "package main\n"
for _, tt := range []struct {
name string
s string
}{
{
name: "array expression",
s: `[1, 2, 3]`,
},
{
name: "object expression",
s: `{a: 1, b: "2"}`,
},
{
name: "function expression",
s: `(a) => a`,
},
{
name: "function expression with default",
s: `(a, b=2) => a + b`,
},
{
name: "function block",
s: `(a, b) => {
c = a + b
return c
}`,
},
{
name: "call expression",
s: `(() => 2)()`,
},
{
name: "call expression with argument",
s: `((v) => v)(v:2)`,
},
{
name: "identifier",
s: `my_value = 2
my_value
`,
},
{
name: "boolean literal",
s: `true`,
},
{
name: "date time literal",
s: `2019-05-15T12:00:00Z`,
},
{
name: "duration literal",
s: `5s`,
},
{
name: "float literal",
s: `1.0`,
},
{
name: "integer literal",
s: `5`,
},
{
name: "regexp literal",
s: `/abc/`,
},
{
name: "string literal",
s: `"hello world"`,
},
{
name: `binary expression`,
s: `"gpu" == "cpu"`,
},
{
name: "logical expression",
s: `true or false`,
},
{
name: "imports",
s: `import "csv"`,
},
{
name: "option statement",
s: `option now = () => 2019-05-22T00:00:00Z`,
},
{
name: "option statement for subpackage",
s: `import c "csv"
import "testing"
option testing.loadMem = (csv) => c.from(csv: csv)
`,
},
{
name: "variable assignment",
s: `a = 1`,
},
{
name: "test statement",
s: `test foo = {}`,
},
{
name: "conditional expression",
s: `if 1 == 2 then 5 else 3`,
},
{
name: "index expression",
s: `[1, 2, 3][1]`,
},
{
name: "unary negative expression",
s: `-1d`,
},
{
name: "unary exists operator",
s: `import "internal/testutil"
r = testutil.makeRecord(o: {a: 1})
exists r.b
`,
},
{
name: "string expression",
s: `name = "World"
"Hello ${name}!"`,
},
} {
t.Run(tt.name, func(t *testing.T) {
ctx := context.Background()
want, err := runtime.AnalyzeSource(ctx, prelude+tt.s)
if err != nil {
t.Fatalf("unexpected error analyzing source: %s", err)
}
toAst := semantic.ToAST(want)
fmtdAst, err := astutil.Format(toAst.(*ast.Package).Files[0])
if err != nil {
t.Fatalf("unexpected error from formatter: %s", err)
}
got, err := runtime.AnalyzeSource(ctx, fmtdAst)
if err != nil {
t.Fatalf("unexpected error analyzing generated AST: %s", err)
}
if !cmp.Equal(want, got, semantictest.CmpOptions...) {
t.Fatalf("unexpected semantic graph -want/+got:\n%s", cmp.Diff(want, got, semantictest.CmpOptions...))
}
})
}
} | explode_data.jsonl/66727 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1380
} | [
2830,
3393,
1249,
6349,
1155,
353,
8840,
836,
8,
341,
4777,
855,
52538,
284,
330,
1722,
1887,
1699,
698,
2023,
8358,
17853,
1669,
2088,
3056,
1235,
341,
197,
11609,
914,
198,
197,
1903,
262,
914,
198,
197,
59403,
197,
197,
515,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCreateStorageKeyPlainV10(t *testing.T) {
m := ExamplaryMetadataV10
key, err := CreateStorageKey(m, "Timestamp", "Now", nil, nil)
assert.NoError(t, err)
hex, err := Hex(key)
assert.NoError(t, err)
assert.Equal(t, "0xf0c365c3cf59d671eb72da0e7a4113c49f1f0515f462cdcf84e0f1d6045dfcbb", hex)
} | explode_data.jsonl/3052 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 140
} | [
2830,
3393,
4021,
5793,
1592,
26982,
53,
16,
15,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
32310,
500,
658,
14610,
53,
16,
15,
271,
23634,
11,
1848,
1669,
4230,
5793,
1592,
1255,
11,
330,
20812,
497,
330,
7039,
497,
2092,
11,
2092,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddServiceConvertsToGrpc(t *testing.T) {
files := []fileSpec{
{path: "WORKSPACE"},
{
path: config.DefaultValidBuildFileNames[0],
content: `
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "repo_proto",
srcs = ["foo.proto"],
visibility = ["//visibility:public"],
)
go_proto_library(
name = "repo_go_proto",
importpath = "example.com/repo",
proto = ":repo_proto",
visibility = ["//visibility:public"],
)
go_library(
name = "go_default_library",
embed = [":repo_go_proto"],
importpath = "example.com/repo",
visibility = ["//visibility:public"],
)
`,
}, {
path: "foo.proto",
content: `syntax = "proto3";
option go_package = "example.com/repo";
service {}
`,
},
}
dir, err := createFiles(files)
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
args := []string{"-go_prefix", "example.com/repo"}
if err := runGazelle(dir, args); err != nil {
t.Fatal(err)
}
checkFiles(t, dir, []fileSpec{{
path: config.DefaultValidBuildFileNames[0],
content: `
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
proto_library(
name = "repo_proto",
srcs = ["foo.proto"],
visibility = ["//visibility:public"],
)
go_proto_library(
name = "repo_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "example.com/repo",
proto = ":repo_proto",
visibility = ["//visibility:public"],
)
go_library(
name = "go_default_library",
embed = [":repo_go_proto"],
importpath = "example.com/repo",
visibility = ["//visibility:public"],
)
`,
}})
} | explode_data.jsonl/40393 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 756
} | [
2830,
3393,
2212,
1860,
12012,
82,
1249,
6464,
3992,
1155,
353,
8840,
836,
8,
341,
74075,
1669,
3056,
1192,
8327,
515,
197,
197,
90,
2343,
25,
330,
18470,
44641,
7115,
197,
197,
515,
298,
26781,
25,
2193,
13275,
4088,
11066,
1703,
798... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTry(t *testing.T) {
const SCRIPT = `
function A() {
var x = 1;
try {
x = 2;
} catch(e) {
x = 3;
} finally {
x = 4;
}
return x;
}
var rv = A();
`
testScript(SCRIPT, intToValue(4), t)
} | explode_data.jsonl/75222 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 119
} | [
2830,
3393,
21453,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
7527,
362,
368,
341,
197,
2405,
856,
284,
220,
16,
280,
197,
6799,
341,
298,
10225,
284,
220,
17,
280,
197,
197,
92,
2287,
2026,
8,
341,
298,
10225,
284,
22... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestInvalidPasswordSend(t *testing.T) {
impl, err := newTestSenderCheckerImpl(&smscTestClientOptions{true, false, 0}, time.Hour)
if err != nil {
t.Fatal(err)
}
_, err = impl.Send("+7 921 123 45 67", "test", false)
if err == nil {
t.Fatal(err)
}
} | explode_data.jsonl/23018 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
7928,
4876,
11505,
1155,
353,
8840,
836,
8,
341,
197,
6383,
11,
1848,
1669,
501,
2271,
20381,
35188,
9673,
2099,
41392,
66,
2271,
2959,
3798,
90,
1866,
11,
895,
11,
220,
15,
2137,
882,
73550,
340,
743,
1848,
961,
2092,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAddRecordAndFlush(t *testing.T) {
records := make([]*kinesis.PutRecordsRequestEntry, 0, 500)
record := map[interface{}]interface{}{
"testkey": []byte("test value"),
}
ctrl := gomock.NewController(t)
mockKinesis := mock_kinesis.NewMockPutRecordsClient(ctrl)
mockKinesis.EXPECT().PutRecords(gomock.Any()).Return(&kinesis.PutRecordsOutput{
FailedRecordCount: aws.Int64(0),
}, nil)
outputPlugin, _ := newMockOutputPlugin(mockKinesis, false)
timeStamp := time.Now()
retCode := outputPlugin.AddRecord(&records, record, &timeStamp)
assert.Equal(t, retCode, fluentbit.FLB_OK, "Expected return code to be FLB_OK")
retCode = outputPlugin.Flush(&records)
assert.Equal(t, retCode, fluentbit.FLB_OK, "Expected return code to be FLB_OK")
} | explode_data.jsonl/74100 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
2212,
6471,
3036,
46874,
1155,
353,
8840,
836,
8,
341,
197,
26203,
1669,
1281,
85288,
74,
82789,
39825,
25876,
1900,
5874,
11,
220,
15,
11,
220,
20,
15,
15,
692,
71952,
1669,
2415,
58,
4970,
78134,
4970,
67066,
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 TestLoadTokenFailsBadJson(t *testing.T) {
gibberishJSON := strings.Replace(MockTokenJSON, "expires_on", ";:\"gibberish", -1)
f := writeTestTokenFile(t, "testloadtokenfailsbadjson", gibberishJSON)
defer os.Remove(f.Name())
_, err := LoadToken(f.Name())
expectedSubstring := "failed to decode contents of file"
if err == nil || !strings.Contains(err.Error(), expectedSubstring) {
t.Fatalf("azure: failed to get correct error expected(%s) actual(%s)", expectedSubstring, err.Error())
}
} | explode_data.jsonl/14993 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
5879,
3323,
37,
6209,
17082,
5014,
1155,
353,
8840,
836,
8,
972,
3174,
579,
652,
812,
5370,
1669,
9069,
20858,
66436,
3323,
5370,
11,
330,
48203,
4470,
497,
18963,
75035,
70,
579,
652,
812,
497,
481,
16,
1218,
1166,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGiBToBytes(t *testing.T) {
var sizeInGiB int64 = 3
actual := GiBToBytes(sizeInGiB)
if actual != 3*GiB {
t.Fatalf("Wrong result for GiBToBytes. Got: %d", actual)
}
} | explode_data.jsonl/78371 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
46841,
33,
1249,
7078,
1155,
353,
8840,
836,
8,
341,
2405,
1379,
641,
46841,
33,
526,
21,
19,
284,
220,
18,
271,
88814,
1669,
15392,
33,
1249,
7078,
6856,
641,
46841,
33,
340,
743,
5042,
961,
220,
18,
9,
46841,
33,
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... | 2 |
func TestQueryAutocompleteMaximalRequestURL(t *testing.T) {
expectedQuery := "input=quay+resteraunt+sydney&key=AIzaNotReallyAnAPIKey&language=es&location=1%2C2&offset=5&radius=10000"
server := mockServerForQuery(expectedQuery, 200, `{"status":"OK"}"`)
defer server.s.Close()
c, _ := NewClient(WithAPIKey(apiKey))
c.baseURL = server.s.URL
r := &QueryAutocompleteRequest{
Input: "quay resteraunt sydney",
Offset: 5,
Location: &LatLng{1.0, 2.0},
Radius: 10000,
Language: "es",
}
_, err := c.QueryAutocomplete(context.Background(), r)
if err != nil {
t.Errorf("Unexpected error in constructing request URL: %+v", err)
}
if server.successful != 1 {
t.Errorf("Got URL(s) %v, want %s", server.failed, expectedQuery)
}
} | explode_data.jsonl/76297 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 297
} | [
2830,
3393,
2859,
19602,
20104,
5974,
2861,
1900,
3144,
1155,
353,
8840,
836,
8,
341,
42400,
2859,
1669,
330,
1355,
28,
446,
352,
10,
3927,
2416,
3850,
10,
22860,
18787,
5,
792,
28,
15469,
4360,
2623,
48785,
2082,
7082,
1592,
5,
11528... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGenerateNetworkConfigFileAboutIPAddressIsMissing(t *testing.T) {
key, _, _, _, _ := ssh.ParseAuthorizedKey([]byte("ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBITowPn2Ol1eCvXN5XV+Lb6jfXzgDbXyEdtayadDUJtFrcN2m2mjC1B20VBAoJcZtSYkmjrllS06Q26Te5sTYvE= testkey"))
hw, _ := net.ParseMAC("52:54:00:78:71:f1")
e := &CloudConfigEthernet{
MacAddress: hw,
}
c := StructConfig("user", "host", []ssh.PublicKey{key}, []*CloudConfigEthernet{e})
if err := c.GenerateNetworkConfigFile("."); err != nil {
t.Fatalf("Failed to generate network config file: err='%s'", err.Error())
}
defer c.Delete()
data, _ := ioutil.ReadFile("network-config")
if strings.Contains(string(data), "null") {
t.Errorf("Failed to valid network file, subnets have null")
}
} | explode_data.jsonl/46116 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 355
} | [
2830,
3393,
31115,
12320,
2648,
1703,
10494,
87976,
3872,
25080,
1155,
353,
8840,
836,
8,
341,
23634,
11,
8358,
8358,
8358,
716,
1669,
29230,
8937,
60454,
1592,
10556,
3782,
445,
757,
96780,
7514,
64,
17,
5279,
380,
79,
17,
20,
21,
47... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetValueValid(t *testing.T) {
cipherEngineType := schemas.S5CipherEngineTypeAES
cipheredValue := "{{s5:NmRhN2I1YTFhNGE4ZjUzNzI5ZTNlMjk4YzQ3NWQzMDRiYmRkYjA6OTAzN2E3OGQ0YTFmY2U0ZDRmZmExYmU2}}"
key := testAESKey
c := &Client{}
v := &schemas.S5{
CipherEngineType: &cipherEngineType,
CipherEngineAES: &schemas.S5CipherEngineAES{
Key: &key,
},
Value: &cipheredValue,
}
value, err := c.GetValue(v)
assert.Nil(t, err)
assert.Equal(t, "foo", value)
} | explode_data.jsonl/51170 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
23213,
4088,
1155,
353,
8840,
836,
8,
341,
1444,
10558,
4571,
929,
1669,
61800,
808,
20,
79460,
4571,
929,
69168,
198,
1444,
10558,
291,
1130,
1669,
47219,
82,
20,
37694,
76,
72162,
45,
17,
40,
16,
56,
10808,
71,
6140,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestChunksStorageAllIndexBackends(t *testing.T) {
s, err := e2e.NewScenario(networkName)
require.NoError(t, err)
defer s.Close()
// Start dependencies.
dynamo := e2edb.NewDynamoDB()
bigtable := e2edb.NewBigtable()
cassandra := e2edb.NewCassandra()
stores := []string{"aws-dynamo", "bigtable", "cassandra"}
perStoreDuration := 14 * 24 * time.Hour
consul := e2edb.NewConsul()
require.NoError(t, s.StartAndWaitReady(cassandra, dynamo, bigtable, consul))
// lets build config for each type of Index Store.
now := time.Now()
oldestStoreStartTime := now.Add(time.Duration(-len(stores)) * perStoreDuration)
storeConfigs := make([]storeConfig, len(stores))
for i, store := range stores {
storeConfigs[i] = storeConfig{From: oldestStoreStartTime.Add(time.Duration(i) * perStoreDuration).Format("2006-01-02"), IndexStore: store}
}
storageFlags := mergeFlags(ChunksStorageFlags(), map[string]string{
"-cassandra.addresses": cassandra.NetworkHTTPEndpoint(),
"-cassandra.keyspace": "tests", // keyspace gets created on startup if it does not exist
"-cassandra.replication-factor": "1",
})
// bigtable client needs to set an environment variable when connecting to an emulator
bigtableFlag := map[string]string{"BIGTABLE_EMULATOR_HOST": bigtable.NetworkHTTPEndpoint()}
// here we are starting and stopping table manager for each index store
// this is a workaround to make table manager create tables for each config since it considers only latest schema config while creating tables
for i := range storeConfigs {
require.NoError(t, writeFileToSharedDir(s, cortexSchemaConfigFile, []byte(buildSchemaConfigWith(storeConfigs[i:i+1]))))
tableManager := e2ecortex.NewTableManager("table-manager", mergeFlags(storageFlags, map[string]string{
"-table-manager.retention-period": "2520h", // setting retention high enough
}), "")
tableManager.HTTPService.SetEnvVars(bigtableFlag)
require.NoError(t, s.StartAndWaitReady(tableManager))
// Wait until the first table-manager sync has completed, so that we're
// sure the tables have been created.
require.NoError(t, tableManager.WaitSumMetrics(e2e.Greater(0), "cortex_table_manager_sync_success_timestamp_seconds"))
require.NoError(t, s.Stop(tableManager))
}
// Start rest of the Cortex components.
require.NoError(t, writeFileToSharedDir(s, cortexSchemaConfigFile, []byte(buildSchemaConfigWith(storeConfigs))))
ingester := e2ecortex.NewIngester("ingester", consul.NetworkHTTPEndpoint(), mergeFlags(storageFlags, map[string]string{
"-ingester.retain-period": "0s", // we want to make ingester not retain any chunks in memory after they are flushed so that queries get data only from the store
}), "")
ingester.HTTPService.SetEnvVars(bigtableFlag)
distributor := e2ecortex.NewDistributor("distributor", consul.NetworkHTTPEndpoint(), storageFlags, "")
querier := e2ecortex.NewQuerier("querier", consul.NetworkHTTPEndpoint(), storageFlags, "")
querier.HTTPService.SetEnvVars(bigtableFlag)
require.NoError(t, s.StartAndWaitReady(distributor, ingester, querier))
// Wait until both the distributor and querier have updated the ring.
require.NoError(t, distributor.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
require.NoError(t, querier.WaitSumMetrics(e2e.Equals(512), "cortex_ring_tokens_total"))
client, err := e2ecortex.NewClient(distributor.HTTPEndpoint(), querier.HTTPEndpoint(), "", "", "user-1")
require.NoError(t, err)
// Push and Query some series from Cortex for each day starting from oldest start time from configs until now so that we test all the Index Stores
for ts := oldestStoreStartTime; ts.Before(now); ts = ts.Add(24 * time.Hour) {
series, expectedVector := generateSeries("series_1", ts)
res, err := client.Push(series)
require.NoError(t, err)
require.Equal(t, 200, res.StatusCode)
// lets make ingester flush the chunks immediately to the store
res, err = e2e.GetRequest("http://" + ingester.HTTPEndpoint() + "/flush")
require.NoError(t, err)
require.Equal(t, 204, res.StatusCode)
// Let's wait until all chunks are flushed.
require.NoError(t, ingester.WaitSumMetrics(e2e.Equals(0), "cortex_ingester_flush_queue_length"))
require.NoError(t, ingester.WaitSumMetrics(e2e.Equals(0), "cortex_ingester_flush_series_in_progress"))
// lets verify that chunk store chunk metrics are updated.
require.NoError(t, ingester.WaitSumMetrics(e2e.Greater(0), "cortex_chunk_store_stored_chunks_total"))
require.NoError(t, ingester.WaitSumMetrics(e2e.Greater(0), "cortex_chunk_store_stored_chunk_bytes_total"))
// Query back the series.
result, err := client.Query("series_1", ts)
require.NoError(t, err)
require.Equal(t, model.ValVector, result.Type())
assert.Equal(t, expectedVector, result.(model.Vector))
// check we've queried them from the chunk store.
require.NoError(t, querier.WaitSumMetrics(e2e.Greater(0), "cortex_chunk_store_fetched_chunks_total"))
require.NoError(t, querier.WaitSumMetrics(e2e.Greater(0), "cortex_chunk_store_fetched_chunk_bytes_total"))
}
// Ensure no service-specific metrics prefix is used by the wrong service.
assertServiceMetricsPrefixes(t, Distributor, distributor)
assertServiceMetricsPrefixes(t, Ingester, ingester)
assertServiceMetricsPrefixes(t, Querier, querier)
} | explode_data.jsonl/5389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1797
} | [
2830,
3393,
89681,
5793,
2403,
1552,
3707,
1412,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
384,
17,
68,
7121,
54031,
46542,
675,
340,
17957,
35699,
1155,
11,
1848,
340,
16867,
274,
10421,
2822,
197,
322,
5145,
19543,
624,
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... | 4 |
func TestSetRealOrderDefaults(t *testing.T) {
if !areTestAPIKeysSet() || !canManipulateRealOrders {
t.Skip("Ensure canManipulateRealOrders is true and your API keys are set")
}
} | explode_data.jsonl/30137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 65
} | [
2830,
3393,
1649,
12768,
4431,
16273,
1155,
353,
8840,
836,
8,
341,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
1369,
753,
4814,
92876,
6334,
12768,
24898,
341,
197,
3244,
57776,
445,
64439,
646,
92876,
6334,
12768,
24898,
374,
830,
323... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIncreaseLevel(t *testing.T) {
errorOut := &bytes.Buffer{}
opts := []Option{
ErrorOutput(zapcore.AddSync(errorOut)),
}
withLogger(t, WarnLevel, opts, func(logger *Logger, logs *observer.ObservedLogs) {
logger.Warn("original warn log")
errorLogger := logger.WithOptions(IncreaseLevel(ErrorLevel))
errorLogger.Debug("ignored debug log")
errorLogger.Warn("ignored warn log")
errorLogger.Error("increase level error log")
withFields := errorLogger.With(String("k", "v"))
withFields.Debug("ignored debug log with fields")
withFields.Warn("ignored warn log with fields")
withFields.Error("increase level error log with fields")
assert.Equal(t, []observer.LoggedEntry{
newLoggedEntry(WarnLevel, "original warn log"),
newLoggedEntry(ErrorLevel, "increase level error log"),
newLoggedEntry(ErrorLevel, "increase level error log with fields", String("k", "v")),
}, logs.AllUntimed(), "unexpected logs")
assert.Empty(t, errorOut.String(), "expect no error output")
})
} | explode_data.jsonl/13569 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 354
} | [
2830,
3393,
69556,
4449,
1155,
353,
8840,
836,
8,
341,
18290,
2662,
1669,
609,
9651,
22622,
16094,
64734,
1669,
3056,
5341,
515,
197,
58421,
5097,
13174,
391,
2153,
1904,
12154,
6390,
2662,
6965,
197,
532,
46948,
7395,
1155,
11,
67746,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListFlags(t *testing.T) {
assert := assert.New(t)
cli := test.NewCLI()
cmd := ListCommand(cli)
flag := cmd.Flag("all-namespaces")
assert.NotNil(flag)
flag = cmd.Flag("format")
assert.NotNil(flag)
} | explode_data.jsonl/78035 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
852,
9195,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
86448,
1669,
1273,
7121,
63959,
741,
25920,
1669,
1759,
4062,
70249,
692,
30589,
1669,
5439,
80911,
445,
541,
89044,
27338,
1138,
6948,
93882,
33104,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConverterMapStructWithFieldMapDeeper2(t *testing.T) {
fieldMap := make(map[string]codegen.FieldMapperEntry)
fieldMap["Six.Four.One"] = codegen.FieldMapperEntry{
QualifiedName: "Five.Three.One",
Override: true,
}
lines, err := convertTypes(
"Foo", "Bar",
`struct NestedA {
1: optional string one
}
struct NestedB {
1: required NestedA three
}
struct NestedC {
1: optional NestedA four
}
struct Foo {
1: required NestedB five
}
struct Bar {
1: required NestedC six
}`,
nil,
fieldMap,
)
assert.NoError(t, err)
assertPrettyEqual(t, trim(`
out.Six = &structs.NestedC{}
if in.Five != nil && in.Five.Three != nil {
if out.Six.Four == nil {
out.Six.Four = &structs.NestedA{}
}
out.Six.Four.One = (*string)(in.Five.Three.One)
}`),
lines)
} | explode_data.jsonl/62078 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
14920,
2227,
9422,
2354,
1877,
2227,
1912,
10436,
17,
1155,
353,
8840,
836,
8,
341,
39250,
2227,
1669,
1281,
9147,
14032,
60,
95859,
17087,
10989,
5874,
340,
39250,
2227,
1183,
41460,
991,
413,
37067,
1341,
284,
2038,
4370,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestOf(t *testing.T) {
r := Of([]byte("abc"))
assert.Equal(t, "rmnjb8cjc5tblj21ed4qs821649eduie", r.String())
} | explode_data.jsonl/15929 | {
"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,
2124,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
4940,
10556,
3782,
445,
13683,
5455,
6948,
12808,
1155,
11,
330,
8719,
77,
38978,
23,
66,
62987,
20,
18064,
73,
17,
16,
291,
19,
26358,
23,
17,
16,
21,
19,
24,
55101,
645... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRPMType(t *testing.T) {
// empty to start
if len(SemVerToFacFnMap.VersionFactories) != 0 {
t.Error("semver range was not blank at start of test")
}
u := UnmarshalTester{}
// ensure semver range parser is working
invalidSemVerRange := "not a valid semver range"
SemVerToFacFnMap.Set(invalidSemVerRange, u.NewEntry)
if len(SemVerToFacFnMap.VersionFactories) > 0 {
t.Error("invalid semver range was incorrectly added to SemVerToFacFnMap")
}
// valid semver range can be parsed
SemVerToFacFnMap.Set(">= 1.2.3", u.NewEntry)
if len(SemVerToFacFnMap.VersionFactories) != 1 {
t.Error("valid semver range was not added to SemVerToFacFnMap")
}
u.Rpm.APIVersion = swag.String("2.0.1")
brt := BaseRPMType{}
// version requested matches implementation in map
if _, err := brt.UnmarshalEntry(&u.Rpm); err != nil {
t.Errorf("unexpected error in Unmarshal: %v", err)
}
// version requested fails to match implementation in map
u.Rpm.APIVersion = swag.String("1.2.2")
if _, err := brt.UnmarshalEntry(&u.Rpm); err == nil {
t.Error("unexpected success in Unmarshal for non-matching version")
}
// error in Unmarshal call is raised appropriately
u.Rpm.APIVersion = swag.String("2.2.0")
u2 := UnmarshalFailsTester{}
SemVerToFacFnMap.Set(">= 1.2.3", u2.NewEntry)
if _, err := brt.UnmarshalEntry(&u.Rpm); err == nil {
t.Error("unexpected success in Unmarshal when error is thrown")
}
// version requested fails to match implementation in map
u.Rpm.APIVersion = swag.String("not_a_version")
if _, err := brt.UnmarshalEntry(&u.Rpm); err == nil {
t.Error("unexpected success in Unmarshal for invalid version")
}
} | explode_data.jsonl/31772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 630
} | [
2830,
3393,
49,
8795,
929,
1155,
353,
8840,
836,
8,
341,
197,
322,
4287,
311,
1191,
198,
743,
2422,
3759,
336,
10141,
1249,
28702,
24911,
2227,
35842,
17417,
2433,
8,
961,
220,
15,
341,
197,
3244,
6141,
445,
6998,
423,
2088,
572,
53... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseDjangoQueries(t *testing.T) {
for _, query := range loadQueries(t, "django_queries.txt") {
_, err := Parse(query)
if err != nil {
t.Errorf("failed to parse %q: %v", query, err)
}
}
} | explode_data.jsonl/27193 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 92
} | [
2830,
3393,
14463,
35,
5846,
55261,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
3239,
1669,
2088,
2795,
55261,
1155,
11,
330,
13575,
65588,
3909,
899,
341,
197,
197,
6878,
1848,
1669,
14775,
10741,
340,
197,
743,
1848,
961,
2092,
341,
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... | 3 |
func TestMarshalPlannedOutputs(t *testing.T) {
after, _ := plans.NewDynamicValue(cty.StringVal("after"), cty.DynamicPseudoType)
tests := []struct {
Changes *plans.Changes
Want map[string]output
Err bool
}{
{
&plans.Changes{},
nil,
false,
},
{
&plans.Changes{
Outputs: []*plans.OutputChangeSrc{
{
Addr: addrs.OutputValue{Name: "bar"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{
Action: plans.Create,
After: after,
},
Sensitive: false,
},
},
},
map[string]output{
"bar": {
Sensitive: false,
Value: json.RawMessage(`"after"`),
},
},
false,
},
{ // Delete action
&plans.Changes{
Outputs: []*plans.OutputChangeSrc{
{
Addr: addrs.OutputValue{Name: "bar"}.Absolute(addrs.RootModuleInstance),
ChangeSrc: plans.ChangeSrc{
Action: plans.Delete,
},
Sensitive: false,
},
},
},
map[string]output{},
false,
},
}
for _, test := range tests {
got, err := marshalPlannedOutputs(test.Changes)
if test.Err {
if err == nil {
t.Fatal("succeeded; want error")
}
return
} else if err != nil {
t.Fatalf("unexpected error: %s", err)
}
eq := reflect.DeepEqual(got, test.Want)
if !eq {
t.Fatalf("wrong result:\nGot: %#v\nWant: %#v\n", got, test.Want)
}
}
} | explode_data.jsonl/17742 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 684
} | [
2830,
3393,
55438,
2120,
7295,
61438,
1155,
353,
8840,
836,
8,
341,
197,
10694,
11,
716,
1669,
6649,
7121,
21752,
1130,
40583,
88,
6431,
2208,
445,
10694,
3975,
272,
1881,
42101,
47,
21952,
929,
692,
78216,
1669,
3056,
1235,
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... | 6 |
func TestReversiAnz14(t *testing.T) {
r := NewReversiAnz()
if r.GetEdgeSideTwoCnt() != 0 {
t.Errorf("NG")
}
} | explode_data.jsonl/23037 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
693,
3004,
72,
2082,
89,
16,
19,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
693,
3004,
72,
2082,
89,
741,
743,
435,
2234,
11656,
16384,
11613,
33747,
368,
961,
220,
15,
341,
197,
3244,
13080,
445,
6140,
1138,
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
] | 2 |
func TestStringSegmentation(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("String Segmentation", func() {
dict := make(map[string]bool)
dict["hello"] = true
dict["on"] = true
dict["now"] = true
g.It("Should return true if string can be segmented in dictionary words", func() {
g.Assert(gi.IsStringSegmentation("hellonow", dict)).IsTrue()
})
g.It("Should return true if string can not be segmented in dictionary words", func() {
g.Assert(gi.IsStringSegmentation("helloqon", dict)).IsFalse()
})
})
} | explode_data.jsonl/41486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 190
} | [
2830,
3393,
703,
21086,
367,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
47061,
1224,
47061,
1155,
692,
3174,
23548,
3114,
445,
703,
17209,
31099,
497,
2915,
368,
341,
197,
2698,
849,
1669,
1281,
9147,
14032,
96436,
340,
197,
2698,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDefaultSpringContext_ConditionOnMissingBean(t *testing.T) {
for i := 0; i < 20; i++ { // 测试 Find 无需绑定,不要排序
c, ch := container()
c.Object(&BeanZero{5})
c.Object(new(BeanOne))
c.Object(new(BeanTwo)).On(cond.OnMissingBean("BeanOne"))
c.Object(new(BeanTwo)).Name("another_two").On(cond.OnMissingBean("Null"))
err := c.Refresh()
assert.Nil(t, err)
p := <-ch
var two *BeanTwo
err = p.BeanRegistry().Get(&two)
assert.Nil(t, err)
err = p.BeanRegistry().Get(&two, "another_two")
assert.Nil(t, err)
}
} | explode_data.jsonl/17434 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 257
} | [
2830,
3393,
3675,
25150,
1972,
920,
2111,
680,
1925,
25080,
10437,
1155,
353,
8840,
836,
8,
1476,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
17,
15,
26,
600,
1027,
314,
442,
98313,
66635,
7379,
220,
106431,
113200,
3837,
100148,
746... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransferInputSerialize(t *testing.T) {
c := linearcodec.NewDefault()
m := codec.NewDefaultManager()
if err := m.RegisterCodec(0, c); err != nil {
t.Fatal(err)
}
expected := []byte{
// Codec version
0x00, 0x00,
// amount:
0x00, 0x00, 0x00, 0x00, 0x07, 0x5b, 0xcd, 0x15,
// length:
0x00, 0x00, 0x00, 0x02,
// sig[0]
0x00, 0x00, 0x00, 0x03,
// sig[1]
0x00, 0x00, 0x00, 0x07,
}
in := TransferInput{
Amt: 123456789,
Input: Input{
SigIndices: []uint32{3, 7},
},
}
err := in.Verify()
if err != nil {
t.Fatal(err)
}
result, err := m.Marshal(0, &in)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(expected, result) {
t.Fatalf("\nExpected: 0x%x\nResult: 0x%x", expected, result)
}
} | explode_data.jsonl/31625 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
21970,
2505,
15680,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
13482,
34607,
7121,
3675,
741,
2109,
1669,
34647,
7121,
3675,
2043,
741,
743,
1848,
1669,
296,
19983,
36913,
7,
15,
11,
272,
1215,
1848,
961,
2092,
341,
197,
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... | 5 |
func TestGocloak_GetClientRole(t *testing.T) {
t.Parallel()
client := NewClientWithDebug(t)
tearDown, roleName := CreateClientRole(t, client)
defer tearDown()
cfg := GetConfig(t)
token := GetAdminToken(t, client)
role, err := client.GetClientRole(
token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID,
roleName,
)
assert.NoError(t, err, "GetClientRoleI failed")
assert.NotNil(t, role)
token = GetAdminToken(t, client)
role, err = client.GetClientRole(
token.AccessToken,
cfg.GoCloak.Realm,
gocloakClientID,
"Fake-Role-Name",
)
assert.Error(t, err)
assert.Nil(t, role)
} | explode_data.jsonl/79524 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
38,
509,
385,
585,
13614,
2959,
9030,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
25291,
1669,
1532,
2959,
2354,
7939,
1155,
340,
197,
82892,
11,
90947,
1669,
4230,
2959,
9030,
1155,
11,
2943,
340,
16867,
32825,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRuleProps(t *testing.T) {
defer leaktest.AfterTest(t)()
datadriven.Walk(t, "testdata/ruleprops", func(t *testing.T, path string) {
catalog := testcat.New()
datadriven.RunTest(t, path, func(t *testing.T, d *datadriven.TestData) string {
tester := opttester.New(catalog, d.Input)
tester.Flags.ExprFormat = memo.ExprFmtHideStats | memo.ExprFmtHideCost |
memo.ExprFmtHideQualifications | memo.ExprFmtHideScalars
return tester.RunCommand(t, d)
})
})
} | explode_data.jsonl/55160 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 204
} | [
2830,
3393,
11337,
5992,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
2698,
266,
14666,
2071,
1175,
1692,
1155,
11,
330,
92425,
7382,
1111,
4761,
497,
2915,
1155,
353,
8840,
836,
11,
1815,
914,
8,
341,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_entryOu_load(t *testing.T) {
t.Parallel()
type fields struct {
p unsafe.Pointer
}
type want struct {
wantValue string
wantOk bool
}
type test struct {
name string
fields fields
want want
checkFunc func(want, string, bool) error
beforeFunc func()
afterFunc func()
}
defaultCheckFunc := func(w want, gotValue string, gotOk bool) error {
if !reflect.DeepEqual(gotValue, w.wantValue) {
return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotValue, w.wantValue)
}
if !reflect.DeepEqual(gotOk, w.wantOk) {
return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk)
}
return nil
}
tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
fields: fields {
p: nil,
},
want: want{},
checkFunc: defaultCheckFunc,
},
*/
// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
fields: fields {
p: nil,
},
want: want{},
checkFunc: defaultCheckFunc,
}
}(),
*/
}
for _, tc := range tests {
test := tc
t.Run(test.name, func(tt *testing.T) {
tt.Parallel()
defer goleak.VerifyNone(tt, goleak.IgnoreCurrent())
if test.beforeFunc != nil {
test.beforeFunc()
}
if test.afterFunc != nil {
defer test.afterFunc()
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
e := &entryOu{
p: test.fields.p,
}
gotValue, gotOk := e.load()
if err := test.checkFunc(test.want, gotValue, gotOk); err != nil {
tt.Errorf("error = %v", err)
}
})
}
} | explode_data.jsonl/61536 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 856
} | [
2830,
3393,
9078,
46,
84,
12411,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
13158,
5043,
2036,
341,
197,
3223,
19860,
41275,
198,
197,
532,
13158,
1366,
2036,
341,
197,
50780,
1130,
914,
198,
197,
50780,
11578,
262,
1807,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_Problem0015(t *testing.T) {
ast := assert.New(t)
qs := []question{
question{
para{[]int{1, -1, -1, 0}},
ans{[][]int{
[]int{-1, 0, 1},
}},
},
question{
para{[]int{-1, 0, 1, 2, 2, 2, 2, -1, -4}},
ans{[][]int{
[]int{-4, 2, 2},
[]int{-1, -1, 2},
[]int{-1, 0, 1},
}},
},
question{
para{[]int{0, 0, 0, 0, 0}},
ans{[][]int{
[]int{0, 0, 0},
}},
},
question{
para{[]int{1, 1, -2}},
ans{[][]int{
[]int{-2, 1, 1},
}},
},
question{
para{[]int{0, 0, 0}},
ans{[][]int{
[]int{0, 0, 0},
}},
},
// 如需多个测试,可以复制上方元素。
}
for _, q := range qs {
a, p := q.ans, q.para
ast.Equal(a.one, threeSum(p.one), "输入:%v", p)
fmt.Println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
}
} | explode_data.jsonl/74110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 490
} | [
2830,
3393,
16670,
10121,
15,
15,
16,
20,
1155,
353,
8840,
836,
8,
341,
88836,
1669,
2060,
7121,
1155,
692,
18534,
82,
1669,
3056,
7841,
4257,
197,
197,
7841,
515,
298,
197,
14794,
90,
1294,
396,
90,
16,
11,
481,
16,
11,
481,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTryAddState(t *testing.T) {
tests := []struct {
name string
runErrF func() error
runErrMessage []byte
metrics []telegraf.Metric
assertF func(*testing.T, []telegraf.Metric)
}{
{
name: "should append state=0 field to existing metric",
runErrF: func() error {
return nil
},
metrics: []telegraf.Metric{
mb().
n("nagios").
f("perfdata", 0).b(),
mb().
n("nagios_state").
f("service_output", "OK: system working").b(),
},
assertF: func(t *testing.T, metrics []telegraf.Metric) {
exp := []telegraf.Metric{
mb().
n("nagios").
f("perfdata", 0).b(),
mb().
n("nagios_state").
f("service_output", "OK: system working").
f("state", 0).b(),
}
assertEqual(t, exp, metrics)
},
},
{
name: "should create 'nagios_state state=0' and same timestamp as others",
runErrF: func() error {
return nil
},
metrics: []telegraf.Metric{
mb().
n("nagios").
f("perfdata", 0).b(),
},
assertF: func(t *testing.T, metrics []telegraf.Metric) {
exp := []telegraf.Metric{
mb().
n("nagios").
f("perfdata", 0).b(),
mb().
n("nagios_state").
f("state", 0).b(),
}
assertEqual(t, exp, metrics)
},
},
{
name: "should create 'nagios_state state=0' and recent timestamp",
runErrF: func() error {
return nil
},
metrics: []telegraf.Metric{},
assertF: func(t *testing.T, metrics []telegraf.Metric) {
require.Len(t, metrics, 1)
m := metrics[0]
require.Equal(t, "nagios_state", m.Name())
s, ok := m.GetField("state")
require.True(t, ok)
require.Equal(t, int64(0), s)
require.WithinDuration(t, time.Now().UTC(), m.Time(), 10*time.Second)
},
},
{
name: "should return metrics with state unknown and thrown error is service_output",
runErrF: func() error {
return errors.New("non parsable error")
},
metrics: []telegraf.Metric{
mb().
n("nagios_state").b(),
},
assertF: func(t *testing.T, metrics []telegraf.Metric) {
exp := []telegraf.Metric{
mb().
n("nagios_state").
f("state", 3).
f("service_output", "non parsable error").b(),
}
assertEqual(t, exp, metrics)
},
},
{
name: "should return metrics with state unknown and service_output error from error message parameter",
runErrF: func() error {
return errors.New("")
},
runErrMessage: []byte("some error message"),
metrics: []telegraf.Metric{
mb().
n("nagios_state").b(),
},
assertF: func(t *testing.T, metrics []telegraf.Metric) {
exp := []telegraf.Metric{
mb().
n("nagios_state").
f("state", 3).
f("service_output", "some error message").b(),
}
assertEqual(t, exp, metrics)
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
metrics := AddState(tt.runErrF(), tt.runErrMessage, tt.metrics)
tt.assertF(t, metrics)
})
}
} | explode_data.jsonl/60290 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1450
} | [
2830,
3393,
21453,
2212,
1397,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
56742,
7747,
37,
981,
2915,
368,
1465,
198,
197,
56742,
7747,
2052,
3056,
3782,
198,
197,
2109,
13468,
981,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStorageAppend(t *testing.T) {
ents := []pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}}
tests := []struct {
entries []pb.Entry
werr error
wentries []pb.Entry
}{
{
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}},
},
{
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 6}, {Index: 5, Term: 6}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 6}, {Index: 5, Term: 6}},
},
{
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
},
// truncate incoming entries, truncate the existing entries and append
{
[]pb.Entry{{Index: 2, Term: 3}, {Index: 3, Term: 3}, {Index: 4, Term: 5}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 5}},
},
// truncate the existing entries and append
{
[]pb.Entry{{Index: 4, Term: 5}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 5}},
},
// direct append
{
[]pb.Entry{{Index: 6, Term: 5}},
nil,
[]pb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 5}},
},
}
for i, tt := range tests {
s := &MemoryStorage{ents: ents}
err := s.Append(tt.entries)
if err != tt.werr {
t.Errorf("#%d: err = %v, want %v", i, err, tt.werr)
}
if !reflect.DeepEqual(s.ents, tt.wentries) {
t.Errorf("#%d: entries = %v, want %v", i, s.ents, tt.wentries)
}
}
} | explode_data.jsonl/66757 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 764
} | [
2830,
3393,
5793,
23877,
1155,
353,
8840,
836,
8,
341,
197,
805,
1669,
3056,
16650,
22330,
2979,
1552,
25,
220,
18,
11,
17519,
25,
220,
18,
2137,
314,
1552,
25,
220,
19,
11,
17519,
25,
220,
19,
2137,
314,
1552,
25,
220,
20,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestFormatterBackgroundDefault(test *testing.T) {
formatted, err := formatter.Format("{gray | background}gray{default | background}")
assert.NoError(test, err)
assert.Equal(test, "\x1b[100mgray\x1b[49m", formatted)
} | explode_data.jsonl/39756 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 78
} | [
2830,
3393,
14183,
8706,
3675,
8623,
353,
8840,
836,
8,
341,
37410,
12127,
11,
1848,
1669,
24814,
9978,
13976,
11650,
760,
4004,
92,
11650,
90,
2258,
760,
4004,
55266,
6948,
35699,
8623,
11,
1848,
340,
6948,
12808,
8623,
11,
2917,
87,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestInitExtIPMapping(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
// a.extIPMapper should be nil by default
a, err := NewAgent(&AgentConfig{
Trickle: true, // to avoid starting gathering candidates
})
if err != nil {
t.Fatalf("Failed to create agent: %v", err)
}
if a.extIPMapper != nil {
t.Fatal("a.extIPMapper should be nil by default")
}
assert.NoError(t, a.Close())
// a.extIPMapper should be nil when NAT1To1IPs is a non-nil empty array
a, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{},
NAT1To1IPCandidateType: CandidateTypeHost,
Trickle: true, // to avoid starting gathering candidates
})
if err != nil {
t.Fatalf("Failed to create agent: %v", err)
}
if a.extIPMapper != nil {
t.Fatal("a.extIPMapper should be nil by default")
}
assert.NoError(t, a.Close())
// NewAgent should return an error when 1:1 NAT for host candidate is enabled
// but the candidate type does not appear in the CandidateTypes.
_, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{"1.2.3.4"},
NAT1To1IPCandidateType: CandidateTypeHost,
CandidateTypes: []CandidateType{CandidateTypeRelay},
Trickle: true, // to avoid starting gathering candidates
})
if err != ErrIneffectiveNAT1To1IPMappingHost {
t.Fatalf("Unexpected error: %v", err)
}
// NewAgent should return an error when 1:1 NAT for srflx candidate is enabled
// but the candidate type does not appear in the CandidateTypes.
_, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{"1.2.3.4"},
NAT1To1IPCandidateType: CandidateTypeServerReflexive,
CandidateTypes: []CandidateType{CandidateTypeRelay},
Trickle: true, // to avoid starting gathering candidates
})
if err != ErrIneffectiveNAT1To1IPMappingSrflx {
t.Fatalf("Unexpected error: %v", err)
}
// NewAgent should return an error when 1:1 NAT for host candidate is enabled
// along with mDNS with MulticastDNSModeQueryAndGather
_, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{"1.2.3.4"},
NAT1To1IPCandidateType: CandidateTypeHost,
MulticastDNSMode: MulticastDNSModeQueryAndGather,
Trickle: true, // to avoid starting gathering candidates
})
if err != ErrMulticastDNSWithNAT1To1IPMapping {
t.Fatalf("Unexpected error: %v", err)
}
// NewAgent should return if newExternalIPMapper() returns an error.
_, err = NewAgent(&AgentConfig{
NAT1To1IPs: []string{"bad.2.3.4"}, // bad IP
NAT1To1IPCandidateType: CandidateTypeHost,
Trickle: true, // to avoid starting gathering candidates
})
if err != ErrInvalidNAT1To1IPMapping {
t.Fatalf("Unexpected error: %v", err)
}
} | explode_data.jsonl/50573 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1084
} | [
2830,
3393,
3803,
6756,
3298,
6807,
1155,
353,
8840,
836,
8,
341,
69931,
1669,
1273,
10600,
49,
28628,
1155,
340,
16867,
1895,
2822,
197,
322,
264,
9220,
3298,
10989,
1265,
387,
2092,
553,
1638,
198,
11323,
11,
1848,
1669,
1532,
16810,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestList_UnmarshalValue(t *testing.T) {
type TList struct {
Name string
List *List
}
// JSON
gtest.C(t, func(t *gtest.T) {
var tlist *TList
err := gconv.Struct(map[string]interface{}{
"name": "john",
"list": []byte(`[1,2,3]`),
}, &tlist)
t.Assert(err, nil)
t.Assert(tlist.Name, "john")
t.Assert(tlist.List.FrontAll(), []interface{}{1, 2, 3})
})
// Map
gtest.C(t, func(t *gtest.T) {
var tlist *TList
err := gconv.Struct(map[string]interface{}{
"name": "john",
"list": []interface{}{1, 2, 3},
}, &tlist)
t.Assert(err, nil)
t.Assert(tlist.Name, "john")
t.Assert(tlist.List.FrontAll(), []interface{}{1, 2, 3})
})
} | explode_data.jsonl/30918 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 325
} | [
2830,
3393,
852,
40687,
27121,
1130,
1155,
353,
8840,
836,
8,
341,
13158,
350,
852,
2036,
341,
197,
21297,
914,
198,
197,
10675,
353,
852,
198,
197,
532,
197,
322,
4718,
198,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
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... | 1 |
func TestAccAWSDBClusterParameterGroup_importBasic(t *testing.T) {
resourceName := "aws_rds_cluster_parameter_group.bar"
parameterGroupName := fmt.Sprintf("cluster-parameter-group-test-terraform-%d", acctest.RandInt())
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBClusterParameterGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBClusterParameterGroupConfig(parameterGroupName),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
} | explode_data.jsonl/77483 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
14603,
36136,
3506,
28678,
4971,
2808,
18434,
15944,
1155,
353,
8840,
836,
8,
341,
50346,
675,
1669,
330,
8635,
1710,
5356,
28441,
24899,
6288,
22001,
1837,
197,
16181,
50569,
1669,
8879,
17305,
445,
18855,
89412,
4351,
16839,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindAll(t *testing.T) {
svgElement := testElement()
equalSlices(t, "Find", []*svgparser.Element{
element("rect", map[string]string{"width": "5", "height": "3", "id": "inFirst"}),
element("rect", map[string]string{"width": "5", "height": "2", "id": "inFirst"}),
element("rect", map[string]string{"width": "5", "height": "1"}),
}, svgElement.FindAll("rect"))
equalSlices(t, "Find", []*svgparser.Element{}, svgElement.FindAll("circle"))
} | explode_data.jsonl/74165 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 174
} | [
2830,
3393,
9885,
2403,
1155,
353,
8840,
836,
8,
341,
1903,
7239,
1691,
1669,
1273,
1691,
2822,
7727,
1751,
50,
37414,
1155,
11,
330,
9885,
497,
29838,
15196,
9657,
20139,
515,
197,
43707,
445,
2851,
497,
2415,
14032,
30953,
4913,
3098,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPrimitiveGetString(t *testing.T) {
client := newPrimitiveClient()
result, err := client.GetString(context.Background(), nil)
if err != nil {
t.Fatalf("GetString: %v", err)
}
if r := cmp.Diff(result.StringWrapper, StringWrapper{
Empty: to.StringPtr(""),
Field: to.StringPtr("goodrequest"),
}); r != "" {
t.Fatal(r)
}
} | explode_data.jsonl/61680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
33313,
48905,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
33313,
2959,
741,
9559,
11,
1848,
1669,
2943,
21166,
5378,
19047,
1507,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
48905,
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,
1... | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.