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 TestUserStringWith(t *testing.T) {
user := tgbotapi.User{
ID: 0,
FirstName: "Test",
LastName: "Test",
UserName: "",
LanguageCode: "en",
IsBot: false,
}
if user.String() != "Test Test" {
t.Fail()
}
} | explode_data.jsonl/25792 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
1474,
703,
2354,
1155,
353,
8840,
836,
8,
341,
19060,
1669,
53188,
6331,
2068,
7344,
515,
197,
29580,
25,
1843,
220,
15,
345,
197,
197,
26584,
25,
262,
330,
2271,
756,
197,
197,
27920,
25,
257,
330,
2271,
756,
197,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestTarDestinationName(t *testing.T) {
dir, err := ioutil.TempDir(os.TempDir(), "input")
dir2, err2 := ioutil.TempDir(os.TempDir(), "output")
if err != nil || err2 != nil {
t.Errorf("unexpected error: %v | %v", err, err2)
t.FailNow()
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Errorf("Unexpected error cleaning up: %v", err)
}
if err := os.RemoveAll(dir2); err != nil {
t.Errorf("Unexpected error cleaning up: %v", err)
}
}()
files := []struct {
name string
data string
}{
{
name: "foo",
data: "foobarbaz",
},
{
name: "dir/blah",
data: "bazblahfoo",
},
{
name: "some/other/directory",
data: "with more data here",
},
{
name: "blah",
data: "same file name different data",
},
}
// ensure files exist on disk
for _, file := range files {
filepath := path.Join(dir, file.name)
if err := os.MkdirAll(path.Dir(filepath), 0755); err != nil {
t.Errorf("unexpected error: %v", err)
t.FailNow()
}
createTmpFile(t, filepath, file.data)
}
reader, writer := io.Pipe()
go func() {
if err := makeTar(dir, dir2, writer); err != nil {
t.Errorf("unexpected error: %v", err)
}
}()
tarReader := tar.NewReader(reader)
for {
hdr, err := tarReader.Next()
if err == io.EOF {
break
} else if err != nil {
t.Errorf("unexpected error: %v", err)
t.FailNow()
}
if !strings.HasPrefix(hdr.Name, path.Base(dir2)) {
t.Errorf("expected %q as destination filename prefix, saw: %q", path.Base(dir2), hdr.Name)
}
}
} | explode_data.jsonl/58289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 675
} | [
2830,
3393,
62733,
33605,
675,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
9638,
65009,
6184,
1507,
330,
1355,
1138,
48532,
17,
11,
1848,
17,
1669,
43144,
65009,
6184,
9638,
65009,
6184,
1507,
330,
3006,
113... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRepo(t *testing.T) {
repo := &model.Repository{
GitHubRepo: model.GitHubRepo{
Owner: "tower",
RepoName: "div",
},
URL: "https://xxx",
DefaultBranch: "blue",
InstallID: 9,
}
branch := &model.Branch{
GitHubBranch: model.GitHubBranch{
Branch: "blue",
},
LastScannedAt: 1234,
ReportSummary: model.ScanReportSummary{
PkgTypes: []model.PkgType{model.PkgRubyGems},
PkgCount: 3,
VulnCount: 2,
VulnPkgCount: 1,
},
}
t.Run("Update default branch status", func(t *testing.T) {
client := newTestTable(t)
inserted, err := client.InsertRepo(repo)
require.NoError(t, err)
assert.True(t, inserted)
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, branch))
r1, err := client.FindRepoByFullName(repo.Owner, repo.RepoName)
require.NoError(t, err)
assert.Equal(t, r1.Branch, *branch)
})
t.Run("Update default branch status if LastScannedAt is greater", func(t *testing.T) {
client := newTestTable(t)
inserted, err := client.InsertRepo(repo)
require.NoError(t, err)
assert.True(t, inserted)
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, branch))
b2 := &model.Branch{
GitHubBranch: model.GitHubBranch{
Branch: "blue",
},
LastScannedAt: 2345,
ReportSummary: model.ScanReportSummary{
PkgTypes: []model.PkgType{model.PkgRubyGems},
PkgCount: 4,
VulnCount: 5,
VulnPkgCount: 6,
},
}
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, b2))
r1, err := client.FindRepoByFullName(repo.Owner, repo.RepoName)
require.NoError(t, err)
assert.Equal(t, r1.Branch, *b2)
})
t.Run("Do not update default branch status if LastScannedAt is lesser", func(t *testing.T) {
client := newTestTable(t)
inserted, err := client.InsertRepo(repo)
require.NoError(t, err)
assert.True(t, inserted)
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, branch))
b2 := &model.Branch{
GitHubBranch: model.GitHubBranch{
Branch: "blue",
},
LastScannedAt: 1000,
ReportSummary: model.ScanReportSummary{
PkgTypes: []model.PkgType{model.PkgRubyGems},
PkgCount: 4,
VulnCount: 5,
VulnPkgCount: 6,
},
}
// No error, but not updated
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, b2))
r1, err := client.FindRepoByFullName(repo.Owner, repo.RepoName)
require.NoError(t, err)
assert.Equal(t, r1.Branch, *branch)
})
t.Run("Do not update if not default branch", func(t *testing.T) {
client := newTestTable(t)
inserted, err := client.InsertRepo(repo)
require.NoError(t, err)
// Change default branch name
require.NoError(t, client.SetRepoDefaultBranchName(&repo.GitHubRepo, "main"))
assert.True(t, inserted)
require.NoError(t, client.UpdateBranchIfDefault(&repo.GitHubRepo, branch))
r1, err := client.FindRepoByFullName(repo.Owner, repo.RepoName)
require.NoError(t, err)
assert.NotEqual(t, r1.Branch, *branch)
})
} | explode_data.jsonl/79215 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1339
} | [
2830,
3393,
25243,
1155,
353,
8840,
836,
8,
341,
17200,
5368,
1669,
609,
2528,
25170,
515,
197,
9600,
275,
19316,
25243,
25,
1614,
1224,
275,
19316,
25243,
515,
298,
197,
13801,
25,
262,
330,
77578,
756,
298,
197,
25243,
675,
25,
330,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeletionHeaders(t *testing.T) {
world, ri, _, blockingSender, _, _, tlf := setupTest(t, 1)
defer world.Cleanup()
u := world.GetUsers()[0]
trip := newConvTriple(t, tlf, u.Username)
res, err := ri.NewConversationRemote2(context.TODO(), chat1.NewConversationRemote2Arg{
IdTriple: trip,
TLFMessage: chat1.MessageBoxed{
ClientHeader: chat1.MessageClientHeader{
Conv: trip,
TlfName: u.Username,
TlfPublic: false,
},
KeyGeneration: 1,
},
})
require.NoError(t, err)
// Send a message and two edits.
_, firstMessageID, _, err := blockingSender.Send(context.TODO(), res.ConvID, chat1.MessagePlaintext{
ClientHeader: chat1.MessageClientHeader{
Conv: trip,
Sender: u.User.GetUID().ToBytes(),
TlfName: u.Username,
MessageType: chat1.MessageType_TEXT,
},
MessageBody: chat1.NewMessageBodyWithText(chat1.MessageText{Body: "foo"}),
}, 0)
require.NoError(t, err)
_, editID, _, err := blockingSender.Send(context.TODO(), res.ConvID, chat1.MessagePlaintext{
ClientHeader: chat1.MessageClientHeader{
Conv: trip,
Sender: u.User.GetUID().ToBytes(),
TlfName: u.Username,
MessageType: chat1.MessageType_EDIT,
Supersedes: firstMessageID,
},
MessageBody: chat1.NewMessageBodyWithEdit(chat1.MessageEdit{MessageID: firstMessageID, Body: "bar"}),
}, 0)
require.NoError(t, err)
_, editID2, _, err := blockingSender.Send(context.TODO(), res.ConvID, chat1.MessagePlaintext{
ClientHeader: chat1.MessageClientHeader{
Conv: trip,
Sender: u.User.GetUID().ToBytes(),
TlfName: u.Username,
MessageType: chat1.MessageType_EDIT,
Supersedes: firstMessageID,
},
MessageBody: chat1.NewMessageBodyWithEdit(chat1.MessageEdit{MessageID: firstMessageID, Body: "baz"}),
}, 0)
require.NoError(t, err)
// Now prepare a deletion.
deletion := chat1.MessagePlaintext{
ClientHeader: chat1.MessageClientHeader{
Conv: trip,
Sender: u.User.GetUID().ToBytes(),
TlfName: u.Username,
MessageType: chat1.MessageType_DELETE,
Supersedes: firstMessageID,
},
MessageBody: chat1.NewMessageBodyWithDelete(chat1.MessageDelete{MessageIDs: []chat1.MessageID{firstMessageID}}),
}
preparedDeletion, _, err := blockingSender.Prepare(context.TODO(), deletion, &res.ConvID)
require.NoError(t, err)
// Assert that the deletion gets the edit too.
deletedIDs := map[chat1.MessageID]bool{}
for _, id := range preparedDeletion.ClientHeader.Deletes {
deletedIDs[id] = true
}
if len(deletedIDs) != 3 {
t.Fatalf("expected 3 deleted IDs, found %d", len(deletedIDs))
}
if !deletedIDs[firstMessageID] {
t.Fatalf("expected message #%d to be deleted", firstMessageID)
}
if !deletedIDs[editID] {
t.Fatalf("expected message #%d to be deleted", editID)
}
if !deletedIDs[editID2] {
t.Fatalf("expected message #%d to be deleted", editID2)
}
} | explode_data.jsonl/50758 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1202
} | [
2830,
3393,
1912,
52625,
10574,
1155,
353,
8840,
836,
8,
341,
76508,
11,
24185,
11,
8358,
22188,
20381,
11,
8358,
8358,
259,
11008,
1669,
6505,
2271,
1155,
11,
220,
16,
340,
16867,
1879,
727,
60639,
2822,
10676,
1669,
1879,
2234,
7137,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPopulateCluster_TopologyInvalidValue_Required(t *testing.T) {
c := buildMinimalCluster()
c.Spec.Topology.Masters = "123"
c.Spec.Topology.Nodes = "abc"
expectErrorFromPopulateCluster(t, c, "topology")
} | explode_data.jsonl/75044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 82
} | [
2830,
3393,
11598,
6334,
28678,
94819,
2449,
7928,
1130,
62,
8164,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1936,
88328,
28678,
741,
1444,
36473,
17557,
2449,
1321,
14199,
284,
330,
16,
17,
18,
698,
1444,
36473,
17557,
2449,
52184,
284... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestExec(t *testing.T) {
for _, conf := range configs(overlay) {
t.Logf("Running test with conf: %+v", conf)
const uid = 343
spec := testutil.NewSpecWithArgs("sleep", "100")
rootDir, bundleDir, err := testutil.SetupContainer(spec, conf)
if err != nil {
t.Fatalf("error setting up container: %v", err)
}
defer os.RemoveAll(rootDir)
defer os.RemoveAll(bundleDir)
// Create and start the container.
s, err := container.Create(testutil.UniqueContainerID(), spec, conf, bundleDir, "", "")
if err != nil {
t.Fatalf("error creating container: %v", err)
}
defer s.Destroy()
if err := s.Start(conf); err != nil {
t.Fatalf("error starting container: %v", err)
}
// expectedPL lists the expected process state of the container.
expectedPL := []*control.Process{
{
UID: 0,
PID: 1,
PPID: 0,
C: 0,
Cmd: "sleep",
},
{
UID: uid,
PID: 2,
PPID: 0,
C: 0,
Cmd: "sleep",
},
}
// Verify that "sleep 100" is running.
if err := waitForProcessList(s, expectedPL[:1]); err != nil {
t.Error(err)
}
execArgs := control.ExecArgs{
Filename: "/bin/sleep",
Argv: []string{"sleep", "5"},
Envv: []string{"PATH=" + os.Getenv("PATH")},
WorkingDirectory: "/",
KUID: uid,
}
// Verify that "sleep 100" and "sleep 5" are running after exec.
// First, start running exec (whick blocks).
status := make(chan error, 1)
go func() {
exitStatus, err := s.Execute(&execArgs)
if err != nil {
status <- err
} else if exitStatus != 0 {
status <- fmt.Errorf("failed with exit status: %v", exitStatus)
} else {
status <- nil
}
}()
if err := waitForProcessList(s, expectedPL); err != nil {
t.Fatal(err)
}
// Ensure that exec finished without error.
select {
case <-time.After(10 * time.Second):
t.Fatalf("container timed out waiting for exec to finish.")
case st := <-status:
if st != nil {
t.Errorf("container failed to exec %v: %v", execArgs, err)
}
}
}
} | explode_data.jsonl/48919 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 889
} | [
2830,
3393,
10216,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
2335,
1669,
2088,
42309,
7,
21118,
8,
341,
197,
3244,
98954,
445,
18990,
1273,
448,
2335,
25,
68524,
85,
497,
2335,
692,
197,
4777,
14617,
284,
220,
18,
19,
18,
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 TestNestListOfMaps(t *testing.T) {
callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, `
package foo
// Blah is a test.
// +k8s:openapi-gen=true
// +k8s:openapi-gen=x-kubernetes-type-tag:type_test
type Blah struct {
// Nested list of maps
NestedListOfMaps [][]map[string]string
}
`)
if callErr != nil {
t.Fatal(callErr)
}
if funcErr != nil {
t.Fatal(funcErr)
}
assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref),
`, callBuffer.String())
assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Blah is a test.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"NestedListOfMaps": {
SchemaProps: spec.SchemaProps{
Description: "Nested list of maps",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Allows: true,
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
},
},
},
},
},
},
},
},
},
Required: []string{"NestedListOfMaps"},
},
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-type-tag": "type_test",
},
},
},
}
}
`, funcBuffer.String())
} | explode_data.jsonl/3361 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 587
} | [
2830,
3393,
45,
477,
64090,
36562,
1155,
353,
8840,
836,
8,
341,
67288,
7747,
11,
2915,
7747,
11,
2060,
11,
1618,
4095,
11,
2915,
4095,
1669,
1273,
5002,
7082,
929,
6492,
1155,
11,
22074,
1722,
15229,
271,
322,
2502,
1466,
374,
264,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestApplication_FindCepNotFoundNoSaveCepNotFounr(t *testing.T) {
cr := new(CepRepositoryMock)
s := "12345678"
cr.On("GetCep", s).Return(nil, true)
cr.On("SaveCep", s).Return(nil, false)
app := GetInstance(cr)
_, err := app.FindCep(s)
cr.AssertExpectations(t)
assert.Error(t, err, "cep_not_found")
} | explode_data.jsonl/58369 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
4988,
95245,
34,
747,
10372,
2753,
8784,
34,
747,
2623,
37,
1624,
81,
1155,
353,
8840,
836,
8,
341,
91492,
1669,
501,
3025,
747,
4624,
11571,
340,
1903,
1669,
330,
16,
17,
18,
19,
20,
21,
22,
23,
698,
91492,
8071,
445,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNonResourceCoversWildcard(t *testing.T) {
escalationTest{
ownerRules: []authorizationapi.PolicyRule{
{Verbs: sets.NewString("get", "post"), NonResourceURLs: sets.NewString("/foo/*", "/bar/*")},
},
servantRules: []authorizationapi.PolicyRule{
{Verbs: sets.NewString("get", "post"), NonResourceURLs: sets.NewString("/foo/", "/bar/")},
{Verbs: sets.NewString("get", "post"), NonResourceURLs: sets.NewString("/foo/1", "/bar/1")},
{Verbs: sets.NewString("get", "post"), NonResourceURLs: sets.NewString("/foo/*", "/bar/*")},
},
expectedCovered: true,
}.test(t)
} | explode_data.jsonl/9062 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 227
} | [
2830,
3393,
8121,
4783,
34,
8969,
92988,
1155,
353,
8840,
836,
8,
341,
80629,
278,
367,
2271,
515,
197,
197,
8118,
26008,
25,
3056,
39554,
2068,
1069,
8018,
11337,
515,
298,
197,
90,
10141,
1279,
25,
7289,
7121,
703,
445,
455,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTagSuccess(t *testing.T) {
testRepo := newTestRepo(t)
defer testRepo.cleanup(t)
testTag := "testTag"
require.Nil(t, testRepo.sut.Tag(testTag, "message"))
tags, err := testRepo.sut.TagsForBranch(testRepo.branchName)
require.Nil(t, err)
require.Contains(t, tags, testTag)
} | explode_data.jsonl/14044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 124
} | [
2830,
3393,
5668,
7188,
1155,
353,
8840,
836,
8,
341,
18185,
25243,
1669,
501,
2271,
25243,
1155,
340,
16867,
1273,
25243,
87689,
1155,
692,
18185,
5668,
1669,
330,
1944,
5668,
698,
17957,
59678,
1155,
11,
1273,
25243,
514,
332,
23676,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDefaultPost(t *testing.T) {
assert.NotEqual(t, "NYC", Get("state"))
SetDefault("state", "NYC")
assert.Equal(t, "NYC", Get("state"))
} | explode_data.jsonl/5548 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 60
} | [
2830,
3393,
3675,
4133,
1155,
353,
8840,
836,
8,
341,
6948,
15000,
2993,
1155,
11,
330,
23054,
34,
497,
2126,
445,
2454,
5455,
22212,
3675,
445,
2454,
497,
330,
23054,
34,
1138,
6948,
12808,
1155,
11,
330,
23054,
34,
497,
2126,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestDeleteValid(t *testing.T) {
storage := makeClusterTestStorage()
ctx := kapi.WithUser(kapi.WithNamespace(kapi.NewContext(), ""), &user.DefaultInfo{Name: "system:admin"})
obj, err := storage.Delete(ctx, "cluster-admins", nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
switch r := obj.(type) {
case *unversioned.Status:
if r.Status != "Success" {
t.Fatalf("Got back non-success status: %#v", r)
}
default:
t.Fatalf("Got back non-status result: %v", r)
}
} | explode_data.jsonl/80718 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 196
} | [
2830,
3393,
6435,
4088,
1155,
353,
8840,
836,
8,
341,
197,
16172,
1669,
1281,
28678,
2271,
5793,
2822,
20985,
1669,
595,
2068,
26124,
1474,
5969,
2068,
26124,
22699,
5969,
2068,
7121,
1972,
1507,
77130,
609,
872,
13275,
1731,
63121,
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... | 4 |
func TestSendEthereumClaims(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockCosmos := mocks.NewMockCosmosClient(mockCtrl)
mockCosmos.EXPECT().FromAddress().Return(sdk.AccAddress{}).AnyTimes()
biggerNonceMatcher := HasBiggerNonce(0)
mockCosmos.EXPECT().SyncBroadcastMsg(biggerNonceMatcher).Return(&sdk.TxResponse{}, nil).Times(8)
s := peggyBroadcastClient{
daemonQueryClient: nil,
broadcastClient: mockCosmos,
}
deposits := []*wrappers.PeggySendToCosmosEvent{
{
EventNonce: big.NewInt(2),
Amount: big.NewInt(123),
},
{
EventNonce: big.NewInt(6),
Amount: big.NewInt(456),
},
}
withdraws := []*wrappers.PeggyTransactionBatchExecutedEvent{
{
EventNonce: big.NewInt(1),
BatchNonce: big.NewInt(0),
},
{
EventNonce: big.NewInt(3),
BatchNonce: big.NewInt(0),
},
}
valsetUpdates := []*wrappers.PeggyValsetUpdatedEvent{
{
EventNonce: big.NewInt(4),
NewValsetNonce: big.NewInt(0),
RewardAmount: big.NewInt(0),
},
{
EventNonce: big.NewInt(5),
NewValsetNonce: big.NewInt(0),
RewardAmount: big.NewInt(0),
},
{
EventNonce: big.NewInt(7),
NewValsetNonce: big.NewInt(0),
RewardAmount: big.NewInt(0),
},
}
erc20Deployed := []*wrappers.PeggyERC20DeployedEvent{
{
EventNonce: big.NewInt(8),
},
}
s.SendEthereumClaims(context.Background(),
0,
deposits,
withdraws,
valsetUpdates,
erc20Deployed,
time.Microsecond,
)
} | explode_data.jsonl/19860 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 693
} | [
2830,
3393,
11505,
36,
18532,
372,
51133,
1155,
353,
8840,
836,
8,
1476,
77333,
15001,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
16867,
7860,
15001,
991,
18176,
2822,
77333,
54224,
8631,
1669,
68909,
7121,
11571,
54224,
8631,
2959,
303... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWatcherUnsubscribe(t *testing.T) {
var err error
timeout := 100 * time.Millisecond * timeMultiplier
// test an error is returned without subscription
t.Run("no subscription", func(t *testing.T) {
w := NewWatcher(nil, nil)
if err := w.Unsubscribe("non-existent"); err == nil {
t.Errorf("did not return an error for Unsubscribe call without subscription")
}
})
// test unsubscription prevents further events from being sent
t.Run("prevents further events", func(t *testing.T) {
wi := watch.NewRaceFreeFake()
mock := &podWatcherMock{wi: wi}
w := NewWatcher(mock, nil)
if err = w.Start(); err != nil {
t.Fatalf("setup failed, Start returned error: %v", err)
}
sessionName := "session-one"
eventChan, err := w.Subscribe(sessionName)
if err != nil {
t.Fatalf("subscribe unexpectedly returned error for %v: %v", sessionName, err)
}
if err = w.Unsubscribe(sessionName); err != nil {
t.Fatalf("Unsubscribe unexpectedly returned error: %v", err)
}
wi.Add(newPodWithSessionName(t, sessionName))
select {
case event := <-eventChan:
if event != nil {
t.Errorf("received event unexpectedly: %v", event)
}
case <-time.After(timeout):
break // never passed is also valid
}
})
} | explode_data.jsonl/38177 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 445
} | [
2830,
3393,
47248,
1806,
9384,
1155,
353,
8840,
836,
8,
341,
2405,
1848,
1465,
198,
78395,
1669,
220,
16,
15,
15,
353,
882,
71482,
353,
882,
66873,
271,
197,
322,
1273,
458,
1465,
374,
5927,
2041,
15142,
198,
3244,
16708,
445,
2152,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDcodeStruct(t *testing.T) {
//t.Skip("skipping TestDcodeStruct")
u := User{}
_ = CodecDecode("82a249640aa44e616d65aa6861727279206461796f", &u)
if u.ID != 10 {
t.Errorf("CodecDecode result: %+v", u)
}
} | explode_data.jsonl/30440 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 101
} | [
2830,
3393,
35,
1851,
9422,
1155,
353,
8840,
836,
8,
341,
197,
322,
83,
57776,
445,
4886,
5654,
3393,
35,
1851,
9422,
5130,
10676,
1669,
2657,
16094,
197,
62,
284,
67077,
32564,
445,
23,
17,
64,
17,
19,
24,
21,
19,
15,
5305,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_New(t *testing.T) {
table := []Ident{
{"", []string{}},
{"widget", []string{"widget"}},
{"widget_id", []string{"widget", "ID"}},
{"WidgetID", []string{"Widget", "ID"}},
{"Widget_ID", []string{"Widget", "ID"}},
{"widget_ID", []string{"widget", "ID"}},
{"widget/ID", []string{"widget", "ID"}},
{"widgetID", []string{"widget", "ID"}},
{"widgetName", []string{"widget", "Name"}},
{"JWTName", []string{"JWT", "Name"}},
{"JWTname", []string{"JWTname"}},
{"jwtname", []string{"jwtname"}},
{"sql", []string{"SQL"}},
{"sQl", []string{"SQL"}},
{"id", []string{"ID"}},
{"Id", []string{"ID"}},
{"iD", []string{"ID"}},
{"html", []string{"HTML"}},
{"Html", []string{"HTML"}},
{"HTML", []string{"HTML"}},
{"with `code` inside", []string{"with", "`code`", "inside"}},
{"Donald E. Knuth", []string{"Donald", "E.", "Knuth"}},
{"Random text with *(bad)* characters", []string{"Random", "text", "with", "*(bad)*", "characters"}},
{"Allow_Under_Scores", []string{"Allow", "Under", "Scores"}},
{"Trailing bad characters!@#", []string{"Trailing", "bad", "characters!@#"}},
{"!@#Leading bad characters", []string{"!@#", "Leading", "bad", "characters"}},
{"Squeeze separators", []string{"Squeeze", "separators"}},
{"Test with + sign", []string{"Test", "with", "sign"}},
{"Malmö", []string{"Malmö"}},
{"Garçons", []string{"Garçons"}},
{"Opsů", []string{"Opsů"}},
{"Ærøskøbing", []string{"Ærøskøbing"}},
{"Aßlar", []string{"Aßlar"}},
{"Japanese: 日本語", []string{"Japanese", "日本語"}},
}
for _, tt := range table {
t.Run(tt.Original, func(st *testing.T) {
r := require.New(st)
i := New(tt.Original)
r.Equal(tt.Original, i.Original)
r.Equal(tt.Parts, i.Parts)
})
}
} | explode_data.jsonl/82649 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 730
} | [
2830,
3393,
39582,
1155,
353,
8840,
836,
8,
341,
26481,
1669,
3056,
28301,
515,
197,
197,
4913,
497,
3056,
917,
6257,
1583,
197,
197,
4913,
9797,
497,
3056,
917,
4913,
9797,
48085,
197,
197,
4913,
9797,
842,
497,
3056,
917,
4913,
9797... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTeamsService_RemoveTeamRepoBySlug(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/orgs/org/teams/slug/repos/owner/repo", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
w.WriteHeader(http.StatusNoContent)
})
ctx := context.Background()
_, err := client.Teams.RemoveTeamRepoBySlug(ctx, "org", "slug", "owner", "repo")
if err != nil {
t.Errorf("Teams.RemoveTeamRepoBySlug returned error: %v", err)
}
const methodName = "RemoveTeamRepoBySlug"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Teams.RemoveTeamRepoBySlug(ctx, "\n", "\n", "\n", "\n")
return err
})
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Teams.RemoveTeamRepoBySlug(ctx, "org", "slug", "owner", "repo")
})
} | explode_data.jsonl/4541 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 336
} | [
2830,
3393,
60669,
1860,
66843,
14597,
25243,
1359,
54968,
1155,
353,
8840,
836,
8,
341,
25291,
11,
59807,
11,
8358,
49304,
1669,
6505,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
1775,
82,
41361,
14,
38496,
2687,
43213,
49505,
14,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHTTP_BuildingURL(t *testing.T) {
t.Parallel()
baseUrl := "http://example.com"
cases := []struct {
name string
startingUrl string
path string
queryParams string
expectedURL string
}{
{
"one of each",
baseUrl,
`"one"`,
`"firstKey=firstVal"`,
"http://example.com/one?firstKey=firstVal",
},
{
"query params no path",
baseUrl,
`""`,
`"firstKey=firstVal"`,
"http://example.com?firstKey=firstVal",
},
{
"path no query params",
baseUrl,
`"one"`,
`""`,
"http://example.com/one",
},
{
"many of each",
baseUrl,
`"one/two/three"`,
`"firstKey=firstVal&secondKey=secondVal"`,
"http://example.com/one/two/three?firstKey=firstVal&secondKey=secondVal",
},
{
"existing path",
"http://example.com/one",
`"two"`,
`"firstKey=firstVal"`,
"http://example.com/one/two?firstKey=firstVal",
},
{
"existing query param",
"http://example.com?firstKey=firstVal",
`"one"`,
`"secondKey=secondVal"`,
"http://example.com/one?firstKey=firstVal&secondKey=secondVal",
},
{
"existing path and query param",
"http://example.com/one?firstKey=firstVal",
`"two"`,
`"secondKey=secondVal"`,
"http://example.com/one/two?firstKey=firstVal&secondKey=secondVal",
},
}
for _, test := range cases {
t.Run(test.name, func(t *testing.T) {
ep := adapters.ExtendedPath{}
qp := adapters.QueryParameters{}
err := json.Unmarshal([]byte(test.path), &ep)
err = json.Unmarshal([]byte(test.queryParams), &qp)
hga := adapters.HTTPGet{
URL: cltest.WebURL(t, test.startingUrl),
QueryParams: qp,
ExtendedPath: ep,
}
hpa := adapters.HTTPPost{
URL: cltest.WebURL(t, test.startingUrl),
QueryParams: qp,
ExtendedPath: ep,
}
requestGET, _ := hga.GetRequest()
assert.Equal(t, test.expectedURL, requestGET.URL.String())
requestPOST, _ := hpa.GetRequest("")
assert.Equal(t, test.expectedURL, requestPOST.URL.String())
assert.Nil(t, err)
})
}
} | explode_data.jsonl/36143 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 939
} | [
2830,
3393,
9230,
96686,
287,
3144,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
24195,
2864,
1669,
330,
1254,
1110,
8687,
905,
1837,
1444,
2264,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
21375,
287,
2864,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPluginErrorNoResult(t *testing.T) {
ctx := context.Background()
manager, _ := plugins.New(nil, "test-instance-id", inmem.New())
backend := &testPlugin{}
manager.Register("test_plugin", backend)
config, err := ParseConfig([]byte(`{"plugin": "test_plugin"}`), nil, []string{"test_plugin"})
if err != nil {
t.Fatal(err)
}
plugin := New(config, manager)
plugin.Log(ctx, &server.Info{Error: fmt.Errorf("some error")})
plugin.Log(ctx, &server.Info{Error: ast.Errors{&ast.Error{
Code: "some_error",
}}})
if len(backend.events) != 2 || backend.events[0].Error == nil || backend.events[1].Error == nil {
t.Fatal("Unexpected events:", backend.events)
}
} | explode_data.jsonl/2169 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 250
} | [
2830,
3393,
11546,
1454,
2753,
2077,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
92272,
11,
716,
1669,
17215,
7121,
27907,
11,
330,
1944,
73655,
12897,
497,
304,
10536,
7121,
12367,
197,
20942,
1669,
609,
1944,
11546,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConditions(t *testing.T) {
cases := []struct {
in WhereConditions
source string
tags map[string]string
fields map[string]interface{}
pass bool
}{
{ // multi conditions
fields: map[string]interface{}{"a": int64(2), "c": "xyz"},
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: GT,
LHS: &Identifier{Name: "b"},
RHS: &NumberLiteral{IsInt: true, Int: int64(1)},
},
},
},
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: GT,
LHS: &Identifier{Name: "d"},
RHS: &NumberLiteral{IsInt: true, Int: int64(1)},
},
},
},
},
pass: false,
},
{
fields: map[string]interface{}{"a": int64(2)},
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: GT,
LHS: &Identifier{Name: "a"},
RHS: &NumberLiteral{IsInt: true, Int: int64(1)},
},
},
},
},
pass: true,
},
{
pass: true,
fields: map[string]interface{}{"a": "abc"},
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: IN,
LHS: &Identifier{Name: "a"},
RHS: NodeList{
&StringLiteral{Val: "123"},
&StringLiteral{Val: "abc"},
&NumberLiteral{Float: 123.0},
},
},
},
},
},
},
{
pass: true,
source: "abc",
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: IN,
LHS: &Identifier{Name: "source"},
RHS: NodeList{
&StringLiteral{Val: "xyz"},
&StringLiteral{Val: "abc"},
&NumberLiteral{Float: 123.0},
},
},
},
},
},
},
{
pass: true,
source: "abc",
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: NEQ,
LHS: &Identifier{Name: "source"},
RHS: &StringLiteral{Val: "xyz"},
},
},
},
},
},
{
pass: false,
source: "abc",
in: WhereConditions{
&WhereCondition{
conditions: []Node{
&BinaryExpr{
Op: EQ,
LHS: &Identifier{Name: "source"},
RHS: &StringLiteral{Val: "xyz"},
},
},
},
},
},
}
for _, tc := range cases {
tu.Equals(t, tc.pass, tc.in.Eval(tc.source, tc.tags, tc.fields))
t.Logf("[ok] %s => %v, source: %s, tags: %+#v, fields: %+#v", tc.in, tc.pass, tc.source, tc.tags, tc.fields)
}
} | explode_data.jsonl/57795 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1389
} | [
2830,
3393,
35435,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
17430,
257,
10967,
35435,
198,
197,
47418,
914,
198,
197,
3244,
2032,
256,
2415,
14032,
30953,
198,
197,
55276,
2415,
14032,
31344,
16094,
197,
414... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTagCreation(t *testing.T) {
blame := blameutils.SetupBlame(t)
t.Run("GitOrgTagCreation", func(t *testing.T) {
tag := GitOrgTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_org", valueTag.GetKey())
assert.Equal(t, blameutils.Org, valueTag.GetValue())
})
t.Run("GitRepoTagCreation", func(t *testing.T) {
tag := GitRepoTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_repo", valueTag.GetKey())
assert.Equal(t, blameutils.Repository, valueTag.GetValue())
})
t.Run("GitFileTagCreation", func(t *testing.T) {
tag := GitFileTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_file", valueTag.GetKey())
assert.Equal(t, blameutils.FilePath, valueTag.GetValue())
})
t.Run("GitCommitTagCreation", func(t *testing.T) {
tag := GitCommitTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_commit", valueTag.GetKey())
assert.Equal(t, blameutils.CommitHash1, valueTag.GetValue())
})
t.Run("GitLastModifiedAtCreation", func(t *testing.T) {
tag := GitLastModifiedAtTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_last_modified_at", valueTag.GetKey())
assert.Equal(t, "2020-03-28 21:42:46", valueTag.GetValue())
})
t.Run("GitLastModifiedByCreation", func(t *testing.T) {
tag := GitLastModifiedByTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_last_modified_by", valueTag.GetKey())
assert.Equal(t, "schosterbarak@gmail.com", valueTag.GetValue())
})
t.Run("GitModifiersCreation", func(t *testing.T) {
tag := GitModifiersTag{}
valueTag := EvaluateTag(t, &tag, blame)
assert.Equal(t, "git_modifiers", valueTag.GetKey())
assert.Equal(t, "jonjozwiak/schosterbarak", valueTag.GetValue())
})
t.Run("Tag description tests", func(t *testing.T) {
tag := tags.Tag{}
defaultDescription := tag.GetDescription()
cwd, _ := os.Getwd()
g := TagGroup{}
g.InitTagGroup(cwd, nil)
for _, tag := range g.GetTags() {
assert.NotEqual(t, defaultDescription, tag.GetDescription())
assert.NotEqual(t, "", tag.GetDescription())
}
})
} | explode_data.jsonl/75476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 874
} | [
2830,
3393,
5668,
32701,
1155,
353,
8840,
836,
8,
341,
96421,
373,
1669,
18555,
6031,
39820,
4923,
373,
1155,
340,
3244,
16708,
445,
46562,
42437,
5668,
32701,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
60439,
1669,
21120,
42437,
566... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewBoltDB(t *testing.T) {
testdb, err = NewBoltDB("test.db")
if err != nil {
t.Fatalf("Could not create/open database file. %v", err)
}
} | explode_data.jsonl/51081 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 63
} | [
2830,
3393,
3564,
33,
6181,
3506,
1155,
353,
8840,
836,
8,
341,
18185,
1999,
11,
1848,
284,
1532,
33,
6181,
3506,
445,
1944,
7076,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
12895,
537,
1855,
37644,
4625,
1034,
13,
1018,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestNodeListH(t *testing.T) {
stg, _ := storage.Get("mock")
envs.Get().SetStorage(stg)
viper.Set("verbose", 0)
var (
n1 = getNodeAsset("test1", "", true)
n2 = getNodeAsset("test2", "", false)
nl = types.NewNodeList()
)
nl.Items = append(nl.Items, &n1)
nl.Items = append(nl.Items, &n2)
v, err := v1.View().Node().NewList(nl).ToJson()
assert.NoError(t, err)
tests := []struct {
name string
headers map[string]string
handler func(http.ResponseWriter, *http.Request)
expectedBody string
expectedCode int
}{
{
name: "checking get node list successfully",
handler: node.NodeListH,
expectedBody: string(v),
expectedCode: http.StatusOK,
},
}
for _, tc := range tests {
err = envs.Get().GetStorage().Del(context.Background(), stg.Collection().Node().Info(), types.EmptyString)
assert.NoError(t, err)
for _, n := range nl.Items {
err = stg.Put(context.Background(), stg.Collection().Node().Info(), stg.Key().Node(n.Meta.Name), &n, nil)
assert.NoError(t, err)
}
t.Run(tc.name, func(t *testing.T) {
// Create assert request to pass to our handler. We don't have any query parameters for now, so we'll
// pass 'nil' as the third parameter.
req, err := http.NewRequest("GET", "/cluster/node", nil)
assert.NoError(t, err)
if tc.headers != nil {
for key, val := range tc.headers {
req.Header.Set(key, val)
}
}
r := mux.NewRouter()
r.HandleFunc("/cluster/node", tc.handler)
setRequestVars(r, req)
// We create assert ResponseRecorder (which satisfies http.ResponseWriter) to record the response.
res := httptest.NewRecorder()
// Our handlers satisfy http.Handler, so we can call their ServeHTTP method
// directly and pass in our Request and ResponseRecorder.
r.ServeHTTP(res, req)
// Check the status code is what we expect.
assert.Equal(t, tc.expectedCode, res.Code, "status code not equal")
body, err := ioutil.ReadAll(res.Body)
assert.NoError(t, err)
if res.Code == http.StatusOK {
assert.Equal(t, tc.expectedBody, string(v), "status code not error")
} else {
assert.Equal(t, tc.expectedBody, string(body), "incorrect status code")
}
})
}
} | explode_data.jsonl/47394 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 885
} | [
2830,
3393,
1955,
852,
39,
1155,
353,
8840,
836,
8,
1476,
18388,
70,
11,
716,
1669,
5819,
2234,
445,
16712,
1138,
57538,
82,
2234,
1005,
1649,
5793,
5895,
70,
340,
5195,
12858,
4202,
445,
14883,
497,
220,
15,
692,
2405,
2399,
197,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestHeaderStorage(t *testing.T) {
db := NewMemoryDatabase()
// Create a test header to move around the database and make sure it's really new
header := &model.Header{Number: big.NewInt(42), Extra: []byte("test header"), ClaudeCtxHash: &model.ClaudeContextHash{}}
if entry := ReadHeader(db, header.Hash(), header.Number.Uint64()); entry != nil {
t.Fatalf("Non existent header returned: %v", entry)
}
// Write and verify the header in the database
WriteHeader(db, header)
if entry := ReadHeader(db, header.Hash(), header.Number.Uint64()); entry == nil {
t.Fatalf("Stored header not found")
} else if entry.Hash() != header.Hash() {
t.Fatalf("Retrieved header mismatch: have %v, want %v", entry, header)
}
if entry := ReadHeaderRLP(db, header.Hash(), header.Number.Uint64()); entry == nil {
t.Fatalf("Stored header RLP not found")
} else {
hasher := sha3.NewLegacyKeccak256()
hasher.Write(entry)
if hash := common.BytesToHash(hasher.Sum(nil)); hash != header.Hash() {
t.Fatalf("Retrieved RLP header mismatch: have %v, want %v", entry, header)
}
}
// Delete the header and verify the execution
DeleteHeader(db, header.Hash(), header.Number.Uint64())
if entry := ReadHeader(db, header.Hash(), header.Number.Uint64()); entry != nil {
t.Fatalf("Deleted header returned: %v", entry)
}
} | explode_data.jsonl/72779 | {
"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,
4047,
5793,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
1532,
10642,
5988,
2822,
197,
322,
4230,
264,
1273,
4247,
311,
3271,
2163,
279,
4625,
323,
1281,
2704,
432,
594,
2167,
501,
198,
20883,
1669,
609,
2528,
15753,
90,
283... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplication_StartUnified(t *testing.T) {
factories, err := defaults.Components()
assert.Nil(t, err)
app := New(factories)
portArg := []string{
"metrics-port",
}
addresses := getMultipleAvailableLocalAddresses(t, uint(len(portArg)))
for i, addr := range addresses {
_, port, err := net.SplitHostPort(addr)
if err != nil {
t.Fatalf("failed to split host and port from %q: %v", addr, err)
}
app.v.Set(portArg[i], port)
}
app.v.Set("config", "testdata/otelsvc-config.yaml")
appDone := make(chan struct{})
go func() {
defer close(appDone)
if err := app.StartUnified(); err != nil {
t.Errorf("app.StartUnified() got %v, want nil", err)
return
}
}()
<-app.readyChan
// TODO: Add a way to change configuration files so we can get the ports dynamically
if !isAppAvailable(t, "http://localhost:13133") {
t.Fatalf("app didn't reach ready state")
}
// We have to wait here work around a data race bug in Jaeger
// (https://github.com/jaegertracing/jaeger/pull/1625) caused
// by stopping immediately after starting.
//
// Without this Sleep we were observing this bug on our side:
// https://github.com/open-telemetry/opentelemetry-service/issues/43
// The Sleep ensures that Jaeger Start() is fully completed before
// we call Jaeger Stop().
// TODO: Jaeger bug is already fixed, remove this once we update Jaeger
// to latest version.
time.Sleep(1 * time.Second)
close(app.stopTestChan)
<-appDone
} | explode_data.jsonl/63208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 515
} | [
2830,
3393,
4988,
38056,
85379,
1155,
353,
8840,
836,
8,
341,
1166,
52893,
11,
1848,
1669,
16674,
59788,
741,
6948,
59678,
1155,
11,
1848,
692,
28236,
1669,
1532,
955,
52893,
692,
52257,
2735,
1669,
3056,
917,
515,
197,
197,
1,
43262,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewUID(t *testing.T) {
uid, e := NewUID()
if e != nil {
t.Fatal(e)
}
t.Logf("length: %d, uuid: %s", len(uid), uid)
for i := 0; i < 100000; i++ {
u, _ := NewUID()
if u == uid {
t.Fatal("same uuid")
}
}
} | explode_data.jsonl/37080 | {
"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,
3564,
6463,
1155,
353,
8840,
836,
8,
341,
197,
2423,
11,
384,
1669,
1532,
6463,
2822,
743,
384,
961,
2092,
341,
197,
3244,
26133,
2026,
340,
197,
630,
3244,
98954,
445,
4129,
25,
1018,
67,
11,
16040,
25,
1018,
82,
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... | 4 |
func TestConvertRun(t *testing.T) {
tests := map[string]struct {
config common.MapStr
input beat.Event
expected beat.Event
fail bool
errContains string
}{
"missing field": {
config: common.MapStr{
"fields": []common.MapStr{
{"from": "port", "type": "integer"},
{"from": "address", "to": "ip", "type": "ip"},
},
},
input: beat.Event{
Fields: common.MapStr{
"port": "80",
},
},
expected: beat.Event{
Fields: common.MapStr{
"port": "80",
},
},
fail: true,
},
"put error no clone": {
config: common.MapStr{
"fields": []common.MapStr{
{"from": "port", "to": "port.number", "type": "integer"},
},
},
input: beat.Event{
Fields: common.MapStr{
"port": "80",
},
},
expected: beat.Event{
Fields: common.MapStr{
"port": "80",
},
},
fail: true,
},
"put error with clone": {
config: common.MapStr{
"fields": []common.MapStr{
{"from": "id", "to": "event.id", "type": "integer"},
{"from": "port", "to": "port.number", "type": "integer"},
},
},
input: beat.Event{
Fields: common.MapStr{
"id": "32",
"port": "80",
},
},
expected: beat.Event{
Fields: common.MapStr{
"id": "32",
"port": "80",
},
},
fail: true,
},
"invalid conversion": {
config: common.MapStr{
"fields": []common.MapStr{
{"from": "address", "to": "ip", "type": "ip"},
},
},
input: beat.Event{
Fields: common.MapStr{
"address": "-",
},
},
expected: beat.Event{
Fields: common.MapStr{
"address": "-",
},
},
fail: true,
errContains: "unable to convert value [-]: value is not a valid IP address",
},
}
for title, tt := range tests {
t.Run(title, func(t *testing.T) {
processor, err := New(common.MustNewConfigFrom(tt.config))
if err != nil {
t.Fatal(err)
}
result, err := processor.Run(&tt.input)
if tt.expected.Fields != nil {
assert.Equal(t, tt.expected.Fields.Flatten(), result.Fields.Flatten())
assert.Equal(t, tt.expected.Meta.Flatten(), result.Meta.Flatten())
assert.Equal(t, tt.expected.Timestamp, result.Timestamp)
}
if tt.fail {
assert.Error(t, err)
t.Log("got expected error", err)
if tt.errContains != "" {
assert.Contains(t, err.Error(), tt.errContains)
}
return
}
assert.NoError(t, err)
})
}
} | explode_data.jsonl/13566 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1195
} | [
2830,
3393,
12012,
6727,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
25873,
414,
4185,
10104,
2580,
198,
197,
22427,
981,
9382,
6904,
198,
197,
42400,
262,
9382,
6904,
198,
197,
63052,
286,
1807,
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... | 5 |
func TestValidateS3BucketLifecycleStorageClass(t *testing.T) {
validStorageClass := []string{
"STANDARD_IA",
"GLACIER",
}
for _, v := range validStorageClass {
_, errors := validateS3BucketLifecycleStorageClass(v, "storage_class")
if len(errors) != 0 {
t.Fatalf("%q should be valid storage class: %q", v, errors)
}
}
invalidStorageClass := []string{
"STANDARD",
"1234",
}
for _, v := range invalidStorageClass {
_, errors := validateS3BucketLifecycleStorageClass(v, "storage_class")
if len(errors) == 0 {
t.Fatalf("%q should be invalid storage class", v)
}
}
} | explode_data.jsonl/78575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 234
} | [
2830,
3393,
17926,
50,
18,
36018,
62731,
5793,
1957,
1155,
353,
8840,
836,
8,
341,
56322,
5793,
1957,
1669,
3056,
917,
515,
197,
197,
1,
784,
38635,
87490,
756,
197,
197,
1,
3825,
1706,
16289,
756,
197,
630,
2023,
8358,
348,
1669,
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... | 5 |
func TestURLString(t *testing.T) {
testCases := map[string]struct {
t *URL
want string
}{
"nil": {},
"empty": {
t: &URL{},
want: "",
},
"relative": {
t: &URL{Path: "/path/to/something"},
want: "/path/to/something",
},
"nopath": {
t: HTTPS("foo"),
want: "https://foo",
},
"absolute": {
t: &URL{
Scheme: "http",
Host: "path",
Path: "/to/something",
},
want: "http://path/to/something",
},
}
for n, tc := range testCases {
t.Run(n, func(t *testing.T) {
got := tc.t
if diff := cmp.Diff(tc.want, got.String()); diff != "" {
t.Errorf("unexpected string (-want, +got) = %v", diff)
}
if diff := cmp.Diff(tc.want, got.URL().String()); diff != "" {
t.Errorf("unexpected URL (-want, +got) = %v", diff)
}
})
}
} | explode_data.jsonl/71960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 400
} | [
2830,
3393,
3144,
703,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
3244,
262,
353,
3144,
198,
197,
50780,
914,
198,
197,
59403,
197,
197,
79925,
788,
14573,
197,
197,
1,
3194,
788,
341,
298,
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... | 3 |
func TestFormProps(t *testing.T) {
testUnit := dbus.UnitStatus{
Name: "test.service",
LoadState: "loaded",
ActiveState: "active",
SubState: "running",
}
testprops := Properties{
ExecMainPID: 0,
ExecMainStatus: 0,
ExecMainCode: 1,
ActiveEnterTimestamp: 1571850129000000,
IPAccounting: true,
IPEgressBytes: 100,
IPIngressBytes: 50,
IPEgressPackets: 100,
IPIngressPackets: 50,
}
event, err := formProperties(testUnit, testprops)
assert.NoError(t, err)
testEvent := common.MapStr{
"state": "active",
"exec_code": "exited",
"load_state": "loaded",
"name": "test.service",
"state_since": time.Unix(0, 1571850129000000*1000),
"sub_state": "running",
"resources": common.MapStr{"network": common.MapStr{
"in": common.MapStr{
"bytes": 50,
"packets": 50},
"out": common.MapStr{
"bytes": 100,
"packets": 100},
},
},
}
assert.NotEmpty(t, event.MetricSetFields["resources"])
assert.Equal(t, event.MetricSetFields["state_since"], testEvent["state_since"])
assert.NotEmpty(t, event.RootFields)
} | explode_data.jsonl/79843 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
1838,
5992,
1155,
353,
8840,
836,
8,
341,
18185,
4562,
1669,
73696,
25159,
2522,
515,
197,
21297,
25,
286,
330,
1944,
5736,
756,
197,
197,
5879,
1397,
25,
256,
330,
15589,
756,
197,
197,
5728,
1397,
25,
330,
3028,
756,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDocMarshal(t *testing.T) {
result, err := Marshal(docData)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(result, marshalTestToml) {
t.Errorf("Bad marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", marshalTestToml, result)
}
} | explode_data.jsonl/46306 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
9550,
55438,
1155,
353,
8840,
836,
8,
341,
9559,
11,
1848,
1669,
35667,
19153,
1043,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
743,
753,
9651,
12808,
4456,
11,
60771,
2271,
24732,
75,
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... | 3 |
func TestSafePerfGroupLeaderMap(t *testing.T) {
sm := safePerfGroupLeaderMap{}
_, p := sm.lookup(8)
equals(t, false, p)
sm.removeInPlace(map[uint64]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}})
equals(t, 0, len(sm.getMap()))
sm.remove(map[uint64]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}})
equals(t, 0, len(sm.getMap()))
m := newPerfGroupLeaderMap()
m[1] = &perfGroupLeader{source: &dummyPerfGroupLeaderEventSourceLeader{id: 1}}
m[2] = &perfGroupLeader{source: &dummyPerfGroupLeaderEventSourceLeader{id: 2}}
m[3] = &perfGroupLeader{source: &dummyPerfGroupLeaderEventSourceLeader{id: 3}}
sm = safePerfGroupLeaderMap{}
var leaders []*perfGroupLeader
for _, v := range m {
leaders = append(leaders, v)
}
sm.updateInPlace(leaders)
equals(t, 3, len(sm.getMap()))
equals(t, m, sm.getMap())
sm.removeInPlace(map[uint64]struct{}{2: struct{}{}})
delete(m, 2)
equals(t, 2, len(sm.getMap()))
equals(t, m, sm.getMap())
sm = safePerfGroupLeaderMap{}
wg := sync.WaitGroup{}
for i := 0; i < 8; i++ {
wg.Add(1)
go func(i int) {
for x := uint64(0); x < 1000; x++ {
switch x % 3 {
case 0:
s := &dummyPerfGroupLeaderEventSourceLeader{id: x}
l := &perfGroupLeader{source: s}
sm.update([]*perfGroupLeader{l})
case 1:
_, _ = sm.lookup(x)
case 2:
sm.remove(map[uint64]struct{}{x: struct{}{}})
}
}
wg.Done()
}(i)
}
wg.Wait()
} | explode_data.jsonl/17389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 655
} | [
2830,
3393,
25663,
3889,
69,
2808,
52621,
2227,
1155,
353,
8840,
836,
8,
341,
72023,
1669,
6092,
3889,
69,
2808,
52621,
2227,
16094,
197,
6878,
281,
1669,
1525,
39937,
7,
23,
340,
197,
7176,
1155,
11,
895,
11,
281,
692,
72023,
4850,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetURLParameters(t *testing.T) {
mainRouter := Router{}
postsRouter := Router{}
bag := newURLParameterBag(2)
bag.add("id", "100")
bag.add("name", "dummy")
f := assertRequestHasParameterHandler(t, bag)
_ = mainRouter.Register(http.MethodGet, "/path1/{id}/{name:[a-z]{1,5}}", f)
bag2 := newURLParameterBag(2)
bag2.add("name", "dummy/file/src/image.jpg")
f2 := assertRequestHasParameterHandler(t, bag2)
_ = mainRouter.Register(http.MethodGet, "/path1/{name:.*}", f2)
bag3 := newURLParameterBag(2)
bag3.add("name", "2020-05-05")
f3 := assertRequestHasParameterHandler(t, bag3)
_ = mainRouter.Register(http.MethodGet, "/{date:[0-9]{4}-[0-9]{2}-[0-9]{2}}", f3)
bag4 := newURLParameterBag(2)
bag4.add("id", "123")
bag4.add("name", "2020-05-05")
f4 := assertRequestHasParameterHandler(t, bag4)
_ = postsRouter.Register(http.MethodGet, "/{date:[0-9]{4}-[0-9]{2}-[0-9]{2}}", f4)
_ = mainRouter.Prefix("/posts/{id}", &postsRouter)
assertPathFound(t, mainRouter, "GET", "/path1/100/dummy")
assertPathFound(t, mainRouter, "GET", "/path1/dummy/file/src/image.jpg")
assertPathFound(t, mainRouter, "GET", "/2020-05-05")
assertPathFound(t, mainRouter, "GET", "/posts/123/2020-05-05")
} | explode_data.jsonl/31720 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 517
} | [
2830,
3393,
1949,
3144,
9706,
1155,
353,
8840,
836,
8,
341,
36641,
9523,
1669,
10554,
16094,
197,
12664,
9523,
1669,
10554,
31483,
2233,
351,
1669,
501,
3144,
4971,
12933,
7,
17,
340,
2233,
351,
1364,
445,
307,
497,
330,
16,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCalSegment(t *testing.T) {
t2, _ := ParseTimestamp("20190702", "20060102")
calc := dayCalculator
t1, _ := calc.ParseSegmentTime("20190702")
assert.Equal(t, t2, t1)
t2, _ = ParseTimestamp("201907", "200601")
calc = monthCalculator
t1, _ = calc.ParseSegmentTime("201907")
assert.Equal(t, t2, t1)
t2, _ = ParseTimestamp("2019", "2006")
calc = yearCalculator
t1, _ = calc.ParseSegmentTime("2019")
assert.Equal(t, t2, t1)
} | explode_data.jsonl/75705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
8851,
21086,
1155,
353,
8840,
836,
8,
341,
3244,
17,
11,
716,
1669,
14775,
20812,
445,
17,
15,
16,
24,
15,
22,
15,
17,
497,
330,
17,
15,
15,
21,
15,
16,
15,
17,
1138,
1444,
16927,
1669,
1899,
55743,
198,
3244,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRedefineBuiltin(t *testing.T) {
gopClTest(t, `
func main() {
const a = append + len
}
const (
append = iota
len
)
`, `package main
const (
append = iota
len
)
func main() {
const a = append + len
}
`)
} | explode_data.jsonl/73575 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 96
} | [
2830,
3393,
49,
4219,
482,
33,
25628,
1155,
353,
8840,
836,
8,
341,
3174,
453,
5066,
2271,
1155,
11,
22074,
2830,
1887,
368,
341,
4777,
264,
284,
8737,
488,
2422,
198,
630,
1024,
2399,
82560,
284,
81910,
198,
33111,
198,
340,
7808,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetCreateCASTemplate(t *testing.T) {
sc := &v1_storage.StorageClass{}
sc.Annotations = make(map[string]string)
tests := map[string]struct {
scCreateCASAnnotation string
scCASTypeAnnotation string
envJivaCAST string
envCStorCAST string
expectedCAST string
}{
"CAST annotation is present": {
"cast-create-from-annotation",
"",
"",
"",
"cast-create-from-annotation",
},
"CAST annotation is absent/empty and cas type is cstor": {
"",
"cstor",
"",
"cast-cstor-create-from-env",
"cast-cstor-create-from-env",
},
"CAST annotation is absent/empty and cas type is jiva": {
"",
"jiva",
"cast-jiva-create-from-env",
"",
"cast-jiva-create-from-env",
},
"CAST annotation is absent/empty and cas type unknown": {
"",
"unknown",
"cast-jiva-create-from-env",
"cast-cstor-create-from-env",
"",
},
}
defer func() {
os.Unsetenv(string(menv.CASTemplateToCreateCStorSnapshotENVK))
os.Unsetenv(string(menv.CASTemplateToCreateJivaSnapshotENVK))
}()
for name, test := range tests {
t.Run(name, func(t *testing.T) {
sc.Annotations[string(v1alpha1.CASTemplateKeyForSnapshotCreate)] = test.scCreateCASAnnotation
sc.Annotations[string(v1alpha1.CASTypeKey)] = test.scCASTypeAnnotation
os.Setenv(string(menv.CASTemplateToCreateCStorSnapshotENVK), test.envCStorCAST)
os.Setenv(string(menv.CASTemplateToCreateJivaSnapshotENVK), test.envJivaCAST)
castName := getCreateCASTemplate(sc)
if castName != test.expectedCAST {
t.Fatalf("unexpected cast name, wanted %q got %q", test.expectedCAST, castName)
}
})
}
} | explode_data.jsonl/561 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 713
} | [
2830,
3393,
1949,
4021,
34163,
3708,
1155,
353,
8840,
836,
8,
341,
29928,
1669,
609,
85,
16,
23310,
43771,
1957,
16094,
29928,
91172,
284,
1281,
9147,
14032,
30953,
340,
78216,
1669,
2415,
14032,
60,
1235,
341,
197,
29928,
4021,
87516,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoute_GetDeployment(t *testing.T) {
route := Route{}
route.deployment = "example"
got := route.GetDeployment()
if got != route.deployment {
t.Errorf("GetDeployment() = %s, want %s", got, route.deployment)
}
} | explode_data.jsonl/67781 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 87
} | [
2830,
3393,
4899,
13614,
75286,
1155,
353,
8840,
836,
8,
341,
7000,
2133,
1669,
9572,
16094,
7000,
2133,
2285,
52799,
284,
330,
8687,
698,
3174,
354,
1669,
6021,
2234,
75286,
2822,
743,
2684,
961,
6021,
2285,
52799,
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
] | 2 |
func TestQueryInterfaceNoParam(t *testing.T) {
assert.NoError(t, prepareEngine())
type GetVar5 struct {
Id int64 `xorm:"autoincr pk"`
Msg bool `xorm:"bit"`
}
assert.NoError(t, testEngine.Sync2(new(GetVar5)))
var data = GetVar5{
Msg: false,
}
_, err := testEngine.Insert(data)
assert.NoError(t, err)
records, err := testEngine.Table("get_var5").Limit(1).QueryInterface()
assert.NoError(t, err)
assert.EqualValues(t, 1, len(records))
assert.EqualValues(t, 1, toInt64(records[0]["id"]))
assert.EqualValues(t, 0, toInt64(records[0]["msg"]))
records, err = testEngine.Table("get_var5").Where(builder.Eq{"id": 1}).QueryInterface()
assert.NoError(t, err)
assert.EqualValues(t, 1, len(records))
assert.EqualValues(t, 1, toInt64(records[0]["id"]))
assert.EqualValues(t, 0, toInt64(records[0]["msg"]))
} | explode_data.jsonl/70220 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 346
} | [
2830,
3393,
2859,
5051,
2753,
2001,
1155,
353,
8840,
836,
8,
341,
6948,
35699,
1155,
11,
10549,
4571,
12367,
13158,
2126,
3962,
20,
2036,
341,
197,
67211,
220,
526,
21,
19,
1565,
87,
493,
2974,
3902,
98428,
22458,
8805,
197,
197,
6611... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValueUndefined(t *testing.T) {
t.Parallel()
ctx, cancel := testAllocate(t, "form.html")
defer cancel()
var value string
err := Run(ctx, Value("foo", &value, ByID))
want := `could not retrieve attribute "value": encountered an undefined value`
got := fmt.Sprint(err)
if !strings.Contains(got, want) {
t.Fatalf("want error %q, got %q", want, got)
}
} | explode_data.jsonl/59473 | {
"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,
1130,
30571,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
1273,
75380,
1155,
11,
330,
627,
2564,
1138,
16867,
9121,
2822,
2405,
897,
914,
198,
9859,
1669,
6452,
7502,
11,
5162,
445,
7975,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRequireTxt(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
console.log(require('./test.txt'))
`,
"/test.txt": `This is a test.`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38478 | {
"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,
17959,
35629,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
12160,
1665,
23482,
8283,
1944,
3909... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateFromPartialFile(t *testing.T) {
partialApp :=
`metadata:
labels:
labels.local/from-file: file
labels.local/from-args: file
annotations:
annotations.local/from-file: file
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
syncPolicy:
automated:
prune: true
`
path := "helm-values"
Given(t).
When().
// app should be auto-synced once created
CreateFromPartialFile(partialApp, "--path", path, "-l", "labels.local/from-args=args", "--helm-set", "foo=foo").
Then().
Expect(Success("")).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(NoConditions()).
And(func(app *Application) {
assert.Equal(t, map[string]string{"labels.local/from-file": "file", "labels.local/from-args": "args"}, app.ObjectMeta.Labels)
assert.Equal(t, map[string]string{"annotations.local/from-file": "file"}, app.ObjectMeta.Annotations)
assert.Equal(t, []string{"resources-finalizer.argocd.argoproj.io"}, app.ObjectMeta.Finalizers)
assert.Equal(t, path, app.Spec.Source.Path)
assert.Equal(t, []HelmParameter{{Name: "foo", Value: "foo"}}, app.Spec.Source.Helm.Parameters)
})
} | explode_data.jsonl/35664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 443
} | [
2830,
3393,
4021,
3830,
37314,
1703,
1155,
353,
8840,
836,
8,
341,
3223,
20894,
2164,
19687,
197,
197,
63,
17637,
510,
220,
9201,
510,
262,
9201,
11033,
91106,
14203,
25,
1034,
198,
262,
9201,
11033,
91106,
12,
2116,
25,
1034,
198,
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 TestCache(t *testing.T) {
// Register the test.
NewWithT(t)
// Init dinero client.
client := NewClient(appID, "AUD", 1*time.Minute)
// Get latest forex rates.
response1, err := client.Rates.List()
if err != nil {
if strings.HasPrefix(err.Error(), setBaseNotAllowedResponsePrefix) {
t.Skipf("skipping test, unsuitable app ID: %s", err)
}
t.Fatalf("Unexpected error running client.Rates.List(): %s", err.Error())
}
// Fetch results again
response2, ok := client.Cache.Get("AUD", time.Now())
if !ok {
t.Fatalf("Expected response when fetching from cache for base currency AUD, got: %v", response2)
}
first, _ := json.Marshal(response1)
second, _ := json.Marshal(response2)
Expect(first).To(MatchJSON(second))
// Expire the cache
client.Cache.Expire("AUD", time.Now())
// Fetch results again (from the cache), now it's cleared.
response2, _ = client.Cache.Get("AUD", time.Now())
// Should be nothing.
Expect(response2).Should(BeNil())
} | explode_data.jsonl/72017 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 351
} | [
2830,
3393,
8233,
1155,
353,
8840,
836,
8,
341,
197,
322,
8451,
279,
1273,
624,
197,
3564,
2354,
51,
1155,
692,
197,
322,
15690,
65808,
2943,
624,
25291,
1669,
1532,
2959,
11462,
915,
11,
330,
61278,
497,
220,
16,
77053,
75770,
692,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestInitialBoardAdvanceP1Wins(t *testing.T) {
b := InitialBoard()
b.P1.Direction = Right
b.P2.Direction = Right
w, _ := b.Advance()
assert.Equal(t, w, (Winner)(P1Wins))
} | explode_data.jsonl/7801 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
6341,
11932,
95027,
47,
16,
96186,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
4127,
11932,
2822,
2233,
1069,
16,
47282,
284,
10083,
198,
2233,
1069,
17,
47282,
284,
10083,
271,
6692,
11,
716,
1669,
293,
17865,
85,
681,
2822... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCreateNewTasks(t *testing.T) {
t.Parallel()
req := &swarming.SwarmingRpcsNewTaskRequest{Name: "hello!"}
expectReq := &swarming.SwarmingRpcsTaskRequest{Name: "hello!"}
c := context.Background()
Convey(`Test fatal response`, t, func() {
service := &testService{
newTask: func(c context.Context, req *swarming.SwarmingRpcsNewTaskRequest) (*swarming.SwarmingRpcsTaskRequestMetadata, error) {
return nil, &googleapi.Error{Code: 404}
},
}
_, err := createNewTasks(c, service, []*swarming.SwarmingRpcsNewTaskRequest{req})
So(err, ShouldErrLike, "404")
})
goodService := &testService{
newTask: func(c context.Context, req *swarming.SwarmingRpcsNewTaskRequest) (*swarming.SwarmingRpcsTaskRequestMetadata, error) {
return &swarming.SwarmingRpcsTaskRequestMetadata{
Request: &swarming.SwarmingRpcsTaskRequest{
Name: req.Name,
},
}, nil
},
}
Convey(`Test single success`, t, func() {
results, err := createNewTasks(c, goodService, []*swarming.SwarmingRpcsNewTaskRequest{req})
So(err, ShouldBeNil)
So(results, ShouldHaveLength, 1)
So(results[0].Request, ShouldResemble, expectReq)
})
Convey(`Test many success`, t, func() {
reqs := make([]*swarming.SwarmingRpcsNewTaskRequest, 0, 12)
for i := 0; i < 12; i++ {
reqs = append(reqs, req)
}
results, err := createNewTasks(c, goodService, reqs)
So(err, ShouldBeNil)
So(results, ShouldHaveLength, 12)
for i := 0; i < 12; i++ {
So(results[i].Request, ShouldResemble, expectReq)
}
})
} | explode_data.jsonl/27127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 605
} | [
2830,
3393,
4021,
3564,
25449,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
24395,
1669,
609,
2280,
32902,
808,
86,
32902,
49,
47313,
3564,
6262,
1900,
63121,
25,
330,
14990,
8958,
532,
24952,
27234,
1669,
609,
2280,
32902,
80... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestArrayComprehensions(t *testing.T) {
nestedTerm := `[{"x": [a[i] | xs = [{"a": ["baz", j]} | q[p]; p.a != "bar"; j = "foo"]; xs[j].a[k] = "foo"]}]`
nestedExpected := ArrayTerm(
ObjectTerm(Item(
StringTerm("x"),
ArrayComprehensionTerm(
RefTerm(VarTerm("a"), VarTerm("i")),
NewBody(
Equality.Expr(
VarTerm("xs"),
ArrayComprehensionTerm(
ObjectTerm(Item(StringTerm("a"), ArrayTerm(StringTerm("baz"), VarTerm("j")))),
NewBody(
NewExpr(RefTerm(VarTerm("q"), VarTerm("p"))),
NotEqual.Expr(RefTerm(VarTerm("p"), StringTerm("a")), StringTerm("bar")),
Equality.Expr(VarTerm("j"), StringTerm("foo")),
),
),
),
Equality.Expr(
RefTerm(VarTerm("xs"), VarTerm("j"), StringTerm("a"), VarTerm("k")),
StringTerm("foo"),
),
),
),
)),
)
assertParseOneTerm(t, "nested", nestedTerm, nestedExpected)
assertParseOneTerm(t, "ambiguous or", "[ a | b ]", ArrayComprehensionTerm(
VarTerm("a"),
MustParseBody("b"),
))
} | explode_data.jsonl/50465 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
1857,
1092,
30782,
4664,
1155,
353,
8840,
836,
8,
1476,
9038,
9980,
17249,
1669,
77644,
4913,
87,
788,
508,
64,
989,
60,
760,
11943,
284,
61753,
64,
788,
4383,
42573,
497,
502,
13989,
760,
2804,
11407,
5265,
281,
5849,
961... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIntegration_WriterContentType(t *testing.T) {
ctx := context.Background()
client, bucket := testConfig(ctx, t)
defer client.Close()
obj := client.Bucket(bucket).Object("content")
testCases := []struct {
content string
setType, wantType string
}{
{
content: "It was the best of times, it was the worst of times.",
wantType: "text/plain; charset=utf-8",
},
{
content: "<html><head><title>My first page</title></head></html>",
wantType: "text/html; charset=utf-8",
},
{
content: "<html><head><title>My first page</title></head></html>",
setType: "text/html",
wantType: "text/html",
},
{
content: "<html><head><title>My first page</title></head></html>",
setType: "image/jpeg",
wantType: "image/jpeg",
},
}
for i, tt := range testCases {
if err := writeObject(ctx, obj, tt.setType, []byte(tt.content)); err != nil {
t.Errorf("writing #%d: %v", i, err)
}
attrs, err := obj.Attrs(ctx)
if err != nil {
t.Errorf("obj.Attrs: %v", err)
continue
}
if got := attrs.ContentType; got != tt.wantType {
t.Errorf("Content-Type = %q; want %q\nContent: %q\nSet Content-Type: %q", got, tt.wantType, tt.content, tt.setType)
}
}
} | explode_data.jsonl/8903 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 521
} | [
2830,
3393,
52464,
2763,
2542,
29504,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
25291,
11,
15621,
1669,
1273,
2648,
7502,
11,
259,
340,
16867,
2943,
10421,
2822,
22671,
1669,
2943,
1785,
11152,
58934,
568,
1190,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestApplyProfiles(t *testing.T) {
tests := []struct {
description string
config SkaffoldConfig
profile string
expectedConfig SkaffoldConfig
shouldErr bool
}{
{
description: "unknown profile",
config: SkaffoldConfig{},
profile: "profile",
shouldErr: true,
},
{
description: "build type",
profile: "profile",
config: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
},
BuildType: v1alpha2.BuildType{
LocalBuild: &v1alpha2.LocalBuild{},
},
},
Deploy: v1alpha2.DeployConfig{},
Profiles: []v1alpha2.Profile{
{
Name: "profile",
Build: v1alpha2.BuildConfig{
BuildType: v1alpha2.BuildType{
GoogleCloudBuild: &v1alpha2.GoogleCloudBuild{},
},
},
},
},
},
expectedConfig: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
},
BuildType: v1alpha2.BuildType{
GoogleCloudBuild: &v1alpha2.GoogleCloudBuild{},
},
},
Deploy: v1alpha2.DeployConfig{},
},
},
{
description: "tag policy",
profile: "dev",
config: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
},
TagPolicy: v1alpha2.TagPolicy{GitTagger: &v1alpha2.GitTagger{}},
},
Deploy: v1alpha2.DeployConfig{},
Profiles: []v1alpha2.Profile{
{
Name: "dev",
Build: v1alpha2.BuildConfig{
TagPolicy: v1alpha2.TagPolicy{ShaTagger: &v1alpha2.ShaTagger{}},
},
},
},
},
expectedConfig: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
},
TagPolicy: v1alpha2.TagPolicy{ShaTagger: &v1alpha2.ShaTagger{}},
},
Deploy: v1alpha2.DeployConfig{},
},
},
{
description: "artifacts",
profile: "profile",
config: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
},
TagPolicy: v1alpha2.TagPolicy{GitTagger: &v1alpha2.GitTagger{}},
},
Deploy: v1alpha2.DeployConfig{},
Profiles: []v1alpha2.Profile{
{
Name: "profile",
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
{ImageName: "imageProd"},
},
},
},
},
},
expectedConfig: SkaffoldConfig{
Build: v1alpha2.BuildConfig{
Artifacts: []*v1alpha2.Artifact{
{ImageName: "image"},
{ImageName: "imageProd"},
},
TagPolicy: v1alpha2.TagPolicy{GitTagger: &v1alpha2.GitTagger{}},
},
Deploy: v1alpha2.DeployConfig{},
},
},
{
description: "deploy",
profile: "profile",
config: SkaffoldConfig{
Build: v1alpha2.BuildConfig{},
Deploy: v1alpha2.DeployConfig{
DeployType: v1alpha2.DeployType{
KubectlDeploy: &v1alpha2.KubectlDeploy{},
},
},
Profiles: []v1alpha2.Profile{
{
Name: "profile",
Deploy: v1alpha2.DeployConfig{
DeployType: v1alpha2.DeployType{
HelmDeploy: &v1alpha2.HelmDeploy{},
},
},
},
},
},
expectedConfig: SkaffoldConfig{
Build: v1alpha2.BuildConfig{},
Deploy: v1alpha2.DeployConfig{
DeployType: v1alpha2.DeployType{
HelmDeploy: &v1alpha2.HelmDeploy{},
},
},
},
}}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
err := test.config.ApplyProfiles([]string{test.profile})
testutil.CheckErrorAndDeepEqual(t, test.shouldErr, err, test.expectedConfig, test.config)
})
}
} | explode_data.jsonl/16739 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1863
} | [
2830,
3393,
28497,
62719,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
42407,
262,
914,
198,
197,
25873,
260,
4818,
2649,
813,
2648,
198,
197,
197,
5365,
286,
914,
198,
197,
42400,
2648,
4818,
2649,
813,
2648,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestContextWithClient(t *testing.T) {
testCases := []struct {
desc string
input context.Context
expected client.Info
}{
{
desc: "no peer information, empty client",
input: context.Background(),
expected: client.Info{},
},
{
desc: "existing client with IP, no peer information",
input: client.NewContext(context.Background(), client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
},
}),
expected: client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
},
},
},
{
desc: "empty client, with peer information",
input: peer.NewContext(context.Background(), &peer.Peer{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
},
}),
expected: client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
},
},
},
{
desc: "existing client, existing IP gets overridden with peer information",
input: peer.NewContext(client.NewContext(context.Background(), client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 4),
},
}), &peer.Peer{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 5),
},
}),
expected: client.Info{
Addr: &net.IPAddr{
IP: net.IPv4(1, 2, 3, 5),
},
},
},
}
for _, tC := range testCases {
t.Run(tC.desc, func(t *testing.T) {
cl := client.FromContext(contextWithClient(tC.input))
assert.Equal(t, tC.expected, cl)
})
}
} | explode_data.jsonl/80335 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 698
} | [
2830,
3393,
1972,
2354,
2959,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
41653,
257,
914,
198,
197,
22427,
262,
2266,
9328,
198,
197,
42400,
2943,
20132,
198,
197,
59403,
197,
197,
515,
298,
41653,
25,
257... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestQueryHeader1(t *testing.T) {
var token string
g := newServer(Options{
Secret: "secret123",
})
g.GET("/login", func(c *gin.Context) {
token = GetToken(c)
})
g.POST("/login", func(c *gin.Context) {
c.String(http.StatusOK, "OK")
})
r1 := request(g, requestOptions{URL: "/login"})
r2 := request(g, requestOptions{
Method: "POST",
URL: "/login",
Headers: map[string]string{
"Cookie": r1.Header().Get("Set-Cookie"),
"X-CSRF-Token": token,
},
})
if body := r2.Body.String(); body != "OK" {
t.Error("Response is not OK: ", body)
}
} | explode_data.jsonl/22731 | {
"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,
2859,
4047,
16,
1155,
353,
8840,
836,
8,
341,
2405,
3950,
914,
198,
3174,
1669,
501,
5475,
7,
3798,
515,
197,
7568,
50856,
25,
330,
20474,
16,
17,
18,
756,
197,
8824,
3174,
17410,
4283,
3673,
497,
2915,
1337,
353,
8163,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClusterPeerURLs(t *testing.T) {
tests := []struct {
mems []*Member
wurls []string
}{
// single peer with a single address
{
mems: []*Member{
newTestMember(1, []string{"http://192.0.2.1"}, "", nil),
},
wurls: []string{"http://192.0.2.1"},
},
// single peer with a single address with a port
{
mems: []*Member{
newTestMember(1, []string{"http://192.0.2.1:8001"}, "", nil),
},
wurls: []string{"http://192.0.2.1:8001"},
},
// several members explicitly unsorted
{
mems: []*Member{
newTestMember(2, []string{"http://192.0.2.3", "http://192.0.2.4"}, "", nil),
newTestMember(3, []string{"http://192.0.2.5", "http://192.0.2.6"}, "", nil),
newTestMember(1, []string{"http://192.0.2.1", "http://192.0.2.2"}, "", nil),
},
wurls: []string{"http://192.0.2.1", "http://192.0.2.2", "http://192.0.2.3", "http://192.0.2.4", "http://192.0.2.5", "http://192.0.2.6"},
},
// no members
{
mems: []*Member{},
wurls: []string{},
},
// peer with no peer urls
{
mems: []*Member{
newTestMember(3, []string{}, "", nil),
},
wurls: []string{},
},
}
for i, tt := range tests {
c := newTestCluster(tt.mems)
urls := c.PeerURLs()
if !reflect.DeepEqual(urls, tt.wurls) {
t.Errorf("#%d: PeerURLs = %v, want %v", i, urls, tt.wurls)
}
}
} | explode_data.jsonl/52332 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 657
} | [
2830,
3393,
28678,
30888,
3144,
82,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
2109,
11852,
220,
29838,
9366,
198,
197,
6692,
20502,
3056,
917,
198,
197,
59403,
197,
197,
322,
3175,
14397,
448,
264,
3175,
2621,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSign(t *testing.T) {
message := []byte("Hello world!")
priv, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
t.Errorf("Failed to generate keys %s\n", err)
}
signature, err := util.Sign(message, priv)
if err != nil {
t.Errorf("Failed to sign message %s\n", err)
}
if util.VerifySignature(message, signature, &priv.PublicKey) != nil {
t.Errorf("Signature expected true, actual false")
}
priv1, err := rsa.GenerateKey(rand.Reader, 1024)
signature1, err := util.Sign(message, priv1)
if util.VerifySignature(message, signature1, &priv.PublicKey) == nil {
t.Error("Signature expect false, actual true")
}
} | explode_data.jsonl/37607 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 239
} | [
2830,
3393,
7264,
1155,
353,
8840,
836,
8,
341,
24753,
1669,
3056,
3782,
445,
9707,
1879,
66506,
71170,
11,
1848,
1669,
68570,
57582,
1592,
37595,
47431,
11,
220,
16,
15,
17,
19,
340,
743,
1848,
961,
2092,
341,
197,
3244,
13080,
445,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestWriteRecord(t *testing.T) {
b := &walpb.Record{}
typ := int64(0xABCD)
d := []byte("Hello world!")
buf := new(bytes.Buffer)
e := newEncoder(buf, 0, 0)
e.encode(&walpb.Record{Type: typ, Data: d})
e.flush()
decoder := newDecoder(ioutil.NopCloser(buf))
err := decoder.decode(b)
if err != nil {
t.Errorf("err = %v, want nil", err)
}
if b.Type != typ {
t.Errorf("type = %d, want %d", b.Type, typ)
}
if !reflect.DeepEqual(b.Data, d) {
t.Errorf("data = %v, want %v", b.Data, d)
}
} | explode_data.jsonl/36705 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
7985,
6471,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
609,
26397,
16650,
49959,
16094,
25314,
1669,
526,
21,
19,
7,
15,
78146,
6484,
340,
2698,
1669,
3056,
3782,
445,
9707,
1879,
22988,
26398,
1669,
501,
23158,
22622,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestStore_CreateShardSnapShot(t *testing.T) {
s := MustOpenStore()
defer s.Close()
// Create a new shard and verify that it exists.
if err := s.CreateShard("db0", "rp0", 1, true); err != nil {
t.Fatal(err)
} else if sh := s.Shard(1); sh == nil {
t.Fatalf("expected shard")
} else if di := s.DatabaseIndex("db0"); di == nil {
t.Errorf("expected database index")
}
dir, e := s.CreateShardSnapshot(1)
if e != nil {
t.Fatal(e)
}
if dir == "" {
t.Fatal("empty directory name")
}
} | explode_data.jsonl/44150 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
6093,
34325,
2016,
567,
61871,
36402,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
15465,
5002,
6093,
741,
16867,
274,
10421,
2822,
197,
322,
4230,
264,
501,
52069,
323,
10146,
429,
432,
6724,
624,
743,
1848,
1669,
274,
7251,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSuspendResume(t *testing.T) {
controller := newController()
wfcset := controller.wfclientset.ArgoprojV1alpha1().Workflows("")
wf := unmarshalWF(stepsTemplateParallelismLimit)
wf, err := wfcset.Create(wf)
assert.NoError(t, err)
// suspend the workflow
err = util.SuspendWorkflow(wfcset, wf.ObjectMeta.Name)
assert.NoError(t, err)
wf, err = wfcset.Get(wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
assert.True(t, *wf.Spec.Suspend)
// operate should not result in no workflows being created since it is suspended
woc := newWorkflowOperationCtx(wf, controller)
woc.operate()
pods, err := controller.kubeclientset.CoreV1().Pods("").List(metav1.ListOptions{})
assert.NoError(t, err)
assert.Equal(t, 0, len(pods.Items))
// resume the workflow and operate again. two pods should be able to be scheduled
err = util.ResumeWorkflow(wfcset, wf.ObjectMeta.Name)
assert.NoError(t, err)
wf, err = wfcset.Get(wf.ObjectMeta.Name, metav1.GetOptions{})
assert.NoError(t, err)
assert.Nil(t, wf.Spec.Suspend)
woc = newWorkflowOperationCtx(wf, controller)
woc.operate()
pods, err = controller.kubeclientset.CoreV1().Pods("").List(metav1.ListOptions{})
assert.NoError(t, err)
assert.Equal(t, 2, len(pods.Items))
} | explode_data.jsonl/54364 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
50,
12758,
28563,
1155,
353,
8840,
836,
8,
341,
61615,
1669,
501,
2051,
741,
6692,
8316,
746,
1669,
6461,
1418,
69,
2972,
746,
18979,
45926,
73,
53,
16,
7141,
16,
1005,
6776,
38140,
31764,
6692,
69,
1669,
650,
27121,
32131... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplyStackPolicy(t *testing.T) {
stackName := "StackName"
policyPath := "./test_resources/test_stackpolicy.json"
ctx := stack_mocks.SetupContext(t, []string{"cmd", "set-stack-policy", stackName, policyPath})
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockAWSPI := stack_mocks.NewMockCloudFormationAPI(mockCtrl)
ctx.CloudFormation = mockAWSPI
template := stack_mocks.ReadFile(t, policyPath)
input := createStackPolicyInput(&template, &stackName)
mockAWSPI.EXPECT().SetStackPolicy(&input).Return(nil, nil).Times(1)
ApplyStackPolicy(ctx)
} | explode_data.jsonl/19686 | {
"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,
28497,
4336,
13825,
1155,
353,
8840,
836,
8,
341,
48227,
675,
1669,
330,
4336,
675,
698,
3223,
8018,
1820,
1669,
5924,
1944,
35569,
12697,
15528,
34790,
4323,
698,
20985,
1669,
5611,
717,
25183,
39820,
1972,
1155,
11,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestExtractOverwrittenFile(t *testing.T) {
img, err := tarball.ImageFromPath("testdata/overwritten_file.tar", nil)
if err != nil {
t.Fatalf("Error loading image: %v", err)
}
tr := tar.NewReader(mutate.Extract(img))
for {
header, err := tr.Next()
if errors.Is(err, io.EOF) {
break
}
name := header.Name
if strings.Contains(name, "foo.txt") {
var buf bytes.Buffer
buf.ReadFrom(tr)
if strings.Contains(buf.String(), "foo") {
t.Errorf("Contents of file were not correctly overwritten")
}
}
}
} | explode_data.jsonl/3087 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
28959,
1918,
25569,
1703,
1155,
353,
8840,
836,
8,
341,
39162,
11,
1848,
1669,
12183,
3959,
7528,
3830,
1820,
445,
92425,
14,
1975,
25569,
2458,
28048,
497,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRequestRateLimit(t *testing.T) {
tc := &testTime{now: time.Now()}
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if tc.slept == 0 {
w.Header().Set("X-RateLimit-Remaining", "0")
w.Header().Set("X-RateLimit-Reset", strconv.Itoa(int(tc.now.Add(time.Second).Unix())))
http.Error(w, "403 Forbidden", http.StatusForbidden)
}
}))
defer ts.Close()
c := getClient(ts.URL)
c.time = tc
resp, err := c.requestRetry(http.MethodGet, "/", "", nil)
if err != nil {
t.Errorf("Error from request: %v", err)
} else if resp.StatusCode != 200 {
t.Errorf("Expected status code 200, got %d", resp.StatusCode)
} else if tc.slept < time.Second {
t.Errorf("Expected to sleep for at least a second, got %v", tc.slept)
}
} | explode_data.jsonl/6243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 315
} | [
2830,
3393,
1900,
11564,
16527,
1155,
353,
8840,
836,
8,
341,
78255,
1669,
609,
1944,
1462,
90,
3328,
25,
882,
13244,
23509,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_parseOutput2(t *testing.T) {
case2 := `DISK OK - free space: /root 3326 MB (56%); | /root=2643MB;5948;5958;0;5968`
expectedServiceOutput := "DISK OK - free space: /root 3326 MB (56%); "
expectedLongServiceOutput := ""
expectedServicePerfData := map[string]float64{
"/root": 2643.0,
}
serviceOutput, longServiceOutput, servicePerfData := parseOutput(case2)
assert.Equal(t, expectedServiceOutput, serviceOutput)
assert.Equal(t, expectedLongServiceOutput, longServiceOutput)
assert.Equal(t, expectedServicePerfData, servicePerfData)
} | explode_data.jsonl/8925 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 191
} | [
2830,
3393,
21039,
5097,
17,
1155,
353,
8840,
836,
8,
341,
2722,
17,
1669,
1565,
21202,
42,
10402,
481,
1910,
3550,
25,
608,
2888,
220,
18,
18,
17,
21,
13339,
320,
20,
21,
4,
1215,
760,
608,
2888,
28,
17,
21,
19,
18,
8412,
26,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func Test_mjHandler_runAnalysisMajsoulMessageTask(t *testing.T) {
debugMode = true
startLo := 33020
endLo := 33369
h := &mjHandler{
majsoulMessageQueue: make(chan []byte, 1000),
majsoulRoundData: &majsoulRoundData{accountID: gameConf.MajsoulAccountID},
majsoulRecordMap: map[string]*majsoulRecordBaseInfo{},
}
h.majsoulRoundData.roundData = newGame(h.majsoulRoundData)
s := struct {
Level string `json:"level"`
Message string `json:"message"`
}{}
logData, err := ioutil.ReadFile(logFile)
if err != nil {
t.Fatal(err)
}
lines := strings.Split(string(logData), "\n")
for i, line := range lines[startLo-1 : endLo] {
debug.Lo = i + 1
if line == "" {
continue
}
if err := json.Unmarshal([]byte(line), &s); err != nil {
fmt.Println(err)
continue
}
if s.Level != "INFO" {
fmt.Println(s.Message)
//t.Fatal(s.Message)
break
}
h.majsoulMessageQueue <- []byte([]byte(s.Message))
}
go h.runAnalysisMajsoulMessageTask()
for {
if len(h.majsoulMessageQueue) == 0 {
break
}
time.Sleep(time.Second)
}
} | explode_data.jsonl/48429 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 474
} | [
2830,
3393,
717,
73,
3050,
14007,
26573,
44,
23720,
10965,
2052,
6262,
1155,
353,
8840,
836,
8,
341,
39730,
3636,
284,
830,
271,
21375,
4262,
1669,
220,
18,
18,
15,
17,
15,
198,
6246,
4262,
1669,
220,
18,
18,
18,
21,
24,
271,
9598... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBuildConfig(t *testing.T) {
mockWsRoot := "/root/dir"
testCases := map[string]struct {
inBuild BuildArgsOrString
wantedBuild DockerBuildArgs
}{
"simple case: BuildString path to dockerfile": {
inBuild: BuildArgsOrString{
BuildString: aws.String("my/Dockerfile"),
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "my/Dockerfile")),
Context: aws.String(filepath.Join(mockWsRoot, "my")),
},
},
"Different context than dockerfile": {
inBuild: BuildArgsOrString{
BuildArgs: DockerBuildArgs{
Dockerfile: aws.String("build/dockerfile"),
Context: aws.String("cmd/main"),
},
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "build/dockerfile")),
Context: aws.String(filepath.Join(mockWsRoot, "cmd/main")),
},
},
"no dockerfile specified": {
inBuild: BuildArgsOrString{
BuildArgs: DockerBuildArgs{
Context: aws.String("cmd/main"),
},
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "cmd", "main", "Dockerfile")),
Context: aws.String(filepath.Join(mockWsRoot, "cmd", "main")),
},
},
"no dockerfile or context specified": {
inBuild: BuildArgsOrString{
BuildArgs: DockerBuildArgs{
Args: map[string]string{
"goodDog": "bowie",
},
},
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "Dockerfile")),
Context: aws.String(mockWsRoot),
Args: map[string]string{
"goodDog": "bowie",
},
},
},
"including args": {
inBuild: BuildArgsOrString{
BuildArgs: DockerBuildArgs{
Dockerfile: aws.String("my/Dockerfile"),
Args: map[string]string{
"goodDog": "bowie",
"badGoose": "HONK",
},
},
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "my/Dockerfile")),
Context: aws.String(filepath.Join(mockWsRoot, "my")),
Args: map[string]string{
"goodDog": "bowie",
"badGoose": "HONK",
},
},
},
"including build options": {
inBuild: BuildArgsOrString{
BuildArgs: DockerBuildArgs{
Target: aws.String("foobar"),
CacheFrom: []string{
"foo/bar:latest",
"foo/bar/baz:1.2.3",
},
},
},
wantedBuild: DockerBuildArgs{
Dockerfile: aws.String(filepath.Join(mockWsRoot, "Dockerfile")),
Context: aws.String(mockWsRoot),
Target: aws.String("foobar"),
CacheFrom: []string{
"foo/bar:latest",
"foo/bar/baz:1.2.3",
},
},
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
s := Image{
Build: tc.inBuild,
}
got := s.BuildConfig(mockWsRoot)
require.Equal(t, tc.wantedBuild, *got)
})
}
} | explode_data.jsonl/79733 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1308
} | [
2830,
3393,
11066,
2648,
1155,
353,
8840,
836,
8,
341,
77333,
74733,
8439,
1669,
3521,
2888,
88226,
698,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
17430,
11066,
257,
7854,
4117,
2195,
703,
198,
197,
6692,
7566,
11066,
40549,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_parseCiid(t *testing.T) {
log.SetLevel(log.TraceLevel)
A := &StdMiid{
sn: "A",
vn: "1.1",
va: "",
t: 22,
}
B := &StdMiid{
sn: "B",
vn: "1.1",
va: "",
t: 22,
}
C := &StdMiid{
sn: "C",
vn: "1.1",
va: "",
t: 22,
}
D := &StdMiid{
sn: "D",
vn: "1.1",
va: "",
t: 22,
}
E := &StdMiid{
sn: "E",
vn: "1.1",
va: "",
t: 22,
}
type args struct {
id string
}
tests := []struct {
name string
args args
wantCiid Ciid
}{
{
"simple",
args{
"msA/1.17/dev-123ab%3333s",
},
&StdCiid{
miid: &StdMiid{
sn: "msA",
vn: "1.17",
va: "dev-123ab",
t: 3333,
},
},
},
{
"one Call",
args{
"msA/1.17/dev-123ab%3333s(A/1.1%22s)",
},
&StdCiid{
miid: &StdMiid{sn: "msA", vn: "1.17", va: "dev-123ab", t: 3333},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "A",
vn: "1.1",
va: "",
t: 22,
},
},
},
},
},
{
"one Call Plus another one",
args{
"msA/1.17/dev-123ab%3333s(A/1.1%22s+B/1.1%22s)",
},
&StdCiid{
miid: &StdMiid{sn: "msA", vn: "1.17", va: "dev-123ab", t: 3333},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "A",
vn: "1.1",
va: "",
t: 22,
},
},
&StdCiid{
miid: &StdMiid{
sn: "B",
vn: "1.1",
va: "",
t: 22,
},
},
},
},
},
{
"one Call Plus another one and one call",
args{
"msA/1.17/dev-123ab%3333s(A/1.1%22s+B/1.1%22s(C/1.1%22s))",
},
&StdCiid{
miid: &StdMiid{sn: "msA", vn: "1.17", va: "dev-123ab", t: 3333},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "A",
vn: "1.1",
va: "",
t: 22,
},
},
&StdCiid{
miid: &StdMiid{
sn: "B",
vn: "1.1",
va: "",
t: 22,
},
ciids: Stack{
&StdCiid{
miid: &StdMiid{
sn: "C",
vn: "1.1",
va: "",
t: 22,
},
},
},
},
},
},
},
{
"simple",
args{
"A/1.1%22s(B/1.1%22s+C/1.1%22s(D/1.1%22s+E/1.1%22s))",
},
&StdCiid{miid: A, ciids: Stack{
&StdCiid{miid: B},
&StdCiid{miid: C, ciids: Stack{
&StdCiid{miid: D},
&StdCiid{miid: E},
}}}},
},
{
"simple",
args{
"A/1.1%22s(B/1.1%22s)",
},
&StdCiid{miid: A,
ciids: Stack{
&StdCiid{miid: B},
},
},
},
{
"simple",
args{
"A/1.1%22s(B/1.1%22s+C/1.1%22s)",
},
&StdCiid{miid: A,
ciids: Stack{
&StdCiid{miid: B},
&StdCiid{miid: C},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotCiid := parseCiid(tt.args.id); !reflect.DeepEqual(gotCiid, tt.wantCiid) {
t.Errorf("parseCiid() = %v, want %v", gotCiid, tt.wantCiid)
}
})
}
} | explode_data.jsonl/64796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2046
} | [
2830,
3393,
21039,
34,
54483,
1155,
353,
8840,
836,
8,
341,
6725,
4202,
4449,
12531,
46920,
4449,
692,
22985,
1669,
609,
22748,
41887,
307,
515,
197,
48251,
25,
330,
32,
756,
197,
5195,
77,
25,
330,
16,
13,
16,
756,
197,
53911,
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 TestGetFileType(t *testing.T) {
mounter := New("fake/path")
testCase := []struct {
name string
expectedType FileType
setUp func() (string, string, error)
}{
{
"Directory Test",
FileTypeDirectory,
func() (string, string, error) {
tempDir, err := ioutil.TempDir("", "test-get-filetype-")
return tempDir, tempDir, err
},
},
{
"File Test",
FileTypeFile,
func() (string, string, error) {
tempFile, err := ioutil.TempFile("", "test-get-filetype")
if err != nil {
return "", "", err
}
tempFile.Close()
return tempFile.Name(), tempFile.Name(), nil
},
},
}
for idx, tc := range testCase {
path, cleanUpPath, err := tc.setUp()
if err != nil {
t.Fatalf("[%d-%s] unexpected error : %v", idx, tc.name, err)
}
if len(cleanUpPath) > 0 {
defer os.RemoveAll(cleanUpPath)
}
fileType, err := mounter.GetFileType(path)
if err != nil {
t.Fatalf("[%d-%s] unexpected error : %v", idx, tc.name, err)
}
if fileType != tc.expectedType {
t.Fatalf("[%d-%s] expected %s, but got %s", idx, tc.name, tc.expectedType, fileType)
}
}
} | explode_data.jsonl/48689 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 510
} | [
2830,
3393,
1949,
71873,
1155,
353,
8840,
836,
8,
341,
2109,
39914,
1669,
1532,
445,
30570,
50976,
5130,
18185,
4207,
1669,
3056,
1235,
341,
197,
11609,
260,
914,
198,
197,
42400,
929,
93238,
198,
197,
8196,
2324,
286,
2915,
368,
320,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanSupport(t *testing.T) {
tmpDir, err := utiltesting.MkTmpdir("glusterfs_test")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
}
defer os.RemoveAll(tmpDir)
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))
plug, err := plugMgr.FindPluginByName("kubernetes.io/glusterfs")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if plug.GetPluginName() != "kubernetes.io/glusterfs" {
t.Errorf("Wrong name: %s", plug.GetPluginName())
}
if plug.CanSupport(&volume.Spec{PersistentVolume: &api.PersistentVolume{Spec: api.PersistentVolumeSpec{PersistentVolumeSource: api.PersistentVolumeSource{}}}}) {
t.Errorf("Expected false")
}
if plug.CanSupport(&volume.Spec{Volume: &api.Volume{VolumeSource: api.VolumeSource{}}}) {
t.Errorf("Expected false")
}
} | explode_data.jsonl/48308 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 331
} | [
2830,
3393,
6713,
7916,
1155,
353,
8840,
836,
8,
341,
20082,
6184,
11,
1848,
1669,
4094,
8840,
1321,
74,
35986,
3741,
445,
6072,
4993,
3848,
4452,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
841,
6825,
2730,
5419,
25,
1018... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestParseOptDomainSearchList(t *testing.T) {
data := []byte{
7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
}
opt, err := ParseOptDomainSearchList(data)
require.NoError(t, err)
require.Equal(t, OptionDomainSearchList, opt.Code())
require.Equal(t, 2, len(opt.DomainSearchList.Labels))
require.Equal(t, "example.com", opt.DomainSearchList.Labels[0])
require.Equal(t, "subnet.example.org", opt.DomainSearchList.Labels[1])
require.Contains(t, opt.String(), "searchlist=[example.com subnet.example.org]", "String() should contain the correct domain search output")
} | explode_data.jsonl/53131 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 284
} | [
2830,
3393,
14463,
21367,
13636,
5890,
852,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
3056,
3782,
515,
197,
197,
22,
11,
364,
68,
516,
364,
87,
516,
364,
64,
516,
364,
76,
516,
364,
79,
516,
364,
75,
516,
364,
68,
516,
220,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteNoName(t *testing.T) {
cmdArgs := []string{"delete", "groupsnapshots"}
expected := "error: at least one argument needs to be provided for groupsnapshot name"
testCommon(t, cmdArgs, nil, expected, true)
} | explode_data.jsonl/20433 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
6435,
2753,
675,
1155,
353,
8840,
836,
8,
341,
25920,
4117,
1669,
3056,
917,
4913,
4542,
497,
330,
16753,
6861,
27634,
16707,
42400,
1669,
330,
841,
25,
518,
3245,
825,
5693,
3880,
311,
387,
3897,
369,
5203,
9601,
829,
698... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAllowsReferencedSecret(t *testing.T) {
ns := "myns"
admit := NewServiceAccount()
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
admit.SetExternalKubeInformerFactory(informerFactory)
admit.LimitSecretReferences = true
admit.RequireAPIToken = false
// Add the default service account for the ns with a secret reference into the cache
informerFactory.Core().V1().ServiceAccounts().Informer().GetStore().Add(&corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: DefaultServiceAccountName,
Namespace: ns,
},
Secrets: []corev1.ObjectReference{
{Name: "foo"},
},
})
pod1 := &api.Pod{
Spec: api.PodSpec{
Volumes: []api.Volume{
{VolumeSource: api.VolumeSource{Secret: &api.SecretVolumeSource{SecretName: "foo"}}},
},
},
}
attrs := admission.NewAttributesRecord(pod1, nil, api.Kind("Pod").WithVersion("version"), ns, "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
if err := admit.Admit(attrs); err != nil {
t.Errorf("Unexpected error: %v", err)
}
pod2 := &api.Pod{
Spec: api.PodSpec{
Containers: []api.Container{
{
Name: "container-1",
Env: []api.EnvVar{
{
Name: "env-1",
ValueFrom: &api.EnvVarSource{
SecretKeyRef: &api.SecretKeySelector{
LocalObjectReference: api.LocalObjectReference{Name: "foo"},
},
},
},
},
},
},
},
}
attrs = admission.NewAttributesRecord(pod2, nil, api.Kind("Pod").WithVersion("version"), ns, "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
if err := admit.Admit(attrs); err != nil {
t.Errorf("Unexpected error: %v", err)
}
pod2 = &api.Pod{
Spec: api.PodSpec{
InitContainers: []api.Container{
{
Name: "container-1",
Env: []api.EnvVar{
{
Name: "env-1",
ValueFrom: &api.EnvVarSource{
SecretKeyRef: &api.SecretKeySelector{
LocalObjectReference: api.LocalObjectReference{Name: "foo"},
},
},
},
},
},
},
},
}
attrs = admission.NewAttributesRecord(pod2, nil, api.Kind("Pod").WithVersion("version"), ns, "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
if err := admit.Admit(attrs); err != nil {
t.Errorf("Unexpected error: %v", err)
}
} | explode_data.jsonl/61349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 988
} | [
2830,
3393,
79595,
47447,
5767,
19773,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
330,
76,
1872,
82,
1837,
98780,
1763,
1669,
1532,
1860,
7365,
741,
17430,
34527,
4153,
1669,
6051,
388,
7121,
16997,
641,
34527,
4153,
27907,
11,
6461,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestList_Run(t *testing.T) {
ctrl := gomock.NewController(t)
mockStore := mocks.NewMockProjectUsersLister(ctrl)
defer ctrl.Finish()
var expected []mongodbatlas.AtlasUser
listOpts := &ListOpts{
store: mockStore,
}
mockStore.
EXPECT().
ProjectUsers(listOpts.ProjectID, listOpts.NewListOptions()).
Return(expected, nil).
Times(1)
if err := listOpts.Run(); err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
} | explode_data.jsonl/46219 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 177
} | [
2830,
3393,
852,
84158,
1155,
353,
8840,
836,
8,
341,
84381,
1669,
342,
316,
1176,
7121,
2051,
1155,
340,
77333,
6093,
1669,
68909,
7121,
11571,
7849,
7137,
852,
261,
62100,
340,
16867,
23743,
991,
18176,
2822,
2405,
3601,
3056,
71155,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDomainList(t *testing.T) {
args := testutil.Args
scenarios := []testutil.TestScenario{
{
Args: args("domain list --service-id 123 --version 1"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsOK,
},
WantOutput: listDomainsShortOutput,
},
{
Args: args("domain list --service-id 123 --version 1 --verbose"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsOK,
},
WantOutput: listDomainsVerboseOutput,
},
{
Args: args("domain list --service-id 123 --version 1 -v"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsOK,
},
WantOutput: listDomainsVerboseOutput,
},
{
Args: args("domain --verbose list --service-id 123 --version 1"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsOK,
},
WantOutput: listDomainsVerboseOutput,
},
{
Args: args("-v domain list --service-id 123 --version 1"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsOK,
},
WantOutput: listDomainsVerboseOutput,
},
{
Args: args("domain list --service-id 123 --version 1"),
API: mock.API{
ListVersionsFn: testutil.ListVersions,
ListDomainsFn: listDomainsError,
},
WantError: errTest.Error(),
},
}
for _, testcase := range scenarios {
t.Run(testcase.Name, func(t *testing.T) {
var stdout bytes.Buffer
opts := testutil.NewRunOpts(testcase.Args, &stdout)
opts.APIClient = mock.APIClient(testcase.API)
err := app.Run(opts)
testutil.AssertErrorContains(t, err, testcase.WantError)
testutil.AssertString(t, testcase.WantOutput, stdout.String())
})
}
} | explode_data.jsonl/17440 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 741
} | [
2830,
3393,
13636,
852,
1155,
353,
8840,
836,
8,
341,
31215,
1669,
1273,
1314,
51015,
198,
29928,
60494,
1669,
3056,
1944,
1314,
8787,
54031,
515,
197,
197,
515,
298,
197,
4117,
25,
2827,
445,
12204,
1140,
1177,
7936,
12897,
220,
16,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMessageExportSetDefaultsExportEnabledExportFromTimestampNil(t *testing.T) {
// Test retained as protection against regression of MM-13185
mes := &MessageExportSettings{
EnableExport: NewBool(true),
}
mes.SetDefaults()
require.True(t, *mes.EnableExport)
require.Equal(t, "01:00", *mes.DailyRunTime)
require.Equal(t, int64(0), *mes.ExportFromTimestamp)
require.True(t, *mes.ExportFromTimestamp <= GetMillis())
require.Equal(t, 10000, *mes.BatchSize)
} | explode_data.jsonl/50691 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 166
} | [
2830,
3393,
2052,
16894,
1649,
16273,
16894,
5462,
16894,
3830,
20812,
19064,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
34263,
438,
9135,
2348,
30549,
315,
21665,
12,
16,
18,
16,
23,
20,
198,
2109,
288,
1669,
609,
2052,
16894,
608... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReconnectOFSwitch(t *testing.T) {
br := "br07"
err := PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))
defer DeleteOVSBridge(br)
bridge := binding.NewOFBridge(br)
reconnectCh := make(chan struct{})
var connectCount int
go func() {
for range reconnectCh {
connectCount++
}
}()
err = bridge.Connect(maxRetry, reconnectCh)
require.Nil(t, err, "Failed to start OFService")
defer bridge.Disconnect()
require.Equal(t, connectCount, 1)
// The max delay for the initial connection is 5s. Here we assume the OVS is stopped then started after 8s, and
// check that we can re-connect to it after that delay.
go func() {
DeleteOVSBridge(br)
time.Sleep(8 * time.Second)
err := PrepareOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to prepare OVS bridge: %v", err))
}()
err = DeleteOVSBridge(br)
require.Nil(t, err, fmt.Sprintf("Failed to delete bridge: %v", err))
time.Sleep(12 * time.Second)
require.Equal(t, 2, connectCount)
} | explode_data.jsonl/23788 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
693,
6459,
46,
8485,
5539,
1155,
353,
8840,
836,
8,
341,
80255,
1669,
330,
1323,
15,
22,
698,
9859,
1669,
31166,
38957,
16680,
11183,
41237,
340,
17957,
59678,
1155,
11,
1848,
11,
8879,
17305,
445,
9408,
311,
10549,
506,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRemoveSubAddressing_Normalize(t *testing.T) {
tests := []struct {
tags map[string]string
email string
want string
}{
{
tags: map[string]string{"email.com": "+"},
email: "a@email.com",
want: "a@email.com",
},
{
tags: map[string]string{"email.com": "+"},
email: "a+b+c@email.com",
want: "a@email.com",
},
{
tags: map[string]string{"email.com": "-"},
email: "a--b-c@email.com",
want: "a@email.com",
},
{
tags: map[string]string{},
email: "a+b@email.com",
want: "a+b@email.com",
},
}
for i, tt := range tests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
ea := NewEmailAddress(tt.email)
NewRemoveSubAddressing(tt.tags).Normalize(ea)
if got := ea.String(); !reflect.DeepEqual(got, tt.want) {
t.Errorf("RemoveSubAddressing.Normalize() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/57366 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 420
} | [
2830,
3393,
13021,
3136,
4286,
287,
74900,
551,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
3244,
2032,
220,
2415,
14032,
30953,
198,
197,
57549,
914,
198,
197,
50780,
220,
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... | 2 |
func TestPolicySafeToEvict(t *testing.T) {
ctx := context.Background()
tests := []struct {
name string
podSpec corev1.PodSpec
annotations map[string]string
violations int
}{
{
name: "allow with annotation and volume",
violations: 0,
podSpec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/host-path",
},
},
},
},
},
annotations: map[string]string{
"cluster-autoscaler.kubernetes.io/safe-to-evict": "true",
},
},
{
name: "disallow with annotation and volume",
violations: 1,
podSpec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/host-path",
},
},
},
},
},
annotations: map[string]string{
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
},
},
{
name: "disallow with volume and without annotation",
violations: 1,
podSpec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: "/host-path",
},
},
},
},
},
annotations: map[string]string{},
},
{
name: "allow with annotation and no volume",
violations: 0,
podSpec: corev1.PodSpec{
Containers: []corev1.Container{
{
Image: "gcr.io/some-gcr-repo/security/k-rail",
},
},
},
annotations: map[string]string{
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
raw, _ := json.Marshal(corev1.Pod{Spec: tt.podSpec, ObjectMeta: metav1.ObjectMeta{Annotations: tt.annotations}})
ar := &admissionv1beta1.AdmissionRequest{
Namespace: "namespace",
Name: "name",
Object: runtime.RawExtension{Raw: raw},
Resource: metav1.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"},
}
v := PolicySafeToEvict{}
conf := policies.Config{}
if got := v.Validate(ctx, conf, ar); !reflect.DeepEqual(len(got), tt.violations) {
t.Errorf("PolicySafeToEvict() %s got %v want %v violations", tt.name, len(got), tt.violations)
}
})
}
} | explode_data.jsonl/71772 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1142
} | [
2830,
3393,
13825,
25663,
1249,
34112,
849,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
3223,
347,
8327,
257,
6200,
85,
16,
88823,
8327,
198,
197,
197,
39... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateCron(t *testing.T) {
testCases := map[string]struct {
input string
shouldPass bool
}{
"valid cron expression": {
input: "* * * * *",
shouldPass: true,
},
"invalid cron": {
input: "* * * * ? *",
shouldPass: false,
},
"valid schedule descriptor": {
input: "@every 5m",
shouldPass: true,
},
"invalid schedule": {
input: "@every 5 minutes",
shouldPass: false,
},
"bypass with rate()": {
input: "rate(la la la)",
shouldPass: true,
},
"bypass with cron()": {
input: "cron(0 9 3W * ? *)",
shouldPass: true,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
got := validateCron(tc.input)
if tc.shouldPass {
require.NoError(t, got)
} else {
require.NotNil(t, got)
}
})
}
} | explode_data.jsonl/34554 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 401
} | [
2830,
3393,
17926,
34,
2248,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
2415,
14032,
60,
1235,
341,
197,
22427,
414,
914,
198,
197,
197,
5445,
12187,
1807,
198,
197,
59403,
197,
197,
1,
1891,
46582,
7493,
788,
341,
298,
22427,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLabelShardedMetaFilter_Filter_Basic(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
defer cancel()
relabelContentYaml := `
- action: drop
regex: "A"
source_labels:
- cluster
- action: keep
regex: "keepme"
source_labels:
- message
`
var relabelConfig []*relabel.Config
testutil.Ok(t, yaml.Unmarshal([]byte(relabelContentYaml), &relabelConfig))
f := NewLabelShardedMetaFilter(relabelConfig)
input := map[ulid.ULID]*metadata.Meta{
ULID(1): {
Thanos: metadata.Thanos{
Labels: map[string]string{"cluster": "B", "message": "keepme"},
},
},
ULID(2): {
Thanos: metadata.Thanos{
Labels: map[string]string{"something": "A", "message": "keepme"},
},
},
ULID(3): {
Thanos: metadata.Thanos{
Labels: map[string]string{"cluster": "A", "message": "keepme"},
},
},
ULID(4): {
Thanos: metadata.Thanos{
Labels: map[string]string{"cluster": "A", "something": "B", "message": "keepme"},
},
},
ULID(5): {
Thanos: metadata.Thanos{
Labels: map[string]string{"cluster": "B"},
},
},
ULID(6): {
Thanos: metadata.Thanos{
Labels: map[string]string{"cluster": "B", "message": "keepme"},
},
},
}
expected := map[ulid.ULID]*metadata.Meta{
ULID(1): input[ULID(1)],
ULID(2): input[ULID(2)],
ULID(6): input[ULID(6)],
}
m := newTestFetcherMetrics()
testutil.Ok(t, f.Filter(ctx, input, m.synced))
testutil.Equals(t, 3.0, promtest.ToFloat64(m.synced.WithLabelValues(labelExcludedMeta)))
testutil.Equals(t, expected, input)
} | explode_data.jsonl/67636 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 709
} | [
2830,
3393,
2476,
2016,
20958,
12175,
5632,
68935,
1668,
5971,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
16,
17,
15,
77053,
32435,
340,
16867,
9121,
2822,
17200,
1502,
2762,
56,
9467... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelRetry(t *testing.T) {
sr := &snowflakeRestful{
TokenAccessor: getSimpleTokenAccessor(),
FuncPost: postTestQueryNotExecuting,
FuncCancelQuery: cancelTestRetry,
}
ctx := context.Background()
err := cancelQuery(ctx, sr, getOrGenerateRequestIDFromContext(ctx), time.Second)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/44749 | {
"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,
9269,
51560,
1155,
353,
8840,
836,
8,
341,
1903,
81,
1669,
609,
74478,
63456,
12416,
1262,
515,
197,
33299,
29889,
25,
256,
633,
16374,
3323,
29889,
3148,
197,
197,
9626,
4133,
25,
286,
1736,
2271,
2859,
2623,
51853,
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... | 2 |
func TestBuildInvalidTarget(t *testing.T) {
folder := testlib.Mktmp(t)
writeGoodMain(t, folder)
target := "linux"
config := config.Project{
Builds: []config.Build{
{
ID: "foo",
Binary: "foo",
Targets: []string{target},
},
},
}
ctx := context.New(config)
ctx.Git.CurrentTag = "5.6.7"
build := ctx.Config.Builds[0]
err := Default.Build(ctx, build, api.Options{
Target: target,
Name: build.Binary,
Path: filepath.Join(folder, "dist", target, build.Binary),
})
require.EqualError(t, err, "linux is not a valid build target")
require.Len(t, ctx.Artifacts.List(), 0)
} | explode_data.jsonl/54145 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
11066,
7928,
6397,
1155,
353,
8840,
836,
8,
341,
1166,
2018,
1669,
1273,
2740,
1321,
74,
5173,
1155,
340,
24945,
15216,
6202,
1155,
11,
8527,
340,
28861,
1669,
330,
14210,
698,
25873,
1669,
2193,
30944,
515,
197,
197,
11066,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLDSIngressRouteOutsideRootNamespaces(t *testing.T) {
rh, cc, done := setup(t, func(reh *contour.ResourceEventHandler) {
reh.IngressRouteRootNamespaces = []string{"roots"}
})
defer done()
// assert that there is only a static listener
assertEqual(t, &v2.DiscoveryResponse{
VersionInfo: "0",
Resources: []types.Any{
any(t, staticListener()),
},
TypeUrl: listenerType,
Nonce: "0",
}, streamLDS(t, cc))
// ir1 is an ingressroute that is not in the root namespaces
ir1 := &ingressroutev1.IngressRoute{
ObjectMeta: metav1.ObjectMeta{
Name: "simple",
Namespace: "default",
},
Spec: ingressroutev1.IngressRouteSpec{
VirtualHost: &ingressroutev1.VirtualHost{Fqdn: "example.com"},
Routes: []ingressroutev1.Route{{
Match: "/",
Services: []ingressroutev1.Service{{
Name: "kuard",
Port: 8080,
}},
}},
},
}
// add ingressroute
rh.OnAdd(ir1)
// assert that there is only a static listener
assertEqual(t, &v2.DiscoveryResponse{
VersionInfo: "1",
Resources: []types.Any{
any(t, staticListener()),
},
TypeUrl: listenerType,
Nonce: "1",
}, streamLDS(t, cc))
} | explode_data.jsonl/22828 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 483
} | [
2830,
3393,
43,
5936,
641,
2483,
4899,
41365,
8439,
7980,
27338,
1155,
353,
8840,
836,
8,
341,
7000,
71,
11,
12527,
11,
2814,
1669,
6505,
1155,
11,
2915,
5801,
71,
353,
772,
413,
20766,
17945,
8,
341,
197,
197,
11063,
5337,
2483,
48... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_getMods(t *testing.T) {
if strings.Join(getMods(781), "") != "[NoFail TouchDevice Hidden HalfTime]" {
t.Fatal("Expected \"[NoFail TouchDevice Hidden HalfTime]\" but got \"" + strings.Join(getMods(781), "") + "\".")
}
} | explode_data.jsonl/66164 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
3062,
81500,
1155,
353,
8840,
836,
8,
341,
743,
9069,
22363,
5433,
81500,
7,
22,
23,
16,
701,
11700,
961,
10545,
2753,
19524,
19338,
6985,
34242,
25839,
1462,
19177,
341,
197,
3244,
26133,
445,
18896,
7245,
58,
2753,
19524,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInference(t *testing.T) {
log.SetLogLevel(logger.DebugLevel)
act := NewActivity(getActivityMetadata())
tc := test.NewTestActivityContext(getActivityMetadata())
var data interface{}
_ = json.Unmarshal([]byte("{\"device\":\"RESTDevice\",\"gateway\":\"HelloWorldGroup\",\"id\":\"fa9f3c8d-e4ec-4d48-b6f0-def16a5f1523\",\"readings\":[{\"deviceName\":\"RESTDevice\",\"id\":\"8b5080ba-f3f8-427a-8429-ac5cf6d2e823\",\"mediaType\":\"image/jpeg\",\"origin\":1650595536601,\"profileName\":\"Generic-REST-Device\",\"resourceName\":\"image_reading\",\"value\":\"/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////2wBDAf//////////////////////////////////////////////////////////////////////////////////////wAARCADqATkDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECA//EACQQAQEBAAIBBAMBAQEBAAAAAAABESExQQISUXFhgZGxocHw/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/xAAWEQEBAQAAAAAAAAAAAAAAAAAAEQH/2gAMAwEAAhEDEQA/AMriLyCKgg1gQwCgs4FTMOdutepjQak+FzMSVqgxZdRdPPIIvH5WzzGdBriphtTeAXg2ZjKA1pqKDUGZca3foBek8gFv8Ie3fKdA1qb8s7hoL6eLVt51FsAnql3Ut1M7AWbflLMDkEMX/F6/YjK/pADFQAUNA6alYagKk72m/j9p4Bq2fDDSYKLNXPNLoHE/NT6RYC31cJxZ3yWVM+aBYi/S2ZgiAsnYJx5D21vPmqrm3PTfpQQwyAC8JZvSKDni41ZrMuUVVl+Uz9w9v/1QWrZsZ5nFPHYH+JZyureQSF5M+fJ0CAfwRAVRBQA1DAWVUayoJUWoDpsxntPsueBV4+VxhdyAtv8AjOLGpIDMLbeGvbF4iozJfr/WukAVABAXAQXEAAASzVAZdO2WNordm+emFl7XcQSNZiFtv0C9w90nhJf4mA1u+GcJFwIyAqL/AOovwgGNfSRqdIrNa29M0gKCAojU9PAMjWXpckEJFNFEAAXEUBABYz6rZ0ureQc9vyt9XxDF2QAXtABcQAs0AZywkvluJbyipifas52DcyxjlZweAO0xri/hc+wZOEKIu6nSyeToVZyWXwvCg53gW81QQ7aTNAn5dGZJPs1UXURQAUEMCXQLZE93PRZ5hPTgNMrbIzKCm52LZwCs+2M8w2g3sjPuZAXb4IsMAUACzVUGM4/K+md6vEXUUyM5PDR0IxYe6ramih0VNBrS4xoqN8Q1BFQk3yqyAsioioAAKgDSJL4/jQIn5igLrPqtOuf6oOaxbMoAltUAhhIoJiiggrPu+AaOIxtAX3JbaAIaLwi4t9X4T3fg2AFtqcrUUarP20zUDAmqoE0WRBZPNVUVEAAAAVAC8kvih2DSKxOdBqs7Z0l0gI0mKAC4AuHE7ZtBriM+744QAAAAABAFsveIttBICyaikvy1+r/Cen5rWQHIBQa4rIDRqSl5qDWqziqgAAAATA7BpGdqXb2C2+J/UgAtRQBSQtkBWb6vhLbQAAAAAEBRAAAAAUbm+GZNdPxAP+ql2Tjwx7/wIgZ8iKvBk+CJoCXii9gaqZ/qqihAAAEVABGkBFUwBftNkZ3QW34QAAABFAQAVAAAAAARVkl8gs/43sk1jL45LvHArepk+E9XTG35oLqsmIKmLAEygKg0y1AFQBUXwgAAAoBC34S3UAAABAVAAAAAABAUQAVABdRQa1PcYyit2z58M8C4ouM2NXpOEGeWtNZUatiAIoAKIoCoAoG4C9MW6dgIoAIAAAAAAACKWAgL0CAAAALiANCKioNLgM1CrLihmTafkt1EF3SZ5ZVUW4mnIKvAi5fhEURVDWVQBRAAAAAAAAQFRVyAyulgAqCKlF8IqLsEgC9mGoC+IusqCrv5ZEUVOk1RuJfwSLOOkGFi4XPCoYYrNiKauosBGi9ICstM1UAAAAAAFQ0VcTBAXUGgIqGoKhKAzRRUQUAwxoSrGRpkQA/qiosOL9oJptMRRVZa0VUqSiChE6BqMgCwqKqIogAIAqKCKgKoogg0lBFuIKgAAAKNRlf2gqsftsEtZWoAAqAACKoMqAAeSoqp39kL2AqLOlE8rEBFQARYALhigrNC9gGmooLp4TweEQFFBFAECgIoAu0ifIAqAAA//9k=\",\"valueType\":\"String\"}],\"source\":1650595536601743000}"), &data)
value, _ := base64.StdEncoding.DecodeString(data.(map[string]interface{})["readings"].([]interface{})[0].(map[string]interface{})["value"].(string))
//setup attrs
tc.SetSetting("method", "POST")
tc.SetSetting("timeout", 100000)
var urlMapping interface{}
_ = json.Unmarshal([]byte("[{\"Alias\":\"0\",\"URL\":\"https://tibcocvmodel-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/c0f2ffe4-bb8f-4f09-a552-b85332af6769/classify/iterations/Iteration1/image\"}]"), &urlMapping)
tc.SetSetting("urlMapping", urlMapping)
tc.SetSetting("leftToken", "$")
tc.SetSetting("rightToken", "$")
// tc.SetSetting("variablesDef", "")
var httpHeaders interface{}
_ = json.Unmarshal([]byte("[{\"Key\":\"Accept\",\"Value\":\"application/json\"},{\"Key\":\"Content-Type\",\"Value\":\"application/json-patch+json\"}]"), &httpHeaders)
tc.SetSetting("httpHeaders", httpHeaders)
tc.SetInput("URL", "0")
var headers interface{}
_ = json.Unmarshal([]byte("[{\"key\":\"Accept\",\"value\":\"*/*\"},{\"key\":\"Accept-Encoding\",\"value\":\"gz, defalte, br\"},{\"key\":\"Connection\",\"value\":\"keep-alive\"},{\"key\":\"Prediction-Key\",\"value\":\"3589909f8bd04276acda68e253dfccba\"},{\"key\":\"Content-Type\",\"value\":\"application/octet-stream\"}]"), &headers)
tc.SetInput("Headers", headers)
// tc.SetInput("Method", properties)
tc.SetInput("Body", value)
// tc.SetInput("Variables", properties)
tc.SetInput("SkipCondition", false)
_, err := act.Eval(tc)
assert.Nil(t, err)
if err != nil {
t.Logf("Could not publish a message: %s", err)
// t.Fail()
}
} | explode_data.jsonl/70799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2191
} | [
2830,
3393,
641,
2202,
1155,
353,
8840,
836,
8,
341,
6725,
4202,
72676,
37833,
20345,
4449,
692,
92699,
1669,
1532,
4052,
32090,
14610,
2398,
78255,
1669,
1273,
7121,
2271,
4052,
1972,
32090,
14610,
12367,
2405,
821,
3749,
16094,
197,
62,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_addOnEmpty(t *testing.T) {
dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
}
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
sshConfig := filepath.Join(dir, "config")
if err := add(sshConfig, "test.okteto", model.Localhost, 8080); err != nil {
t.Fatal(err)
}
cfg, err := getConfig(sshConfig)
if err != nil {
t.Fatal(err)
}
h := cfg.getHost("test.okteto")
if h == nil {
t.Fatal("couldn't find test.okteto")
}
if err := remove(sshConfig, "test.okteto"); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/53873 | {
"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,
2891,
1925,
3522,
1155,
353,
8840,
836,
8,
341,
48532,
11,
1848,
1669,
43144,
65009,
6184,
19814,
14676,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
743,
1848,
1669,
2643,
84427,
14161,
1215,
1848,
961,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestParseExpressions(t *testing.T) {
for _, test := range testExpr {
t.Run(test.input, func(t *testing.T) {
expr, err := ParseExpr(test.input)
// Unexpected errors are always caused by a bug.
require.NotEqual(t, err, errUnexpected, "unexpected error occurred")
if !test.fail {
require.NoError(t, err)
require.Equal(t, test.expected, expr, "error on input '%s'", test.input)
} else {
require.Error(t, err)
require.Contains(t, err.Error(), test.errMsg, "unexpected error on input '%s', expected '%s', got '%s'", test.input, test.errMsg, err.Error())
errorList, ok := err.(ParseErrors)
require.True(t, ok, "unexpected error type")
for _, e := range errorList {
require.True(t, 0 <= e.PositionRange.Start, "parse error has negative position\nExpression '%s'\nError: %v", test.input, e)
require.True(t, e.PositionRange.Start <= e.PositionRange.End, "parse error has negative length\nExpression '%s'\nError: %v", test.input, e)
require.True(t, e.PositionRange.End <= Pos(len(test.input)), "parse error is not contained in input\nExpression '%s'\nError: %v", test.input, e)
}
}
})
}
} | explode_data.jsonl/3392 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 459
} | [
2830,
3393,
14463,
40315,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
1273,
16041,
341,
197,
3244,
16708,
8623,
10046,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
8122,
649,
11,
1848,
1669,
14775,
16041,
8623,
10046,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListArtifact(t *testing.T) {
ctx := context.Background()
datastore := createInmemoryDataStore(t, mockScope.NewTestScope())
testStoragePrefix, err := datastore.ConstructReference(ctx, datastore.GetBaseContainerFQN(ctx), "test")
assert.NoError(t, err)
dcRepo := &mocks.DataCatalogRepo{
MockDatasetRepo: &mocks.DatasetRepo{},
MockArtifactRepo: &mocks.ArtifactRepo{},
MockTagRepo: &mocks.TagRepo{},
}
expectedDataset := getTestDataset()
mockDatasetModel := models.Dataset{
DatasetKey: models.DatasetKey{
Project: expectedDataset.Id.Project,
Domain: expectedDataset.Id.Domain,
Name: expectedDataset.Id.Name,
Version: expectedDataset.Id.Version,
UUID: expectedDataset.Id.UUID,
},
}
expectedArtifact := getTestArtifact()
mockArtifactModel := getExpectedArtifactModel(ctx, t, datastore, expectedArtifact)
t.Run("List Artifact on invalid filter", func(t *testing.T) {
artifactManager := NewArtifactManager(dcRepo, datastore, testStoragePrefix, mockScope.NewTestScope())
filter := &datacatalog.FilterExpression{
Filters: []*datacatalog.SinglePropertyFilter{
{
PropertyFilter: &datacatalog.SinglePropertyFilter_DatasetFilter{
DatasetFilter: &datacatalog.DatasetPropertyFilter{
Property: &datacatalog.DatasetPropertyFilter_Project{
Project: "test",
},
},
},
},
},
}
artifactResponse, err := artifactManager.ListArtifacts(ctx, datacatalog.ListArtifactsRequest{Dataset: getTestDataset().Id, Filter: filter})
assert.Error(t, err)
assert.Nil(t, artifactResponse)
responseCode := status.Code(err)
assert.Equal(t, codes.InvalidArgument, responseCode)
})
t.Run("List Artifacts with Partition and Tag", func(t *testing.T) {
artifactManager := NewArtifactManager(dcRepo, datastore, testStoragePrefix, mockScope.NewTestScope())
filter := &datacatalog.FilterExpression{
Filters: []*datacatalog.SinglePropertyFilter{
{
PropertyFilter: &datacatalog.SinglePropertyFilter_PartitionFilter{
PartitionFilter: &datacatalog.PartitionPropertyFilter{
Property: &datacatalog.PartitionPropertyFilter_KeyVal{
KeyVal: &datacatalog.KeyValuePair{Key: "key1", Value: "val1"},
},
},
},
},
{
PropertyFilter: &datacatalog.SinglePropertyFilter_PartitionFilter{
PartitionFilter: &datacatalog.PartitionPropertyFilter{
Property: &datacatalog.PartitionPropertyFilter_KeyVal{
KeyVal: &datacatalog.KeyValuePair{Key: "key2", Value: "val2"},
},
},
},
},
{
PropertyFilter: &datacatalog.SinglePropertyFilter_TagFilter{
TagFilter: &datacatalog.TagPropertyFilter{
Property: &datacatalog.TagPropertyFilter_TagName{
TagName: "special",
},
},
},
},
},
}
dcRepo.MockDatasetRepo.On("Get", mock.Anything,
mock.MatchedBy(func(dataset models.DatasetKey) bool {
return dataset.Project == expectedDataset.Id.Project &&
dataset.Domain == expectedDataset.Id.Domain &&
dataset.Name == expectedDataset.Id.Name &&
dataset.Version == expectedDataset.Id.Version
})).Return(mockDatasetModel, nil)
mockArtifacts := []models.Artifact{
mockArtifactModel,
mockArtifactModel,
}
dcRepo.MockArtifactRepo.On("List", mock.Anything,
mock.MatchedBy(func(dataset models.DatasetKey) bool {
return dataset.Project == expectedDataset.Id.Project &&
dataset.Domain == expectedDataset.Id.Domain &&
dataset.Name == expectedDataset.Id.Name &&
dataset.Version == expectedDataset.Id.Version
}),
mock.MatchedBy(func(listInput models.ListModelsInput) bool {
return len(listInput.Filters) == 5 &&
len(listInput.JoinEntityToConditionMap) == 2 &&
listInput.Filters[0].GetDBEntity() == common.Partition &&
listInput.Filters[1].GetDBEntity() == common.Partition &&
listInput.Filters[2].GetDBEntity() == common.Partition &&
listInput.Filters[3].GetDBEntity() == common.Partition &&
listInput.Filters[4].GetDBEntity() == common.Tag &&
listInput.JoinEntityToConditionMap[common.Partition] != nil &&
listInput.JoinEntityToConditionMap[common.Tag] != nil &&
listInput.Limit == 50 &&
listInput.Offset == 0
})).Return(mockArtifacts, nil)
artifactResponse, err := artifactManager.ListArtifacts(ctx, datacatalog.ListArtifactsRequest{Dataset: expectedDataset.Id, Filter: filter})
assert.NoError(t, err)
assert.NotEmpty(t, artifactResponse)
})
t.Run("List Artifacts with No Partition", func(t *testing.T) {
artifactManager := NewArtifactManager(dcRepo, datastore, testStoragePrefix, mockScope.NewTestScope())
filter := &datacatalog.FilterExpression{Filters: nil}
dcRepo.MockDatasetRepo.On("Get", mock.Anything,
mock.MatchedBy(func(dataset models.DatasetKey) bool {
return dataset.Project == expectedDataset.Id.Project &&
dataset.Domain == expectedDataset.Id.Domain &&
dataset.Name == expectedDataset.Id.Name &&
dataset.Version == expectedDataset.Id.Version
})).Return(mockDatasetModel, nil)
mockArtifacts := []models.Artifact{
mockArtifactModel,
mockArtifactModel,
}
dcRepo.MockArtifactRepo.On("List", mock.Anything,
mock.MatchedBy(func(dataset models.DatasetKey) bool {
return dataset.Project == expectedDataset.Id.Project &&
dataset.Domain == expectedDataset.Id.Domain &&
dataset.Name == expectedDataset.Id.Name &&
dataset.Version == expectedDataset.Id.Version
}),
mock.MatchedBy(func(listInput models.ListModelsInput) bool {
return len(listInput.Filters) == 0 &&
len(listInput.JoinEntityToConditionMap) == 0
})).Return(mockArtifacts, nil)
artifactResponse, err := artifactManager.ListArtifacts(ctx, datacatalog.ListArtifactsRequest{Dataset: expectedDataset.Id, Filter: filter})
assert.NoError(t, err)
assert.NotEmpty(t, artifactResponse)
})
} | explode_data.jsonl/20014 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2351
} | [
2830,
3393,
852,
85578,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
8924,
4314,
1669,
1855,
641,
17269,
1043,
6093,
1155,
11,
7860,
10803,
7121,
2271,
10803,
2398,
18185,
5793,
14335,
11,
1848,
1669,
64986,
4801,
1235,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_packetConnLocalAddr(t *testing.T) {
deadbeefHW := net.HardwareAddr{0xde, 0xad, 0xbe, 0xef, 0xde, 0xad}
p := &packetConn{
ifi: &net.Interface{
HardwareAddr: deadbeefHW,
},
}
if want, got := deadbeefHW, p.LocalAddr().(*Addr).HardwareAddr; !bytes.Equal(want, got) {
t.Fatalf("unexpected hardware address:\n- want: %v\n- got: %v", want, got)
}
} | explode_data.jsonl/35214 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 170
} | [
2830,
3393,
21078,
9701,
7319,
13986,
1155,
353,
8840,
836,
8,
341,
197,
33754,
1371,
823,
38252,
1669,
4179,
3839,
37750,
13986,
90,
15,
56185,
11,
220,
15,
55254,
11,
220,
15,
42459,
11,
220,
15,
47510,
11,
220,
15,
56185,
11,
220... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestRESTClientPodCPU(t *testing.T) {
targetTimestamp := 1
window := 30 * time.Second
tc := restClientTestCase{
desiredMetricValues: PodMetricsInfo{
"test-pod-0": {Value: 5000, Timestamp: offsetTimestampBy(targetTimestamp), Window: window},
"test-pod-1": {Value: 5000, Timestamp: offsetTimestampBy(targetTimestamp), Window: window},
"test-pod-2": {Value: 5000, Timestamp: offsetTimestampBy(targetTimestamp), Window: window},
},
resourceName: v1.ResourceCPU,
targetTimestamp: targetTimestamp,
window: window,
reportedPodMetrics: []map[string]int64{{"test": 5000}, {"test": 5000}, {"test": 5000}},
}
tc.runTest(t)
} | explode_data.jsonl/64897 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 251
} | [
2830,
3393,
38307,
2959,
23527,
31615,
1155,
353,
8840,
836,
8,
341,
28861,
20812,
1669,
220,
16,
198,
23545,
1669,
220,
18,
15,
353,
882,
32435,
198,
78255,
1669,
2732,
2959,
16458,
515,
197,
52912,
2690,
54310,
6227,
25,
16821,
27328,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTx_ChangeToAddress(t *testing.T) {
t.Run("missing address and nil fees", func(t *testing.T) {
tx := bt.NewTx()
assert.NotNil(t, tx)
err := tx.From(
"07912972e42095fe58daaf09161c5a5da57be47c2054dc2aaa52b30fefa1940b",
0,
"76a914af2590a45ae401651fdbdf59a76ad43d1862534088ac",
4000000)
assert.NoError(t, err)
err = tx.ChangeToAddress("", nil)
assert.Error(t, err)
})
t.Run("nil fees, valid address", func(t *testing.T) {
tx := bt.NewTx()
assert.NotNil(t, tx)
err := tx.From(
"07912972e42095fe58daaf09161c5a5da57be47c2054dc2aaa52b30fefa1940b",
0,
"76a914af2590a45ae401651fdbdf59a76ad43d1862534088ac",
4000000)
assert.NoError(t, err)
err = tx.ChangeToAddress("1GHMW7ABrFma2NSwiVe9b9bZxkMB7tuPZi", nil)
assert.Error(t, err)
})
t.Run("valid fees, valid address", func(t *testing.T) {
tx := bt.NewTx()
assert.NotNil(t, tx)
err := tx.From(
"07912972e42095fe58daaf09161c5a5da57be47c2054dc2aaa52b30fefa1940b",
0,
"76a914af2590a45ae401651fdbdf59a76ad43d1862534088ac",
4000000)
assert.NoError(t, err)
err = tx.ChangeToAddress("1GHMW7ABrFma2NSwiVe9b9bZxkMB7tuPZi", bt.DefaultFees())
assert.NoError(t, err)
assert.Equal(t, 1, tx.OutputCount())
assert.Equal(t, "76a914a7a1a7fd7d279b57b84e596cbbf82608efdb441a88ac", tx.Outputs[0].LockingScript.ToString())
})
} | explode_data.jsonl/28744 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 690
} | [
2830,
3393,
31584,
27588,
844,
1249,
4286,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
30616,
2621,
323,
2092,
12436,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
46237,
1669,
19592,
7121,
31584,
741,
197,
6948,
93882,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFallbackSCSV(t *testing.T) {
test := &serverTest{
name: "FallbackSCSV",
// OpenSSL 1.0.1j is needed for the -fallback_scsv option.
command: []string{"openssl", "s_client", "-fallback_scsv"},
expectHandshakeErrorIncluding: "inppropriate protocol fallback",
}
runServerTestTLS11(t, test)
} | explode_data.jsonl/80567 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
87206,
3540,
17803,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
609,
4030,
2271,
515,
197,
11609,
25,
330,
87206,
3540,
17803,
756,
197,
197,
322,
65617,
220,
16,
13,
15,
13,
16,
73,
374,
4362,
369,
279,
481,
73311,
13171... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddParagraph(t *testing.T) {
doc := document.New()
if len(doc.Paragraphs()) != 0 {
t.Errorf("expected 0 paragraphs, got %d", len(doc.Paragraphs()))
}
doc.AddParagraph()
if len(doc.Paragraphs()) != 1 {
t.Errorf("expected 1 paragraphs, got %d", len(doc.Paragraphs()))
}
doc.AddParagraph()
if len(doc.Paragraphs()) != 2 {
t.Errorf("expected 2 paragraphs, got %d", len(doc.Paragraphs()))
}
} | explode_data.jsonl/61207 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 165
} | [
2830,
3393,
2212,
42165,
1155,
353,
8840,
836,
8,
341,
59536,
1669,
2197,
7121,
741,
743,
2422,
19153,
41288,
9216,
82,
2140,
961,
220,
15,
341,
197,
3244,
13080,
445,
7325,
220,
15,
42643,
11,
2684,
1018,
67,
497,
2422,
19153,
41288,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestComponentManager_NoCallStopIfNoCallStart(t *testing.T) {
c := Component3{}
cm := Manager{}
cm.Inject(&c)
err := cm.Stop(context.Background())
require.NoError(t, err)
require.False(t, c.stopped)
require.False(t, c.started)
err = cm.Start(context.Background())
require.NoError(t, err)
require.False(t, c.stopped)
require.True(t, c.started)
err = cm.Stop(context.Background())
require.NoError(t, err)
require.True(t, c.stopped)
require.True(t, c.started)
} | explode_data.jsonl/35608 | {
"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,
2189,
2043,
36989,
7220,
10674,
2679,
2753,
7220,
3479,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
5578,
18,
16094,
98316,
1669,
10567,
16094,
98316,
41046,
2099,
66,
340,
9859,
1669,
9961,
30213,
5378,
19047,
2398,
17957,
3569... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadArtifact_WorkflowNoStatus_NotFound(t *testing.T) {
store, manager, job := initWithJob(t)
defer store.Close()
// report workflow
workflow := util.NewWorkflow(&v1alpha1.Workflow{
ObjectMeta: v1.ObjectMeta{
Name: "MY_NAME",
Namespace: "MY_NAMESPACE",
UID: "run-1",
CreationTimestamp: v1.NewTime(time.Unix(11, 0).UTC()),
OwnerReferences: []v1.OwnerReference{{
APIVersion: "kubeflow.org/v1beta1",
Kind: "ScheduledWorkflow",
Name: "SCHEDULE_NAME",
UID: types.UID(job.UUID),
}},
}})
err := manager.ReportWorkflowResource(workflow)
assert.Nil(t, err)
_, err = manager.ReadArtifact("run-1", "node-1", "artifact-1")
assert.True(t, util.IsUserErrorCodeMatch(err, codes.NotFound))
} | explode_data.jsonl/28399 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
4418,
85578,
87471,
4965,
2753,
2522,
60816,
6650,
1155,
353,
8840,
836,
8,
341,
57279,
11,
6645,
11,
2618,
1669,
13864,
12245,
1155,
340,
16867,
3553,
10421,
741,
197,
322,
1895,
28288,
198,
197,
56249,
1669,
4094,
7121,
62... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestURLTemplate(t *testing.T) {
testcases := []struct {
name string
jobType prowapi.ProwJobType
org string
repo string
job string
build string
expect string
k8sOnly bool
}{
{
name: "k8s presubmit",
jobType: prowapi.PresubmitJob,
org: "kubernetes",
repo: "kubernetes",
job: "k8s-pre-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/0/k8s-pre-1/1/",
k8sOnly: true,
},
{
name: "k8s-security presubmit",
jobType: prowapi.PresubmitJob,
org: "kubernetes-security",
repo: "kubernetes",
job: "k8s-pre-1",
build: "1",
expect: "https://console.cloud.google.com/storage/browser/kubernetes-security-prow/pr-logs/pull/kubernetes-security_kubernetes/0/k8s-pre-1/1/",
k8sOnly: true,
},
{
name: "k8s/test-infra presubmit",
jobType: prowapi.PresubmitJob,
org: "kubernetes",
repo: "test-infra",
job: "ti-pre-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/test-infra/0/ti-pre-1/1/",
k8sOnly: true,
},
{
name: "foo/k8s presubmit",
jobType: prowapi.PresubmitJob,
org: "foo",
repo: "kubernetes",
job: "k8s-pre-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/foo_kubernetes/0/k8s-pre-1/1/",
},
{
name: "foo-bar presubmit",
jobType: prowapi.PresubmitJob,
org: "foo",
repo: "bar",
job: "foo-pre-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/foo_bar/0/foo-pre-1/1/",
},
{
name: "k8s postsubmit",
jobType: prowapi.PostsubmitJob,
org: "kubernetes",
repo: "kubernetes",
job: "k8s-post-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/logs/k8s-post-1/1/",
},
{
name: "k8s periodic",
jobType: prowapi.PeriodicJob,
job: "k8s-peri-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/logs/k8s-peri-1/1/",
},
{
name: "empty periodic",
jobType: prowapi.PeriodicJob,
job: "nan-peri-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/logs/nan-peri-1/1/",
},
{
name: "k8s batch",
jobType: prowapi.BatchJob,
org: "kubernetes",
repo: "kubernetes",
job: "k8s-batch-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/batch/k8s-batch-1/1/",
k8sOnly: true,
},
{
name: "foo bar batch",
jobType: prowapi.BatchJob,
org: "foo",
repo: "bar",
job: "k8s-batch-1",
build: "1",
expect: *deckPath + "/view/gcs/" + *bucket + "/pr-logs/pull/foo_bar/batch/k8s-batch-1/1/",
},
}
for _, tc := range testcases {
if !*k8sProw && tc.k8sOnly {
continue
}
var pj = prowapi.ProwJob{
ObjectMeta: metav1.ObjectMeta{Name: tc.name},
Spec: prowapi.ProwJobSpec{
Type: tc.jobType,
Job: tc.job,
},
Status: prowapi.ProwJobStatus{
BuildID: tc.build,
},
}
if tc.jobType != prowapi.PeriodicJob {
pj.Spec.Refs = &prowapi.Refs{
Pulls: []prowapi.Pull{{}},
Org: tc.org,
Repo: tc.repo,
}
}
var b bytes.Buffer
if err := c.Plank.JobURLTemplate.Execute(&b, &pj); err != nil {
t.Fatalf("Error executing template: %v", err)
}
res := b.String()
if res != tc.expect {
t.Errorf("tc: %s, Expect URL: %s, got %s", tc.name, tc.expect, res)
}
}
} | explode_data.jsonl/55572 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1895
} | [
2830,
3393,
3144,
7275,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
68577,
929,
47558,
2068,
1069,
651,
12245,
929,
198,
197,
87625,
257,
914,
198,
197,
17200,
5368,
262,
914,
198... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestEncode(t *testing.T) {
for _, p := range pairs {
buf := make([]byte, StdEncoding.EncodedLen(len(p.decoded)))
StdEncoding.Encode(buf, []byte(p.decoded))
testEqual(t, "Encode(%q) = %q, want %q", p.decoded, string(buf), p.encoded)
}
} | explode_data.jsonl/43938 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 112
} | [
2830,
3393,
32535,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
281,
1669,
2088,
13530,
341,
197,
26398,
1669,
1281,
10556,
3782,
11,
42517,
14690,
26598,
6737,
11271,
6901,
1295,
28020,
6737,
5929,
197,
197,
22748,
14690,
50217,
10731,
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 TestRequirementConstructor(t *testing.T) {
requirementConstructorTests := []struct {
Key string
Op Operator
Vals sets.String
Success bool
}{
{"x", InOperator, nil, false},
{"x", NotInOperator, sets.NewString(), false},
{"x", InOperator, sets.NewString("foo"), true},
{"x", NotInOperator, sets.NewString("foo"), true},
{"x", ExistsOperator, nil, true},
{"x", DoesNotExistOperator, nil, true},
{"1foo", InOperator, sets.NewString("bar"), true},
{"1234", InOperator, sets.NewString("bar"), true},
{"y", GreaterThanOperator, sets.NewString("1.1"), true},
{"z", LessThanOperator, sets.NewString("5.3"), true},
{"foo", GreaterThanOperator, sets.NewString("bar"), false},
{"barz", LessThanOperator, sets.NewString("blah"), false},
{strings.Repeat("a", 254), ExistsOperator, nil, false}, //breaks DNS rule that len(key) <= 253
}
for _, rc := range requirementConstructorTests {
if _, err := NewRequirement(rc.Key, rc.Op, rc.Vals); err == nil && !rc.Success {
t.Errorf("expected error with key:%#v op:%v vals:%v, got no error", rc.Key, rc.Op, rc.Vals)
} else if err != nil && rc.Success {
t.Errorf("expected no error with key:%#v op:%v vals:%v, got:%v", rc.Key, rc.Op, rc.Vals, err)
}
}
} | explode_data.jsonl/66796 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 495
} | [
2830,
3393,
75802,
13288,
1155,
353,
8840,
836,
8,
341,
17957,
478,
13288,
18200,
1669,
3056,
1235,
341,
197,
55242,
257,
914,
198,
197,
197,
7125,
414,
28498,
198,
197,
17446,
1127,
262,
7289,
6431,
198,
197,
197,
7188,
1807,
198,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestNamespaceIndexHighConcurrentQueriesWithoutTimeouts(t *testing.T) {
testNamespaceIndexHighConcurrentQueries(t,
testNamespaceIndexHighConcurrentQueriesOptions{
withTimeouts: false,
})
} | explode_data.jsonl/34830 | {
"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,
22699,
1552,
11976,
1109,
3231,
55261,
26040,
7636,
82,
1155,
353,
8840,
836,
8,
341,
18185,
22699,
1552,
11976,
1109,
3231,
55261,
1155,
345,
197,
18185,
22699,
1552,
11976,
1109,
3231,
55261,
3798,
515,
298,
46948,
7636,
82,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestThresholdIsCorrectlyCalledForCount(t *testing.T) {
count := getMockCount(t)
for i := 0; i < 10; i++ {
count.Increment()
}
count.ThresholdedResult(20) // will fail if parameters are wrong
} | explode_data.jsonl/57753 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 75
} | [
2830,
3393,
37841,
3872,
33092,
398,
20960,
2461,
2507,
1155,
353,
8840,
836,
8,
341,
18032,
1669,
633,
11571,
2507,
1155,
340,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
26,
600,
1027,
341,
197,
18032,
5337,
13477,
741,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestErrFlows(t *testing.T) {
bldr := &nop.Builder{Err: errors.New("not okay")}
expectedErrEventMsg := "Warning BuildExecuteFailed Failed to execute Build"
build := newBuild("test")
f := &fixture{
t: t,
objects: []runtime.Object{build},
kubeobjects: nil,
client: fake.NewSimpleClientset(build),
kubeclient: k8sfake.NewSimpleClientset(),
}
stopCh := make(chan struct{})
eventCh := make(chan string, 1024)
defer close(stopCh)
defer close(eventCh)
c, i, k8sI := f.newController(bldr, eventCh)
f.updateIndex(i, []*v1alpha1.Build{build})
i.Start(stopCh)
k8sI.Start(stopCh)
if err := c.syncHandler(getKey(build, t)); err == nil {
t.Errorf("Expect error syncing build")
}
select {
case statusEvent := <-eventCh:
if !strings.Contains(statusEvent, expectedErrEventMsg) {
t.Errorf("Event message; wanted %q, got %q", expectedErrEventMsg, statusEvent)
}
case <-time.After(2 * time.Second):
t.Fatalf("No events published")
}
} | explode_data.jsonl/30873 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 400
} | [
2830,
3393,
7747,
3882,
4241,
1155,
353,
8840,
836,
8,
341,
2233,
72377,
1669,
609,
62813,
15641,
90,
7747,
25,
5975,
7121,
445,
1921,
16910,
42132,
42400,
7747,
1556,
6611,
1669,
330,
12087,
7854,
17174,
9408,
21379,
311,
9026,
7854,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCollisionSystemAddByInterface(t *testing.T) {
engo.Mailbox = &engo.MessageManager{}
sys := &CollisionSystem{}
sys.New(nil)
phys := &PhysicsSystem{VelocityIterations: 3, PositionIterations: 8}
basic := ecs.NewBasic()
space := common.SpaceComponent{
Width: 10,
Height: 10,
}
entityBodyDef := box2d.NewB2BodyDef()
entityBodyDef.Type = box2d.B2BodyType.B2_dynamicBody
entityBodyDef.Position = Conv.ToBox2d2Vec(space.Center())
entityBodyDef.Angle = Conv.DegToRad(space.Rotation)
boxBody := World.CreateBody(entityBodyDef)
var entityShape box2d.B2PolygonShape
entityShape.SetAsBox(Conv.PxToMeters(space.Width/2),
Conv.PxToMeters(space.Height/2))
entityFixtureDef := box2d.B2FixtureDef{
Shape: &entityShape,
Density: 1,
Friction: 1,
}
boxBody.CreateFixtureFromDef(&entityFixtureDef)
e := collisionEntity{&basic, &space, &Box2dComponent{Body: boxBody}}
sys.AddByInterface(e)
phys.AddByInterface(e)
if len(sys.entities) != 1 {
t.Errorf("AddByInterface failed for collision system; wanted %d, have %d", 1, len(sys.entities))
}
if len(phys.entities) != 1 {
t.Errorf("AddByInterface failed for physics system; wanted %d, have %d", 1, len(sys.entities))
}
} | explode_data.jsonl/58614 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 470
} | [
2830,
3393,
32280,
2320,
2212,
1359,
5051,
1155,
353,
8840,
836,
8,
341,
197,
64653,
73103,
2011,
284,
609,
64653,
8472,
2043,
16094,
41709,
1669,
609,
32280,
2320,
16094,
41709,
7121,
27907,
692,
197,
41205,
1669,
609,
33899,
2320,
90,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCountWithSample(t *testing.T) {
result := (&Metric{
Name: "test",
Value: 1.11111,
Type: Counter,
SampleRate: 0.33,
}).String()
if expected := "test:1.11111|c|@0.33"; expected != result {
t.Errorf("metric string is different.\nExpected: \"%s\".\n Got: \"%s\"", expected, result)
}
} | explode_data.jsonl/14847 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
2507,
2354,
17571,
1155,
353,
8840,
836,
8,
341,
9559,
1669,
15899,
54310,
515,
197,
21297,
25,
981,
330,
1944,
756,
197,
47399,
25,
414,
220,
16,
13,
16,
16,
16,
16,
16,
345,
197,
27725,
25,
981,
19735,
345,
197,
7568... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStartStop(t *testing.T) {
n := New("teststartstop", lookupFunc)
n.Start()
if err := n.Stop(); err != nil {
t.Fatalf("Address Manager failed to stop: %v", err)
}
} | explode_data.jsonl/26474 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 69
} | [
2830,
3393,
3479,
10674,
1155,
353,
8840,
836,
8,
341,
9038,
1669,
1532,
445,
1944,
2468,
9495,
497,
18615,
9626,
340,
9038,
12101,
741,
743,
1848,
1669,
308,
30213,
2129,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
4286,
10567,
4641,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRetryPolicySuccessNoDownload(t *testing.T) {
srv, close := mock.NewServer()
defer close()
srv.SetResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("response body")))
pl := NewPipeline(srv, NewRetryPolicy(nil))
req, err := NewRequest(context.Background(), http.MethodGet, srv.URL())
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
req.SkipBodyDownload()
resp, err := pl.Do(req)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if resp.StatusCode != http.StatusOK {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
resp.Body.Close()
} | explode_data.jsonl/24389 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 229
} | [
2830,
3393,
51560,
13825,
7188,
2753,
11377,
1155,
353,
8840,
836,
8,
341,
1903,
10553,
11,
3265,
1669,
7860,
7121,
5475,
741,
16867,
3265,
741,
1903,
10553,
4202,
2582,
30389,
26124,
15872,
19886,
52989,
701,
7860,
26124,
5444,
10556,
37... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBot_LogOut(t *testing.T) {
type fields struct {
Configuration Configuration
apiClient apiClient
BotUser User
messageMHs []matcherHandler
editedMessageMHs []matcherHandler
channelPostMHs []matcherHandler
editedChannelPostMHs []matcherHandler
inlineQueryMHs []matcherHandler
chosenInlineResultMHs []matcherHandler
callbackQueryMHs []matcherHandler
myChatMemberMHs []matcherHandler
chatMemberMHs []matcherHandler
}
tests := []struct {
name string
fields fields
wantErr bool
}{
{
fields: fields{
apiClient: &mockAPIClient{
method: "logOut",
interfaceMethod: func() interface{} {
return map[string]interface{}{
"id": 123456.,
}
},
bytesMethod: func() []byte {
return []byte("")
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Bot{
Configuration: tt.fields.Configuration,
apiClient: tt.fields.apiClient,
BotUser: tt.fields.BotUser,
messageMHs: tt.fields.messageMHs,
editedMessageMHs: tt.fields.editedMessageMHs,
channelPostMHs: tt.fields.channelPostMHs,
editedChannelPostMHs: tt.fields.editedChannelPostMHs,
inlineQueryMHs: tt.fields.inlineQueryMHs,
chosenInlineResultMHs: tt.fields.chosenInlineResultMHs,
callbackQueryMHs: tt.fields.callbackQueryMHs,
myChatMemberMHs: tt.fields.myChatMemberMHs,
chatMemberMHs: tt.fields.chatMemberMHs,
}
if err := b.LogOut(); (err != nil) != tt.wantErr {
t.Errorf("Bot.LogOut() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
} | explode_data.jsonl/46085 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 846
} | [
2830,
3393,
23502,
44083,
2662,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
197,
7688,
260,
12221,
198,
197,
54299,
2959,
1797,
6330,
2959,
198,
197,
12791,
354,
1474,
2290,
2657,
198,
197,
24753,
48202,
82,
310,
3056,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.