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 TestNoName(t *testing.T) {
client, _, shutdownServer := getFreshApiserverAndClient(t, func() runtime.Object {
return &servicecatalog.ClusterServiceBroker{}
})
defer shutdownServer()
if err := testNoName(client); err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/51878 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 93
} | [
2830,
3393,
2753,
675,
1155,
353,
8840,
836,
8,
341,
25291,
11,
8358,
23766,
5475,
1669,
633,
55653,
91121,
2836,
3036,
2959,
1155,
11,
2915,
368,
15592,
8348,
341,
197,
853,
609,
7936,
26539,
72883,
1860,
65545,
16094,
197,
3518,
16867... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestExpandFileSourceWithKeyAndError(t *testing.T) {
fakeFS := fs.MakeFakeFS()
fakeFS.Create("dir/fa1")
fakeFS.Create("dir/fa2")
fakeFS.Create("dir/readme")
fa := flagsAndArgs{
FileSources: []string{"foo-key=dir/fa*"},
}
err := fa.ExpandFileSource(fakeFS)
if err == nil {
t.Fatalf("FileSources should not be correctly expanded: %v", fa.FileSources)
}
} | explode_data.jsonl/53906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 144
} | [
2830,
3393,
38946,
1703,
3608,
2354,
1592,
3036,
1454,
1155,
353,
8840,
836,
8,
341,
1166,
726,
8485,
1669,
8619,
50133,
52317,
8485,
741,
1166,
726,
8485,
7251,
445,
3741,
87562,
16,
1138,
1166,
726,
8485,
7251,
445,
3741,
87562,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSortWeightedLabeled(t *testing.T) {
for i, test := range []struct {
x []float64
l []bool
w []float64
ansx []float64
ansl []bool
answ []float64
}{
{
x: []float64{8, 3, 7, 8, 4},
ansx: []float64{3, 4, 7, 8, 8},
},
{
x: []float64{8, 3, 7, 8, 4},
w: []float64{.5, 1, 1, .5, 1},
ansx: []float64{3, 4, 7, 8, 8},
answ: []float64{1, 1, 1, .5, .5},
},
{
x: []float64{8, 3, 7, 8, 4},
l: []bool{false, false, true, false, true},
ansx: []float64{3, 4, 7, 8, 8},
ansl: []bool{false, true, true, false, false},
},
{
x: []float64{8, 3, 7, 8, 4},
l: []bool{false, false, true, false, true},
w: []float64{.5, 1, 1, .5, 1},
ansx: []float64{3, 4, 7, 8, 8},
ansl: []bool{false, true, true, false, false},
answ: []float64{1, 1, 1, .5, .5},
},
} {
SortWeightedLabeled(test.x, test.l, test.w)
if !floats.Same(test.x, test.ansx) {
t.Errorf("SortWeightedLabelled mismatch case %d. Expected x %v, Found x %v", i, test.ansx, test.x)
}
if (test.l != nil) && !reflect.DeepEqual(test.l, test.ansl) {
t.Errorf("SortWeightedLabelled mismatch case %d. Expected l %v, Found l %v", i, test.ansl, test.l)
}
if (test.w != nil) && !floats.Same(test.w, test.answ) {
t.Errorf("SortWeightedLabelled mismatch case %d. Expected w %v, Found w %v", i, test.answ, test.w)
}
}
if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), make([]float64, 3)) }) {
t.Errorf("SortWeighted did not panic with x, labels length mismatch")
}
if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), nil) }) {
t.Errorf("SortWeighted did not panic with x, labels length mismatch")
}
if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 3), make([]float64, 2)) }) {
t.Errorf("SortWeighted did not panic with x, weights length mismatch")
}
if !panics(func() { SortWeightedLabeled(make([]float64, 3), nil, make([]float64, 2)) }) {
t.Errorf("SortWeighted did not panic with x, weights length mismatch")
}
} | explode_data.jsonl/1786 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 960
} | [
2830,
3393,
10231,
8295,
291,
43,
22320,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
10225,
262,
3056,
3649,
21,
19,
198,
197,
8810,
262,
3056,
2641,
198,
197,
6692,
262,
3056,
3649,
21,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStubFunc(t *testing.T) {
tt := new(Mock)
defer tt.Close()
tt.StubFunc(Dosomething, func(a int) int {
fmt.Println("stub Dosomething")
return a + 100
})
if Dosomething(1) != 101 {
t.Fatal("stub Dosomething failed")
}
} | explode_data.jsonl/16778 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 106
} | [
2830,
3393,
33838,
9626,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
501,
66436,
340,
16867,
17853,
10421,
2822,
3244,
83,
7758,
392,
9626,
5432,
436,
11532,
11,
2915,
2877,
526,
8,
526,
341,
197,
11009,
12419,
445,
59398,
56920,
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 TestProfilingDiagnostics(t *testing.T) {
tcs := []struct {
defaults *profilingDiagnostics
enabledEnv string
portEnv string
expected *profilingDiagnostics
}{
{defaults: newProfilingDiagnostics(false, 6060), enabledEnv: "", portEnv: "", expected: newProfilingDiagnostics(false, 6060)},
{defaults: newProfilingDiagnostics(true, 8080), enabledEnv: "", portEnv: "", expected: newProfilingDiagnostics(true, 8080)},
{defaults: newProfilingDiagnostics(false, 6060), enabledEnv: "false", portEnv: "8080", expected: newProfilingDiagnostics(false, 8080)},
{defaults: newProfilingDiagnostics(false, 6060), enabledEnv: "true", portEnv: "8080", expected: newProfilingDiagnostics(true, 8080)},
{defaults: newProfilingDiagnostics(false, 6060), enabledEnv: "true", portEnv: "", expected: newProfilingDiagnostics(true, 6060)},
}
for i, tc := range tcs {
t.Run(fmt.Sprintf("testcase %d", i), func(t *testing.T) {
os.Clearenv()
if tc.enabledEnv != "" {
err := os.Setenv(profilingEnabledEnvName, tc.enabledEnv)
assert.NoError(t, err)
}
if tc.portEnv != "" {
err := os.Setenv(profilingPortEnvName, tc.portEnv)
assert.NoError(t, err)
}
err := tc.defaults.overrideWithEnv()
assert.NoError(t, err)
assert.Exactly(t, tc.expected, tc.defaults)
})
}
} | explode_data.jsonl/33537 | {
"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,
18592,
7979,
35,
18938,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11940,
82,
256,
353,
21826,
7979,
35,
18938,
198,
197,
197,
15868,
14359,
914,
198,
197,
52257,
14359,
262,
914,
198,
197,
42400... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestZed(t *testing.T) {
t.Parallel()
dirs, err := findZTests()
require.NoError(t, err)
for d := range dirs {
d := d
t.Run(d, func(t *testing.T) {
t.Parallel()
ztest.Run(t, d)
})
}
t.Run("ParquetBoomerang", func(t *testing.T) {
runParquetBoomerangs(t, dirs)
})
t.Run("ZsonBoomerang", func(t *testing.T) {
runZsonBoomerangs(t, dirs)
})
} | explode_data.jsonl/67533 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
57,
291,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2698,
16838,
11,
1848,
1669,
1477,
57,
18200,
741,
17957,
35699,
1155,
11,
1848,
340,
2023,
294,
1669,
2088,
42248,
341,
197,
2698,
1669,
294,
198,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestWebsocketSubscriber_SubscribeToEvents(t *testing.T) {
t.Run("subscribes and ignores confirmation message", func(t *testing.T) {
wss := WebsocketSubscriber{Endpoint: wsMockUrl.String(), Manager: TestsMockManager{true}}
events := make(chan Event)
sub, err := wss.SubscribeToEvents(events)
if err != nil {
t.Errorf("SubscribeToEvents() error = %v", err)
return
}
defer sub.Unsubscribe()
event := <-events
mockevent := string(event)
if mockevent == "confirmation" {
t.Error("SubscribeToEvents() got unexpected confirmation")
return
}
if mockevent != "event" {
t.Errorf("SubscribeToEvents() got unexpected message = %v", mockevent)
return
}
})
t.Run("subscribes and does not expect confirmation message", func(t *testing.T) {
wss := WebsocketSubscriber{Endpoint: wsMockUrl.String(), Manager: TestsMockManager{false}}
events := make(chan Event)
sub, err := wss.SubscribeToEvents(events, false)
if err != nil {
t.Errorf("SubscribeToEvents() error = %v", err)
return
}
defer sub.Unsubscribe()
event := <-events
mockevent := string(event)
if mockevent != "event" {
t.Errorf("SubscribeToEvents() got unexpected message = %v", mockevent)
return
}
})
t.Run("fails subscribe to invalid URL", func(t *testing.T) {
wss := WebsocketSubscriber{Endpoint: "", Manager: TestsMockManager{false}}
events := make(chan Event)
sub, err := wss.SubscribeToEvents(events)
if err == nil {
sub.Unsubscribe()
t.Error("SubscribeToEvents() expected error, but got nil")
return
}
})
t.Run("subscribes and attempts reconnect", func(t *testing.T) {
wss := WebsocketSubscriber{Endpoint: wsMockUrl.String(), Manager: &TestsReconnectManager{}}
events := make(chan Event)
sub, err := wss.SubscribeToEvents(events, false)
if err != nil {
t.Errorf("SubscribeToEvents() error = %v", err)
return
}
defer sub.Unsubscribe()
event := <-events
mockevent := string(event)
if mockevent != "event" {
t.Errorf("SubscribeToEvents() got unexpected message = %v", mockevent)
return
}
})
} | explode_data.jsonl/60473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 785
} | [
2830,
3393,
5981,
9556,
40236,
36359,
6273,
1249,
7900,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1966,
11592,
9433,
323,
48278,
19539,
1943,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6692,
778,
1669,
4895,
9556,
40236,
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... | 4 |
func TestStringPowers(t *testing.T) {
var p Word
for b := 2; b <= 16; b++ {
for p = 0; p <= 512; p++ {
x := nat(nil).expWW(Word(b), p)
xs := x.utoa(b)
xs2 := itoa(x, b)
if !bytes.Equal(xs, xs2) {
t.Errorf("failed at %d ** %d in base %d: %s != %s", b, p, b, xs, xs2)
}
}
if b >= 3 && testing.Short() {
break
}
}
} | explode_data.jsonl/57385 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 188
} | [
2830,
3393,
703,
47,
15965,
1155,
353,
8840,
836,
8,
341,
2405,
281,
9322,
198,
2023,
293,
1669,
220,
17,
26,
293,
2651,
220,
16,
21,
26,
293,
1027,
341,
197,
2023,
281,
284,
220,
15,
26,
281,
2651,
220,
20,
16,
17,
26,
281,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSanitiseBytesForString(t *testing.T) {
goodString := "Cliente - Doc. identificación"
badString := BadStringToHexFunction(goodString)
str := sanitiseBytesForString([]byte(badString), logging.NewNoopLogger())
assert.Equal(t, "Cliente - Doc. identificaci�n", str)
} | explode_data.jsonl/29076 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 97
} | [
2830,
3393,
23729,
275,
1064,
7078,
2461,
703,
1155,
353,
8840,
836,
8,
341,
3174,
1386,
703,
1669,
330,
25835,
481,
21709,
13,
3524,
52407,
698,
2233,
329,
703,
1669,
11461,
703,
1249,
20335,
5152,
3268,
1386,
703,
340,
11355,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLockWorks(t *testing.T) {
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
ip, port, err := c.Port(defaultPort)
if err != nil {
t.Fatal(err)
}
addr := fmt.Sprintf("sqlserver://sa:%v@%v:%v?master", saPassword, ip, port)
p := &SQLServer{}
d, err := p.Open(addr)
if err != nil {
t.Fatalf("%v", err)
}
dt.Test(t, d, []byte("SELECT 1"))
ms := d.(*SQLServer)
err = ms.Lock()
if err != nil {
t.Fatal(err)
}
err = ms.Unlock()
if err != nil {
t.Fatal(err)
}
// make sure the 2nd lock works (RELEASE_LOCK is very finicky)
err = ms.Lock()
if err != nil {
t.Fatal(err)
}
err = ms.Unlock()
if err != nil {
t.Fatal(err)
}
})
} | explode_data.jsonl/49646 | {
"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,
11989,
37683,
1155,
353,
8840,
836,
8,
341,
2698,
74,
8840,
41288,
7957,
2271,
1155,
11,
32247,
11,
2915,
1155,
353,
8840,
836,
11,
272,
40204,
1944,
33672,
1731,
8,
341,
197,
46531,
11,
2635,
11,
1848,
1669,
272,
43013,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStore_GetVulnerability_SetVulnerability(t *testing.T) {
dbTempFile, err := ioutil.TempFile("", "grype-db-test-store")
if err != nil {
t.Fatalf("could not create temp file: %+v", err)
}
defer os.Remove(dbTempFile.Name())
store, cleanupFn, err := New(dbTempFile.Name(), true)
defer cleanupFn()
if err != nil {
t.Fatalf("could not create store: %+v", err)
}
extra := []v2.Vulnerability{
{
ID: "my-cve-33333",
RecordSource: "record-source",
PackageName: "package-name-2",
Namespace: "my-namespace",
VersionConstraint: "< 1.0",
VersionFormat: "semver",
CPEs: []string{"a-cool-cpe"},
ProxyVulnerabilities: []string{"another-cve", "an-other-cve"},
FixedInVersion: "2.0.1",
},
{
ID: "my-other-cve-33333",
RecordSource: "record-source",
PackageName: "package-name-3",
Namespace: "my-namespace",
VersionConstraint: "< 509.2.2",
VersionFormat: "semver",
CPEs: []string{"a-cool-cpe"},
ProxyVulnerabilities: []string{"another-cve", "an-other-cve"},
},
}
expected := []v2.Vulnerability{
{
ID: "my-cve",
RecordSource: "record-source",
PackageName: "package-name",
Namespace: "my-namespace",
VersionConstraint: "< 1.0",
VersionFormat: "semver",
CPEs: []string{"a-cool-cpe"},
ProxyVulnerabilities: []string{"another-cve", "an-other-cve"},
FixedInVersion: "1.0.1",
},
{
ID: "my-other-cve",
RecordSource: "record-source",
PackageName: "package-name",
Namespace: "my-namespace",
VersionConstraint: "< 509.2.2",
VersionFormat: "semver",
CPEs: []string{"a-cool-cpe"},
ProxyVulnerabilities: []string{"another-cve", "an-other-cve"},
FixedInVersion: "4.0.5",
},
}
total := append(expected, extra...)
if err = store.AddVulnerability(total...); err != nil {
t.Fatalf("failed to set Vulnerability: %+v", err)
}
var allEntries []model.VulnerabilityModel
store.db.Find(&allEntries)
if len(allEntries) != len(total) {
t.Fatalf("unexpected number of entries: %d", len(allEntries))
}
assertVulnerabilityReader(t, store, expected[0].Namespace, expected[0].PackageName, expected)
// gut check on reader
storeReader, othercleanfn, err := reader.New(dbTempFile.Name())
defer othercleanfn()
if err != nil {
t.Fatalf("could not open db reader: %+v", err)
}
assertVulnerabilityReader(t, storeReader, expected[0].Namespace, expected[0].PackageName, expected)
} | explode_data.jsonl/78502 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1282
} | [
2830,
3393,
6093,
13614,
53,
58401,
2897,
14812,
53,
58401,
2897,
1155,
353,
8840,
836,
8,
341,
20939,
12151,
1703,
11,
1848,
1669,
43144,
65009,
1703,
19814,
330,
901,
499,
60399,
16839,
33252,
1138,
743,
1848,
961,
2092,
341,
197,
324... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSetHomeScreen(t *testing.T) {
t.Log("We need to test the SetHomeScreen.")
{
hs, err := tesoro.PNGToString("checked.png")
if err != nil {
t.Errorf("\t\tError reading homescreen: %s", err)
}
fmt.Println("[WHAT TO DO] Click on \"Confirm\"")
_, msgType := common.Call(client, client.SetHomescreen(hs))
if msgType != 2 {
t.Errorf("\t\tExpected msgType=2, received %d", msgType)
} else {
t.Log("\t\tEverything went fine, \\ʕ◔ϖ◔ʔ/ YAY!")
}
}
} | explode_data.jsonl/46204 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 213
} | [
2830,
3393,
1649,
7623,
7971,
1155,
353,
8840,
836,
8,
1476,
3244,
5247,
445,
1654,
1184,
311,
1273,
279,
2573,
7623,
7971,
13053,
197,
515,
197,
81692,
11,
1848,
1669,
50209,
18307,
94301,
5870,
445,
7549,
3508,
1138,
197,
743,
1848,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestScrapeLoopCacheMemoryExhaustionProtection(t *testing.T) {
s := teststorage.New(t)
defer s.Close()
sapp, err := s.Appender()
if err != nil {
t.Error(err)
}
appender := &collectResultAppender{next: sapp}
var (
signal = make(chan struct{})
scraper = &testScraper{}
app = func() storage.Appender { return appender }
)
defer close(signal)
ctx, cancel := context.WithCancel(context.Background())
sl := newScrapeLoop(ctx,
scraper,
nil, nil,
nopMutator,
nopMutator,
app,
nil,
0,
true,
)
numScrapes := 0
scraper.scrapeFunc = func(ctx context.Context, w io.Writer) error {
numScrapes++
if numScrapes < 5 {
s := ""
for i := 0; i < 500; i++ {
s = fmt.Sprintf("%smetric_%d_%d 42\n", s, i, numScrapes)
}
w.Write([]byte(fmt.Sprintf(s + "&")))
} else {
cancel()
}
return nil
}
go func() {
sl.run(10*time.Millisecond, time.Hour, nil)
signal <- struct{}{}
}()
select {
case <-signal:
case <-time.After(5 * time.Second):
t.Fatalf("Scrape wasn't stopped.")
}
if len(sl.cache.series) > 2000 {
t.Fatalf("More than 2000 series cached. Got: %d", len(sl.cache.series))
}
} | explode_data.jsonl/56126 | {
"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,
3326,
19842,
14620,
8233,
10642,
840,
15074,
290,
78998,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
1273,
16172,
7121,
1155,
340,
16867,
274,
10421,
2822,
1903,
676,
11,
1848,
1669,
274,
5105,
1659,
741,
743,
1848,
961,
2092,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReadYAMLStreamDefaultValue(t *testing.T) {
f := newFixture(t)
defer f.TearDown()
f.File("Tiltfile", `
result = read_yaml_stream("dne.yaml", ["hello", "goodbye"])
load('assert.tilt', 'assert')
assert.equals(['hello', 'goodbye'], result)
`)
_, err := f.ExecFile("Tiltfile")
if err != nil {
fmt.Println(f.PrintOutput())
}
require.NoError(t, err)
} | explode_data.jsonl/10608 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 155
} | [
2830,
3393,
4418,
56,
31102,
3027,
41533,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
18930,
1155,
340,
16867,
282,
836,
682,
4454,
2822,
1166,
8576,
445,
51,
2963,
1192,
497,
22074,
1382,
284,
1349,
64380,
12673,
445,
67,
811,
334... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIdentityEncodeDecode(t *testing.T) {
enc := NewIdentityEncoder()
dec := NewIdentityDecoder()
payload, err := enc.Encode([]byte("howdy"))
require.NoError(t, err)
actual, err := dec.Decode(payload)
require.NoError(t, err)
require.Equal(t, "howdy", string(actual))
} | explode_data.jsonl/74781 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
18558,
32535,
32564,
1155,
353,
8840,
836,
8,
341,
197,
954,
1669,
1532,
18558,
19921,
741,
197,
8169,
1669,
1532,
18558,
20732,
2822,
76272,
11,
1848,
1669,
3209,
50217,
10556,
3782,
445,
5158,
10258,
5455,
17957,
35699,
1155... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTransformNestedMessagesHoisting(t *testing.T) {
schema := []byte(`
syntax = "proto3";
package api.myapp;
message SearchResponse {
repeated Result results = 1;
message Result {
string url = 1;
string title = 2;
repeated string snippets = 3;
}
}
`)
input := new(bytes.Buffer)
input.Write(schema)
output := new(bytes.Buffer)
transformer := proto2gql.NewTransformer(output)
if err := transformer.Transform(input); err != nil {
t.Fatal(err)
}
expected := `
type ApiMyappSearchResponse {
results: [ApiMyappSearchResponseResult]
}
type ApiMyappSearchResponseResult {
url: String
title: String
snippets: [String]
}
`
expected = strings.TrimSpace(expected)
actual := strings.TrimSpace(output.String())
if expected != actual {
t.Fatalf("Expected %s to equal to %s", expected, actual)
}
} | explode_data.jsonl/2067 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 311
} | [
2830,
3393,
8963,
71986,
15820,
47978,
11083,
1155,
353,
8840,
836,
8,
341,
1903,
3416,
1669,
3056,
3782,
61528,
56193,
284,
330,
15110,
18,
876,
1722,
6330,
12618,
676,
401,
1994,
7542,
2582,
341,
17200,
41954,
5714,
3059,
284,
220,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestContextRenderRedirectWithAbsolutePath(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
c.Request, _ = http.NewRequest("POST", "http://example.com", nil)
c.Redirect(http.StatusFound, "http://google.com")
c.Writer.WriteHeaderNow()
assert.Equal(t, http.StatusFound, w.Code)
assert.Equal(t, "http://google.com", w.Header().Get("Location"))
} | explode_data.jsonl/26799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 139
} | [
2830,
3393,
1972,
6750,
17725,
2354,
39211,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
54320,
70334,
7121,
47023,
741,
1444,
11,
716,
1669,
4230,
2271,
1972,
3622,
692,
1444,
9659,
11,
716,
284,
1758,
75274,
445,
2946,
497,
330,
1254,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSchemaParser_SimpleTypeInheritingMultipleInterfaces(t *testing.T) {
body := `type Hello implements Wo, rld { }`
astDoc := parse(t, body)
expected := ast.NewDocument(&ast.Document{
Loc: testLoc(0, 33),
Definitions: []ast.Node{
ast.NewObjectDefinition(&ast.ObjectDefinition{
Loc: testLoc(0, 33),
Name: ast.NewName(&ast.Name{
Value: "Hello",
Loc: testLoc(5, 10),
}),
Directives: []*ast.Directive{},
Interfaces: []*ast.Named{
ast.NewNamed(&ast.Named{
Name: ast.NewName(&ast.Name{
Value: "Wo",
Loc: testLoc(22, 24),
}),
Loc: testLoc(22, 24),
}),
ast.NewNamed(&ast.Named{
Name: ast.NewName(&ast.Name{
Value: "rld",
Loc: testLoc(26, 29),
}),
Loc: testLoc(26, 29),
}),
},
Fields: []*ast.FieldDefinition{},
}),
},
})
if !reflect.DeepEqual(astDoc, expected) {
t.Fatalf("unexpected document, expected: %v, got: %v", expected, astDoc)
}
} | explode_data.jsonl/73870 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 479
} | [
2830,
3393,
8632,
6570,
1098,
6456,
929,
641,
1923,
5853,
32089,
41066,
1155,
353,
8840,
836,
8,
341,
35402,
1669,
1565,
1313,
21927,
5169,
27258,
11,
435,
507,
314,
335,
3989,
88836,
9550,
1669,
4715,
1155,
11,
2487,
340,
42400,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestProxyWithNoAnnotation(t *testing.T) {
ing := buildIngress()
data := map[string]string{}
ing.SetAnnotations(data)
i, err := NewParser(&resolver.Mock{}).Parse(ing)
if err != nil {
t.Fatalf("unexpected error parsing a valid")
}
p, ok := i.(*Config)
if !ok {
t.Fatalf("expected a Config type")
}
if p.ConnectTimeout != 5 {
t.Errorf("expected 5 as connect-timeout but returned %v", p.ConnectTimeout)
}
if p.SendTimeout != 60 {
t.Errorf("expected 60 as send-timeout but returned %v", p.SendTimeout)
}
if p.ReadTimeout != 60 {
t.Errorf("expected 60 as read-timeout but returned %v", p.ReadTimeout)
}
if p.BufferSize != "4k" {
t.Errorf("expected 4k as buffer-size but returned %v", p.BufferSize)
}
if p.BodySize != "1m" {
t.Errorf("expected 1m as body-size but returned %v", p.BodySize)
}
} | explode_data.jsonl/52490 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 318
} | [
2830,
3393,
16219,
2354,
2753,
19711,
1155,
353,
8840,
836,
8,
341,
197,
287,
1669,
1936,
641,
2483,
2822,
8924,
1669,
2415,
14032,
30953,
16094,
197,
287,
4202,
21418,
2592,
692,
8230,
11,
1848,
1669,
1532,
6570,
2099,
48943,
24664,
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... | 8 |
func TestNewRangeDeleteParamsWithHTTPClient(t *testing.T) {
cli := &http.Client{}
p := NewRangeDeleteParamsWithHTTPClient(cli)
require.NotNil(t, p.HTTPClient)
assert.Equal(t, cli, p.HTTPClient)
} | explode_data.jsonl/38289 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
3564,
6046,
6435,
4870,
2354,
9230,
2959,
1155,
353,
8840,
836,
8,
341,
86448,
1669,
609,
1254,
11716,
16094,
3223,
1669,
1532,
6046,
6435,
4870,
2354,
9230,
2959,
70249,
340,
17957,
93882,
1155,
11,
281,
27358,
2959,
340,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStatNotExistent(t *testing.T) {
client := getClient(t)
resp, err := client.Stat("/_test/nonexistent")
assertPathError(t, err, "stat", "/_test/nonexistent", os.ErrNotExist)
assert.Nil(t, resp)
} | explode_data.jsonl/44784 | {
"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,
15878,
2623,
840,
18128,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
86287,
1155,
692,
34653,
11,
1848,
1669,
2943,
53419,
4283,
62,
1944,
91130,
64085,
1138,
6948,
1820,
1454,
1155,
11,
1848,
11,
330,
9878,
497,
3521,
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 |
func TestGetAssetStatsCursorValidation(t *testing.T) {
tt := test.Start(t)
defer tt.Finish()
test.ResetHorizonDB(t, tt.HorizonDB)
q := &Q{tt.HorizonSession()}
for _, testCase := range []struct {
name string
cursor string
expectedError string
}{
{
"cursor does not use underscore as serpator",
"usdc-GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H",
"invalid asset stats cursor",
},
{
"cursor has no underscore",
"usdc",
"invalid asset stats cursor",
},
{
"cursor has too many underscores",
"usdc_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum4_",
"invalid asset type in asset stats cursor",
},
{
"issuer in cursor is invalid",
"usd_abcdefghijklmnopqrstuv_credit_alphanum4",
"invalid issuer in asset stats cursor",
},
{
"asset type in cursor is invalid",
"usd_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum",
"invalid asset type in asset stats cursor",
},
{
"asset code in cursor is too long",
"abcdefghijklmnopqrstuv_GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H_credit_alphanum12",
"invalid asset stats cursor",
},
} {
t.Run(testCase.name, func(t *testing.T) {
page := db2.PageQuery{
Cursor: testCase.cursor,
Order: "asc",
Limit: 5,
}
results, err := q.GetAssetStats("", "", page)
tt.Assert.Empty(results)
tt.Assert.NotNil(err)
tt.Assert.Contains(err.Error(), testCase.expectedError)
})
}
} | explode_data.jsonl/42377 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 725
} | [
2830,
3393,
1949,
16604,
16635,
14543,
13799,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
1273,
12101,
1155,
340,
16867,
17853,
991,
18176,
741,
18185,
36660,
39601,
16973,
3506,
1155,
11,
17853,
3839,
269,
16973,
3506,
692,
18534,
1669... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDb_IteratorPinsRef(t *testing.T) {
h := newDbHarness(t)
defer h.close()
h.put("foo", "hello")
// Get iterator that will yield the current contents of the DB.
iter := h.db.NewIterator(nil, nil)
// Write to force compactions
h.put("foo", "newvalue1")
for i := 0; i < 100; i++ {
h.put(numKey(i), strings.Repeat(fmt.Sprintf("v%09d", i), 100000/10))
}
h.put("foo", "newvalue2")
iter.First()
testKeyVal(t, iter, "foo->hello")
if iter.Next() {
t.Errorf("expect eof")
}
iter.Release()
} | explode_data.jsonl/6013 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 214
} | [
2830,
3393,
7994,
7959,
465,
850,
47,
1330,
3945,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
7994,
74248,
1155,
340,
16867,
305,
4653,
2822,
9598,
3597,
445,
7975,
497,
330,
14990,
5130,
197,
322,
2126,
15091,
429,
686,
7540,
279,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestCommit(t *testing.T) {
// Test Setup
state := NewMockManager()
user1 := user.New("1", "Franco", "franco@gmail.com")
user2 := user.New("2", "Jack", "jack@gmail.com")
user3 := user.New("3", "Jacob", "jacob@gmail.com")
// Should be able to apply insert
state.Stage(user1, "insert")
state.Stage(user2, "insert")
state.Stage(user3, "insert")
err := state.Commit()
assert.Nil(t, err)
// Should have an empty state after successful apply
assert.Len(t, state.Status(), 0)
// Should be able to apply update
user1.Name = "Not Franco"
user2.Name = "Not Jack"
user3.Name = "Not Jacob"
state.Stage(user1, "update")
state.Stage(user2, "update")
state.Stage(user3, "update")
err = state.Commit()
assert.Nil(t, err)
// Should be able to apply delete
state.Stage(user1, "delete")
state.Stage(user2, "delete")
state.Stage(user3, "delete")
err = state.Commit()
assert.Nil(t, err)
} | explode_data.jsonl/58867 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 348
} | [
2830,
3393,
33441,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
18626,
198,
24291,
1669,
1532,
11571,
2043,
741,
19060,
16,
1669,
1196,
7121,
445,
16,
497,
330,
75331,
1015,
497,
330,
1626,
18557,
10375,
905,
1138,
19060,
17,
1669,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestNestedPauseNsRegression(t *testing.T) {
t.Parallel()
input := bytes.NewBuffer([]byte(`{"memstats": {"PauseNs":[438238,506913]}}`))
expected := &datatype.GCListType{Key: "memstats.PauseNs", Value: []uint64{438238, 506913}}
mapper := datatype.DefaultMapper()
container, _ := datatype.JobResultDataTypes(input.Bytes(), mapper)
if !container.List()[0].Equal(expected) {
t.Errorf("container.List()[0] = (%#v); want (%#v)", container.List()[0], expected)
}
} | explode_data.jsonl/57175 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 181
} | [
2830,
3393,
71986,
28391,
47360,
45200,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22427,
1669,
5820,
7121,
4095,
10556,
3782,
5809,
4913,
10536,
16260,
788,
5212,
28391,
47360,
8899,
19,
18,
23,
17,
18,
23,
11,
20,
15,
21,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestWatchInterpretations(t *testing.T) {
codec := latest.Codec
// Declare some pods to make the test cases compact.
podFoo := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
podBar := &api.Pod{JSONBase: api.JSONBase{ID: "bar"}}
podBaz := &api.Pod{JSONBase: api.JSONBase{ID: "baz"}}
firstLetterIsB := func(obj runtime.Object) bool {
return obj.(*api.Pod).ID[0] == 'b'
}
// All of these test cases will be run with the firstLetterIsB FilterFunc.
table := map[string]struct {
actions []string // Run this test item for every action here.
prevNodeValue string
nodeValue string
expectEmit bool
expectType watch.EventType
expectObject runtime.Object
}{
"create": {
actions: []string{"create", "get"},
nodeValue: runtime.EncodeOrDie(codec, podBar),
expectEmit: true,
expectType: watch.Added,
expectObject: podBar,
},
"create but filter blocks": {
actions: []string{"create", "get"},
nodeValue: runtime.EncodeOrDie(codec, podFoo),
expectEmit: false,
},
"delete": {
actions: []string{"delete"},
prevNodeValue: runtime.EncodeOrDie(codec, podBar),
expectEmit: true,
expectType: watch.Deleted,
expectObject: podBar,
},
"delete but filter blocks": {
actions: []string{"delete"},
nodeValue: runtime.EncodeOrDie(codec, podFoo),
expectEmit: false,
},
"modify appears to create 1": {
actions: []string{"set", "compareAndSwap"},
nodeValue: runtime.EncodeOrDie(codec, podBar),
expectEmit: true,
expectType: watch.Added,
expectObject: podBar,
},
"modify appears to create 2": {
actions: []string{"set", "compareAndSwap"},
prevNodeValue: runtime.EncodeOrDie(codec, podFoo),
nodeValue: runtime.EncodeOrDie(codec, podBar),
expectEmit: true,
expectType: watch.Added,
expectObject: podBar,
},
"modify appears to delete": {
actions: []string{"set", "compareAndSwap"},
prevNodeValue: runtime.EncodeOrDie(codec, podBar),
nodeValue: runtime.EncodeOrDie(codec, podFoo),
expectEmit: true,
expectType: watch.Deleted,
expectObject: podBar, // Should return last state that passed the filter!
},
"modify modifies": {
actions: []string{"set", "compareAndSwap"},
prevNodeValue: runtime.EncodeOrDie(codec, podBar),
nodeValue: runtime.EncodeOrDie(codec, podBaz),
expectEmit: true,
expectType: watch.Modified,
expectObject: podBaz,
},
"modify ignores": {
actions: []string{"set", "compareAndSwap"},
nodeValue: runtime.EncodeOrDie(codec, podFoo),
expectEmit: false,
},
}
for name, item := range table {
for _, action := range item.actions {
w := newEtcdWatcher(true, firstLetterIsB, codec, versioner, nil)
emitCalled := false
w.emit = func(event watch.Event) {
emitCalled = true
if !item.expectEmit {
return
}
if e, a := item.expectType, event.Type; e != a {
t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a)
}
if e, a := item.expectObject, event.Object; !reflect.DeepEqual(e, a) {
t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a)
}
}
var n, pn *etcd.Node
if item.nodeValue != "" {
n = &etcd.Node{Value: item.nodeValue}
}
if item.prevNodeValue != "" {
pn = &etcd.Node{Value: item.prevNodeValue}
}
w.sendResult(&etcd.Response{
Action: action,
Node: n,
PrevNode: pn,
})
if e, a := item.expectEmit, emitCalled; e != a {
t.Errorf("'%v - %v': expected %v, got %v", name, action, e, a)
}
w.Stop()
}
}
} | explode_data.jsonl/40973 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1604
} | [
2830,
3393,
14247,
3306,
8043,
804,
1155,
353,
8840,
836,
8,
341,
43343,
66,
1669,
5535,
20274,
66,
198,
197,
322,
61310,
1045,
54587,
311,
1281,
279,
1273,
5048,
16830,
624,
3223,
347,
40923,
1669,
609,
2068,
88823,
90,
5370,
3978,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestQuit(t *testing.T) {
ctx := context.Background()
driver, err := CreateSession(ctx, wdAddress(), 3, nil)
if err != nil {
t.Fatal(err)
}
driver.Quit(ctx)
if _, err := driver.WindowHandles(ctx); err == nil {
t.Fatal("Got nil err, expected unknown session err")
}
} | explode_data.jsonl/68740 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 109
} | [
2830,
3393,
42856,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
2822,
33652,
11,
1848,
1669,
4230,
5283,
7502,
11,
45404,
4286,
1507,
220,
18,
11,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestPrivateActivityYesHeatmapHasNoContentForOtherUser(t *testing.T) {
defer prepareTestEnv(t)()
testPrivateActivityDoSomethingForActionEntries(t)
testPrivateActivityHelperEnablePrivateActivity(t)
session := loginUser(t, privateActivityTestOtherUser)
hasContent := testPrivateActivityHelperHasHeatmapContentFromSession(t, session)
assert.False(t, hasContent, "other user should not see heatmap content")
} | explode_data.jsonl/51669 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 117
} | [
2830,
3393,
16787,
4052,
9454,
61306,
2186,
10281,
2753,
2762,
2461,
11409,
1474,
1155,
353,
8840,
836,
8,
341,
16867,
10549,
2271,
14359,
1155,
8,
741,
18185,
16787,
4052,
5404,
23087,
2461,
2512,
24533,
1155,
340,
18185,
16787,
4052,
55... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_getInputEnvVarsFromStrings(t *testing.T) {
tests := []struct {
name string
envVars []string
wantedEnvVars []corev1.EnvVar
wantErr bool
}{
{
name: "Test case 1: with valid two key value pairs",
envVars: []string{"key=value", "key1=value1"},
wantedEnvVars: []corev1.EnvVar{
{
Name: "key",
Value: "value",
},
{
Name: "key1",
Value: "value1",
},
},
wantErr: false,
},
{
name: "Test case 2: one env var with missing value",
envVars: []string{"key=value", "key1="},
wantedEnvVars: []corev1.EnvVar{
{
Name: "key",
Value: "value",
},
{
Name: "key1",
Value: "",
},
},
wantErr: false,
},
{
name: "Test case 3: one env var with no value and no =",
envVars: []string{"key=value", "key1"},
wantErr: true,
},
{
name: "Test case 4: one env var with multiple values",
envVars: []string{"key=value", "key1=value1=value2"},
wantedEnvVars: []corev1.EnvVar{
{
Name: "key",
Value: "value",
},
{
Name: "key1",
Value: "value1=value2",
},
},
wantErr: false,
},
{
name: "Test case 5: two env var with same key",
envVars: []string{"key=value", "key=value1"},
wantErr: true,
},
{
name: "Test case 6: one env var with base64 encoded value",
envVars: []string{"key=value", "key1=SSd2ZSBnb3QgYSBsb3ZlbHkgYnVuY2ggb2YgY29jb251dHMhCg=="},
wantedEnvVars: []corev1.EnvVar{
{
Name: "key",
Value: "value",
},
{
Name: "key1",
Value: "SSd2ZSBnb3QgYSBsb3ZlbHkgYnVuY2ggb2YgY29jb251dHMhCg==",
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
envVars, err := getInputEnvVarsFromStrings(tt.envVars)
if err == nil && !tt.wantErr {
if !reflect.DeepEqual(tt.wantedEnvVars, envVars) {
t.Errorf("corev1.Env values are not matching with expected values, expected: %v, got %v", tt.wantedEnvVars, envVars)
}
} else if err == nil && tt.wantErr {
t.Error("error was expected, but no error was returned")
} else if err != nil && !tt.wantErr {
t.Errorf("test failed, no error was expected, but got unexpected error: %s", err)
}
})
}
} | explode_data.jsonl/65176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1173
} | [
2830,
3393,
3062,
2505,
14359,
28305,
3830,
20859,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
688,
914,
198,
197,
57538,
28305,
981,
3056,
917,
198,
197,
6692,
7566,
14359,
28305,
3056,
98645,
16,
81214,
396... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamespaceFlushNotBootstrapped(t *testing.T) {
ns, closer := newTestNamespace(t)
defer closer()
err := ns.WarmFlush(xtime.Now(), nil)
require.Equal(t, errNamespaceNotBootstrapped, err)
require.Equal(t, errNamespaceNotBootstrapped, ns.ColdFlush(nil))
} | explode_data.jsonl/35354 | {
"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,
22699,
46874,
2623,
17919,
495,
5677,
1155,
353,
8840,
836,
8,
341,
84041,
11,
12128,
1669,
501,
2271,
22699,
1155,
340,
16867,
12128,
741,
9859,
1669,
12268,
1175,
2178,
46874,
2075,
1678,
13244,
1507,
2092,
340,
17957,
12808... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestABCIConsensusParams(t *testing.T) {
cp := DefaultConsensusParams()
abciCP := TM2PB.ConsensusParams(cp)
cp2 := UpdateConsensusParams(*cp, abciCP)
assert.Equal(t, *cp, cp2)
} | explode_data.jsonl/65075 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 77
} | [
2830,
3393,
1867,
11237,
15220,
13626,
4870,
1155,
353,
8840,
836,
8,
341,
52018,
1669,
7899,
15220,
13626,
4870,
741,
197,
370,
5855,
7123,
1669,
23975,
17,
40637,
94594,
13626,
4870,
44075,
340,
52018,
17,
1669,
5549,
15220,
13626,
4870... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReaderSuccessReturnsCorrectBodyWithOneFunction(t *testing.T) {
replicas := uint64(5)
labels := map[string]string{
"function": "bar",
}
services := []swarm.Service{
swarm.Service{
Spec: swarm.ServiceSpec{
Mode: swarm.ServiceMode{
Replicated: &swarm.ReplicatedService{
Replicas: &replicas,
},
},
Annotations: swarm.Annotations{
Name: "bar",
Labels: labels,
},
TaskTemplate: swarm.TaskSpec{
ContainerSpec: swarm.ContainerSpec{
Env: []string{
"fprocess=bar",
},
Image: "foo/bar:latest",
Labels: labels,
},
},
},
},
}
m := metrics.MetricOptions{}
c := &testServiceApiClient{
serviceListServices: services,
serviceListError: nil,
}
handler := handlers.MakeFunctionReader(m, c)
w := httptest.NewRecorder()
r := &http.Request{}
handler.ServeHTTP(w, r)
functions := []requests.Function{
requests.Function{
Name: "bar",
Image: "foo/bar:latest",
InvocationCount: 0,
Replicas: 5,
EnvProcess: "bar",
Labels: &map[string]string{
"function": "bar",
},
},
}
marshalled, _ := json.Marshal(functions)
expected := string(marshalled)
if w.Body.String() != expected {
t.Errorf("handler returned wrong body: got %v want %v",
w.Body.String(), expected)
}
} | explode_data.jsonl/63780 | {
"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,
5062,
7188,
16446,
33092,
5444,
2354,
3966,
5152,
1155,
353,
8840,
836,
8,
341,
73731,
52210,
1669,
2622,
21,
19,
7,
20,
340,
95143,
1669,
2415,
14032,
30953,
515,
197,
197,
1,
1688,
788,
330,
2257,
756,
197,
630,
1903,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNamespacePost(t *testing.T) {
r, _ := http.NewRequest("POST", "/v1/user/123", nil)
w := httptest.NewRecorder()
ns := NewNamespace("/v1")
ns.Post("/user/:id", func(ctx *context.Context) {
ctx.Output.Body([]byte(ctx.Input.Param(":id")))
})
AddNamespace(ns)
BeeApp.Handlers.ServeHTTP(w, r)
if w.Body.String() != "123" {
t.Errorf("TestNamespacePost can't run, get the response is " + w.Body.String())
}
} | explode_data.jsonl/12605 | {
"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,
22699,
4133,
1155,
353,
8840,
836,
8,
341,
7000,
11,
716,
1669,
1758,
75274,
445,
2946,
497,
3521,
85,
16,
11739,
14,
16,
17,
18,
497,
2092,
340,
6692,
1669,
54320,
70334,
7121,
47023,
2822,
84041,
1669,
1532,
22699,
4283,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRoleUpdate(t *testing.T) {
h := newHelper(t)
res := h.repoMakeRole()
helpers.AllowMe(h, types.RoleRbacResource(0), "update")
newName := "updated-" + rs()
newHandle := "updated-" + rs()
h.apiInit().
Put(fmt.Sprintf("/roles/%d", res.ID)).
FormData("name", newName).
FormData("handle", newHandle).
Expect(t).
Status(http.StatusOK).
Assert(helpers.AssertNoErrors).
End()
res = h.lookupRoleByID(res.ID)
h.a.NotNil(res)
h.a.Equal(newName, res.Name)
h.a.Equal(newHandle, res.Handle)
} | explode_data.jsonl/8342 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 228
} | [
2830,
3393,
9030,
4289,
1155,
353,
8840,
836,
8,
341,
9598,
1669,
501,
5511,
1155,
340,
10202,
1669,
305,
46169,
8078,
9030,
741,
197,
21723,
29081,
7823,
3203,
11,
4494,
35955,
49,
55877,
4783,
7,
15,
701,
330,
2386,
5130,
8638,
675,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetNbrEntry(t *testing.T) {
svr := &NDPServer{}
svr.InitGlobalDS()
initServerBasic()
nbrEntry := svr.GetNeighborEntry("2002::1/64")
if nbrEntry != nil {
t.Error("there is no entry in the database and we received nbr info", nbrEntry)
}
populateNbrInfoTest(svr)
nbrEntry = svr.GetNeighborEntry("2002::1/64")
if !reflect.DeepEqual(*nbrEntry, nbr[0]) {
t.Error("Get Entry for ipAddr 2002::1/64 failed", "received info", nbrEntry, "strore info", nbr[0])
}
svr.DeInitGlobalDS()
} | explode_data.jsonl/38852 | {
"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,
1949,
45,
1323,
5874,
1155,
353,
8840,
836,
8,
341,
1903,
18920,
1669,
609,
8065,
5012,
2836,
16094,
1903,
18920,
26849,
11646,
5936,
741,
28248,
5475,
15944,
741,
9038,
1323,
5874,
1669,
13559,
81,
2234,
88109,
5874,
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... | 3 |
func TestTrimSpace_space(t *testing.T) {
extraChars := " state \r\t"
want := "state"
got := TrimSpace(extraChars)
if want != got {
t.Fatalf("wrong trim, want: %q got: %q", want, got)
}
} | explode_data.jsonl/62252 | {
"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,
25656,
9914,
14663,
1155,
353,
8840,
836,
8,
341,
8122,
2172,
32516,
1669,
330,
1584,
220,
1124,
81,
4955,
698,
50780,
1669,
330,
2454,
698,
3174,
354,
1669,
44376,
9914,
83790,
32516,
692,
743,
1366,
961,
2684,
341,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 2 |
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
initializeLogLevel()
RunSpecsWithDefaultAndCustomReporters(t,
"Controller Suite",
[]Reporter{printer.NewlineReporter{}})
} | explode_data.jsonl/81307 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 67
} | [
2830,
3393,
7082,
82,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
692,
97129,
72676,
2822,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,
1155,
345,
197,
197,
1,
2051,
20977,
756,
197,
197,
1294,
52766,
90,
62956,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClientMetrics(t *testing.T) {
c, _ := NewClient(Config{EnableMetrics: true})
m, err := c.Metrics()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if m.Requests != 0 {
t.Errorf("Unexpected output: %s", m)
}
} | explode_data.jsonl/24034 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 100
} | [
2830,
3393,
2959,
27328,
1155,
353,
8840,
836,
8,
341,
1444,
11,
716,
1669,
1532,
2959,
33687,
90,
11084,
27328,
25,
830,
8824,
2109,
11,
1848,
1669,
272,
1321,
13468,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
29430,
1465... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestValidateDelegateHTTPRoute(t *testing.T) {
testCases := []struct {
name string
route *networking.HTTPRoute
valid bool
}{
{name: "empty", route: &networking.HTTPRoute{ // nothing
}, valid: false},
{name: "simple", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
}},
}, valid: true},
{name: "no destination", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: nil,
}},
}, valid: false},
{name: "weighted", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 25,
}, {
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 75,
}},
}, valid: true},
{name: "total weight > 100", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 55,
}, {
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 50,
}},
}, valid: false},
{name: "total weight < 100", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz.south"},
Weight: 49,
}, {
Destination: &networking.Destination{Host: "foo.baz.east"},
Weight: 50,
}},
}, valid: false},
{name: "simple redirect", route: &networking.HTTPRoute{
Redirect: &networking.HTTPRedirect{
Uri: "/lerp",
Authority: "foo.biz",
},
}, valid: true},
{name: "conflicting redirect and route", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
}},
Redirect: &networking.HTTPRedirect{
Uri: "/lerp",
Authority: "foo.biz",
},
}, valid: false},
{name: "request response headers", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
}},
}, valid: true},
{name: "valid headers", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Request: &networking.Headers_HeaderOperations{
Add: map[string]string{
"name": "",
},
Set: map[string]string{
"name": "",
},
Remove: []string{
"name",
},
},
Response: &networking.Headers_HeaderOperations{
Add: map[string]string{
"name": "",
},
Set: map[string]string{
"name": "",
},
Remove: []string{
"name",
},
},
},
}},
}, valid: true},
{name: "empty header name - request add", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Request: &networking.Headers_HeaderOperations{
Add: map[string]string{
"": "value",
},
},
},
}},
}, valid: false},
{name: "empty header name - request set", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Request: &networking.Headers_HeaderOperations{
Set: map[string]string{
"": "value",
},
},
},
}},
}, valid: false},
{name: "empty header name - request remove", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Request: &networking.Headers_HeaderOperations{
Remove: []string{
"",
},
},
},
}},
}, valid: false},
{name: "empty header name - response add", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Response: &networking.Headers_HeaderOperations{
Add: map[string]string{
"": "value",
},
},
},
}},
}, valid: false},
{name: "empty header name - response set", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Response: &networking.Headers_HeaderOperations{
Set: map[string]string{
"": "value",
},
},
},
}},
}, valid: false},
{name: "empty header name - response remove", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.baz"},
Headers: &networking.Headers{
Response: &networking.Headers_HeaderOperations{
Remove: []string{
"",
},
},
},
}},
}, valid: false},
{name: "null header match", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: []*networking.HTTPMatchRequest{{
Headers: map[string]*networking.StringMatch{
"header": nil,
},
}},
}, valid: false},
{name: "nil match", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: nil,
}, valid: true},
{name: "match with nil element", route: &networking.HTTPRoute{
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: []*networking.HTTPMatchRequest{nil},
}, valid: true},
{name: "invalid mirror percent", route: &networking.HTTPRoute{
MirrorPercent: &types.UInt32Value{Value: 101},
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: []*networking.HTTPMatchRequest{nil},
}, valid: false},
{name: "invalid mirror percentage", route: &networking.HTTPRoute{
MirrorPercentage: &networking.Percent{
Value: 101,
},
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: []*networking.HTTPMatchRequest{nil},
}, valid: false},
{name: "valid mirror percentage", route: &networking.HTTPRoute{
MirrorPercentage: &networking.Percent{
Value: 1,
},
Route: []*networking.HTTPRouteDestination{{
Destination: &networking.Destination{Host: "foo.bar"},
}},
Match: []*networking.HTTPMatchRequest{nil},
}, valid: true},
{name: "delegate route with delegate", route: &networking.HTTPRoute{
Delegate: &networking.Delegate{
Name: "test",
Namespace: "test",
},
}, valid: false},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if err := validateDelegateHTTPRoute(tc.route); (err == nil) != tc.valid {
t.Fatalf("got valid=%v but wanted valid=%v: %v", err == nil, tc.valid, err)
}
})
}
} | explode_data.jsonl/56367 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 3154
} | [
2830,
3393,
17926,
9381,
9230,
4899,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
220,
914,
198,
197,
7000,
2133,
353,
17511,
287,
27358,
4899,
198,
197,
56322,
1807,
198,
197,
59403,
197,
197,
47006,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetSetCookies(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != GET {
t.Errorf("Expected method %q; got %q", GET, r.Method)
}
c, err := r.Cookie("API-Cookie-Name1")
if err != nil {
t.Error(err)
}
if c == nil {
t.Errorf("Expected non-nil request Cookie 'API-Cookie-Name1'")
} else if c.Value != "api-cookie-value1" {
t.Errorf("Expected 'API-Cookie-Name1' == %q; got %q", "api-cookie-value1", c.Value)
}
c, err = r.Cookie("API-Cookie-Name2")
if err != nil {
t.Error(err)
}
if c == nil {
t.Errorf("Expected non-nil request Cookie 'API-Cookie-Name2'")
} else if c.Value != "api-cookie-value2" {
t.Errorf("Expected 'API-Cookie-Name2' == %q; got %q", "api-cookie-value2", c.Value)
}
}))
defer ts.Close()
New().Get(ts.URL).AddCookies([]*http.Cookie{
&http.Cookie{Name: "API-Cookie-Name1", Value: "api-cookie-value1"},
&http.Cookie{Name: "API-Cookie-Name2", Value: "api-cookie-value2"},
}).End()
} | explode_data.jsonl/25476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 464
} | [
2830,
3393,
1949,
1649,
50672,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
7890,
341,
298,
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... | 8 |
func TestBatchOptions(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
wantMaxSize := 8 << 10
wantMaxNodes := 500
d := newTestDag()
b := NewBatch(ctx, d, MaxSizeBatchOption(wantMaxSize), MaxNodesBatchOption(wantMaxNodes))
if b.opts.maxSize != wantMaxSize {
t.Fatalf("maxSize incorrect, want: %d, got: %d", wantMaxSize, b.opts.maxSize)
}
if b.opts.maxNodes != wantMaxNodes {
t.Fatalf("maxNodes incorrect, want: %d, got: %d", wantMaxNodes, b.opts.maxNodes)
}
} | explode_data.jsonl/47778 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 206
} | [
2830,
3393,
21074,
3798,
1155,
353,
8840,
836,
8,
341,
20985,
11,
9121,
1669,
2266,
26124,
9269,
5378,
19047,
2398,
16867,
9121,
2822,
50780,
5974,
1695,
1669,
220,
23,
1115,
220,
16,
15,
198,
50780,
5974,
12288,
1669,
220,
20,
15,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestHandlerServeHTTP(t *testing.T) {
utc, _ := time.LoadLocation("UTC")
d := strings.NewReader(
"97 <45>1 2014-01-09T20:34:44.693891+00:00 host heroku api - Release v1822 created by foo@example.com" +
"97 <45>1*2014-01-09T20:34:44.693891+00:00*host*heroku*api*-*Bogus entirely on purpose yes preciousss" +
"23 BAD FRAMING...")
r, _ := http.NewRequest("POST", "https://logtap.example.org/", d)
r.Header.Set("Logplex-Msg-Count", "3")
w := httptest.NewRecorder()
var actual []*SyslogMessage
f := func(xs []*SyslogMessage, ctx interface{}) {
actual = xs
if ctx != nil {
t.Errorf("ctx is not nil!")
}
}
h := NewHandler(f)
h.Metrics = telemetry.Discard
h.ServeHTTP(w, r)
if w.Code != 200 {
t.Fatal("HTTP status != 200")
}
expected := &SyslogMessage{
Priority: "45",
Version: "1",
Timestamp: time.Date(2014, 1, 9, 20, 34, 44, 693891000, utc),
Hostname: "host",
Appname: "heroku",
Procid: "api",
Msgid: "-",
Text: "Release v1822 created by foo@example.com",
}
if !reflect.DeepEqual(actual[0], expected) {
t.Errorf("%#v != %#v", actual, expected)
}
} | explode_data.jsonl/45255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 500
} | [
2830,
3393,
3050,
60421,
9230,
1155,
353,
8840,
836,
8,
341,
197,
28355,
11,
716,
1669,
882,
13969,
4707,
445,
21183,
1138,
2698,
1669,
9069,
68587,
1006,
197,
197,
1,
24,
22,
366,
19,
20,
29,
16,
220,
17,
15,
16,
19,
12,
15,
16... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_encrypt(t *testing.T) {
config.Load()
pwd := "123456"
enc := encrypt(pwd)
md5Enc := fmt.Sprintf("%x", md5.Sum([]byte(pwd)))
if enc != md5Enc {
t.Errorf("expected encrypted password to be: %s, got: %s", enc, md5Enc)
}
config.PrestConf.AuthEncrypt = "SHA1"
enc = encrypt(pwd)
sha1Enc := fmt.Sprintf("%x", sha1.Sum([]byte(pwd)))
if enc != sha1Enc {
t.Errorf("expected encrypted password to be: %s, got: %s", enc, sha1Enc)
}
} | explode_data.jsonl/35850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
66593,
1155,
353,
8840,
836,
8,
341,
25873,
13969,
2822,
3223,
6377,
1669,
330,
16,
17,
18,
19,
20,
21,
698,
197,
954,
1669,
29625,
97887,
692,
84374,
20,
7408,
1669,
8879,
17305,
4430,
87,
497,
10688,
20,
41676,
10556,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestApplicationContext_SameNameBean(t *testing.T) {
c := gs.New()
c.Object(new(SamePkgHolder))
c.Object(&pkg1.SamePkg{}).Export((*Pkg)(nil))
c.Object(&pkg2.SamePkg{}).Export((*Pkg)(nil))
err := c.Refresh()
assert.Nil(t, err)
} | explode_data.jsonl/17401 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 108
} | [
2830,
3393,
19736,
1098,
373,
675,
10437,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
28081,
7121,
741,
1444,
8348,
1755,
3759,
373,
47,
7351,
8589,
1171,
1444,
8348,
2099,
30069,
16,
808,
373,
47,
7351,
6257,
568,
16894,
26609,
47,
735... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCancelWorkflow_IsIdempotent(t *testing.T) {
w := testWorkflow()
if w.isCanceled {
t.Error("Didn't expect workflow to be canceled.")
}
w.CancelWorkflow()
w.CancelWorkflow()
if !w.isCanceled {
t.Error("Expect workflow to be canceled.")
}
} | explode_data.jsonl/3866 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 105
} | [
2830,
3393,
9269,
62768,
31879,
764,
3262,
63532,
1155,
353,
8840,
836,
8,
341,
6692,
1669,
1273,
62768,
741,
743,
289,
2079,
63263,
341,
197,
3244,
6141,
445,
86519,
944,
1720,
28288,
311,
387,
33446,
13053,
197,
532,
6692,
36491,
6276... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLocationArea(t *testing.T) {
result, _ := pokeapi.LocationArea("1")
assert.Equal(t, "canalave-city-area", result.Name,
"Expect to receive Canalave City area.")
} | explode_data.jsonl/63735 | {
"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,
4707,
8726,
1155,
353,
8840,
836,
8,
341,
9559,
11,
716,
1669,
51551,
2068,
4515,
8726,
445,
16,
1138,
6948,
12808,
1155,
11,
330,
4814,
278,
523,
53329,
29022,
497,
1102,
2967,
345,
197,
197,
1,
17536,
311,
5258,
52648,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSkipRender(t *testing.T) {
t.Parallel()
sources := []source.ByteSource{
{Name: filepath.FromSlash("sect/doc1.html"), Content: []byte("---\nmarkup: markdown\n---\n# title\nsome *content*")},
{Name: filepath.FromSlash("sect/doc2.html"), Content: []byte("<!doctype html><html><body>more content</body></html>")},
{Name: filepath.FromSlash("sect/doc3.md"), Content: []byte("# doc3\n*some* content")},
{Name: filepath.FromSlash("sect/doc4.md"), Content: []byte("---\ntitle: doc4\n---\n# doc4\n*some content*")},
{Name: filepath.FromSlash("sect/doc5.html"), Content: []byte("<!doctype html><html>{{ template \"head\" }}<body>body5</body></html>")},
{Name: filepath.FromSlash("sect/doc6.html"), Content: []byte("<!doctype html><html>{{ template \"head_abs\" }}<body>body5</body></html>")},
{Name: filepath.FromSlash("doc7.html"), Content: []byte("<html><body>doc7 content</body></html>")},
{Name: filepath.FromSlash("sect/doc8.html"), Content: []byte("---\nmarkup: md\n---\n# title\nsome *content*")},
// Issue #3021
{Name: filepath.FromSlash("doc9.html"), Content: []byte("<html><body>doc9: {{< myshortcode >}}</body></html>")},
}
cfg, fs := newTestCfg()
cfg.Set("defaultExtension", "html")
cfg.Set("verbose", true)
cfg.Set("canonifyURLs", true)
cfg.Set("uglyURLs", true)
cfg.Set("baseURL", "http://auth/bub")
for _, src := range sources {
writeSource(t, fs, filepath.Join("content", src.Name), string(src.Content))
}
writeSource(t, fs, filepath.Join("layouts", "_default/single.html"), "{{.Content}}")
writeSource(t, fs, filepath.Join("layouts", "head"), "<head><script src=\"script.js\"></script></head>")
writeSource(t, fs, filepath.Join("layouts", "head_abs"), "<head><script src=\"/script.js\"></script></head>")
writeSource(t, fs, filepath.Join("layouts", "shortcodes", "myshortcode.html"), "SHORT")
buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
tests := []struct {
doc string
expected string
}{
{filepath.FromSlash("public/sect/doc1.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
{filepath.FromSlash("public/sect/doc2.html"), "<!doctype html><html><body>more content</body></html>"},
{filepath.FromSlash("public/sect/doc3.html"), "\n\n<h1 id=\"doc3\">doc3</h1>\n\n<p><em>some</em> content</p>\n"},
{filepath.FromSlash("public/sect/doc4.html"), "\n\n<h1 id=\"doc4\">doc4</h1>\n\n<p><em>some content</em></p>\n"},
{filepath.FromSlash("public/sect/doc5.html"), "<!doctype html><html><head><script src=\"script.js\"></script></head><body>body5</body></html>"},
{filepath.FromSlash("public/sect/doc6.html"), "<!doctype html><html><head><script src=\"http://auth/bub/script.js\"></script></head><body>body5</body></html>"},
{filepath.FromSlash("public/doc7.html"), "<html><body>doc7 content</body></html>"},
{filepath.FromSlash("public/sect/doc8.html"), "\n\n<h1 id=\"title\">title</h1>\n\n<p>some <em>content</em></p>\n"},
{filepath.FromSlash("public/doc9.html"), "<html><body>doc9: SHORT</body></html>"},
}
for _, test := range tests {
file, err := fs.Destination.Open(test.doc)
if err != nil {
t.Fatalf("Did not find %s in target.", test.doc)
}
content := helpers.ReaderToString(file)
if content != test.expected {
t.Errorf("%s content expected:\n%q\ngot:\n%q", test.doc, test.expected, content)
}
}
} | explode_data.jsonl/40671 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1340
} | [
2830,
3393,
35134,
6750,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1903,
2360,
1669,
3056,
2427,
32119,
3608,
515,
197,
197,
63121,
25,
26054,
11439,
88004,
445,
9687,
39510,
16,
2564,
3975,
8883,
25,
3056,
3782,
74083,
59,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseProgression_ParallelChords(t *testing.T) {
par := MustParseProgression("(E F)")
if got, want := par.S().Storex(), "sequence('(E A♭ B F A C5)')"; got != want {
t.Errorf("got [%v] want [%v]", got, want)
}
} | explode_data.jsonl/60939 | {
"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,
14463,
9496,
290,
1088,
277,
7957,
1143,
2260,
1155,
353,
8840,
836,
8,
341,
197,
1732,
1669,
15465,
14463,
9496,
290,
31732,
36,
434,
19107,
743,
2684,
11,
1366,
1669,
1346,
808,
1005,
6093,
87,
1507,
330,
15512,
69963,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestSessionCacheGetAPIGateway(t *testing.T) {
testGetAWSClient(
t, "APIGateway",
func(t *testing.T, cache *sessionCache, region *string, role Role) {
iface := cache.GetAPIGateway(region, role)
if iface == nil {
t.Fail()
return
}
})
} | explode_data.jsonl/18780 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
5283,
8233,
1949,
7082,
40709,
1155,
353,
8840,
836,
8,
341,
18185,
1949,
36136,
2959,
1006,
197,
3244,
11,
330,
7082,
40709,
756,
197,
29244,
1155,
353,
8840,
836,
11,
6500,
353,
5920,
8233,
11,
5537,
353,
917,
11,
3476,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBasicDialSync(t *testing.T) {
df, done, _, callsch := getMockDialFunc()
dsync := NewDialSync(df)
p := peer.ID("testpeer")
ctx := context.Background()
finished := make(chan struct{})
go func() {
_, err := dsync.DialLock(ctx, p)
if err != nil {
t.Error(err)
}
finished <- struct{}{}
}()
go func() {
_, err := dsync.DialLock(ctx, p)
if err != nil {
t.Error(err)
}
finished <- struct{}{}
}()
// short sleep just to make sure we've moved around in the scheduler
time.Sleep(time.Millisecond * 20)
done()
<-finished
<-finished
if len(callsch) > 1 {
t.Fatal("should only have called dial func once!")
}
} | explode_data.jsonl/41481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 266
} | [
2830,
3393,
15944,
35,
530,
12154,
1155,
353,
8840,
836,
8,
341,
85187,
11,
2814,
11,
8358,
6738,
331,
1669,
633,
11571,
35,
530,
9626,
2822,
2698,
12996,
1669,
1532,
35,
530,
12154,
16060,
692,
3223,
1669,
14397,
9910,
445,
1944,
165... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPageRawContent(t *testing.T) {
t.Parallel()
cfg, fs := newTestCfg()
writeSource(t, fs, filepath.Join("content", "raw.md"), `---
title: Raw
---
**Raw**`)
writeSource(t, fs, filepath.Join("layouts", "_default", "single.html"), `{{ .RawContent }}`)
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
require.Len(t, s.RegularPages(), 1)
p := s.RegularPages()[0]
require.Equal(t, p.RawContent(), "**Raw**")
} | explode_data.jsonl/60612 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 185
} | [
2830,
3393,
2665,
20015,
2762,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
50286,
11,
8619,
1669,
501,
2271,
42467,
2822,
24945,
3608,
1155,
11,
8619,
11,
26054,
22363,
445,
1796,
497,
330,
1041,
21324,
3975,
1565,
10952,
2102... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGBBBuild(t *testing.T) {
dir := t.TempDir()
opts := Opts{
Env: golang.Default(),
Packages: []string{
"../test/foo",
"../../../cmds/core/elvish",
},
TempDir: dir,
BinaryDir: "bbin",
BuildOpts: &gbbgolang.BuildOpts{},
}
af := initramfs.NewFiles()
var gbb GBBBuilder
if err := gbb.Build(ulogtest.Logger{TB: t}, af, opts); err != nil {
t.Fatalf("Build(%v, %v); %v != nil", af, opts, err)
}
mustContain := []string{
"bbin/elvish",
"bbin/foo",
}
for _, name := range mustContain {
if !af.Contains(name) {
t.Errorf("expected files to include %q; archive: %v", name, af)
}
}
} | explode_data.jsonl/75711 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
5381,
10098,
1498,
1155,
353,
8840,
836,
8,
341,
48532,
1669,
259,
65009,
6184,
2822,
64734,
1669,
506,
12754,
515,
197,
197,
14359,
25,
342,
37287,
13275,
3148,
197,
10025,
22211,
25,
3056,
917,
515,
298,
197,
1,
1244,
19... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDependencyOutputOptimizationDisableTest(t *testing.T) {
t.Parallel()
expectedOutput := `They said, "No, The answer is 42"`
generatedUniqueId := uniqueId()
cleanupTerraformFolder(t, TEST_FIXTURE_GET_OUTPUT)
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_GET_OUTPUT)
rootPath := filepath.Join(tmpEnvPath, TEST_FIXTURE_GET_OUTPUT, "nested-optimization-disable")
rootTerragruntConfigPath := filepath.Join(rootPath, config.DefaultTerragruntConfigPath)
livePath := filepath.Join(rootPath, "live")
deepDepPath := filepath.Join(rootPath, "deepdep")
s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(generatedUniqueId))
lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(generatedUniqueId))
defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName)
defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)
copyTerragruntConfigAndFillPlaceholders(t, rootTerragruntConfigPath, rootTerragruntConfigPath, s3BucketName, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION)
runTerragrunt(t, fmt.Sprintf("terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath))
// We need to bust the output cache that stores the dependency outputs so that the second run pulls the outputs.
// This is only a problem during testing, where the process is shared across terragrunt runs.
config.ClearOutputCache()
// verify expected output
stdout, _, err := runTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", livePath))
require.NoError(t, err)
outputs := map[string]TerraformOutput{}
require.NoError(t, json.Unmarshal([]byte(stdout), &outputs))
assert.Equal(t, expectedOutput, outputs["output"].Value)
// Now delete the deepdep state and verify it no longer works, because it tries to fetch the deepdep dependency
config.ClearOutputCache()
require.NoError(t, os.Remove(filepath.Join(deepDepPath, "terraform.tfstate")))
require.NoError(t, os.RemoveAll(filepath.Join(deepDepPath, ".terraform")))
_, _, err = runTerragruntCommandWithOutput(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", livePath))
require.Error(t, err)
} | explode_data.jsonl/10128 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 797
} | [
2830,
3393,
36387,
5097,
21367,
65964,
25479,
2271,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
42400,
5097,
1669,
1565,
6865,
1053,
11,
330,
2753,
11,
576,
4226,
374,
220,
19,
17,
8805,
3174,
10543,
72498,
1669,
4911,
764,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddRequire(t *testing.T) {
for _, tt := range addRequireTests {
t.Run(tt.desc, func(t *testing.T) {
testEdit(t, tt.in, tt.out, true, func(f *File) error {
return f.AddRequire(tt.path, tt.vers)
})
})
}
} | explode_data.jsonl/74335 | {
"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,
2212,
17959,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
912,
17959,
18200,
341,
197,
3244,
16708,
47152,
30514,
11,
2915,
1155,
353,
8840,
836,
8,
341,
298,
18185,
4036,
1155,
11,
17853,
1858,
11,
17853,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCanonicalizeResultSets(t *testing.T) {
linkedMonikers := datastructures.DisjointIDSet{}
linkedMonikers.Union("m02", "m05")
state := &State{
ResultSetData: map[string]lsif.ResultSetData{
"s01": {
DefinitionResultID: "",
ReferenceResultID: "",
HoverResultID: "",
MonikerIDs: datastructures.IDSet{"m01": {}},
},
"s02": {
DefinitionResultID: "x01",
ReferenceResultID: "x02",
HoverResultID: "x03",
MonikerIDs: datastructures.IDSet{"m02": {}},
},
"s03": {
DefinitionResultID: "x04",
ReferenceResultID: "x05",
HoverResultID: "",
MonikerIDs: datastructures.IDSet{"m03": {}},
},
"s04": {
DefinitionResultID: "x06",
ReferenceResultID: "x07",
HoverResultID: "",
MonikerIDs: datastructures.IDSet{"m04": {}},
},
"s05": {
DefinitionResultID: "",
ReferenceResultID: "x08",
HoverResultID: "x08",
MonikerIDs: datastructures.IDSet{"m05": {}},
},
},
NextData: map[string]string{
"s01": "s04",
"s03": "s05",
"s04": "s05",
},
LinkedMonikers: linkedMonikers,
}
canonicalizeResultSets(state)
expectedState := &State{
ResultSetData: map[string]lsif.ResultSetData{
"s01": {
DefinitionResultID: "x06",
ReferenceResultID: "x07",
HoverResultID: "x08",
MonikerIDs: datastructures.IDSet{"m01": {}, "m02": {}, "m04": {}, "m05": {}},
},
"s02": {
DefinitionResultID: "x01",
ReferenceResultID: "x02",
HoverResultID: "x03",
MonikerIDs: datastructures.IDSet{"m02": {}, "m05": {}},
},
"s03": {
DefinitionResultID: "x04",
ReferenceResultID: "x05",
HoverResultID: "x08",
MonikerIDs: datastructures.IDSet{"m02": {}, "m03": {}, "m05": {}},
},
"s04": {
DefinitionResultID: "x06",
ReferenceResultID: "x07",
HoverResultID: "x08",
MonikerIDs: datastructures.IDSet{"m02": {}, "m04": {}, "m05": {}},
},
"s05": {
DefinitionResultID: "",
ReferenceResultID: "x08",
HoverResultID: "x08",
MonikerIDs: datastructures.IDSet{"m02": {}, "m05": {}},
},
},
NextData: map[string]string{},
LinkedMonikers: linkedMonikers,
}
if diff := cmp.Diff(expectedState, state); diff != "" {
t.Errorf("unexpected state (-want +got):\n%s", diff)
}
} | explode_data.jsonl/40068 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1208
} | [
2830,
3393,
70914,
551,
2077,
30175,
1155,
353,
8840,
836,
8,
341,
197,
43133,
11095,
53113,
1669,
821,
46094,
10166,
32850,
915,
1649,
16094,
197,
43133,
11095,
53113,
10616,
290,
445,
76,
15,
17,
497,
330,
76,
15,
20,
5130,
24291,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGrow(t *testing.T) {
m := &HashMap{}
m.Grow(uintptr(63))
for { // make sure to wait for resize operation to finish
if atomic.LoadUintptr(&m.resizing) == 0 {
break
}
time.Sleep(time.Microsecond * 50)
}
d := m.mapData()
if d.keyshifts != 58 {
t.Error("Grow operation did not result in correct internal map data structure.")
}
} | explode_data.jsonl/24427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 137
} | [
2830,
3393,
56788,
1155,
353,
8840,
836,
8,
341,
2109,
1669,
609,
18497,
16094,
2109,
1224,
651,
8488,
3505,
7,
21,
18,
4390,
2023,
314,
442,
1281,
2704,
311,
3783,
369,
20925,
5666,
311,
6248,
198,
197,
743,
24510,
13969,
21570,
3505... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnlink(t *testing.T) {
s, err := Run()
ok(t, err)
defer s.Close()
c, err := proto.Dial(s.Addr())
ok(t, err)
defer c.Close()
t.Run("simple", func(t *testing.T) {
s.Set("foo", "bar")
s.HSet("aap", "noot", "mies")
s.Set("one", "two")
s.SetTTL("one", time.Second*1234)
s.Set("three", "four")
mustDo(t, c,
"UNLINK", "one", "aap", "nosuch",
proto.Int(2),
)
equals(t, time.Duration(0), s.TTL("one"))
})
t.Run("direct", func(t *testing.T) {
s.Set("foo", "bar")
s.Unlink("foo")
got, err := s.Get("foo")
equals(t, ErrKeyNotFound, err)
equals(t, "", got)
})
} | explode_data.jsonl/44815 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 310
} | [
2830,
3393,
1806,
2080,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
6452,
741,
59268,
1155,
11,
1848,
340,
16867,
274,
10421,
741,
1444,
11,
1848,
1669,
18433,
98462,
1141,
93626,
2398,
59268,
1155,
11,
1848,
340,
16867,
272,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAppRollbackSuccessful(t *testing.T) {
Given(t).
Path(guestbookPath).
When().
CreateApp().
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
assert.NotEmpty(t, app.Status.Sync.Revision)
}).
And(func(app *Application) {
appWithHistory := app.DeepCopy()
appWithHistory.Status.History = []RevisionHistory{{
ID: 1,
Revision: app.Status.Sync.Revision,
DeployedAt: metav1.Time{Time: metav1.Now().UTC().Add(-1 * time.Minute)},
Source: app.Spec.Source,
}, {
ID: 2,
Revision: "cdb",
DeployedAt: metav1.Time{Time: metav1.Now().UTC().Add(-2 * time.Minute)},
Source: app.Spec.Source,
}}
patch, _, err := diff.CreateTwoWayMergePatch(app, appWithHistory, &Application{})
assert.NoError(t, err)
app, err = AppClientset.ArgoprojV1alpha1().Applications(ArgoCDNamespace).Patch(context.Background(), app.Name, types.MergePatchType, patch, metav1.PatchOptions{})
assert.NoError(t, err)
// sync app and make sure it reaches InSync state
_, err = RunCli("app", "rollback", app.Name, "1")
assert.NoError(t, err)
}).
Expect(Event(EventReasonOperationStarted, "rollback")).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
assert.Equal(t, SyncStatusCodeSynced, app.Status.Sync.Status)
assert.NotNil(t, app.Status.OperationState.SyncResult)
assert.Equal(t, 2, len(app.Status.OperationState.SyncResult.Resources))
assert.Equal(t, OperationSucceeded, app.Status.OperationState.Phase)
assert.Equal(t, 3, len(app.Status.History))
})
} | explode_data.jsonl/35626 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 673
} | [
2830,
3393,
2164,
32355,
1419,
36374,
1155,
353,
8840,
836,
8,
341,
9600,
2071,
1155,
4292,
197,
69640,
3268,
3045,
2190,
1820,
4292,
197,
197,
4498,
25829,
197,
75569,
2164,
25829,
197,
7568,
1721,
25829,
197,
197,
12209,
25829,
197,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestValidateLocalsGlobals(t *testing.T) {
tcs := []struct {
name string
code []byte
err error
}{
{
name: "get_local",
code: []byte{
operators.GetLocal, 0,
operators.Drop,
},
err: nil,
},
{
name: "get_local invalid index",
code: []byte{
operators.GetLocal, 100,
operators.Drop,
},
err: InvalidLocalIndexError(100),
},
{
name: "get_local overflow",
code: []byte{
operators.GetLocal, 0,
},
err: UnbalancedStackErr(wasm.ValueTypeI32),
},
{
name: "get_local type mismatch",
code: []byte{
operators.I32Const, 1,
operators.GetLocal, 1,
operators.I32Add,
},
err: InvalidTypeError{wasm.ValueTypeI32, wasm.ValueTypeI64},
},
{
name: "set_local",
code: []byte{
operators.I32Const, 12,
operators.SetLocal, 0,
},
err: nil,
},
{
name: "set_local underflow",
code: []byte{
operators.SetLocal, 0,
},
err: ErrStackUnderflow,
},
{
name: "set_local type mismatch",
code: []byte{
operators.I32Const, 1,
operators.SetLocal, 1,
},
err: InvalidTypeError{wasm.ValueTypeI64, wasm.ValueTypeI32},
},
{
name: "tee_local",
code: []byte{
operators.I64Const, 1,
operators.TeeLocal, 1,
operators.Drop,
},
err: nil,
},
{
name: "get_global",
code: []byte{
operators.GetGlobal, 0,
operators.Drop,
},
err: nil,
},
{
name: "get_global overflow",
code: []byte{
operators.GetGlobal, 2,
},
err: UnbalancedStackErr(wasm.ValueTypeF64),
},
{
name: "get_global type mismatch",
code: []byte{
operators.GetGlobal, 0,
operators.I64Const, 1,
operators.I64Add,
operators.Drop,
},
err: InvalidTypeError{wasm.ValueTypeI64, wasm.ValueTypeI32},
},
{
name: "get_global invalid index",
code: []byte{
operators.GetGlobal, 100,
operators.Drop,
},
err: wasm.InvalidGlobalIndexError(100),
},
{
name: "set_global",
code: []byte{
operators.I64Const, 42,
operators.SetGlobal, 1,
},
err: nil,
},
{
name: "set_global underflow",
code: []byte{
operators.SetGlobal, 1,
},
err: ErrStackUnderflow,
},
{
name: "set_global type mismatch",
code: []byte{
operators.F32Const, 0, 0, 0, 0,
operators.SetGlobal, 1,
},
err: InvalidTypeError{wasm.ValueTypeI64, wasm.ValueTypeF32},
},
}
for i := range tcs {
tc := tcs[i]
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
mod := wasm.Module{
GlobalIndexSpace: []wasm.GlobalEntry{
{Type: wasm.GlobalVar{Type: wasm.ValueTypeI32}},
{Type: wasm.GlobalVar{Type: wasm.ValueTypeI64}},
{Type: wasm.GlobalVar{Type: wasm.ValueTypeF64}},
},
}
sig := wasm.FunctionSig{Form: 0x60 /* Must always be 0x60 */}
fn := wasm.FunctionBody{
Module: &mod,
Code: tc.code,
Locals: []wasm.LocalEntry{
{Count: 1, Type: wasm.ValueTypeI32},
{Count: 1, Type: wasm.ValueTypeI64},
{Count: 1, Type: wasm.ValueTypeF64},
},
}
_, err := verifyBody(&sig, &fn, &mod)
if err != tc.err {
t.Fatalf("verify returned '%v', want '%v'", err, tc.err)
}
})
}
} | explode_data.jsonl/16565 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1571
} | [
2830,
3393,
17926,
9152,
1127,
48592,
1155,
353,
8840,
836,
8,
341,
3244,
4837,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
43343,
3056,
3782,
198,
197,
9859,
220,
1465,
198,
197,
59403,
197,
197,
515,
298,
11609,
25,
330,
455,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDoRebalance(t *testing.T) {
Convey("Given a defaultConsumer", t, func() {
dc := &defaultConsumer{
model: Clustering,
}
topic := "test"
broker := "127.0.0.1:8889"
clientID := "clientID"
mqs := []*primitive.MessageQueue{
{
Topic: topic,
BrokerName: "",
QueueId: 0,
},
{
Topic: topic,
BrokerName: "",
QueueId: 1,
},
}
dc.topicSubscribeInfoTable.Store(topic, mqs)
sub := &internal.SubscriptionData{}
dc.subscriptionDataTable.Store(topic, sub)
ctrl := gomock.NewController(t)
defer ctrl.Finish()
namesrvCli := internal.NewMockNamesrvs(ctrl)
namesrvCli.EXPECT().FindBrokerAddrByTopic(gomock.Any()).Return(broker)
dc.namesrv = namesrvCli
rmqCli := internal.NewMockRMQClient(ctrl)
rmqCli.EXPECT().InvokeSync(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&remote.RemotingCommand{
Body: []byte("{\"consumerIdList\": [\"a1\", \"a2\", \"a3\"] }"),
}, nil)
rmqCli.EXPECT().ClientID().Return(clientID)
dc.client = rmqCli
var wg sync.WaitGroup
wg.Add(1)
dc.allocate = func(cg string, clientID string, mqAll []*primitive.MessageQueue, cidAll []string) []*primitive.MessageQueue {
assert.Equal(t, cidAll, []string{"a1", "a2", "a3"})
wg.Done()
return nil
}
dc.doBalance()
wg.Wait()
})
} | explode_data.jsonl/16330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 609
} | [
2830,
3393,
5404,
693,
21571,
1155,
353,
8840,
836,
8,
341,
93070,
5617,
445,
22043,
264,
1638,
29968,
497,
259,
11,
2915,
368,
341,
197,
87249,
1669,
609,
2258,
29968,
515,
298,
19727,
25,
2435,
36694,
345,
197,
197,
630,
197,
3244,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestToSubdomainURL(t *testing.T) {
ns := mockNamesys{}
n, err := newNodeWithMockNamesys(ns)
if err != nil {
t.Fatal(err)
}
coreAPI, err := coreapi.NewCoreAPI(n)
if err != nil {
t.Fatal(err)
}
testCID, err := coreAPI.Unixfs().Add(n.Context(), files.NewBytesFile([]byte("fnord")))
if err != nil {
t.Fatal(err)
}
ns["/ipns/dnslink.long-name.example.com"] = path.FromString(testCID.String())
ns["/ipns/dnslink.too-long.f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o.example.com"] = path.FromString(testCID.String())
httpRequest := httptest.NewRequest("GET", "http://127.0.0.1:8080", nil)
httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil)
httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil)
httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https")
for _, test := range []struct {
// in:
request *http.Request
gwHostname string
path string
// out:
url string
err error
}{
// DNSLink
{httpRequest, "localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil},
// Hostname with port
{httpRequest, "localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil},
// CIDv0 → CIDv1base32
{httpRequest, "localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil},
// CIDv1 with long sha512
{httpRequest, "localhost", "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")},
// PeerID as CIDv1 needs to have libp2p-key multicodec
{httpRequest, "localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil},
{httpRequest, "localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil},
// PeerID: ed25519+identity multihash → CIDv1Base36
{httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil},
{httpRequest, "sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil},
// HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169
{httpRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil},
{httpsRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil},
{httpsProxiedRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil},
} {
url, err := toSubdomainURL(test.gwHostname, test.path, test.request, coreAPI)
if url != test.url || !equalError(err, test.err) {
t.Errorf("(%s, %s) returned (%s, %v), expected (%s, %v)", test.gwHostname, test.path, url, err, test.url, test.err)
}
}
} | explode_data.jsonl/26658 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1667
} | [
2830,
3393,
1249,
3136,
12204,
3144,
1155,
353,
8840,
836,
8,
341,
84041,
1669,
7860,
7980,
1047,
16094,
9038,
11,
1848,
1669,
33560,
2354,
11571,
7980,
1047,
39417,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestInstanceof(t *testing.T) {
const SCRIPT = `
var rv;
try {
true();
} catch (e) {
rv = e instanceof TypeError;
}
`
testScript(SCRIPT, valueTrue, t)
} | explode_data.jsonl/75261 | {
"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,
2523,
1055,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
2405,
17570,
280,
6799,
341,
197,
42808,
543,
197,
92,
2287,
320,
68,
8,
341,
197,
78484,
284,
384,
8083,
25030,
280,
197,
532,
197,
19324,
18185,
5910,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSinglePartitionSubscriberSimpleMsgAck(t *testing.T) {
subscription := subscriptionPartition{"projects/123456/locations/us-central1-b/subscriptions/my-sub", 0}
receiver := newTestMessageReceiver(t)
msg1 := seqMsgWithOffsetAndSize(22, 100)
msg2 := seqMsgWithOffsetAndSize(23, 200)
verifiers := test.NewVerifiers(t)
subStream := test.NewRPCVerifier(t)
subStream.Push(initSubReqCommit(subscription), initSubResp(), nil)
subStream.Push(initFlowControlReq(), msgSubResp(msg1, msg2), nil)
verifiers.AddSubscribeStream(subscription.Path, subscription.Partition, subStream)
cmtStream := test.NewRPCVerifier(t)
cmtStream.Push(initCommitReq(subscription), initCommitResp(), nil)
cmtStream.Push(commitReq(24), commitResp(1), nil)
verifiers.AddCommitStream(subscription.Path, subscription.Partition, cmtStream)
mockServer.OnTestStart(verifiers)
defer mockServer.OnTestEnd()
sub := newTestSinglePartitionSubscriber(t, receiver.onMessage, subscription)
if gotErr := sub.WaitStarted(); gotErr != nil {
t.Errorf("Start() got err: (%v)", gotErr)
}
receiver.ValidateMsg(msg1).Ack()
receiver.ValidateMsg(msg2).Ack()
sub.Stop()
if gotErr := sub.WaitStopped(); gotErr != nil {
t.Errorf("Stop() got err: (%v)", gotErr)
}
} | explode_data.jsonl/31647 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 450
} | [
2830,
3393,
10888,
49978,
40236,
16374,
6611,
55559,
1155,
353,
8840,
836,
8,
341,
28624,
12124,
1669,
15142,
49978,
4913,
17161,
14,
16,
17,
18,
19,
20,
21,
14,
31309,
62431,
84081,
16,
1455,
37885,
29966,
34198,
17967,
497,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func Test_JoinTeam(t *testing.T) {
tests := []struct {
name string
prep func(*testSetup)
teamID string
wantResCode int
}{
{
name: "should return 400 when team id is not provided",
wantResCode: http.StatusBadRequest,
},
{
name: "should return 401 when authorizer returns ErrInvalidToken",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(primitive.ObjectID{}, authCommon.ErrInvalidToken).Times(1)
},
wantResCode: http.StatusUnauthorized,
},
{
name: "should return 500 when authorizer returns unknown error",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(primitive.ObjectID{}, errors.New("authorizer err")).Times(1)
},
wantResCode: http.StatusInternalServerError,
},
{
name: "should return 400 when team service returns ErrInvalidID",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(testUserId, nil).Times(1)
setup.mockTService.EXPECT().AddUserWithIDToTeamWithID(setup.testCtx, testUserId.Hex(), "testteam").
Return(services.ErrInvalidID).Times(1)
},
wantResCode: http.StatusBadRequest,
},
{
name: "should return 404 when team service returns ErrNotFound",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(testUserId, nil).Times(1)
setup.mockTService.EXPECT().AddUserWithIDToTeamWithID(setup.testCtx, testUserId.Hex(), "testteam").
Return(services.ErrNotFound).Times(1)
},
wantResCode: http.StatusNotFound,
},
{
name: "should return 400 when team service returns ErrUserInTeam",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(testUserId, nil).Times(1)
setup.mockTService.EXPECT().AddUserWithIDToTeamWithID(setup.testCtx, testUserId.Hex(), "testteam").
Return(services.ErrUserInTeam).Times(1)
},
wantResCode: http.StatusBadRequest,
},
{
name: "should return 500 when team service returns unknown error",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(testUserId, nil).Times(1)
setup.mockTService.EXPECT().AddUserWithIDToTeamWithID(setup.testCtx, testUserId.Hex(), "testteam").
Return(errors.New("service err")).Times(1)
},
wantResCode: http.StatusInternalServerError,
},
{
name: "should return 200",
teamID: "testteam",
prep: func(setup *testSetup) {
setup.mockAuthorizer.EXPECT().GetUserIdFromToken(testAuthToken).
Return(testUserId, nil).Times(1)
setup.mockTService.EXPECT().AddUserWithIDToTeamWithID(setup.testCtx, testUserId.Hex(), "testteam").
Return(nil).Times(1)
},
wantResCode: http.StatusOK,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
setup := setupTest(t, map[string]string{
environment.JWTSecret: "test",
})
defer setup.ctrl.Finish()
mockRenderPageCall(setup)
if tt.prep != nil {
tt.prep(setup)
}
testutils.AddRequestWithFormParamsToCtx(setup.testCtx, http.MethodPost, map[string]string{
"id": tt.teamID,
})
attachAuthCookie(setup.testCtx)
setup.router.JoinTeam(setup.testCtx)
assert.Equal(t, tt.wantResCode, setup.w.Code)
})
}
} | explode_data.jsonl/32969 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1479
} | [
2830,
3393,
10598,
1961,
14597,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
286,
914,
198,
197,
40346,
79,
286,
2915,
4071,
1944,
21821,
340,
197,
197,
9196,
915,
414,
914,
198,
197,
50780,
1061,
2078,
526,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStartAnalysis(t *testing.T) {
t.Run("should populate analysis vulnerabilities", func(t *testing.T) {
analysis := &horusec.Analysis{}
dockerMock := &docker.Mock{}
output := "[{\"filePath\":\"/src/node/auth.js\",\"messages\":[],\"errorCount\":0,\"warningCount\":0,\"fixableErrorCount\":0,\"fixableWarningCount\":0,\"usedDeprecatedRules\":[]},{\"filePath\":\"/src/node/injection.js\",\"messages\":[],\"errorCount\":0,\"warningCount\":0,\"fixableErrorCount\":0,\"fixableWarningCount\":0,\"usedDeprecatedRules\":[]},{\"filePath\":\"/src/node/product.js\",\"messages\":[{\"ruleId\":\"security/detect-unsafe-regex\",\"severity\":1,\"message\":\"Unsafe Regular Expression\",\"line\":53,\"column\":27,\"nodeType\":\"Literal\",\"endLine\":53,\"endColumn\":92}],\"errorCount\":0,\"warningCount\":1,\"fixableErrorCount\":0,\"fixableWarningCount\":0,\"source\":\"var config = require(\\\"../config\\\"),\\n pgp = require('pg-promise')(),\\n db = pgp(config.db.connectionString);\\n\\nfunction list_products() {\\n \\n var q = \\\"SELECT * FROM products;\\\";\\n\\n return db.many(q);\\n}\\n\\nfunction getProduct(product_id) {\\n\\n var q = \\\"SELECT * FROM products WHERE id = '\\\" + product_id + \\\"';\\\";\\n\\n return db.one(q);\\n}\\n\\nfunction search(query) {\\n\\n var q = \\\"SELECT * FROM products WHERE name ILIKE '%\\\" + query + \\\"%' OR description ILIKE '%\\\" + query + \\\"%';\\\";\\n\\n return db.many(q);\\n\\n}\\n\\nfunction purchase(cart) {\\n\\n var q = \\\"INSERT INTO purchases(mail, product_name, user_name, product_id, address, phone, ship_date, price) VALUES('\\\" +\\n cart.mail + \\\"', '\\\" +\\n cart.product_name + \\\"', '\\\" +\\n cart.username + \\\"', '\\\" +\\n cart.product_id + \\\"', '\\\" +\\n cart.address + \\\"', '\\\" +\\n cart.ship_date + \\\"', '\\\" +\\n cart.phone + \\\"', '\\\" +\\n cart.price +\\n \\\"');\\\";\\n\\n return db.one(q);\\n\\n}\\n\\nfunction get_purcharsed(username) {\\n\\n var q = \\\"SELECT * FROM purchases WHERE user_name = '\\\" + username + \\\"';\\\";\\n\\n return db.many(q);\\n\\n}\\n\\nfunction validateEmail ( string ) {\\n var emailExpression = /^([a-zA-Z0-9_\\\\.\\\\-])+\\\\@(([a-zA-Z0-9\\\\-])+\\\\.)+([a-zA-Z0-9]{2,4})+$/;\\n\\n return emailExpression.test( string );\\n}\\n\\nvar actions = {\\n \\\"list\\\": list_products,\\n \\\"getProduct\\\": getProduct,\\n \\\"search\\\": search,\\n \\\"purchase\\\": purchase,\\n \\\"getPurchased\\\": get_purcharsed\\n}\\n\\nmodule.exports = actions;\",\"usedDeprecatedRules\":[]}]"
dockerMock.On("CreateLanguageAnalysisContainer").Return(output, nil)
config := &cliConfig.Config{}
config.SetWorkDir(&workdir.WorkDir{})
service := formatters.NewFormatterService(analysis, dockerMock, config, &horusec.Monitor{})
formatter := NewFormatter(service)
formatter.StartAnalysis("")
assert.Equal(t, 1, len(analysis.AnalysisVulnerabilities))
})
t.Run("should return error parsing output", func(t *testing.T) {
analysis := &horusec.Analysis{}
dockerMock := &docker.Mock{}
output := "!@#!@#"
dockerMock.On("CreateLanguageAnalysisContainer").Return(output, nil)
config := &cliConfig.Config{}
config.SetWorkDir(&workdir.WorkDir{})
service := formatters.NewFormatterService(analysis, dockerMock, config, &horusec.Monitor{})
formatter := NewFormatter(service)
formatter.StartAnalysis("")
assert.Equal(t, 0, len(analysis.AnalysisVulnerabilities))
})
t.Run("should return no vulnerabilities when empty output", func(t *testing.T) {
analysis := &horusec.Analysis{}
dockerMock := &docker.Mock{}
dockerMock.On("CreateLanguageAnalysisContainer").Return("", nil)
config := &cliConfig.Config{}
config.SetWorkDir(&workdir.WorkDir{})
service := formatters.NewFormatterService(analysis, dockerMock, config, &horusec.Monitor{})
formatter := NewFormatter(service)
formatter.StartAnalysis("")
assert.Equal(t, 0, len(analysis.AnalysisVulnerabilities))
})
t.Run("should return error when executing container", func(t *testing.T) {
analysis := &horusec.Analysis{}
dockerMock := &docker.Mock{}
dockerMock.On("CreateLanguageAnalysisContainer").Return("", errors.New("test"))
config := &cliConfig.Config{}
config.SetWorkDir(&workdir.WorkDir{})
service := formatters.NewFormatterService(analysis, dockerMock, config, &horusec.Monitor{})
formatter := NewFormatter(service)
formatter.StartAnalysis("")
assert.Equal(t, 0, len(analysis.AnalysisVulnerabilities))
})
t.Run("should ignore tool", func(t *testing.T) {
analysis := &horusec.Analysis{}
dockerMock := &docker.Mock{}
dockerMock.On("CreateLanguageAnalysisContainer").Return("", errors.New("test"))
config := &cliConfig.Config{}
config.SetToolsToIgnore([]string{"Eslint"})
config.SetWorkDir(&workdir.WorkDir{})
service := formatters.NewFormatterService(analysis, dockerMock, config, &horusec.Monitor{})
formatter := NewFormatter(service)
formatter.StartAnalysis("")
assert.Equal(t, 0, len(analysis.AnalysisVulnerabilities))
})
} | explode_data.jsonl/75481 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1960
} | [
2830,
3393,
3479,
26573,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5445,
30446,
6358,
51127,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
197,
34484,
1669,
609,
19530,
810,
66,
8624,
9092,
16094,
197,
2698,
13659,
11571,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestRegisterEncoder(t *testing.T) {
testEncoders(func() {
assert.NoError(t, RegisterEncoder("foo", newNilEncoder), "expected to be able to register the encoder foo")
testEncodersRegistered(t, "foo")
})
} | explode_data.jsonl/54643 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 76
} | [
2830,
3393,
8690,
19921,
1155,
353,
8840,
836,
8,
341,
18185,
7408,
52498,
18552,
368,
341,
197,
6948,
35699,
1155,
11,
8451,
19921,
445,
7975,
497,
501,
19064,
19921,
701,
330,
7325,
311,
387,
2952,
311,
4161,
279,
23668,
15229,
1138,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestRuleAutoIncUnsigned(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
sqls := []string{
"CREATE TABLE `tb` ( `id` int(10) NOT NULL AUTO_INCREMENT, `c` longblob, PRIMARY KEY (`id`));",
"ALTER TABLE `tbl` ADD COLUMN `id` int(10) NOT NULL AUTO_INCREMENT;",
}
for _, sql := range sqls {
q, err := NewQuery4Audit(sql)
if err == nil {
rule := q.RuleAutoIncUnsigned()
if rule.Item != "COL.003" {
t.Error("Rule not match:", rule.Item, "Expect : COL.003")
}
} else {
t.Error("sqlparser.Parse Error:", err)
}
}
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
} | explode_data.jsonl/76845 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 272
} | [
2830,
3393,
11337,
13253,
39245,
56421,
1155,
353,
8840,
836,
8,
341,
83825,
5247,
20345,
445,
82867,
729,
25,
1018,
82,
497,
4185,
2234,
5152,
675,
2398,
30633,
82,
1669,
3056,
917,
515,
197,
197,
1,
22599,
14363,
1565,
18387,
63,
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... | 4 |
func Test_NilFilterDoesntPanic(t *testing.T) {
t.Parallel()
for _, tc := range []string{
`{namespace="dev", container_name="cart"} |= "" |= "bloop"`,
`{namespace="dev", container_name="cart"} |= "bleep" |= ""`,
`{namespace="dev", container_name="cart"} |= "bleep" |= "" |= "bloop"`,
`{namespace="dev", container_name="cart"} |= "bleep" |= "" |= "bloop"`,
`{namespace="dev", container_name="cart"} |= "bleep" |= "bloop" |= ""`,
} {
t.Run(tc, func(t *testing.T) {
expr, err := ParseLogSelector(tc)
require.Nil(t, err)
filter, err := expr.Filter()
require.Nil(t, err)
require.True(t, filter.Filter([]byte("bleepbloop")))
})
}
} | explode_data.jsonl/62861 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 293
} | [
2830,
3393,
1604,
321,
5632,
21468,
406,
47,
31270,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2023,
8358,
17130,
1669,
2088,
3056,
917,
515,
197,
197,
63,
90,
2231,
428,
3583,
497,
5476,
1269,
428,
11452,
9207,
8662,
1591,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportImportRequestResponsePairs_ReturnsWarningsIfDeprecatedQuerytSet(t *testing.T) {
RegisterTestingT(t)
cache := cache.NewInMemoryCache()
cfg := Configuration{Webserver: false}
cacheMatcher := matching.CacheMatcher{RequestCache: cache, Webserver: cfg.Webserver}
hv := Hoverfly{Cfg: &cfg, CacheMatcher: cacheMatcher, Simulation: models.NewSimulation()}
RegisterTestingT(t)
encodedPair := v2.RequestMatcherResponsePairViewV5{
Response: v2.ResponseDetailsViewV5{
Status: 200,
Body: base64String("hello_world"),
EncodedBody: true,
Headers: map[string][]string{"Content-Encoding": []string{"gzip"}}},
RequestMatcher: v2.RequestMatcherViewV5{
DeprecatedQuery: []v2.MatcherViewV5{
v2.MatcherViewV5{
Matcher: "exact",
Value: "deprecated",
},
},
},
}
result := hv.importRequestResponsePairViews([]v2.RequestMatcherResponsePairViewV5{encodedPair})
Expect(result.WarningMessages).To(HaveLen(1))
Expect(result.WarningMessages[0].Message).To(ContainSubstring("data.pairs[0].request.deprecatedQuery"))
} | explode_data.jsonl/75458 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 416
} | [
2830,
3393,
11511,
11511,
1900,
2582,
54228,
53316,
82,
20140,
2679,
51344,
2859,
83,
1649,
1155,
353,
8840,
836,
8,
341,
79096,
16451,
51,
1155,
692,
52680,
1669,
6500,
7121,
641,
10642,
8233,
741,
50286,
1669,
12221,
90,
5981,
4030,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDeleteUpdateRegression(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.Parallel()
// Create siafile
sf := newBlankTestFile()
// Apply updates with the last update as a delete update. This use to trigger
// a panic. No need to check the return value as we are only concerned with the
// panic
update := sf.createDeleteUpdate()
sf.createAndApplyTransaction(update, update)
} | explode_data.jsonl/14703 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
6435,
4289,
45200,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
7039,
741,
197,
532,
3244,
41288,
7957,
2822,
197,
322,
4230,
49889,
1192,
198,
53024,
1669,
501,
22770,
2271,
1703,
2822,
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 TestOptionBool_Eq(t *testing.T) {
assertEq(t, []eqAssert{
{NewOptionBool(NewBool(true)), NewBool(true), false},
{NewOptionBool(NewBool(false)), NewOptionBool(NewBool(false)), true},
{NewOptionBoolEmpty(), NewOptionBoolEmpty(), true},
})
} | explode_data.jsonl/40250 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 103
} | [
2830,
3393,
5341,
11233,
2089,
80,
1155,
353,
8840,
836,
8,
341,
6948,
27312,
1155,
11,
3056,
11006,
8534,
515,
197,
197,
90,
3564,
5341,
11233,
35063,
11233,
3715,
5731,
1532,
11233,
3715,
701,
895,
1583,
197,
197,
90,
3564,
5341,
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 TestMysqlSocket(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipped Unix socket test on Windows")
}
requireMysqlVars(t)
dir, err := ioutil.TempDir("", "csql-proxy-tests")
if err != nil {
log.Fatalf("unable to create tmp dir: %s", err)
}
defer os.RemoveAll(dir)
cfg := mysql.Config{
User: *mysqlUser,
Passwd: *mysqlPass,
Net: "unix",
Addr: path.Join(dir, *mysqlConnName),
DBName: *mysqlDb,
AllowNativePasswords: true,
}
proxyConnTest(t, *mysqlConnName, "mysql", cfg.FormatDSN(), 0, dir)
} | explode_data.jsonl/47451 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 306
} | [
2830,
3393,
44,
14869,
10286,
1155,
353,
8840,
836,
8,
341,
743,
15592,
97574,
3126,
621,
330,
27077,
1,
341,
197,
3244,
57776,
445,
19290,
6450,
46995,
7575,
1273,
389,
5515,
1138,
197,
532,
17957,
44,
14869,
28305,
1155,
692,
48532,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLookupHashCreate(t *testing.T) {
lookuphash := createLookup(t, "lookup_hash", false)
vc := &vcursor{}
err := lookuphash.(Lookup).Create(vc, [][]sqltypes.Value{{sqltypes.NewInt64(1)}}, [][]byte{[]byte("\x16k@\xb4J\xbaK\xd6")}, false /* ignoreMode */)
if err != nil {
t.Error(err)
}
if got, want := len(vc.queries), 1; got != want {
t.Errorf("vc.queries length: %v, want %v", got, want)
}
vc.queries = nil
err = lookuphash.(Lookup).Create(vc, [][]sqltypes.Value{{sqltypes.NULL}}, [][]byte{[]byte("\x16k@\xb4J\xbaK\xd6")}, false /* ignoreMode */)
if err != nil {
t.Error(err)
}
if got, want := len(vc.queries), 1; got != want {
t.Errorf("vc.queries length: %v, want %v", got, want)
}
err = lookuphash.(Lookup).Create(vc, [][]sqltypes.Value{{sqltypes.NewInt64(1)}}, [][]byte{[]byte("bogus")}, false /* ignoreMode */)
want := "lookup.Create.vunhash: invalid keyspace id: 626f677573"
if err == nil || err.Error() != want {
t.Errorf("lookuphash.Create(bogus) err: %v, want %s", err, want)
}
} | explode_data.jsonl/3420 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 439
} | [
2830,
3393,
34247,
6370,
4021,
1155,
353,
8840,
836,
8,
341,
197,
21020,
8296,
1669,
1855,
34247,
1155,
11,
330,
21020,
8950,
497,
895,
340,
5195,
66,
1669,
609,
7362,
3823,
31483,
9859,
1669,
18615,
8296,
12832,
34247,
568,
4021,
80698... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDedup(t *testing.T) {
// make it []string
testcases := map[[3]RR][]string{
[...]RR{
newRR(t, "mIek.nl. IN A 127.0.0.1"),
newRR(t, "mieK.nl. IN A 127.0.0.1"),
newRR(t, "miek.Nl. IN A 127.0.0.1"),
}: []string{"mIek.nl.\t3600\tIN\tA\t127.0.0.1"},
[...]RR{
newRR(t, "miEk.nl. 2000 IN A 127.0.0.1"),
newRR(t, "mieK.Nl. 1000 IN A 127.0.0.1"),
newRR(t, "Miek.nL. 500 IN A 127.0.0.1"),
}: []string{"miEk.nl.\t500\tIN\tA\t127.0.0.1"},
[...]RR{
newRR(t, "miek.nl. IN A 127.0.0.1"),
newRR(t, "miek.nl. CH A 127.0.0.1"),
newRR(t, "miek.nl. IN A 127.0.0.1"),
}: []string{"miek.nl.\t3600\tIN\tA\t127.0.0.1",
"miek.nl.\t3600\tCH\tA\t127.0.0.1",
},
[...]RR{
newRR(t, "miek.nl. CH A 127.0.0.1"),
newRR(t, "miek.nl. IN A 127.0.0.1"),
newRR(t, "miek.de. IN A 127.0.0.1"),
}: []string{"miek.nl.\t3600\tCH\tA\t127.0.0.1",
"miek.nl.\t3600\tIN\tA\t127.0.0.1",
"miek.de.\t3600\tIN\tA\t127.0.0.1",
},
[...]RR{
newRR(t, "miek.de. IN A 127.0.0.1"),
newRR(t, "miek.nl. 200 IN A 127.0.0.1"),
newRR(t, "miek.nl. 300 IN A 127.0.0.1"),
}: []string{"miek.de.\t3600\tIN\tA\t127.0.0.1",
"miek.nl.\t200\tIN\tA\t127.0.0.1",
},
}
for rr, expected := range testcases {
out := Dedup([]RR{rr[0], rr[1], rr[2]}, nil)
for i, o := range out {
if o.String() != expected[i] {
t.Fatalf("expected %v, got %v", expected[i], o.String())
}
}
}
} | explode_data.jsonl/44692 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 856
} | [
2830,
3393,
35,
291,
454,
1155,
353,
8840,
836,
8,
341,
197,
322,
1281,
432,
3056,
917,
198,
18185,
23910,
1669,
2415,
15505,
18,
60,
8106,
45725,
917,
515,
197,
197,
58,
61399,
8106,
515,
298,
8638,
8106,
1155,
11,
330,
76,
40,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestICMPString(t *testing.T) {
for _, tt := range icmpStringTests {
s := tt.in.String()
if s != tt.out {
t.Errorf("got %s; want %s", s, tt.out)
}
}
} | explode_data.jsonl/55240 | {
"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,
1317,
5781,
703,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
17853,
1669,
2088,
91826,
703,
18200,
341,
197,
1903,
1669,
17853,
1858,
6431,
741,
197,
743,
274,
961,
17853,
2532,
341,
298,
3244,
13080,
445,
22390,
1018,
82,
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
] | 3 |
func Test_PackMulti(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
srcPath := gdebug.TestDataPath("files")
goFilePath := gdebug.TestDataPath("data/data.go")
pkgName := "data"
array, err := gfile.ScanDir(srcPath, "*", false)
t.Assert(err, nil)
err = gres.PackToGoFile(strings.Join(array, ","), goFilePath, pkgName)
t.Assert(err, nil)
})
} | explode_data.jsonl/26299 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 156
} | [
2830,
3393,
1088,
473,
20358,
1155,
353,
8840,
836,
8,
341,
3174,
1944,
727,
1155,
11,
2915,
1155,
353,
82038,
836,
8,
341,
197,
41144,
1820,
1669,
342,
8349,
8787,
1043,
1820,
445,
7198,
1138,
197,
30680,
19090,
1669,
342,
8349,
8787... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMySQLDriver(t *testing.T) {
asrt := assert.New(t)
driver := new(MySQL)
asrt.Implements((*core.Driver)(nil), driver)
asrt.Implements((*core.Version)(nil), driver.Version())
conf, err := core.NewConfig("../examples/testdata")
if asrt.NoError(err) {
conf.WithEnv("development")
testDriver(t, harness{driver, conf.Dsn()})
}
asrt.Equal(".sql", driver.Ext())
} | explode_data.jsonl/17375 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 150
} | [
2830,
3393,
59224,
11349,
1155,
353,
8840,
836,
8,
341,
60451,
3342,
1669,
2060,
7121,
1155,
692,
33652,
1669,
501,
37485,
6688,
340,
60451,
3342,
26914,
4674,
26609,
2153,
41768,
2376,
8385,
701,
5579,
340,
60451,
3342,
26914,
4674,
2660... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLoadCastle(t *testing.T) {
tt := []struct {
home, castle string
fail bool
}{
{"emptyHome", "dotfiles", true},
{"noRepos", "dotfiles", true},
{"home1", "dotfiles", false},
{"home1", "private", false},
{"home1", "nogit", true},
{"home1", "none", true},
{"home1", "", true},
}
for _, tc := range tt {
t.Run(tc.home+":"+tc.castle, func(t *testing.T) {
tmpHomePath, cleanup := setupHomedir(t, tc.home)
defer cleanup()
got, err := loadCastle(tc.castle)
if err != nil {
if !tc.fail {
t.Fatalf("unexpected error: %v", err)
}
return
}
if got == nil {
t.Fatal("got nil castle without an error")
}
if got.name != tc.castle {
t.Errorf("castle name is wrong (want '%s', got '%s')", tc.castle, got.name)
}
wantPath, _ := filepath.Abs(filepath.Join(tmpHomePath, ".homesick/repos", tc.castle))
if got.path != wantPath {
t.Errorf("castle path wrong (want: '%s', got: '%s)", wantPath, got.path)
}
})
}
} | explode_data.jsonl/56641 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 451
} | [
2830,
3393,
5879,
86603,
1155,
353,
8840,
836,
8,
341,
3244,
83,
1669,
3056,
1235,
341,
197,
197,
5117,
11,
32584,
914,
198,
197,
63052,
260,
1807,
198,
197,
59403,
197,
197,
4913,
3194,
7623,
497,
330,
16119,
7198,
497,
830,
1583,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPoolOneSize(t *testing.T) {
maxSize := 1024
pool := New(1024, maxSize)
if pool.maxSize != maxSize {
t.Fatalf("Invalid max pool size: %d, expected %d", pool.maxSize, maxSize)
}
buf := pool.Get(64)
if len(*buf) != 64 {
t.Fatalf("unexpected buf length: %d", len(*buf))
}
if cap(*buf) != 1024 {
t.Fatalf("unexpected buf cap: %d", cap(*buf))
}
pool.Put(buf)
buf = pool.Get(1025)
if len(*buf) != 1025 {
t.Fatalf("unexpected buf length: %d", len(*buf))
}
if cap(*buf) != 1025 {
t.Fatalf("unexpected buf cap: %d", cap(*buf))
}
pool.Put(buf)
} | explode_data.jsonl/47638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 245
} | [
2830,
3393,
10551,
3966,
1695,
1155,
353,
8840,
836,
8,
341,
22543,
1695,
1669,
220,
16,
15,
17,
19,
198,
85273,
1669,
1532,
7,
16,
15,
17,
19,
11,
61935,
340,
743,
7314,
6678,
1695,
961,
61935,
341,
197,
3244,
30762,
445,
7928,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDoUseMultipartForm(t *testing.T) {
is := is.New(t)
var calls int
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
calls++
is.Equal(r.Method, http.MethodPost)
query := r.FormValue("query")
is.Equal(query, `query {}`)
io.WriteString(w, `{
"data": {
"something": "yes"
}
}`)
}))
defer srv.Close()
ctx := context.Background()
client := NewClient(srv.URL, UseMultipartForm())
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
var responseData map[string]interface{}
err := client.Run(ctx, &Request{q: "query {}"}, &responseData)
is.NoErr(err)
is.Equal(calls, 1) // calls
is.Equal(responseData["something"], "yes")
} | explode_data.jsonl/53421 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 296
} | [
2830,
3393,
5404,
10253,
44,
18204,
1838,
1155,
353,
8840,
836,
8,
341,
19907,
1669,
374,
7121,
1155,
340,
2405,
6738,
526,
198,
1903,
10553,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
96... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetXWso2Basepath(t *testing.T) {
type getXWso2BasepathTestItem struct {
inputVendorExtensions map[string]interface{}
result string
message string
}
dataItems := []getXWso2BasepathTestItem{
{
inputVendorExtensions: map[string]interface{}{"x-wso2-basePath": "/base"},
result: "/base",
message: "usual case",
},
{
inputVendorExtensions: map[string]interface{}{"x-wso2-basepath+++": "/base"},
result: "",
message: "when having incorrect structure",
},
}
for _, item := range dataItems {
resultResources := getXWso2Basepath(item.inputVendorExtensions)
assert.Equal(t, item.result, resultResources, item.message)
}
} | explode_data.jsonl/28622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 345
} | [
2830,
3393,
76622,
54,
704,
17,
3978,
2343,
1155,
353,
8840,
836,
8,
341,
13158,
75656,
54,
704,
17,
3978,
2343,
2271,
1234,
2036,
341,
197,
22427,
44691,
31282,
2415,
14032,
31344,
16094,
197,
9559,
394,
914,
198,
197,
24753,
2290,
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... | 2 |
func TestWithGlg(t *testing.T) {
type test struct {
name string
g *glg.Glg
checkFunc func(Option) error
}
tests := []test{
func() test {
g := glg.New()
return test{
name: "set success when glg is not nil",
g: g,
checkFunc: func(opt Option) error {
got := new(logger)
opt(got)
if !reflect.DeepEqual(got.glg, g) {
return errors.New("invalid params was set")
}
return nil
},
}
}(),
func() test {
g := glg.New()
return test{
name: "returns nothing when glg is nil",
g: nil,
checkFunc: func(opt Option) error {
got := &logger{
glg: g,
}
opt(got)
if !reflect.DeepEqual(got.glg, g) {
return errors.New("invalid params was set")
}
return nil
},
}
}(),
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opt := WithGlg(tt.g)
if err := tt.checkFunc(opt); err != nil {
t.Error(err)
}
})
}
} | explode_data.jsonl/2664 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 507
} | [
2830,
3393,
2354,
38,
11819,
1155,
353,
8840,
836,
8,
341,
13158,
1273,
2036,
341,
197,
11609,
414,
914,
198,
197,
3174,
260,
353,
6072,
70,
1224,
11819,
198,
197,
25157,
9626,
2915,
7,
5341,
8,
1465,
198,
197,
630,
78216,
1669,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetCurlCommand_noBody(t *testing.T) {
req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", nil)
req.Header.Set("Content-Type", "application/json")
libCommand, _ := http2curl.GetCurlCommand(req)
command, _ := GetCurlCommand(req)
if libCommand.String() != command.String() {
t.Errorf("expected library command: %s and command: %s to match", libCommand, command)
}
// Output:
// curl -X 'PUT' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu'
} | explode_data.jsonl/61001 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
1949,
34,
1085,
4062,
6536,
5444,
1155,
353,
8840,
836,
8,
341,
24395,
11,
716,
1669,
1758,
75274,
445,
6221,
497,
330,
1254,
1110,
2136,
7724,
905,
14,
13683,
14,
750,
13,
75076,
30,
73,
41748,
27221,
2152,
96774,
23004,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPreparedCommand_RunS_Fail(t *testing.T) {
stderr := shx.RecordStderr()
defer stderr.Release()
err := shx.RunS("go", "run")
gotStderr := stderr.Output()
if err == nil {
t.Fatal("expected the shx.Command to fail")
}
assert.Empty(t, gotStderr)
} | explode_data.jsonl/57100 | {
"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,
4703,
7212,
4062,
84158,
50,
1400,
604,
1155,
353,
8840,
836,
8,
341,
6736,
615,
1669,
557,
87,
49959,
22748,
615,
741,
16867,
26436,
58693,
2822,
9859,
1669,
557,
87,
16708,
50,
445,
3346,
497,
330,
6108,
1138,
3174,
354,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRowsSortText(t *testing.T) {
uu := map[string]struct {
rows render.Rows
col int
asc, num bool
e render.Rows
}{
"plainAsc": {
rows: render.Rows{
{Fields: []string{"blee", "duh"}},
{Fields: []string{"albert", "blee"}},
},
col: 0,
asc: true,
e: render.Rows{
{Fields: []string{"albert", "blee"}},
{Fields: []string{"blee", "duh"}},
},
},
"plainDesc": {
rows: render.Rows{
{Fields: []string{"blee", "duh"}},
{Fields: []string{"albert", "blee"}},
},
col: 0,
asc: false,
e: render.Rows{
{Fields: []string{"blee", "duh"}},
{Fields: []string{"albert", "blee"}},
},
},
"numericAsc": {
rows: render.Rows{
{Fields: []string{"10", "duh"}},
{Fields: []string{"1", "blee"}},
},
col: 0,
num: true,
asc: true,
e: render.Rows{
{Fields: []string{"1", "blee"}},
{Fields: []string{"10", "duh"}},
},
},
"numericDesc": {
rows: render.Rows{
{Fields: []string{"10", "duh"}},
{Fields: []string{"1", "blee"}},
},
col: 0,
num: true,
asc: false,
e: render.Rows{
{Fields: []string{"10", "duh"}},
{Fields: []string{"1", "blee"}},
},
},
"composite": {
rows: render.Rows{
{Fields: []string{"blee-duh", "duh"}},
{Fields: []string{"blee", "blee"}},
},
col: 0,
asc: true,
e: render.Rows{
{Fields: []string{"blee", "blee"}},
{Fields: []string{"blee-duh", "duh"}},
},
},
}
for k := range uu {
u := uu[k]
t.Run(k, func(t *testing.T) {
u.rows.Sort(u.col, u.asc, u.num, false)
assert.Equal(t, u.e, u.rows)
})
}
} | explode_data.jsonl/66597 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 882
} | [
2830,
3393,
9024,
10231,
1178,
1155,
353,
8840,
836,
8,
341,
10676,
84,
1669,
2415,
14032,
60,
1235,
341,
197,
68438,
257,
3141,
11332,
198,
197,
46640,
414,
526,
198,
197,
197,
5061,
11,
1629,
1807,
198,
197,
7727,
286,
3141,
11332,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFloat(t *testing.T) {
s := rand.NewSource(time.Now().UnixNano())
r := rand.New(s)
for i := 0; i < 100; i++ {
n := r.Float64()
bs := Float642bytes(n)
assert.NotNil(t, bs)
assert.True(t, len(bs) == 8)
assert.Equal(t, n, Bytes2float(bs))
}
} | explode_data.jsonl/71111 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 128
} | [
2830,
3393,
5442,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
10382,
7121,
3608,
9730,
13244,
1005,
55832,
83819,
2398,
7000,
1669,
10382,
7121,
1141,
692,
2023,
600,
1669,
220,
15,
26,
600,
366,
220,
16,
15,
15,
26,
600,
1027,
341,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestConvertFromMapError(t *testing.T) {
// Test that we get an error using ConvertFromMap to convert to an interface{}.
var actual interface{}
expected := awserr.New("SerializationError", `v must be a non-nil pointer to a map[string]interface{} or struct, got *interface {}`, nil).Error()
if err := ConvertFromMap(nil, &actual); err == nil {
t.Errorf("ConvertFromMap with input %#v returned no error, expected error `%s`", nil, expected)
} else if err.Error() != expected {
t.Errorf("ConvertFromMap with input %#v returned error `%s`, expected error `%s`", nil, err, expected)
}
// Test that we get an error using ConvertFromMap to convert to a slice.
var actual2 []interface{}
expected = awserr.New("SerializationError", `v must be a non-nil pointer to a map[string]interface{} or struct, got *[]interface {}`, nil).Error()
if err := ConvertFromMap(nil, &actual2); err == nil {
t.Errorf("ConvertFromMap with input %#v returned no error, expected error `%s`", nil, expected)
} else if err.Error() != expected {
t.Errorf("ConvertFromMap with input %#v returned error `%s`, expected error `%s`", nil, err, expected)
}
} | explode_data.jsonl/20448 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 364
} | [
2830,
3393,
12012,
3830,
2227,
1454,
1155,
353,
8840,
836,
8,
341,
197,
322,
3393,
429,
582,
633,
458,
1465,
1667,
7169,
3830,
2227,
311,
5508,
311,
458,
3749,
6257,
624,
2405,
5042,
3749,
16094,
42400,
1669,
31521,
615,
7121,
445,
35... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAmendForIndexChange(t *testing.T) {
defer config.RestoreFunc()()
config.UpdateGlobal(func(conf *config.Config) {
conf.TiKVClient.AsyncCommit.SafeWindow = 0
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0
})
store, clean := createMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk2.MustExec("use test")
tk.MustExec("set tidb_enable_amend_pessimistic_txn = ON;")
tk.Session().GetSessionVars().EnableAsyncCommit = false
tk.Session().GetSessionVars().Enable1PC = false
tk2.MustExec("drop table if exists t1")
// Add some different column types.
columnNames := []string{"c_int", "c_str", "c_datetime", "c_timestamp", "c_double", "c_decimal", "c_float"}
columnTypes := []string{"int", "varchar(40)", "datetime", "timestamp", "double", "decimal(12, 6)", "float"}
addIndexFunc := func(idxName string, part bool, a, b int) string {
var str string
str = "alter table t"
if part {
str = "alter table t_part"
}
str += " add index " + idxName + " ("
str += strings.Join(columnNames[a:b], ",")
str += ")"
return str
}
for i := 0; i < len(columnTypes); i++ {
for j := i + 1; j <= len(columnTypes); j++ {
// Create table and prepare some data.
tk2.MustExec("drop table if exists t")
tk2.MustExec("drop table if exists t_part")
tk2.MustExec(createTable(false, columnNames, columnTypes))
tk2.MustExec(createTable(true, columnNames, columnTypes))
tk2.MustExec(`insert into t values(1, "1", "2000-01-01", "2020-01-01", "1.1", "123.321", 1.1)`)
tk2.MustExec(`insert into t values(2, "2", "2000-01-02", "2020-01-02", "2.2", "223.322", 2.2)`)
tk2.MustExec(`insert into t_part values(1, "1", "2000-01-01", "2020-01-01", "1.1", "123.321", 1.1)`)
tk2.MustExec(`insert into t_part values(2, "2", "2000-01-02", "2020-01-02", "2.2", "223.322", 2.2)`)
// Start a pessimistic transaction, the amend should succeed for common table.
tk.MustExec("begin pessimistic")
tk.MustExec(`insert into t values(5, "555", "2000-01-05", "2020-01-05", "5.5", "555.555", 5.5)`)
idxName := fmt.Sprintf("index%d%d", i, j)
tk2.MustExec(addIndexFunc(idxName, false, i, j))
tk.MustExec("commit")
tk2.MustExec("admin check table t")
tk.MustExec("begin pessimistic")
tk.MustExec(`insert into t values(6, "666", "2000-01-06", "2020-01-06", "6.6", "666.666", 6.6)`)
tk2.MustExec(fmt.Sprintf(`alter table t drop index %s`, idxName))
tk.MustExec("commit")
tk2.MustExec("admin check table t")
tk2.MustQuery("select count(*) from t").Check(testkit.Rows("4"))
// Start a pessimistic transaction for partition table, the amend should fail.
tk.MustExec("begin pessimistic")
tk.MustExec(`insert into t_part values(5, "555", "2000-01-05", "2020-01-05", "5.5", "555.555", 5.5)`)
tk2.MustExec(addIndexFunc(idxName, true, i, j))
require.Error(t, tk.ExecToErr("commit"))
tk2.MustExec("admin check table t_part")
tk.MustExec("begin pessimistic")
tk.MustExec(`insert into t_part values(6, "666", "2000-01-06", "2020-01-06", "6.6", "666.666", 6.6)`)
tk2.MustExec(fmt.Sprintf(`alter table t_part drop index %s`, idxName))
require.Error(t, tk.ExecToErr("commit"))
tk2.MustExec("admin check table t_part")
tk2.MustQuery("select count(*) from t_part").Check(testkit.Rows("2"))
}
}
} | explode_data.jsonl/12506 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1383
} | [
2830,
3393,
6091,
408,
2461,
1552,
4072,
1155,
353,
8840,
836,
8,
341,
16867,
2193,
31129,
460,
9626,
368,
741,
25873,
16689,
11646,
18552,
29879,
353,
1676,
10753,
8,
341,
197,
67850,
836,
72,
82707,
2959,
44119,
33441,
89828,
4267,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCommandUseSelf(t *testing.T) {
c := &Command{Usage: "foo"}
args := NewArgs([]string{"foo"})
run, err := c.lookupSubCommand(args)
assert.Equal(t, nil, err)
assert.Equal(t, c, run)
} | explode_data.jsonl/60580 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 81
} | [
2830,
3393,
4062,
10253,
12092,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
4062,
90,
14783,
25,
330,
7975,
63159,
31215,
1669,
1532,
4117,
10556,
917,
4913,
7975,
1,
8824,
56742,
11,
1848,
1669,
272,
39937,
3136,
4062,
7356,
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 |
func Test_fmix64(t *testing.T) {
type args struct {
x uint64
}
tests := []struct {
name string
args args
want uint64
}{
{
name: "10",
args: args{
x: 10,
},
want: 7233188113542599437,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := fmix64(tt.args.x); got != tt.want {
t.Errorf("fmix64() = %v, want %v", got, tt.want)
}
})
}
} | explode_data.jsonl/55818 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 210
} | [
2830,
3393,
761,
35071,
21,
19,
1155,
353,
8840,
836,
8,
341,
13158,
2827,
2036,
341,
197,
10225,
2622,
21,
19,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
914,
198,
197,
31215,
2827,
198,
197,
50780,
2622,
21,
19,
198,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestServerQuery(t *testing.T) {
t.Parallel()
o := onpar.New()
defer o.Run(t)
o.BeforeEach(func(t *testing.T) TS {
mockCalc := newMockCalculator()
return TS{
T: t,
mockCalc: mockCalc,
s: server.New(mockCalc),
}
})
o.Group("when the calculator does not return an error", func() {
o.BeforeEach(func(t TS) TS {
close(t.mockCalc.CalculateOutput.Err)
t.mockCalc.CalculateOutput.FinalResult <- map[string][]byte{
"a": marshalEnvelope("a"),
"b": marshalEnvelope("b"),
"invalid": []byte("invalid"),
}
return t
})
o.Spec("it uses the calculator and returns the results", func(t TS) {
resp, err := t.s.Query(context.Background(), &v1.QueryInfo{
Filter: &v1.AnalystFilter{
SourceId: "id",
},
})
Expect(t, err == nil).To(BeTrue())
Expect(t, resp.Envelopes).To(HaveLen(2))
Expect(t, resp.Envelopes[0].SourceId).To(Or(
Equal("a"),
Equal("b"),
))
Expect(t, resp.Envelopes[1].SourceId).To(Or(
Equal("a"),
Equal("b"),
))
Expect(t, resp.Envelopes[0].SourceId).To(Not(Equal(resp.Envelopes[1].SourceId)))
})
o.Spec("it returns an error if an ID is not given", func(t TS) {
_, err := t.s.Query(context.Background(), &v1.QueryInfo{})
Expect(t, err == nil).To(BeFalse())
})
o.Spec("it uses the expected info for the calculator", func(t TS) {
t.s.Query(context.Background(), &v1.QueryInfo{
Filter: &v1.AnalystFilter{
SourceId: "id", TimeRange: &v1.TimeRange{
Start: 99,
End: 101,
},
}})
Expect(t, t.mockCalc.CalculateInput.Route).To(
Chain(Receive(), Equal("id")),
)
Expect(t, t.mockCalc.CalculateInput.AlgName).To(
Chain(Receive(), Equal("timerange")),
)
})
o.Spec("it includes the request in the meta", func(t TS) {
info := &v1.QueryInfo{
Filter: &v1.AnalystFilter{
SourceId: "id", TimeRange: &v1.TimeRange{
Start: 99,
End: 101,
},
}}
t.s.Query(context.Background(), info)
marshelled, err := proto.Marshal(&v1.AggregateInfo{Query: info})
Expect(t, err == nil).To(BeTrue())
Expect(t, t.mockCalc.CalculateInput.Meta).To(
Chain(Receive(), Equal(marshelled)),
)
})
})
o.Group("when the calculator returns an error", func() {
o.BeforeEach(func(t TS) TS {
t.mockCalc.CalculateOutput.Err <- fmt.Errorf("some-error")
close(t.mockCalc.CalculateOutput.FinalResult)
return t
})
o.Spec("it returns an error", func(t TS) {
_, err := t.s.Query(context.Background(), &v1.QueryInfo{
Filter: &v1.AnalystFilter{
SourceId: "id",
},
})
Expect(t, err == nil).To(BeFalse())
})
})
} | explode_data.jsonl/71879 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1260
} | [
2830,
3393,
5475,
2859,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
22229,
1669,
389,
1732,
7121,
741,
16867,
297,
16708,
1155,
692,
22229,
31153,
4854,
18552,
1155,
353,
8840,
836,
8,
22965,
341,
197,
77333,
47168,
1669,
501,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStateToViewRelativeEditPaths(t *testing.T) {
f := tempdir.NewTempDirFixture(t)
m := model.Manifest{
Name: "foo",
}.WithDeployTarget(model.K8sTarget{}).WithImageTarget(model.ImageTarget{}.
WithDockerImage(v1alpha1.DockerImageSpec{Context: f.JoinPath("a", "b", "c")}))
state := newState([]model.Manifest{m})
ms := state.ManifestTargets[m.Name].State
ms.CurrentBuilds["buildcontrol"] = model.BuildRecord{
Edits: []string{
f.JoinPath("a", "b", "c", "foo"),
f.JoinPath("a", "b", "c", "d", "e"),
},
}
ms.BuildHistory = []model.BuildRecord{
{
Edits: []string{
f.JoinPath("a", "b", "c", "foo"),
f.JoinPath("a", "b", "c", "d", "e"),
},
},
}
ms.MutableBuildStatus(m.ImageTargets[0].ID()).PendingFileChanges =
map[string]time.Time{
f.JoinPath("a", "b", "c", "foo"): time.Now(),
f.JoinPath("a", "b", "c", "d", "e"): time.Now(),
}
v := StateToTerminalView(*state, &sync.RWMutex{})
require.Len(t, v.Resources, 2)
r, _ := v.Resource(m.Name)
assert.Equal(t, []string{"foo", filepath.Join("d", "e")}, r.LastBuild().Edits)
assert.Equal(t, []string{"foo", filepath.Join("d", "e")}, r.CurrentBuild.Edits)
assert.Equal(t, []string{filepath.Join("d", "e"), "foo"}, r.PendingBuildEdits) // these are sorted for deterministic ordering
} | explode_data.jsonl/54850 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 558
} | [
2830,
3393,
1397,
1249,
851,
28442,
4036,
26901,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
2730,
3741,
7121,
12151,
6184,
18930,
1155,
340,
2109,
1669,
1614,
72272,
515,
197,
21297,
25,
330,
7975,
756,
197,
7810,
2354,
69464,
6397,
7635... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReadJobConfigProwIgnore(t *testing.T) {
expectExactly := func(expected ...string) func(c *JobConfig) error {
return func(c *JobConfig) error {
expected := sets.NewString(expected...)
actual := sets.NewString()
for _, pres := range c.PresubmitsStatic {
for _, pre := range pres {
actual.Insert(pre.Name)
}
}
if diff := expected.Difference(actual); diff.Len() > 0 {
return fmt.Errorf("missing expected job(s): %q", diff.List())
}
if diff := actual.Difference(expected); diff.Len() > 0 {
return fmt.Errorf("found unexpected job(s): %q", diff.List())
}
return nil
}
}
commonFiles := map[string]string{
"foo_jobs.yaml": `presubmits:
org/foo:
- name: foo_1
spec:
containers:
- image: my-image:latest
command: ["do-the-thing"]`,
"bar_jobs.yaml": `presubmits:
org/bar:
- name: bar_1
spec:
containers:
- image: my-image:latest
command: ["do-the-thing"]`,
"subdir/baz_jobs.yaml": `presubmits:
org/baz:
- name: baz_1
spec:
containers:
- image: my-image:latest
command: ["do-the-thing"]`,
"extraneous.md": `I am unrelated.`,
}
var testCases = []struct {
name string
files map[string]string
verify func(*JobConfig) error
}{
{
name: "no ignore files",
verify: expectExactly("foo_1", "bar_1", "baz_1"),
},
{
name: "ignore file present, all ignored",
files: map[string]string{
ProwIgnoreFileName: `*.yaml`,
},
verify: expectExactly(),
},
{
name: "ignore file present, no match",
files: map[string]string{
ProwIgnoreFileName: `*_ignored.yaml`,
},
verify: expectExactly("foo_1", "bar_1", "baz_1"),
},
{
name: "ignore file present, matches bar file",
files: map[string]string{
ProwIgnoreFileName: `bar_*.yaml`,
},
verify: expectExactly("foo_1", "baz_1"),
},
{
name: "ignore file present, matches subdir",
files: map[string]string{
ProwIgnoreFileName: `subdir/`,
},
verify: expectExactly("foo_1", "bar_1"),
},
{
name: "ignore file present, matches bar and subdir",
files: map[string]string{
ProwIgnoreFileName: `subdir/
bar_jobs.yaml`,
},
verify: expectExactly("foo_1"),
},
{
name: "ignore file in subdir, matches only subdir files",
files: map[string]string{
"subdir/" + ProwIgnoreFileName: `*.yaml`,
},
verify: expectExactly("foo_1", "bar_1"),
},
{
name: "ignore file in root and subdir, matches bar and subdir",
files: map[string]string{
"subdir/" + ProwIgnoreFileName: `*.yaml`,
ProwIgnoreFileName: `bar_jobs.yaml`,
},
verify: expectExactly("foo_1"),
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
jobConfigDir, err := ioutil.TempDir("", "jobConfig")
if err != nil {
t.Fatalf("fail to make tempdir: %v", err)
}
defer os.RemoveAll(jobConfigDir)
err = os.Mkdir(filepath.Join(jobConfigDir, "subdir"), 0777)
if err != nil {
t.Fatalf("fail to make subdir: %v", err)
}
for _, fileMap := range []map[string]string{commonFiles, tc.files} {
for name, content := range fileMap {
fullName := filepath.Join(jobConfigDir, name)
if err := ioutil.WriteFile(fullName, []byte(content), 0666); err != nil {
t.Fatalf("fail to write file %s: %v", fullName, err)
}
}
}
cfg, err := ReadJobConfig(jobConfigDir)
if err != nil {
t.Fatalf("Unexpected error reading job config: %v.", err)
}
if tc.verify != nil {
if err := tc.verify(&cfg); err != nil {
t.Errorf("Verify failed: %v", err)
}
}
})
}
} | explode_data.jsonl/41022 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1615
} | [
2830,
3393,
4418,
12245,
2648,
47,
651,
12497,
1155,
353,
8840,
836,
8,
341,
24952,
65357,
1669,
2915,
15253,
2503,
917,
8,
2915,
1337,
353,
12245,
2648,
8,
1465,
341,
197,
853,
2915,
1337,
353,
12245,
2648,
8,
1465,
341,
298,
42400,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBodySectionName_String(t *testing.T) {
for i, test := range bodySectionNameTests {
s := string(test.parsed.FetchItem())
expected := test.formatted
if expected == "" {
expected = test.raw
}
if expected != s {
t.Errorf("Invalid body section name for #%v: got %v but expected %v", i, s, expected)
}
}
} | explode_data.jsonl/43044 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
5444,
9620,
675,
31777,
1155,
353,
8840,
836,
8,
341,
2023,
600,
11,
1273,
1669,
2088,
2487,
9620,
675,
18200,
341,
197,
1903,
1669,
914,
8623,
556,
18112,
78506,
1234,
12367,
197,
42400,
1669,
1273,
8558,
12127,
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... | 4 |
func TestEC2KeyPair_Diff(t *testing.T) {
tests := []struct {
test string
firstRes resourceaws.AwsKeyPair
secondRes resourceaws.AwsKeyPair
wantErr bool
}{
{
test: "no diff - identical resource",
firstRes: resourceaws.AwsKeyPair{
Id: "foo",
},
secondRes: resourceaws.AwsKeyPair{
Id: "foo",
},
wantErr: false,
},
{
test: "no diff - with PublicKey and KeyNamePrefix",
firstRes: resourceaws.AwsKeyPair{
Id: "bar",
PublicKey: aws.String("ssh-rsa BBBBB3NzaC1yc2E"),
KeyNamePrefix: aws.String("test"),
},
secondRes: resourceaws.AwsKeyPair{
Id: "bar",
PublicKey: nil,
KeyNamePrefix: nil,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.test, func(t *testing.T) {
changelog, err := diff.Diff(tt.firstRes, tt.secondRes)
if err != nil {
panic(err)
}
if len(changelog) > 0 {
for _, change := range changelog {
t.Errorf("got = %v, want %v", awsutil.Prettify(change.From), awsutil.Prettify(change.To))
}
}
})
}
} | explode_data.jsonl/47663 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 539
} | [
2830,
3393,
7498,
17,
1592,
12443,
1557,
3092,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
18185,
414,
914,
198,
197,
42190,
1061,
220,
5101,
8635,
875,
8915,
1592,
12443,
198,
197,
197,
5569,
1061,
5101,
8635,
87... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func Test_runAddCmdBasic(t *testing.T) {
cmd := AddKeyCommand()
cmd.Flags().AddFlagSet(Commands("home").PersistentFlags())
mockIn := testutil.ApplyMockIODiscardOutErr(cmd)
kbHome := t.TempDir()
kb, err := keyring.New(sdk.KeyringServiceName(), keyring.BackendTest, kbHome, mockIn)
require.NoError(t, err)
clientCtx := client.Context{}.WithKeyringDir(kbHome)
ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx)
t.Cleanup(func() {
_ = kb.Delete("keyname1")
_ = kb.Delete("keyname2")
})
cmd.SetArgs([]string{
"keyname1",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=%s", cli.OutputFlag, OutputFormatText),
fmt.Sprintf("--%s=%s", flags.FlagKeyAlgorithm, string(hd.Secp256k1Type)),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
})
mockIn.Reset("y\n")
require.NoError(t, cmd.ExecuteContext(ctx))
mockIn.Reset("N\n")
require.Error(t, cmd.ExecuteContext(ctx))
cmd.SetArgs([]string{
"keyname2",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=%s", cli.OutputFlag, OutputFormatText),
fmt.Sprintf("--%s=%s", flags.FlagKeyAlgorithm, string(hd.Secp256k1Type)),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
})
require.NoError(t, cmd.ExecuteContext(ctx))
require.Error(t, cmd.ExecuteContext(ctx))
mockIn.Reset("y\n")
require.NoError(t, cmd.ExecuteContext(ctx))
cmd.SetArgs([]string{
"keyname4",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=%s", cli.OutputFlag, OutputFormatText),
fmt.Sprintf("--%s=%s", flags.FlagKeyAlgorithm, string(hd.Secp256k1Type)),
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
})
require.NoError(t, cmd.ExecuteContext(ctx))
require.Error(t, cmd.ExecuteContext(ctx))
cmd.SetArgs([]string{
"keyname5",
fmt.Sprintf("--%s=%s", flags.FlagHome, kbHome),
fmt.Sprintf("--%s=true", flags.FlagDryRun),
fmt.Sprintf("--%s=%s", cli.OutputFlag, OutputFormatText),
fmt.Sprintf("--%s=%s", flags.FlagKeyAlgorithm, string(hd.Secp256k1Type)),
})
require.NoError(t, cmd.ExecuteContext(ctx))
// In recovery mode
cmd.SetArgs([]string{
"keyname6",
fmt.Sprintf("--%s=true", flagRecover),
})
// use valid mnemonic and complete recovery key generation successfully
mockIn.Reset("decide praise business actor peasant farm drastic weather extend front hurt later song give verb rhythm worry fun pond reform school tumble august one\n")
require.NoError(t, cmd.ExecuteContext(ctx))
// use invalid mnemonic and fail recovery key generation
mockIn.Reset("invalid mnemonic\n")
require.Error(t, cmd.ExecuteContext(ctx))
// In interactive mode
cmd.SetArgs([]string{
"keyname7",
"-i",
fmt.Sprintf("--%s=false", flagRecover),
})
const password = "password1!"
// set password and complete interactive key generation successfully
mockIn.Reset("\n" + password + "\n" + password + "\n")
require.NoError(t, cmd.ExecuteContext(ctx))
// passwords don't match and fail interactive key generation
mockIn.Reset("\n" + password + "\n" + "fail" + "\n")
require.Error(t, cmd.ExecuteContext(ctx))
} | explode_data.jsonl/77404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1244
} | [
2830,
3393,
14007,
2212,
15613,
15944,
1155,
353,
8840,
836,
8,
341,
25920,
1669,
2691,
1592,
4062,
741,
25920,
51887,
1005,
2212,
12135,
1649,
7,
30479,
445,
5117,
1827,
53194,
9195,
12367,
77333,
641,
1669,
1273,
1314,
36051,
11571,
332... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetDeploymentStatSeries(t *testing.T) {
testCases := []*deployStatsTestData{
defaultDeployStatsTestData,
{
testName: "Bad Environment",
spaceName: "mySpace",
appName: "myApp",
envName: "doesNotExist",
metricsInput: defaultMetricsInput,
cassetteName: "getdeployment",
shouldFail: true,
},
}
for _, testCase := range testCases {
t.Run(testCase.testName, func(t *testing.T) {
r, err := recorder.New(pathToTestJSON + testCase.cassetteName)
require.NoError(t, err, "Failed to open cassette")
defer r.Stop()
fixture := &testFixture{}
fixture.metricsInput = testCase.metricsInput
kc := getDefaultKubeClient(fixture, r.Transport, t)
stats, err := kc.GetDeploymentStatSeries(testCase.spaceName, testCase.appName, testCase.envName,
testCase.startTime, testCase.endTime, testCase.limit)
if testCase.shouldFail {
require.Error(t, err, "Expected an error")
} else {
require.NoError(t, err, "Unexpected error occurred")
require.NotNil(t, stats, "GetDeploymentStats returned nil")
result := fixture.metrics
require.NotNil(t, result, "Metrics API not called")
// Check each metric type
verifyNumberTuples(testCase.metricsInput.cpu, stats.Cores, t, "CPU")
verifyMetricsParams(testCase, result.cpuParams, t, "CPU metrics")
verifyNumberTuples(testCase.metricsInput.memory, stats.Memory, t, "memory")
verifyMetricsParams(testCase, result.memParams, t, "Memory metrics")
verifyNumberTuples(testCase.metricsInput.netTx, stats.NetTx, t, "network sent")
verifyMetricsParams(testCase, result.netTxParams, t, "Network sent metrics")
verifyNumberTuples(testCase.metricsInput.netRx, stats.NetRx, t, "network received")
verifyMetricRangeParams(testCase, result.netRxParams, t, "Network received metrics")
// Check time range
require.Equal(t, testCase.expectStart, int64(*stats.Start), "Incorrect start time")
require.Equal(t, testCase.expectEnd, int64(*stats.End), "Incorrect end time")
}
})
}
} | explode_data.jsonl/41276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 800
} | [
2830,
3393,
1949,
75286,
15878,
25544,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
29838,
35794,
16635,
83920,
515,
197,
11940,
69464,
16635,
83920,
345,
197,
197,
515,
298,
18185,
675,
25,
257,
330,
17082,
11586,
756,
298,
1903,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilter_NoMatchingProcess(t *testing.T) {
r := []types.OpenInstallationRecipe{
{
ID: "1",
Name: "java-agent",
ProcessMatch: []string{"java"},
},
{
ID: "2",
Name: "cassandra-open-source-integration",
ProcessMatch: []string{"cassandra", "cassandradaemon", "cqlsh"},
},
{
ID: "3",
Name: "jmx-open-source-integration",
ProcessMatch: []string{"java.*jboss", "java.*tomcat", "java.*jetty"},
},
}
processes := []types.GenericProcess{
mockProcess{
name: "nonMatchingProcess",
cmdline: "nonMatchingProcess",
},
}
mockRecipeFetcher := recipes.NewMockRecipeFetcher()
mockRecipeFetcher.FetchRecipesVal = r
f := NewRegexProcessFilterer(mockRecipeFetcher)
filtered, err := f.filter(context.Background(), processes, types.DiscoveryManifest{})
require.NoError(t, err)
require.NotNil(t, filtered)
require.Equal(t, 0, len(filtered))
} | explode_data.jsonl/15736 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 419
} | [
2830,
3393,
5632,
36989,
64430,
7423,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
3056,
9242,
12953,
55453,
28780,
515,
197,
197,
515,
298,
29580,
25,
1843,
330,
16,
756,
298,
21297,
25,
260,
330,
10042,
41935,
756,
298,
197,
7423,
8331... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportHandlesDuplicateKVs(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
batchSize := 13
defer row.TestingSetDatumRowConverterBatchSize(batchSize)()
evalCtx := tree.MakeTestingEvalContext(nil)
flowCtx := &execinfra.FlowCtx{
EvalCtx: &evalCtx,
Cfg: &execinfra.ServerConfig{
Settings: &cluster.Settings{},
ExternalStorage: externalStorageFactory,
BulkAdder: func(
_ context.Context, _ *kv.DB, _ hlc.Timestamp,
opts kvserverbase.BulkAdderOptions) (kvserverbase.BulkAdder, error) {
return &duplicateKeyErrorAdder{}, nil
},
TestingKnobs: execinfra.TestingKnobs{
BulkAdderFlushesEveryBatch: true,
},
},
}
// In this test, we'll attempt to import different input formats.
// All imports produce a DuplicateKeyError, which we expect to be propagated.
testSpecs := []testSpec{
newTestSpec(t, csvFormat(), "testdata/csv/data-0"),
newTestSpec(t, mysqlDumpFormat(), "testdata/mysqldump/simple.sql"),
newTestSpec(t, mysqlOutFormat(), "testdata/mysqlout/csv-ish/simple.txt"),
newTestSpec(t, pgCopyFormat(), "testdata/pgcopy/default/test.txt"),
newTestSpec(t, pgDumpFormat(), "testdata/pgdump/simple.sql"),
newTestSpec(t, avroFormat(t, roachpb.AvroOptions_JSON_RECORDS), "testdata/avro/simple-sorted.json"),
}
for _, testCase := range testSpecs {
spec := testCase.getConverterSpec()
t.Run(fmt.Sprintf("duplicate-key-%v", spec.Format.Format), func(t *testing.T) {
progCh := make(chan execinfrapb.RemoteProducerMetadata_BulkProcessorProgress)
defer close(progCh)
go func() {
for range progCh {
}
}()
_, err := runImport(context.Background(), flowCtx, spec, progCh)
require.True(t, errors.HasType(err, &kvserverbase.DuplicateKeyError{}))
})
}
} | explode_data.jsonl/23769 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 716
} | [
2830,
3393,
11511,
65928,
53979,
42,
51737,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
2233,
754,
1695,
1669,
220,
16,
18,
198,
16867,
2802,
8787,
287,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPGWireAuth(t *testing.T) {
defer leaktest.AfterTest(t)()
s, _, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop()
{
unicodeUser := "♫"
t.Run("RootUserAuth", func(t *testing.T) {
// Authenticate as root with certificate and expect success.
rootPgURL, cleanupFn := sqlutils.PGUrl(
t, s.ServingAddr(), "TestPGWireAuth", url.User(security.RootUser))
defer cleanupFn()
if err := trivialQuery(rootPgURL); err != nil {
t.Fatal(err)
}
// Create server.TestUser with a unicode password and a user with a
// unicode username for later tests.
// Only root is allowed to create users.
db, err := gosql.Open("postgres", rootPgURL.String())
if err != nil {
t.Fatal(err)
}
defer db.Close()
if _, err := db.Exec(fmt.Sprintf("CREATE USER %s;", server.TestUser)); err != nil {
t.Fatal(err)
}
if _, err := db.Exec(fmt.Sprintf("CREATE USER %s WITH PASSWORD '蟑♫螂';", unicodeUser)); err != nil {
t.Fatal(err)
}
})
t.Run("UnicodeUserAuth", func(t *testing.T) {
// Try to perform authentication with unicodeUser and no password.
// This case is equivalent to supplying a wrong password.
host, port, err := net.SplitHostPort(s.ServingAddr())
if err != nil {
t.Fatal(err)
}
unicodeUserPgURL := url.URL{
Scheme: "postgres",
User: url.User(unicodeUser),
Host: net.JoinHostPort(host, port),
RawQuery: "sslmode=require",
}
if err := trivialQuery(unicodeUserPgURL); !testutils.IsError(err, "pq: invalid password") {
t.Fatalf("unexpected error: %v", err)
}
// Supply correct password.
unicodeUserPgURL.User = url.UserPassword(unicodeUser, "蟑♫螂")
if err := trivialQuery(unicodeUserPgURL); err != nil {
t.Fatal(err)
}
})
}
t.Run("TestUserAuth", func(t *testing.T) {
testUserPgURL, cleanupFn := sqlutils.PGUrl(
t, s.ServingAddr(), "TestPGWireAuth", url.User(server.TestUser))
defer cleanupFn()
// No password supplied but valid certificate should result in
// successful authentication.
if err := trivialQuery(testUserPgURL); err != nil {
t.Fatal(err)
}
// Test case insensitivity for certificate and password authentication.
testUserPgURL.User = url.User("TesTUser")
if err := trivialQuery(testUserPgURL); err != nil {
t.Fatal(err)
}
// Remove certificates to default to password authentication.
testUserPgURL.RawQuery = "sslmode=require"
// Even though the correct password is supplied (empty string), this
// should fail because we do not support password authentication for
// users with empty passwords.
if err := trivialQuery(testUserPgURL); !testutils.IsError(err, "pq: invalid password") {
t.Fatalf("unexpected error: %v", err)
}
})
} | explode_data.jsonl/15534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1077
} | [
2830,
3393,
11383,
37845,
5087,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
2822,
1903,
11,
8358,
716,
1669,
3538,
6031,
12101,
5475,
1155,
11,
2331,
8787,
5475,
4117,
37790,
16867,
274,
7758,
18487,
1005,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.