text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
func Test_HistoryDBLedgerSourceNextLedger(t *testing.T) {
state := &State{
RWMutex: sync.RWMutex{},
current: Status{
HorizonStatus: HorizonStatus{
ExpHistoryLatest: 3,
},
},
}
ledgerSource := HistoryDBSource{
updateFrequency: 0,
state: state,
}
ledgerChan := ledgerSource.NextLedger(0)
nextLedger := <-ledgerChan
if nextLedger != 3 {
t.Errorf("NextLedger = %d, want 3", nextLedger)
}
} | explode_data.jsonl/34564 | {
"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,
2039,
2579,
3506,
60850,
1389,
3608,
5847,
60850,
1389,
1155,
353,
8840,
836,
8,
341,
24291,
1669,
609,
1397,
515,
197,
11143,
15210,
9371,
25,
12811,
2013,
15210,
9371,
38837,
197,
20121,
25,
8104,
515,
298,
13292,
269,
169... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCustomDefs(t *testing.T) {
callErr, funcErr, assert, callBuffer, funcBuffer := testOpenAPITypeWriter(t, `
package foo
// Blah is a custom type
type Blah struct {
}
func (_ Blah) OpenAPISchemaType() []string { return []string{"string"} }
func (_ Blah) OpenAPISchemaFormat() string { return "date-time" }
`)
if callErr != nil {
t.Fatal(callErr)
}
if funcErr != nil {
t.Fatal(funcErr)
}
assert.Equal(`"base/foo.Blah": schema_base_foo_Blah(ref),
`, callBuffer.String())
assert.Equal(`func schema_base_foo_Blah(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "Blah is a custom type",
Type:foo.Blah{}.OpenAPISchemaType(),
Format:foo.Blah{}.OpenAPISchemaFormat(),
},
},
}
}
`, funcBuffer.String())
} | explode_data.jsonl/3357 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 317
} | [
2830,
3393,
10268,
56031,
1155,
353,
8840,
836,
8,
341,
67288,
7747,
11,
2915,
7747,
11,
2060,
11,
1618,
4095,
11,
2915,
4095,
1669,
1273,
5002,
7082,
929,
6492,
1155,
11,
22074,
1722,
15229,
271,
322,
2502,
1466,
374,
264,
2526,
943,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStream_CanRead(t *testing.T) {
t.Run("test can not read", func(t *testing.T) {
assert := base.NewAssert(t)
for i := streamPosBody; i < 2*streamBlockSize; i++ {
stream := NewStream()
stream.SetWritePos(i)
assert(stream.SetReadPos(i)).IsTrue()
assert(stream.CanRead()).IsFalse()
if (i+1)%streamBlockSize != 0 {
stream.readIndex = (i + 1) % streamBlockSize
assert(stream.CanRead()).IsFalse()
}
stream.Release()
}
})
t.Run("test can read", func(t *testing.T) {
assert := base.NewAssert(t)
for i := streamPosBody; i < 2*streamBlockSize; i++ {
stream := NewStream()
stream.SetWritePos(i + 1)
stream.SetReadPos(i)
assert(stream.CanRead()).IsTrue()
stream.Release()
}
})
} | explode_data.jsonl/21188 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 313
} | [
2830,
3393,
3027,
920,
276,
4418,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
1944,
646,
537,
1349,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
6948,
1669,
2331,
7121,
8534,
1155,
692,
197,
2023,
600,
1669,
4269,
4859,
5444,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestAlphaVolumeSnapshotDataSource(t *testing.T) {
successTestCases := []core.PersistentVolumeClaimSpec{
*testVolumeSnapshotDataSourceInSpec("test_snapshot", "VolumeSnapshot", "snapshot.storage.k8s.io"),
}
failedTestCases := []core.PersistentVolumeClaimSpec{
*testVolumeSnapshotDataSourceInSpec("", "VolumeSnapshot", "snapshot.storage.k8s.io"),
*testVolumeSnapshotDataSourceInSpec("test_snapshot", "PersistentVolumeClaim", "snapshot.storage.k8s.io"),
*testVolumeSnapshotDataSourceInSpec("test_snapshot", "VolumeSnapshot", "storage.k8s.io"),
}
for _, tc := range successTestCases {
if errs := ValidatePersistentVolumeClaimSpec(&tc, field.NewPath("spec")); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
for _, tc := range failedTestCases {
if errs := ValidatePersistentVolumeClaimSpec(&tc, field.NewPath("spec")); len(errs) == 0 {
t.Errorf("expected failure: %v", errs)
}
}
} | explode_data.jsonl/25622 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 332
} | [
2830,
3393,
19384,
18902,
15009,
17173,
1155,
353,
8840,
836,
8,
341,
30553,
2271,
37302,
1669,
3056,
2153,
61655,
18902,
45544,
8327,
515,
197,
197,
9,
1944,
18902,
15009,
17173,
641,
8327,
445,
1944,
53265,
497,
330,
18902,
15009,
497,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestPacketDot11MgmtBeacon(t *testing.T) {
p := gopacket.NewPacket(testPacketDot11MgmtBeacon, LinkTypeIEEE80211Radio, gopacket.Default)
if p.ErrorLayer() != nil {
t.Error("Failed to decode packet:", p.ErrorLayer().Error())
}
expectedLayers := []gopacket.LayerType{LayerTypeRadioTap, LayerTypeDot11, LayerTypeDot11MgmtBeacon}
for i := 0; i < 12; i++ {
expectedLayers = append(expectedLayers, LayerTypeDot11InformationElement)
}
checkLayers(p, expectedLayers, t)
if p.Layer(LayerTypeDot11).(*Dot11).SequenceNumber != 2431 {
t.Error("dot11 invalid sequence number")
}
if p.Layer(LayerTypeDot11).(*Dot11).FragmentNumber != 0 {
t.Error("dot11 invalid fragment number")
}
if _, ok := p.Layer(LayerTypeDot11MgmtBeacon).(*Dot11MgmtBeacon); !ok {
t.Errorf("dot11 management beacon frame was expected")
}
} | explode_data.jsonl/7561 | {
"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,
16679,
34207,
16,
16,
44,
46063,
3430,
22379,
1155,
353,
8840,
836,
8,
341,
3223,
1669,
342,
453,
5709,
7121,
16679,
8623,
16679,
34207,
16,
16,
44,
46063,
3430,
22379,
11,
5948,
929,
76705,
23,
15,
17,
16,
16,
28203,
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... | 6 |
func TestCastOperator(t *testing.T) {
testStr := `<?
$var = (double) 1.0; ?>`
p := NewParser()
p.disableScoping = true
a, _ := p.Parse("test.php", testStr)
tree := []ast.Node{
ast.ExprStmt{Expr: ast.AssignmentExpr{
Assignee: ast.NewVariable("var"),
Value: ast.UnaryCallExpr{
Operand: &ast.Literal{Type: ast.Float, Value: "1.0"},
Operator: "(double)",
Preceding: false,
},
Operator: "=",
}},
}
if !assertEquals(a.Nodes[0], tree[0]) {
t.Fatalf("Cast operator parsing failed")
}
} | explode_data.jsonl/28451 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 241
} | [
2830,
3393,
18714,
18461,
1155,
353,
8840,
836,
8,
341,
18185,
2580,
1669,
1565,
53075,
220,
400,
947,
284,
320,
4331,
8,
220,
16,
13,
15,
26,
3370,
3989,
3223,
1669,
1532,
6570,
741,
3223,
42628,
3326,
33707,
284,
830,
198,
11323,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFavoritesAddAsync(t *testing.T) {
mockCtrl, config, ctx := favTestInit(t, false)
// Only one task at a time
f := newFavoritesWithChan(config, make(chan *favReq, 1))
f.InitForTest()
defer favTestShutdown(t, mockCtrl, config, f)
// Call Add twice in a row, but only get one Add KBPKI call
fav1 := favorites.ToAdd{
Folder: favorites.Folder{
Name: "test",
Type: tlf.Public,
},
Data: favorites.Data{},
Created: false,
}
config.mockKbpki.EXPECT().FavoriteList(gomock.Any()).Return(keybase1.FavoritesResult{}, nil)
config.mockClock.EXPECT().Now().Return(time.Unix(0, 0))
c := make(chan struct{})
// Block until there are multiple outstanding calls
config.mockKbpki.EXPECT().FavoriteAdd(gomock.Any(), fav1.ToKBFolder()).
Do(func(_ context.Context, _ keybase1.Folder) {
<-c
}).Return(nil)
// There should only be one FavoriteAdd call for all of these, and
// none of them should block.
f.AddAsync(ctx, fav1)
f.AddAsync(ctx, fav1)
f.AddAsync(ctx, fav1)
f.AddAsync(ctx, fav1)
f.AddAsync(ctx, fav1)
c <- struct{}{}
} | explode_data.jsonl/14683 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 418
} | [
2830,
3393,
85221,
2212,
6525,
1155,
353,
8840,
836,
8,
341,
77333,
15001,
11,
2193,
11,
5635,
1669,
9244,
2271,
3803,
1155,
11,
895,
340,
197,
322,
8278,
825,
3383,
518,
264,
882,
198,
1166,
1669,
501,
85221,
2354,
46019,
8754,
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 TestGetUserIdFromJwt(t *testing.T) {
// Invalid token layout without two dots
_, err := readAuthToken("abc")
util.AssertError(t, err)
// Invalid base64 data in signature part
_, err = readAuthToken("0.a.a")
util.AssertError(t, err)
// Invalid signature
_, err = readAuthToken("0.a.eyJmb28iOiAiYmFyIn0=")
util.AssertError(t, err)
} | explode_data.jsonl/30509 | {
"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,
1949,
13504,
3830,
72756,
1155,
353,
8840,
836,
8,
341,
197,
322,
13882,
3950,
6789,
2041,
1378,
30994,
198,
197,
6878,
1848,
1669,
1349,
84708,
445,
13683,
1138,
79138,
11711,
1454,
1155,
11,
1848,
692,
197,
322,
13882,
233... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestControllerBuilder_OnLeadingFunc_ControllerError(t *testing.T) {
startedCh := make(chan struct{})
stoppedCh := make(chan struct{})
ctx := context.Background()
fatals := []string{}
b := &ControllerBuilder{
nonZeroExitFn: func(args ...interface{}) {
fatals = append(fatals, fmt.Sprintf("%v", args[0]))
t.Logf("non-zero exit detected: %+v", args)
},
startFunc: func(ctx context.Context, controllerContext *ControllerContext) error {
defer close(startedCh)
return fmt.Errorf("controller failed")
},
}
go func() {
defer close(stoppedCh)
b.getOnStartedLeadingFunc(&ControllerContext{}, 10*time.Second)(ctx)
}()
<-startedCh
select {
case <-stoppedCh:
if len(fatals) == 0 {
t.Fatal("expected non-zero exit, got none")
}
found := false
// this is weird, but normally klog.Fatal() just terminate process.
// however, since we mock the klog.Fatal() we will see both controller failure
// and "controllers terminated prematurely"...
for _, msg := range fatals {
if msg == `graceful termination failed, controllers failed with error: controller failed` {
found = true
}
}
if !found {
t.Fatalf("controller failed message not found in fatals: %#v", fatals)
}
case <-time.After(5 * time.Second):
t.Fatal("unexpected timeout while terminating")
}
} | explode_data.jsonl/67865 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 468
} | [
2830,
3393,
2051,
3297,
35482,
69750,
9626,
30674,
1454,
1155,
353,
8840,
836,
8,
341,
21375,
291,
1143,
1669,
1281,
35190,
2036,
37790,
18388,
17573,
1143,
1669,
1281,
35190,
2036,
37790,
20985,
1669,
2266,
19047,
2822,
1166,
266,
1127,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCallLessArgs(t *testing.T) {
const SCRIPT = `
function A(a, b, c) {
return String(a) + " " + String(b) + " " + String(c);
}
var rv = A(1, 2);
`
testScript(SCRIPT, asciiString("1 2 undefined"), t)
} | explode_data.jsonl/75211 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
7220,
27451,
4117,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
1688,
362,
2877,
11,
293,
11,
272,
8,
341,
853,
923,
2877,
8,
488,
330,
330,
488,
923,
1883,
8,
488,
330,
330,
488,
923,
1337,
317,
630,
947,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImportSymlinks(t *testing.T) {
switch runtime.GOOS {
case "windows", "plan9":
t.Skipf("skipping test on %q as there are no symlinks", runtime.GOOS)
}
newGoPath, err := ioutil.TempDir("", "symlinktest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(newGoPath)
targetPath := newGoPath + "/target"
if err := os.MkdirAll(targetPath, 0755); err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(targetPath+"/f.go", []byte("package mypkg\nvar Foo = 123\n"), 0666); err != nil {
t.Fatal(err)
}
symlinkPath := newGoPath + "/src/x/mypkg"
if err := os.MkdirAll(filepath.Dir(symlinkPath), 0755); err != nil {
t.Fatal(err)
}
if err := os.Symlink(targetPath, symlinkPath); err != nil {
t.Fatal(err)
}
// Add a symlink loop.
if err := os.Symlink(newGoPath+"/src/x", newGoPath+"/src/x/apkg"); err != nil {
t.Fatal(err)
}
withEmptyGoPath(func() {
build.Default.GOPATH = newGoPath
input := `package p
var (
_ = fmt.Print
_ = mypkg.Foo
)
`
output := `package p
import (
"fmt"
"x/mypkg"
)
var (
_ = fmt.Print
_ = mypkg.Foo
)
`
buf, err := Process(newGoPath+"/src/myotherpkg/toformat.go", []byte(input), &Options{})
if err != nil {
t.Fatal(err)
}
if got := string(buf); got != output {
t.Fatalf("results differ\nGOT:\n%s\nWANT:\n%s\n", got, output)
}
})
} | explode_data.jsonl/12423 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 598
} | [
2830,
3393,
11511,
34667,
1014,
15504,
1155,
353,
8840,
836,
8,
341,
8961,
15592,
97574,
3126,
341,
2722,
330,
27077,
497,
330,
10393,
24,
4660,
197,
3244,
57776,
69,
445,
4886,
5654,
1273,
389,
1018,
80,
438,
1052,
525,
902,
6568,
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... | 3 |
func TestImageRef_SVG_1(t *testing.T) {
Startup(nil)
raw, err := ioutil.ReadFile(resources + "svg_1.svg")
require.NoError(t, err)
img, err := NewImageFromBuffer(raw)
require.NoError(t, err)
require.NotNil(t, img)
defer img.Close()
assert.Equal(t, ImageTypeSVG, img.Metadata().Format)
} | explode_data.jsonl/38814 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 126
} | [
2830,
3393,
1906,
3945,
1098,
46641,
62,
16,
1155,
353,
8840,
836,
8,
341,
197,
39076,
27907,
692,
76559,
11,
1848,
1669,
43144,
78976,
52607,
488,
330,
15196,
62,
16,
15228,
1138,
17957,
35699,
1155,
11,
1848,
692,
39162,
11,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestDialAccessDeniedWithRestrictedSD(t *testing.T) {
c := PipeConfig{
SecurityDescriptor: "D:P(A;;0x1200FF;;;WD)",
}
l, err := ListenPipe(testPipeName, &c)
if err != nil {
t.Fatal(err)
}
defer l.Close()
_, err = DialPipe(testPipeName, nil)
if err.(*os.PathError).Err != syscall.ERROR_ACCESS_DENIED {
t.Fatalf("expected ERROR_ACCESS_DENIED, got %v", err)
}
} | explode_data.jsonl/11422 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 168
} | [
2830,
3393,
35,
530,
6054,
54481,
2354,
86405,
5491,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
27805,
2648,
515,
197,
7568,
18429,
11709,
25,
330,
35,
92411,
4346,
6768,
15,
87,
16,
17,
15,
15,
1748,
36328,
17563,
15752,
197,
532,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestReshard(t *testing.T) {
size := 10 // Make bigger to find more races.
n := config.DefaultQueueConfig.Capacity * size
samples, series := createTimeseries(n)
c := NewTestStorageClient()
c.expectSamples(samples, series)
cfg := config.DefaultQueueConfig
cfg.MaxShards = 1
dir, err := ioutil.TempDir("", "TestReshard")
testutil.Ok(t, err)
defer os.RemoveAll(dir)
m := NewQueueManager(nil, dir, newEWMARate(ewmaWeight, shardUpdateDuration), cfg, nil, nil, c, defaultFlushDeadline)
m.StoreSeries(series, 0)
m.Start()
defer m.Stop()
go func() {
for i := 0; i < len(samples); i += config.DefaultQueueConfig.Capacity {
sent := m.Append(samples[i : i+config.DefaultQueueConfig.Capacity])
require.True(t, sent)
time.Sleep(100 * time.Millisecond)
}
}()
for i := 1; i < len(samples)/config.DefaultQueueConfig.Capacity; i++ {
m.shards.stop()
m.shards.start(i)
time.Sleep(100 * time.Millisecond)
}
c.waitForExpectedSamples(t)
} | explode_data.jsonl/1310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 376
} | [
2830,
3393,
1061,
18703,
1155,
353,
8840,
836,
8,
341,
13832,
1669,
220,
16,
15,
442,
7405,
11243,
311,
1477,
803,
20588,
624,
9038,
1669,
2193,
13275,
7554,
2648,
78963,
4018,
353,
1379,
198,
1903,
4023,
11,
4013,
1669,
1855,
18889,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewNodeRegistration(t *testing.T) {
testcases := []struct {
name string
expected kubeadmv1beta1.NodeRegistrationOptions
actual kubeadmv1beta1.NodeRegistrationOptions
}{
{
name: "simple test",
expected: kubeadmv1beta1.NodeRegistrationOptions{
Name: "test name",
CRISocket: "/test/path/to/socket.sock",
KubeletExtraArgs: map[string]string{
"test key": "test value",
},
Taints: []corev1.Taint{
{
Key: "test",
Value: "test value",
Effect: "test effect",
},
},
},
actual: kubeadm.SetNodeRegistrationOptions(
&kubeadmv1beta1.NodeRegistrationOptions{},
kubeadm.WithNodeRegistrationName("test name"),
kubeadm.WithCRISocket("/test/path/to/socket.sock"),
kubeadm.WithTaints([]corev1.Taint{
{
Key: "test",
Value: "test value",
Effect: "test effect",
},
}),
kubeadm.WithKubeletExtraArgs(map[string]string{"test key": "test value"}),
),
},
{
name: "test node-label appending",
expected: kubeadmv1beta1.NodeRegistrationOptions{
KubeletExtraArgs: map[string]string{
"node-labels": "test value one,test value two",
},
},
actual: kubeadm.SetNodeRegistrationOptions(
&kubeadmv1beta1.NodeRegistrationOptions{},
kubeadm.WithKubeletExtraArgs(map[string]string{"node-labels": "test value one"}),
kubeadm.WithKubeletExtraArgs(map[string]string{"node-labels": "test value two"}),
),
},
{
name: "test starting with non-empty base",
expected: kubeadmv1beta1.NodeRegistrationOptions{
CRISocket: "/test/path/to/socket.sock",
KubeletExtraArgs: map[string]string{
"cni-bin-dir": "/opt/cni/bin",
"cni-conf-dir": "/etc/cni/net.d",
},
},
actual: kubeadm.SetNodeRegistrationOptions(
&kubeadmv1beta1.NodeRegistrationOptions{
KubeletExtraArgs: map[string]string{
"cni-bin-dir": "/opt/cni/bin",
"cni-conf-dir": "/etc/cni/net.d",
},
},
kubeadm.WithCRISocket("/test/path/to/socket.sock"),
),
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
if !reflect.DeepEqual(tc.expected, tc.actual) {
t.Fatalf("Expected and actual: \n%v\n%v", tc.expected, tc.actual)
}
})
}
} | explode_data.jsonl/68723 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1048
} | [
2830,
3393,
3564,
1955,
23365,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
11609,
257,
914,
198,
197,
42400,
595,
392,
3149,
26002,
16,
19127,
16,
21714,
23365,
3798,
198,
197,
88814,
256,
595,
392,
3149,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestDependencyMockOutputMergeWithStateTrueNotAllowed(t *testing.T) {
t.Parallel()
cleanupTerraformFolder(t, TEST_FIXTURE_GET_OUTPUT)
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_GET_OUTPUT)
rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_GET_OUTPUT, "mock-outputs-merge-with-state", "merge-with-state-true-validate-only", "live")
parentPath := filepath.Join(rootPath, "parent")
childPath := filepath.Join(rootPath, "child")
stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
err := runTerragruntCommand(t, fmt.Sprintf("terragrunt plan --terragrunt-non-interactive --terragrunt-working-dir %s", parentPath), &stdout, &stderr)
assert.NoError(t, err)
logBufferContentsLineByLine(t, stdout, "plan stdout")
logBufferContentsLineByLine(t, stderr, "plan stderr")
// Verify mocked outputs are used if mock_outputs_merge_with_state is set to true with an allowed command and some
// output in the parent are not applied yet.
stdout.Reset()
stderr.Reset()
require.NoError(
t,
runTerragruntCommand(t, fmt.Sprintf("terragrunt validate --terragrunt-non-interactive --terragrunt-working-dir %s", childPath), &stdout, &stderr),
)
// ... but not when an unallowed command is used
require.Error(
t,
runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", childPath), &stdout, &stderr),
)
} | explode_data.jsonl/10137 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 522
} | [
2830,
3393,
36387,
11571,
5097,
52096,
2354,
1397,
2514,
97634,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
1444,
60639,
51,
13886,
627,
13682,
1155,
11,
13602,
42635,
41486,
12702,
23981,
340,
20082,
14359,
1820,
1669,
2975,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEncode(t *testing.T) {
tests := []struct {
src []byte
dst []byte
out []byte
sz uint32
sameAsDst bool
}{
{
dst: nil,
src: []byte("test"),
out: []byte("\x04\ftest"),
sz: 6,
},
{
src: nil,
out: []byte("\x00"),
sz: 1,
},
{
src: []byte("test"),
dst: []byte("something here already"),
out: []byte("something here already\x04\ftest"),
sz: 6,
},
{
src: []byte("test"),
dst: make([]byte, 4, 10),
out: []byte("\x00\x00\x00\x00\x04\ftest"),
sz: 6,
sameAsDst: true,
},
{
src: []byte("test"),
dst: make([]byte, 4, 11),
out: []byte("\x00\x00\x00\x00\x04\ftest"),
sz: 6,
sameAsDst: true,
},
{
src: []byte("test"),
dst: make([]byte, 4, 9),
out: []byte("\x00\x00\x00\x00\x04\ftest"),
sz: 6,
sameAsDst: false,
},
}
for i, tcase := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
var codec compression.Codec
codec = snappy.New()
dst := make([]byte, len(tcase.dst), cap(tcase.dst))
copy(dst, tcase.dst)
dstHeader := (*reflect.SliceHeader)(unsafe.Pointer(&dst))
out, sz := codec.Encode(tcase.src, dst)
if tcase.sz != sz {
t.Errorf("expected size %d, got %d", tcase.sz, sz)
}
if l := len(tcase.dst) + int(sz); l != len(out) {
t.Errorf("expected length %d, got %d", l, len(out))
}
if !bytes.Equal(tcase.out, out) {
t.Errorf("expected out %q, got %q", tcase.out, out)
}
outHeader := (*reflect.SliceHeader)(unsafe.Pointer(&out))
if tcase.sameAsDst && dstHeader.Data != outHeader.Data {
t.Errorf("expected dst %v to be reused, got %v", dstHeader, outHeader)
}
})
}
} | explode_data.jsonl/52600 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 950
} | [
2830,
3393,
32535,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
41144,
981,
3056,
3782,
198,
197,
52051,
981,
3056,
3782,
198,
197,
13967,
981,
3056,
3782,
198,
197,
1903,
89,
286,
2622,
18,
17,
198,
197,
1903,
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... | 6 |
func TestGetInstalledChaincodesErrorPaths(t *testing.T) {
//获取现有的chaincode安装路径值并设置它
//做完测试后再回来
cip := chaincodeInstallPath
defer SetChaincodesPath(cip)
//创建一个临时目录并在末尾将其删除
dir, err := ioutil.TempDir(os.TempDir(), "chaincodes")
assert.NoError(t, err)
defer os.RemoveAll(dir)
//将上面创建的目录设置为chaincode安装路径
SetChaincodesPath(dir)
err = ioutil.WriteFile(filepath.Join(dir, "idontexist.1.0"), []byte("test"), 0777)
assert.NoError(t, err)
resp, err := GetInstalledChaincodes()
assert.NoError(t, err)
assert.Equal(t, 0, len(resp.Chaincodes),
"Expected 0 chaincodes but GetInstalledChaincodes returned %s chaincodes", len(resp.Chaincodes))
} | explode_data.jsonl/10596 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 335
} | [
2830,
3393,
1949,
60800,
18837,
25814,
1454,
26901,
1155,
353,
8840,
836,
8,
341,
322,
45912,
110857,
8819,
1851,
103999,
76837,
25511,
62926,
43918,
99652,
198,
322,
112555,
81705,
107646,
104150,
198,
1444,
573,
1669,
8781,
1851,
24690,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCertificateDeleteNoID(t *testing.T) {
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
err := RunCertificateDelete(config)
assert.Error(t, err)
})
} | explode_data.jsonl/4822 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 66
} | [
2830,
3393,
33202,
6435,
2753,
915,
1155,
353,
8840,
836,
8,
341,
46948,
2271,
2959,
1155,
11,
2915,
8754,
353,
15613,
2648,
11,
17333,
353,
10413,
72577,
8,
341,
197,
9859,
1669,
6452,
33202,
6435,
8754,
340,
197,
6948,
6141,
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 |
func TestInsertPageNumbers(t *testing.T) {
localFilePath := commonTestFile
remoteFolder := path.Join(remoteBaseTestDataFolder, "DocumentElements", "Fields")
remoteName := "TestInsertPageNumbers.docx"
pageNumber := models.PageNumber{
Alignment: "center",
Format: "{PAGE} of {NUMPAGES}",
}
options := map[string]interface{}{
"folder": remoteFolder,
}
client, ctx := UploadFileToStorage(t, localFilePath, path.Join(remoteFolder, remoteName))
_, _, err := client.WordsApi.InsertPageNumbers(ctx, remoteName, pageNumber, options)
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/23192 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
13780,
2665,
27237,
1155,
353,
8840,
836,
8,
1476,
8854,
19090,
1669,
4185,
2271,
1703,
198,
197,
18147,
13682,
1669,
1815,
22363,
61381,
3978,
83920,
13682,
11,
330,
7524,
11868,
497,
330,
8941,
1138,
197,
18147,
675,
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 TestMultipleEntries(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(2)
cron := New()
cron.AddFunc("0 0 0 1 1 ?", func() {})
cron.AddFunc("* * * * * ?", func() { wg.Done() })
cron.AddFunc("0 0 0 31 12 ?", func() {})
cron.AddFunc("* * * * * ?", func() { wg.Done() })
cron.Start()
defer cron.Stop()
select {
case <-time.After(ONE_SECOND):
t.FailNow()
case <-wait(wg):
}
} | explode_data.jsonl/10558 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 186
} | [
2830,
3393,
32089,
24533,
1155,
353,
8840,
836,
8,
341,
72079,
1669,
609,
12996,
28384,
2808,
16094,
72079,
1904,
7,
17,
692,
1444,
2248,
1669,
1532,
741,
1444,
2248,
1904,
9626,
445,
15,
220,
15,
220,
15,
220,
16,
220,
16,
42313,
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 TestReportWorkflowResource_WorkflowCompleted(t *testing.T) {
store, manager, run := initWithOneTimeRun(t)
namespace := "kubeflow"
defer store.Close()
// report workflow
workflow := util.NewWorkflow(&v1alpha1.Workflow{
ObjectMeta: v1.ObjectMeta{
Name: run.Name,
Namespace: namespace,
UID: types.UID(run.UUID),
Labels: map[string]string{util.LabelKeyWorkflowRunId: run.UUID},
},
Status: v1alpha1.WorkflowStatus{Phase: v1alpha1.NodeFailed},
})
err := manager.ReportWorkflowResource(workflow)
assert.Nil(t, err)
wf, err := store.ArgoClientFake.Workflow(namespace).Get(run.Run.Name, v1.GetOptions{})
assert.Nil(t, err)
assert.Equal(t, wf.Labels[util.LabelKeyWorkflowPersistedFinalState], "true")
} | explode_data.jsonl/77058 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 298
} | [
2830,
3393,
10361,
62768,
4783,
87471,
4965,
22724,
1155,
353,
8840,
836,
8,
341,
57279,
11,
6645,
11,
1598,
1669,
13864,
3966,
1462,
6727,
1155,
340,
56623,
1669,
330,
74,
392,
823,
10303,
698,
16867,
3553,
10421,
741,
197,
322,
1895,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestInterpreterCollections(t *testing.T) {
s, err := parseFile("src/parse/asp/test_data/interpreter/collections.build")
require.NoError(t, err)
assert.EqualValues(t, True, s.Lookup("x"))
assert.EqualValues(t, True, s.Lookup("y"))
assert.EqualValues(t, False, s.Lookup("z"))
} | explode_data.jsonl/81058 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
58426,
52730,
1155,
353,
8840,
836,
8,
341,
1903,
11,
1848,
1669,
4715,
1703,
445,
3548,
14,
6400,
14,
13367,
12697,
1769,
14,
90554,
2899,
3107,
13239,
1138,
17957,
35699,
1155,
11,
1848,
340,
6948,
12808,
6227,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestTokenManager_GenerateToken(t *testing.T) {
const sub = "subject"
const tokenType = "apitoken"
const tokenText = "token"
generator := new(MockTokenGenerator)
generator.On("GenerateToken", sub, NoExpiration, tokenType, tokenText).Return("id", "token", nil)
generator.On("GenerateToken", sub, NoExpiration, tokenType, tokenText).Return("id2", "token2", nil)
store := auth.NewInMemoryTokenStore()
manager := NewTokenManager(generator, store)
tokenID, signedToken, err := manager.GenerateToken(sub, nil, tokenType, tokenText, "tokenName", true)
require.NoError(t, err)
assert.Equal(t, "id", tokenID)
assert.Equal(t, "token", signedToken)
generator.AssertExpectations(t)
tokens, err := store.List(sub)
require.NoError(t, err)
assert.Equal(t, tokens[0].ID, "id")
assert.Equal(t, tokens[0].Name, "tokenName")
assert.Equal(t, tokens[0].Value, "token")
} | explode_data.jsonl/43103 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 316
} | [
2830,
3393,
3323,
2043,
2646,
13220,
3323,
1155,
353,
8840,
836,
8,
341,
4777,
1186,
284,
330,
11501,
698,
4777,
3950,
929,
284,
330,
391,
275,
1679,
698,
4777,
3950,
1178,
284,
330,
5839,
1837,
3174,
15312,
1669,
501,
66436,
3323,
12... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIsCompressed(t *testing.T) {
for _, test := range pubKeyTests {
isCompressed := IsCompressedPubKey(test.key)
wantCompressed := (test.format == pubkeyCompressed)
if isCompressed != wantCompressed {
t.Fatalf("%s (%x) pubkey: unexpected compressed result, "+
"got %v, want %v", test.name, test.key,
isCompressed, wantCompressed)
}
}
} | explode_data.jsonl/71133 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 138
} | [
2830,
3393,
3872,
1092,
14318,
1155,
353,
8840,
836,
8,
341,
2023,
8358,
1273,
1669,
2088,
6675,
1592,
18200,
341,
197,
19907,
1092,
14318,
1669,
2160,
1092,
14318,
29162,
1592,
8623,
4735,
340,
197,
50780,
1092,
14318,
1669,
320,
1944,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestGetDaemonEndpointsFromString1(t *testing.T) {
udpAddr := "127.0.0.1:2000"
tcpAddr := "127.0.0.1:2000"
udpEndpt, _ := resolveUDPAddr(udpAddr)
tcpEndpt, _ := resolveTCPAddr(tcpAddr)
dAddr := udpAddr
dEndpt, err := GetDaemonEndpointsFromString(dAddr)
assert.Nil(t, err)
assert.Equal(t, dEndpt.UDPAddr, udpEndpt)
assert.Equal(t, dEndpt.TCPAddr, tcpEndpt)
} | explode_data.jsonl/49931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 182
} | [
2830,
3393,
1949,
89177,
80786,
44491,
16,
1155,
353,
8840,
836,
8,
341,
197,
31101,
13986,
1669,
330,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
17,
15,
15,
15,
698,
3244,
4672,
13986,
1669,
330,
16,
17,
22,
13,
15,
13,
15,
13,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestReconnectServerStats(t *testing.T) {
ts := RunServerOnPort(TEST_PORT)
opts := reconnectOpts
nc, _ := opts.Connect()
defer nc.Close()
nc.Flush()
ts.Shutdown()
// server is stopped here...
ts = RunServerOnPort(TEST_PORT)
defer ts.Shutdown()
if err := nc.FlushTimeout(5 * time.Second); err != nil {
t.Fatalf("Error on Flush: %v", err)
}
// Make sure the server who is reconnected has the reconnects stats reset.
nc.mu.Lock()
_, cur := nc.currentServer()
nc.mu.Unlock()
if cur.reconnects != 0 {
t.Fatalf("Current Server's reconnects should be 0 vs %d\n", cur.reconnects)
}
} | explode_data.jsonl/44906 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 236
} | [
2830,
3393,
693,
6459,
5475,
16635,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
6452,
5475,
1925,
7084,
50320,
12377,
692,
64734,
1669,
50036,
43451,
198,
197,
1016,
11,
716,
1669,
12185,
43851,
741,
16867,
25126,
10421,
741,
197,
1016,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGreaterEqualFloat32s(t *testing.T) {
t.Parallel()
match, err := path.GreaterEqual(&testType1{
Float32s: []float32{3.1415, 2.7182},
}, "float32s", "2.7181")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
Float32s: []float32{3.1415, 2.7182},
}, "float32s", "3.1415")
require.Nil(t, err)
require.True(t, match)
match, err = path.GreaterEqual(&testType1{
Float32s: []float32{3.1415, 2.7182},
}, "float32s", "3.1416")
require.Nil(t, err)
require.False(t, match)
} | explode_data.jsonl/78476 | {
"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,
41366,
2993,
5442,
18,
17,
82,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
47706,
11,
1848,
1669,
1815,
1224,
28362,
2993,
2099,
1944,
929,
16,
515,
197,
197,
5442,
18,
17,
82,
25,
3056,
3649,
18,
17,
90,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetOrderEvents(t *testing.T) {
t.Skip()
client := NewClient(&Config{
URL: "https://api-kylin.eosasia.one",
Debug: true,
})
events, err := client.GetOrderEvents("helloworld54")
if err != nil {
t.Error(err)
}
event := <-events
fmt.Println(event)
} | explode_data.jsonl/58354 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 113
} | [
2830,
3393,
1949,
4431,
7900,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
741,
25291,
1669,
1532,
2959,
2099,
2648,
515,
197,
79055,
25,
256,
330,
2428,
1110,
2068,
12,
7891,
3732,
1734,
436,
35159,
30973,
756,
197,
34424,
25,
830,
345... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewMqService(t *testing.T) {
seedBroker, leader := NewBrokersWith2Responses(t)
defer seedBroker.Close()
defer leader.Close()
testCases := []struct {
cfg Config
}{
{
cfg: Config{},
},
// todo wait cm chang rpc
{
cfg: Config{
MQ: MQConfig{
BlobDeleteTopic: "test1",
ShardRepairTopic: "test2",
ShardRepairPriorityTopic: "test3",
MsgSender: kafka.ProducerCfg{
BrokerList: []string{seedBroker.Addr()},
TimeoutMs: 1,
},
},
Clustermgr: clustermgr.Config{
LbConfig: rpc.LbConfig{Hosts: []string{"http://127.0.0.1:9321"}},
},
},
},
{
cfg: Config{
MQ: MQConfig{
BlobDeleteTopic: "test1",
ShardRepairTopic: "test2",
ShardRepairPriorityTopic: "test3",
},
Clustermgr: clustermgr.Config{
LbConfig: rpc.LbConfig{Hosts: []string{"http://127.0.0.1:9321"}},
},
},
},
}
for _, tc := range testCases {
_, err := NewService(tc.cfg)
require.Error(t, err)
}
} | explode_data.jsonl/7363 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 528
} | [
2830,
3393,
3564,
44,
80,
1860,
1155,
353,
8840,
836,
8,
341,
197,
22602,
65545,
11,
7653,
1669,
1532,
26272,
26177,
2354,
17,
70743,
1155,
340,
16867,
10320,
65545,
10421,
741,
16867,
7653,
10421,
2822,
18185,
37302,
1669,
3056,
1235,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func Test_decreaseWidth(t *testing.T) {
testcases := []struct {
colsWidth map[int]int
cols []string
want int
}{
{colsWidth: map[int]int{0: 18}, cols: []string{"datname"}, want: 14}, // current width 18 chars, want to be 14
{colsWidth: map[int]int{0: 8}, cols: []string{"datname"}, want: 7}, // current width 8 chars, want to be 7
}
wg := sync.WaitGroup{}
for i, tc := range testcases {
t.Run(fmt.Sprintln(i), func(t *testing.T) {
config := newConfig()
config.view = config.views["activity"]
config.view.OrderKey = 0
config.view.ColsWidth = tc.colsWidth
config.view.Cols = tc.cols
wg.Add(1)
go func() {
v := <-config.viewCh
assert.Equal(t, tc.want, v.ColsWidth[0])
close(config.viewCh)
wg.Done()
}()
fn := decreaseWidth(config)
assert.NoError(t, fn(nil, nil))
})
wg.Wait()
}
} | explode_data.jsonl/69225 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 388
} | [
2830,
3393,
2259,
19947,
3327,
1155,
353,
8840,
836,
8,
341,
18185,
23910,
1669,
3056,
1235,
341,
197,
1444,
3069,
3327,
2415,
18640,
63025,
198,
197,
1444,
3069,
414,
3056,
917,
198,
197,
50780,
414,
526,
198,
197,
59403,
197,
197,
9... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMineAtv(t *testing.T) {
assert := assert.New(t)
mockMiner := NewMockMiner()
var publicationData entities.PublicationData
publicationData.ContextInfo = []byte{1, 2, 3, 4}
publicationData.Header = []byte{1, 2, 3, 4, 5}
publicationData.Identifier = 10
publicationData.PayoutInfo = []byte{1, 2, 3, 4, 5, 6}
atv, err := mockMiner.MineAtv(&publicationData)
assert.NoError(err)
assert.True(bytes.Equal(atv.Transaction.PublicationData.ContextInfo, publicationData.ContextInfo))
assert.True(bytes.Equal(atv.Transaction.PublicationData.Header, publicationData.Header))
assert.True(bytes.Equal(atv.Transaction.PublicationData.PayoutInfo, publicationData.PayoutInfo))
assert.Equal(atv.Transaction.PublicationData.Identifier, publicationData.Identifier)
} | explode_data.jsonl/39849 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 264
} | [
2830,
3393,
63495,
1655,
85,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
77333,
6217,
261,
1669,
1532,
11571,
6217,
261,
2822,
2405,
16599,
1043,
14744,
49139,
367,
1043,
198,
1219,
367,
1043,
9328,
1731,
284,
3056,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestIssue1736(t *testing.T) {
withTestProcess("testvariables2", t, func(p *proc.Target, fixture protest.Fixture) {
assertNoError(p.Continue(), t, "Continue()")
ch1BufVar := evalVariable(p, t, "*(ch1.buf)")
q := fmt.Sprintf("*(*%q)(%d)", ch1BufVar.DwarfType.Common().Name, ch1BufVar.Addr)
t.Logf("%s", q)
ch1BufVar2 := evalVariable(p, t, q)
if ch1BufVar2.Unreadable != nil {
t.Fatal(ch1BufVar2.Unreadable)
}
})
} | explode_data.jsonl/56338 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 201
} | [
2830,
3393,
42006,
16,
22,
18,
21,
1155,
353,
8840,
836,
8,
341,
46948,
2271,
7423,
445,
1944,
18616,
17,
497,
259,
11,
2915,
1295,
353,
15782,
35016,
11,
12507,
8665,
991,
12735,
8,
341,
197,
6948,
2753,
1454,
1295,
2451,
6232,
150... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPullerPeerNotEligible(t *testing.T) {
// Scenario: p1 pulls from p2 or from p3
// but it's not eligible for pulling data from p2 or from p3
gn := &gossipNetwork{}
policyStore := newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p2", "p3")
factoryMock1 := &mocks.CollectionAccessFactory{}
accessPolicyMock1 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock1, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p2")) || bytes.Equal(data.Identity, []byte("p3"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock1.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock1, nil)
p1 := gn.newPuller("p1", policyStore, factoryMock1, membership(peerData{"p2", uint64(1)}, peerData{"p3", uint64(1)})...)
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p2")
factoryMock2 := &mocks.CollectionAccessFactory{}
accessPolicyMock2 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock2, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p2"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock2.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock2, nil)
p2 := gn.newPuller("p2", policyStore, factoryMock2)
dig := &proto.PvtDataDigest{
TxId: "txID1",
Collection: "col1",
Namespace: "ns1",
}
store := Dig2PvtRWSetWithConfig{
privdatacommon.DigKey{
TxId: "txID1",
Collection: "col1",
Namespace: "ns1",
}: &util.PrivateRWSetWithConfig{
RWSet: newPRWSet(),
CollectionConfig: &peer.CollectionConfig{
Payload: &peer.CollectionConfig_StaticCollectionConfig{
StaticCollectionConfig: &peer.StaticCollectionConfig{
Name: "col1",
},
},
},
},
}
p2.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), mock.Anything).Return(store, true, nil)
policyStore = newCollectionStore().withPolicy("col1", uint64(100)).thatMapsTo("p3")
factoryMock3 := &mocks.CollectionAccessFactory{}
accessPolicyMock3 := &mocks.CollectionAccessPolicy{}
Setup(accessPolicyMock3, 1, 2, func(data protoutil.SignedData) bool {
return bytes.Equal(data.Identity, []byte("p3"))
}, map[string]struct{}{"org1": {}, "org2": {}}, false)
factoryMock3.On("AccessPolicy", mock.Anything, mock.Anything).Return(accessPolicyMock1, nil)
p3 := gn.newPuller("p3", policyStore, factoryMock3)
p3.PrivateDataRetriever.(*dataRetrieverMock).On("CollectionRWSet", mock.MatchedBy(protoMatcher(dig)), mock.Anything).Return(store, true, nil)
dasf := &digestsAndSourceFactory{}
d2s := dasf.mapDigest(&privdatacommon.DigKey{Collection: "col1", TxId: "txID1", Namespace: "ns1"}).toSources().create()
fetchedMessages, err := p1.fetch(d2s)
assert.Empty(t, fetchedMessages.AvailableElements)
assert.NoError(t, err)
} | explode_data.jsonl/53264 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1108
} | [
2830,
3393,
36068,
261,
30888,
2623,
6582,
343,
1238,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
25,
281,
16,
33045,
504,
281,
17,
476,
504,
281,
18,
198,
197,
322,
714,
432,
594,
537,
17013,
369,
22266,
821,
504,
281,
17,
476... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMetadataPayloadAttrsMatchFields(t *testing.T) {
setup := metadataProcSetup()
eventFields := getMetadataEventAttrs(t, "")
var mappingFields = []tests.FieldTemplateMapping{
{Template: "system.container.", Mapping: "container."}, // move system.container.*
{Template: "system.container", Mapping: ""}, // delete system.container
{Template: "system.kubernetes.node.", Mapping: "kubernetes.node."}, // move system.kubernetes.node.*
{Template: "system.kubernetes.node", Mapping: ""}, // delete system.kubernetes.node
{Template: "system.kubernetes.pod.", Mapping: "kubernetes.pod."}, // move system.kubernetes.pod.*
{Template: "system.kubernetes.pod", Mapping: ""}, // delete system.kubernetes.pod
{Template: "system.kubernetes.", Mapping: "kubernetes."}, // move system.kubernetes.*
{Template: "system.kubernetes", Mapping: ""}, // delete system.kubernetes
{Template: "system.platform", Mapping: "host.os.platform"},
{Template: "system.configured_hostname", Mapping: "host.name"},
{Template: "system.detected_hostname", Mapping: "host.hostname"},
{Template: "system", Mapping: "host"},
{Template: "service.agent", Mapping: "agent"},
{Template: "user.username", Mapping: "user.name"},
{Template: "process.argv", Mapping: "process.args"},
{Template: "labels.*", Mapping: "labels"},
{Template: "service.node.configured_name", Mapping: "service.node.name"},
}
setup.EventFieldsMappedToTemplateFields(t, eventFields, mappingFields)
} | explode_data.jsonl/64805 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 621
} | [
2830,
3393,
14610,
29683,
53671,
8331,
8941,
1155,
353,
8840,
836,
8,
341,
84571,
1669,
11160,
24508,
21821,
741,
28302,
8941,
1669,
633,
14610,
1556,
53671,
1155,
11,
85617,
2405,
12731,
8941,
284,
3056,
23841,
17087,
7275,
6807,
515,
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 Test_ObjectTracker_No_Expectations(t *testing.T) {
g := gomega.NewWithT(t)
ot := newObjTracker(schema.GroupVersionKind{}, nil)
ot.ExpectationsDone()
g.Expect(ot.Satisfied()).To(gomega.BeTrue(), "populated tracker with no expectations should be satisfied")
} | explode_data.jsonl/52314 | {
"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,
27839,
31133,
36989,
62,
17536,
804,
1155,
353,
8840,
836,
8,
341,
3174,
1669,
342,
32696,
7121,
2354,
51,
1155,
340,
197,
354,
1669,
74259,
31133,
42735,
5407,
5637,
10629,
22655,
2092,
340,
197,
354,
81893,
804,
17453,
741... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestCloseIssue(t *testing.T) {
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPatch {
t.Errorf("Bad method: %s", r.Method)
}
if r.URL.Path != "/repos/k8s/kuber/issues/5" {
t.Errorf("Bad request path: %s", r.URL.Path)
}
b, err := ioutil.ReadAll(r.Body)
if err != nil {
t.Fatalf("Could not read request body: %v", err)
}
var ps map[string]string
if err := json.Unmarshal(b, &ps); err != nil {
t.Errorf("Could not unmarshal request: %v", err)
} else if len(ps) != 1 {
t.Errorf("Wrong length patch: %v", ps)
} else if ps["state"] != "closed" {
t.Errorf("Wrong state: %s", ps["state"])
}
}))
defer ts.Close()
c := getClient(ts.URL)
if err := c.CloseIssue("k8s", "kuber", 5); err != nil {
t.Errorf("Didn't expect error: %v", err)
}
} | explode_data.jsonl/6276 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 380
} | [
2830,
3393,
7925,
42006,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
1758,
20798,
43622,
341,
298... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestNewPRSignedBaseLayer(t *testing.T) {
testBLI := NewPRMMatchExact()
// Success
_pr, err := NewPRSignedBaseLayer(testBLI)
require.NoError(t, err)
pr, ok := _pr.(*prSignedBaseLayer)
require.True(t, ok)
assert.Equal(t, &prSignedBaseLayer{
prCommon: prCommon{prTypeSignedBaseLayer},
BaseLayerIdentity: testBLI,
}, pr)
// Invalid baseLayerIdentity
_, err = NewPRSignedBaseLayer(nil)
assert.Error(t, err)
} | explode_data.jsonl/36508 | {
"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,
3564,
6480,
49312,
3978,
9188,
1155,
353,
8840,
836,
8,
341,
18185,
9389,
40,
1669,
1532,
6480,
8035,
754,
57954,
2822,
197,
322,
13047,
198,
197,
5294,
11,
1848,
1669,
1532,
6480,
49312,
3978,
9188,
8623,
9389,
40,
340,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestUnregisterCluster_DBError(t *testing.T) {
manager := GetManagerInstance()
manager.SetDBConnection(&database.MockDBConnection{
DeleteClusterReturnErr: true,
})
clearManager()
name, color := "cluster", uint32(42)
cluster := CreateCluster(name, color)
manager.clusterCache[*cluster.Name] = cluster
_, err := manager.UnregisterCluster(name)
if err == nil {
t.Error("Expected err for missing Cluster in Cache")
}
} | explode_data.jsonl/24680 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 153
} | [
2830,
3393,
1806,
6343,
28678,
16310,
1454,
1155,
353,
8840,
836,
8,
341,
92272,
1669,
2126,
2043,
2523,
741,
92272,
4202,
3506,
4526,
2099,
12216,
24664,
3506,
4526,
515,
197,
96672,
28678,
5598,
7747,
25,
830,
345,
197,
3518,
40408,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestUnitScheduleCreateTransactionValidateWrong(t *testing.T) {
client := ClientForTestnet()
client.SetAutoValidateChecksums(true)
accountID, err := AccountIDFromString("0.0.123-rmkykd")
assert.NoError(t, err)
scheduleCreate := NewScheduleCreateTransaction().
SetPayerAccountID(accountID)
err = scheduleCreate._ValidateNetworkOnIDs(client)
assert.Error(t, err)
if err != nil {
assert.Equal(t, "network mismatch; some IDs have different networks set", err.Error())
}
} | explode_data.jsonl/19813 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 162
} | [
2830,
3393,
4562,
32210,
4021,
8070,
17926,
29185,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
8423,
2461,
2271,
4711,
741,
25291,
4202,
13253,
17926,
73190,
82,
3715,
340,
86866,
915,
11,
1848,
1669,
8615,
915,
44491,
445,
15,
13,
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... | 2 |
func TestGetExchangeInfo(t *testing.T) {
t.Parallel()
info, err := b.GetExchangeInfo(context.Background())
if err != nil {
t.Error(err)
}
if mockTests {
serverTime := time.Date(2022, 2, 25, 3, 50, 40, int(601*time.Millisecond), time.UTC)
if !info.Servertime.Equal(serverTime) {
t.Errorf("Expected %v, got %v", serverTime, info.Servertime)
}
}
} | explode_data.jsonl/76641 | {
"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,
1949,
31564,
1731,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
27043,
11,
1848,
1669,
293,
2234,
31564,
1731,
5378,
19047,
2398,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
743,
7860,
18200,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTick(t *testing.T) {
ht := StartHTTPTest(t, "base")
defer ht.Finish()
// Just sanity-check that we return the context error...
ctx, cancel := context.WithCancel(context.Background())
cancel()
err := ht.App.Tick(ctx)
ht.Assert.EqualError(err, context.Canceled.Error())
} | explode_data.jsonl/46410 | {
"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,
22213,
1155,
353,
8840,
836,
8,
341,
197,
426,
1669,
5145,
9230,
2271,
1155,
11,
330,
3152,
1138,
16867,
34323,
991,
18176,
2822,
197,
322,
4599,
46842,
15934,
429,
582,
470,
279,
2266,
1465,
9338,
20985,
11,
9121,
1669,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMosaicDefinitionTransactionSerialization(t *testing.T) {
nsId, err := NewNamespaceIdFromName("sname")
assert.Nilf(t, err, "NewNamespaceIdFromName returned error: %s", err)
tx, err := NewMosaicDefinitionTransaction(fakeDeadline, "mosaics", nsId, NewMosaicProperties(true, true, true, 4, big.NewInt(10000)), MijinTest)
assert.Nilf(t, err, "NewMosaicDefinitionTransaction returned error: %s", err)
b, err := tx.generateBytes()
assert.Nilf(t, err, "MosaicDefinitionTransaction.generateBytes returned error: %s", err)
assert.Equal(t, mosaicDefinitionTransactionSerializationCorr, b)
} | explode_data.jsonl/69190 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 203
} | [
2830,
3393,
44,
44783,
10398,
8070,
35865,
1155,
353,
8840,
836,
8,
341,
84041,
764,
11,
1848,
1669,
1532,
22699,
764,
3830,
675,
445,
82,
606,
5130,
6948,
59678,
69,
1155,
11,
1848,
11,
330,
3564,
22699,
764,
3830,
675,
5927,
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... | 1 |
func TestFiles_List(t *testing.T) {
setup()
defer teardown()
fixture := `
{
"files": [
{
"content_type": "text/plain",
"crc32": "66a1512f",
"created_at": "2013-09-07T21:32:03",
"first_accessed_at": null,
"icon": "https://put.io/images/file_types/text.png",
"id": 6546533,
"is_mp4_available": false,
"is_shared": false,
"name": "MyFile.txt",
"opensubtitles_hash": null,
"parent_id": 123,
"screenshot": null,
"size": 92
},
{
"content_type": "video/x-matroska",
"crc32": "cb97ba70",
"created_at": "2013-09-07T21:32:03",
"first_accessed_at": "2013-09-07T21:32:13",
"icon": "https://put.io/thumbnails/aF5rkZVtYV9pV1iWimSOZWJjWWFaXGZdaZBmY2OJY4uJlV5pj5FiXg%3D%3D.jpg",
"id": 7645645,
"is_mp4_available": false,
"is_shared": false,
"name": "MyVideo.mkv",
"opensubtitles_hash": "acc2785ffa573c69",
"parent_id": 123,
"screenshot": "https://put.io/screenshots/aF5rkZVtYV9pV1iWimSOZWJjWWFaXGZdaZBmY2OJY4uJlV5pj5FiXg%3D%3D.jpg",
"size": 1155197659
}
],
"parent": {
"content_type": "application/x-directory",
"crc32": null,
"created_at": "2013-09-07T21:32:03",
"first_accessed_at": null,
"icon": "https://put.io/images/file_types/folder.png",
"id": 123,
"is_mp4_available": false,
"is_shared": false,
"name": "MyFolder",
"opensubtitles_hash": null,
"parent_id": 0,
"screenshot": null,
"size": 1155197751
},
"status": "OK"
}
`
mux.HandleFunc("/v2/files/list", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
// not found handler
parentID := r.URL.Query().Get("parent_id")
if parentID == "2" {
http.NotFound(w, r)
return
}
fmt.Fprintln(w, fixture)
})
ctx := context.Background()
files, parent, err := client.Files.List(ctx, 0)
if err != nil {
t.Error(err)
}
if len(files) != 2 {
t.Errorf("got: %v, want: 2", len(files))
}
if parent.ID != 123 {
t.Errorf("got: %v, want: 123", parent.ID)
}
// negative id
_, _, err = client.Files.List(ctx, -1)
if err == nil {
t.Errorf("negative id accepted")
}
// non-existent parent folder
_, _, err = client.Files.List(ctx, 2)
if err != ErrResourceNotFound {
t.Errorf("got: %v, want: %v", err, ErrResourceNotFound)
}
} | explode_data.jsonl/48315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1044
} | [
2830,
3393,
10809,
27104,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
1166,
12735,
1669,
22074,
515,
1,
7198,
788,
2278,
197,
515,
197,
197,
1,
1796,
1819,
788,
330,
1318,
36971,
756,
197,
197,
1,
66083,
18,
17,
78... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRestartRepublish(t *testing.T) {
ctx := createSweeperTestContext(t)
_, err := ctx.sweeper.SweepInput(spendableInputs[0], defaultFeePref)
if err != nil {
t.Fatal(err)
}
ctx.tick()
sweepTx := ctx.receiveTx()
// Restart sweeper again. No action is expected.
ctx.restartSweeper()
republishedTx := ctx.receiveTx()
if sweepTx.TxHash() != republishedTx.TxHash() {
t.Fatalf("last tx not republished")
}
// Mine the tx to conclude the test properly.
ctx.backend.mine()
ctx.finish(1)
} | explode_data.jsonl/34230 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 198
} | [
2830,
3393,
59354,
18327,
2538,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
1855,
50,
896,
10436,
2271,
1972,
1155,
692,
197,
6878,
1848,
1669,
5635,
514,
896,
10436,
808,
48542,
2505,
1141,
3740,
480,
31946,
58,
15,
1125,
1638,
41941,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHostSimpleProxyNoHeaderForward(t *testing.T) {
var requestHost string
backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
requestHost = r.Host
w.Write([]byte("Hello, client"))
}))
defer backend.Close()
// set up proxy
p := &Proxy{
Next: httpserver.EmptyNext, // prevents panic in some cases when test fails
Upstreams: []Upstream{newFakeUpstream(backend.URL, false, 30*time.Second)},
}
r := httptest.NewRequest("GET", "/", nil)
r.Host = "test.com"
w := httptest.NewRecorder()
p.ServeHTTP(w, r)
if !strings.Contains(backend.URL, "//") {
t.Fatalf("The URL of the backend server doesn't contains //: %s", backend.URL)
}
expectedHost := strings.Split(backend.URL, "//")
if expectedHost[1] != requestHost {
t.Fatalf("Expected %s as a Host header got %s\n", expectedHost[1], requestHost)
}
} | explode_data.jsonl/64239 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 324
} | [
2830,
3393,
9296,
16374,
16219,
2753,
4047,
25925,
1155,
353,
8840,
836,
8,
341,
2405,
1681,
9296,
914,
198,
197,
20942,
1669,
54320,
70334,
7121,
5475,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
2355... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunnerWithOptionsFromEnv(t *testing.T) {
if err := os.Setenv(envScenarigoColor, "true"); err != nil {
t.Fatalf("%+v", err)
}
defer os.Unsetenv(envScenarigoColor)
runner, err := NewRunner(
WithOptionsFromEnv(true),
)
if err != nil {
t.Fatal(err)
}
if !runner.enabledColor {
t.Fatalf("failed to set enabledColor from env")
}
} | explode_data.jsonl/56027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
19486,
74238,
3830,
14359,
1155,
353,
8840,
836,
8,
341,
743,
1848,
1669,
2643,
4202,
3160,
16978,
3326,
268,
277,
7836,
1636,
11,
330,
1866,
5038,
1848,
961,
2092,
341,
197,
3244,
30762,
4430,
10,
85,
497,
1848,
340,
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 TestAwaitImportInsideTry(t *testing.T) {
default_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
async function main(name) {
try {
return await import(name)
} catch {
}
}
main('fs')
`,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
})
} | explode_data.jsonl/38486 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
37352,
11511,
24480,
21453,
1155,
353,
8840,
836,
8,
341,
11940,
57239,
25952,
33,
1241,
832,
1155,
11,
51450,
515,
197,
74075,
25,
2415,
14032,
30953,
515,
298,
197,
3115,
4085,
2857,
788,
22074,
571,
52384,
729,
1887,
3153... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRunCreateToken(t *testing.T) {
var buf bytes.Buffer
fakeClient := &fake.Clientset{}
fakeClient.AddReactor("get", "secrets", func(action core.Action) (handled bool, ret runtime.Object, err error) {
return true, nil, errors.NewNotFound(v1.Resource("secrets"), "foo")
})
testCases := []struct {
name string
token string
usages []string
extraGroups []string
printJoin bool
expectedError bool
}{
{
name: "valid: empty token",
token: "",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:foo"},
expectedError: false,
},
{
name: "valid: non-empty token",
token: "abcdef.1234567890123456",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:foo"},
expectedError: false,
},
{
name: "valid: no extraGroups",
token: "abcdef.1234567890123456",
usages: []string{"signing", "authentication"},
extraGroups: []string{},
expectedError: false,
},
{
name: "invalid: incorrect extraGroups",
token: "abcdef.1234567890123456",
usages: []string{"signing", "authentication"},
extraGroups: []string{"foo"},
expectedError: true,
},
{
name: "invalid: specifying --groups when --usages doesn't include authentication",
token: "abcdef.1234567890123456",
usages: []string{"signing"},
extraGroups: []string{"foo"},
expectedError: true,
},
{
name: "invalid: partially incorrect usages",
token: "abcdef.1234567890123456",
usages: []string{"foo", "authentication"},
extraGroups: []string{"system:bootstrappers:foo"},
expectedError: true,
},
{
name: "invalid: all incorrect usages",
token: "abcdef.1234567890123456",
usages: []string{"foo", "bar"},
extraGroups: []string{"system:bootstrappers:foo"},
expectedError: true,
},
{
name: "invalid: print join command",
token: "",
usages: []string{"signing", "authentication"},
extraGroups: []string{"system:bootstrappers:foo"},
printJoin: true,
expectedError: true,
},
}
for _, tc := range testCases {
bts, err := kubeadmapiv1beta1.NewBootstrapTokenString(tc.token)
if err != nil && len(tc.token) != 0 { // if tc.token is "" it's okay as it will be generated later at runtime
t.Fatalf("token couldn't be parsed for testing: %v", err)
}
cfg := &kubeadmapiv1beta1.InitConfiguration{
ClusterConfiguration: kubeadmapiv1beta1.ClusterConfiguration{
// KubernetesVersion is not used, but we set this explicitly to avoid
// the lookup of the version from the internet when executing ConfigFileAndDefaultsToInternalConfig
KubernetesVersion: "v1.11.0",
},
BootstrapTokens: []kubeadmapiv1beta1.BootstrapToken{
{
Token: bts,
TTL: &metav1.Duration{Duration: 0},
Usages: tc.usages,
Groups: tc.extraGroups,
},
},
}
err = RunCreateToken(&buf, fakeClient, "", cfg, tc.printJoin, "")
if (err != nil) != tc.expectedError {
t.Errorf("Test case %s: RunCreateToken expected error: %v, saw: %v", tc.name, tc.expectedError, (err != nil))
}
}
} | explode_data.jsonl/11811 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1450
} | [
2830,
3393,
6727,
4021,
3323,
1155,
353,
8840,
836,
8,
341,
2405,
6607,
5820,
22622,
198,
1166,
726,
2959,
1669,
609,
30570,
11716,
746,
16094,
1166,
726,
2959,
1904,
693,
5621,
445,
455,
497,
330,
325,
52710,
497,
2915,
15306,
6200,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDynamicDiscoverySimple(t *testing.T) {
dd := &DynamicDiscovery{
ps: mockProcess{
[]facts.Process{
{
PID: 1547,
PPID: 1,
CreateTime: time.Now(),
CmdLineList: []string{"/usr/bin/memcached", "-m", "64", "-p", "11211", "-u", "memcache", "-l", "127.0.0.1", "-P", "/var/run/memcached/memcached.pid"},
Name: "memcached",
MemoryRSS: 0xa88,
CPUPercent: 0.028360216236998047,
CPUTime: 98.55000000000001,
Status: "S",
Username: "memcache",
Executable: "",
ContainerID: "",
},
},
},
netstat: mockNetstat{result: map[int][]facts.ListenAddress{
1547: {
{NetworkFamily: "tcp", Address: "127.0.0.1", Port: 11211},
},
}},
}
ctx := context.Background()
srv, err := dd.Discovery(ctx, 0)
if err != nil {
t.Error(err)
}
if len(srv) != 1 {
t.Errorf("len(srv) == %v, want 1", len(srv))
}
if srv[0].Name != "memcached" {
t.Errorf("Name == %#v, want %#v", srv[0].Name, "memcached")
}
if srv[0].ServiceType != MemcachedService {
t.Errorf("Name == %#v, want %#v", srv[0].ServiceType, MemcachedService)
}
want := []facts.ListenAddress{{NetworkFamily: "tcp", Address: "127.0.0.1", Port: 11211}}
if !reflect.DeepEqual(srv[0].ListenAddresses, want) {
t.Errorf("ListenAddresses == %v, want %v", srv[0].ListenAddresses, want)
}
} | explode_data.jsonl/27781 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 661
} | [
2830,
3393,
21752,
67400,
16374,
1155,
353,
8840,
836,
8,
341,
92265,
1669,
609,
21752,
67400,
515,
197,
35009,
25,
7860,
7423,
515,
298,
197,
1294,
68053,
29012,
515,
571,
197,
515,
464,
10025,
915,
25,
260,
220,
16,
20,
19,
22,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestValidateParentAndDrain(t *testing.T) {
type ParentDrainTime struct {
Parent types.Duration
Drain types.Duration
Valid bool
}
combinations := []ParentDrainTime{
{
Parent: types.Duration{Seconds: 2},
Drain: types.Duration{Seconds: 1},
Valid: true,
},
{
Parent: types.Duration{Seconds: 1},
Drain: types.Duration{Seconds: 1},
Valid: false,
},
{
Parent: types.Duration{Seconds: 1},
Drain: types.Duration{Seconds: 2},
Valid: false,
},
{
Parent: types.Duration{Seconds: 2},
Drain: types.Duration{Seconds: 1, Nanos: 1000000},
Valid: false,
},
{
Parent: types.Duration{Seconds: 2, Nanos: 1000000},
Drain: types.Duration{Seconds: 1},
Valid: false,
},
{
Parent: types.Duration{Seconds: -2},
Drain: types.Duration{Seconds: 1},
Valid: false,
},
{
Parent: types.Duration{Seconds: 2},
Drain: types.Duration{Seconds: -1},
Valid: false,
},
{
Parent: types.Duration{Seconds: 1 + int64(time.Hour/time.Second)},
Drain: types.Duration{Seconds: 10},
Valid: false,
},
{
Parent: types.Duration{Seconds: 10},
Drain: types.Duration{Seconds: 1 + int64(time.Hour/time.Second)},
Valid: false,
},
}
for _, combo := range combinations {
if got := ValidateParentAndDrain(&combo.Drain, &combo.Parent); (got == nil) != combo.Valid {
t.Errorf("Failed: got valid=%t but wanted valid=%t: %v for Parent:%v Drain:%v",
got == nil, combo.Valid, got, combo.Parent, combo.Drain)
}
}
} | explode_data.jsonl/56896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 657
} | [
2830,
3393,
17926,
8387,
3036,
8847,
466,
1155,
353,
8840,
836,
8,
341,
13158,
17022,
8847,
466,
1462,
2036,
341,
197,
197,
8387,
4494,
33795,
198,
197,
197,
8847,
466,
220,
4494,
33795,
198,
197,
197,
4088,
220,
1807,
198,
197,
630,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFsnotifyFakeSymlink(t *testing.T) {
// Create an fsnotify watcher instance and initialize it
watcher, err := NewWatcher()
if err != nil {
t.Fatalf("NewWatcher() failed: %s", err)
}
const testDir string = "_test"
// Create directory to watch
if err := os.Mkdir(testDir, 0777); err != nil {
t.Fatalf("Failed to create test directory: %s", err)
}
defer os.RemoveAll(testDir)
var errorsReceived counter
// Receive errors on the error channel on a separate goroutine
go func() {
for errors := range watcher.Error {
t.Logf("Received error: %s", errors)
errorsReceived.increment()
}
}()
// Count the CREATE events received
var createEventsReceived counter
var otherEventsReceived counter
go func() {
for ev := range watcher.Event {
t.Logf("event received: %s", ev)
if ev.IsCreate() {
createEventsReceived.increment()
} else {
otherEventsReceived.increment()
}
}
}()
// Add a watch for testDir
err = watcher.Watch(testDir)
if err != nil {
t.Fatalf("Watcher.Watch() failed: %s", err)
}
if os.Symlink("_test/zzz", "_test/zzznew") != nil {
t.Fatalf("Failed to create bogus symlink: %s", err)
}
t.Logf("Created bogus symlink")
// We expect this event to be received almost immediately, but let's wait 500 ms to be sure
time.Sleep(500 * time.Millisecond)
// Should not be error, just no events for broken links (watching nothing)
if errorsReceived.value() > 0 {
t.Fatal("fsnotify errors have been received.")
}
if otherEventsReceived.value() > 0 {
t.Fatal("fsnotify other events received on the broken link")
}
// Except for 1 create event (for the link itself)
if createEventsReceived.value() == 0 {
t.Fatal("fsnotify create events were not received after 500 ms")
}
if createEventsReceived.value() > 1 {
t.Fatal("fsnotify more create events received than expected")
}
// Try closing the fsnotify instance
t.Log("calling Close()")
watcher.Close()
} | explode_data.jsonl/50088 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 685
} | [
2830,
3393,
48300,
21948,
52317,
34667,
44243,
1155,
353,
8840,
836,
8,
341,
197,
322,
4230,
458,
8619,
21948,
55727,
2867,
323,
9468,
432,
198,
6692,
28058,
11,
1848,
1669,
1532,
47248,
741,
743,
1848,
961,
2092,
341,
197,
3244,
30762,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestSafeAddClip(t *testing.T) {
assert.EqualValues(t, math.MaxInt64, safeAddClip(math.MaxInt64, 10))
assert.EqualValues(t, math.MaxInt64, safeAddClip(math.MaxInt64, math.MaxInt64))
assert.EqualValues(t, math.MinInt64, safeAddClip(math.MinInt64, -10))
} | explode_data.jsonl/28323 | {
"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,
25663,
2212,
20935,
1155,
353,
8840,
836,
8,
341,
6948,
12808,
6227,
1155,
11,
6888,
14535,
1072,
21,
19,
11,
6092,
2212,
20935,
37270,
14535,
1072,
21,
19,
11,
220,
16,
15,
1171,
6948,
12808,
6227,
1155,
11,
6888,
14535,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParseDuration(t *testing.T) {
_, err := parseDuration("12:34:56,1234", ",", 3)
assert.EqualError(t, err, "astisub: Invalid number of millisecond digits detected in 12:34:56,1234")
_, err = parseDuration("12,123", ",", 3)
assert.EqualError(t, err, "astisub: No hours, minutes or seconds detected in 12,123")
d, err := parseDuration("12:34,123", ",", 3)
assert.NoError(t, err)
assert.Equal(t, 12*time.Minute+34*time.Second+123*time.Millisecond, d)
d, err = parseDuration("12:34:56,123", ",", 3)
assert.NoError(t, err)
assert.Equal(t, 12*time.Hour+34*time.Minute+56*time.Second+123*time.Millisecond, d)
d, err = parseDuration("12:34:56,1", ",", 3)
assert.NoError(t, err)
assert.Equal(t, 12*time.Hour+34*time.Minute+56*time.Second+100*time.Millisecond, d)
d, err = parseDuration("12:34:56.123", ".", 3)
assert.NoError(t, err)
assert.Equal(t, 12*time.Hour+34*time.Minute+56*time.Second+123*time.Millisecond, d)
d, err = parseDuration("1:23:45.67", ".", 2)
assert.NoError(t, err)
assert.Equal(t, time.Hour+23*time.Minute+45*time.Second+67*time.Millisecond, d)
} | explode_data.jsonl/13621 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 462
} | [
2830,
3393,
14463,
12945,
1155,
353,
8840,
836,
8,
341,
197,
6878,
1848,
1669,
4715,
12945,
445,
16,
17,
25,
18,
19,
25,
20,
21,
11,
16,
17,
18,
19,
497,
82978,
220,
18,
340,
6948,
12808,
1454,
1155,
11,
1848,
11,
330,
559,
285,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestValidateExternalInitiator(t *testing.T) {
t.Parallel()
store, cleanup := cltest.NewStore(t)
defer cleanup()
url := cltest.WebURL(t, "https://a.web.url")
// Add duplicate
exi := models.ExternalInitiator{
Name: "duplicate",
URL: &url,
}
assert.NoError(t, store.CreateExternalInitiator(&exi))
tests := []struct {
name string
input string
wantError bool
}{
{"basic", `{"name":"bitcoin","url":"https://test.url"}`, false},
{"basic w/ underscore", `{"name":"bit_coin","url":"https://test.url"}`, false},
{"basic w/ underscore in url", `{"name":"bitcoin","url":"https://chainlink_bit-coin_1.url"}`, false},
{"missing url", `{"name":"missing_url"}`, false},
{"duplicate name", `{"name":"duplicate","url":"https://test.url"}`, true},
{"invalid name characters", `{"name":"<invalid>","url":"https://test.url"}`, true},
{"missing name", `{"url":"https://test.url"}`, true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
var exr models.ExternalInitiatorRequest
assert.NoError(t, json.Unmarshal([]byte(test.input), &exr))
result := services.ValidateExternalInitiator(&exr, store)
cltest.AssertError(t, test.wantError, result)
})
}
} | explode_data.jsonl/75331 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 465
} | [
2830,
3393,
17926,
25913,
3803,
36122,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
57279,
11,
21290,
1669,
1185,
1944,
7121,
6093,
1155,
340,
16867,
21290,
2822,
19320,
1669,
1185,
1944,
6473,
3144,
1155,
11,
330,
2428,
1110,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetVirtualProjectMatch(t *testing.T) {
fixture.EnsureCleanState(t)
err := createAndConfigGlobalProject()
assert.NoError(t, err)
//Create project which matches global project settings
projectName := "proj-" + fixture.Name()
_, err = fixture.RunCli("proj", "create", projectName,
"--description", "Test description",
"-d", fmt.Sprintf("%s,*", common.KubernetesInternalAPIServerAddr),
"-s", "*",
"--orphaned-resources")
assert.NoError(t, err)
proj, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Get(context.Background(), projectName, metav1.GetOptions{})
assert.NoError(t, err)
//Add a label to this project so that this project match global project selector
proj.Labels = map[string]string{"opt": "me"}
_, err = fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.ArgoCDNamespace).Update(context.Background(), proj, metav1.UpdateOptions{})
assert.NoError(t, err)
//Create an app belongs to proj project
_, err = fixture.RunCli("app", "create", fixture.Name(), "--repo", fixture.RepoURL(fixture.RepoURLTypeFile),
"--path", guestbookPath, "--project", proj.Name, "--dest-server", common.KubernetesInternalAPIServerAddr, "--dest-namespace", fixture.DeploymentNamespace())
assert.NoError(t, err)
//App trying to sync a resource which is not blacked listed anywhere
_, err = fixture.RunCli("app", "sync", fixture.Name(), "--resource", "apps:Deployment:guestbook-ui", "--timeout", fmt.Sprintf("%v", 10))
assert.Error(t, err)
assert.Contains(t, err.Error(), "Blocked by sync window")
//app trying to sync a resource which is black listed by global project
_, err = fixture.RunCli("app", "sync", fixture.Name(), "--resource", ":Service:guestbook-ui", "--timeout", fmt.Sprintf("%v", 10))
assert.Contains(t, err.Error(), "Blocked by sync window")
} | explode_data.jsonl/58449 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 626
} | [
2830,
3393,
1949,
33026,
7849,
8331,
1155,
353,
8840,
836,
8,
341,
1166,
12735,
22834,
19098,
27529,
1397,
1155,
340,
9859,
1669,
1855,
3036,
2648,
11646,
7849,
741,
6948,
35699,
1155,
11,
1848,
692,
197,
322,
4021,
2390,
892,
9071,
364... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHostPortPodConnectivity(t *testing.T) {
data, err := setupTest(t)
if err != nil {
t.Fatalf("Error when setting up test: %v", err)
}
defer teardownTest(t, data)
data.testHostPortPodConnectivity(t)
} | explode_data.jsonl/49176 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 83
} | [
2830,
3393,
9296,
7084,
23527,
14611,
1927,
1155,
353,
8840,
836,
8,
341,
8924,
11,
1848,
1669,
6505,
2271,
1155,
340,
743,
1848,
961,
2092,
341,
197,
3244,
30762,
445,
1454,
979,
6243,
705,
1273,
25,
1018,
85,
497,
1848,
340,
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
] | 2 |
func TestSeveralNFPMsWithTheSameID(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{
NFPMs: []config.NFPM{
{
ID: "a",
},
{
ID: "a",
},
},
},
}
require.EqualError(t, Pipe{}.Default(ctx), "found 2 nfpms with the ID 'a', please fix your config")
} | explode_data.jsonl/21989 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 147
} | [
2830,
3393,
34762,
38067,
8795,
16056,
785,
19198,
915,
1155,
353,
8840,
836,
8,
341,
2405,
5635,
284,
609,
2147,
9328,
515,
197,
66156,
25,
2193,
30944,
515,
298,
18317,
37,
8795,
82,
25,
3056,
1676,
2067,
37,
8795,
515,
571,
197,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAuthOnlyAllowedGroups(t *testing.T) {
testCases := []struct {
name string
allowedGroups []string
groups []string
querystring string
expectedStatusCode int
}{
{
name: "NoAllowedGroups",
allowedGroups: []string{},
groups: []string{},
querystring: "",
expectedStatusCode: http.StatusAccepted,
},
{
name: "NoAllowedGroupsUserHasGroups",
allowedGroups: []string{},
groups: []string{"a", "b"},
querystring: "",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserInAllowedGroup",
allowedGroups: []string{"a"},
groups: []string{"a", "b"},
querystring: "",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserNotInAllowedGroup",
allowedGroups: []string{"a"},
groups: []string{"c"},
querystring: "",
expectedStatusCode: http.StatusUnauthorized,
},
{
name: "UserInQuerystringGroup",
allowedGroups: []string{"a", "b"},
groups: []string{"a", "c"},
querystring: "?allowed_groups=a",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserInMultiParamQuerystringGroup",
allowedGroups: []string{"a", "b"},
groups: []string{"b"},
querystring: "?allowed_groups=a&allowed_groups=b,d",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserInOnlyQuerystringGroup",
allowedGroups: []string{},
groups: []string{"a", "c"},
querystring: "?allowed_groups=a,b",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserInDelimitedQuerystringGroup",
allowedGroups: []string{"a", "b", "c"},
groups: []string{"c"},
querystring: "?allowed_groups=a,c",
expectedStatusCode: http.StatusAccepted,
},
{
name: "UserNotInQuerystringGroup",
allowedGroups: []string{},
groups: []string{"c"},
querystring: "?allowed_groups=a,b",
expectedStatusCode: http.StatusForbidden,
},
{
name: "UserInConfigGroupNotInQuerystringGroup",
allowedGroups: []string{"a", "b", "c"},
groups: []string{"c"},
querystring: "?allowed_groups=a,b",
expectedStatusCode: http.StatusForbidden,
},
{
name: "UserInQuerystringGroupNotInConfigGroup",
allowedGroups: []string{"a", "b"},
groups: []string{"c"},
querystring: "?allowed_groups=b,c",
expectedStatusCode: http.StatusUnauthorized,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
emailAddress := "test"
created := time.Now()
session := &sessions.SessionState{
Groups: tc.groups,
Email: emailAddress,
AccessToken: "oauth_token",
CreatedAt: &created,
}
test, err := NewAuthOnlyEndpointTest(tc.querystring, func(opts *options.Options) {
opts.Providers[0].AllowedGroups = tc.allowedGroups
})
if err != nil {
t.Fatal(err)
}
err = test.SaveSession(session)
assert.NoError(t, err)
test.proxy.ServeHTTP(test.rw, test.req)
assert.Equal(t, tc.expectedStatusCode, test.rw.Code)
})
}
} | explode_data.jsonl/36427 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1671
} | [
2830,
3393,
5087,
7308,
35382,
22173,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
2290,
914,
198,
197,
197,
20967,
22173,
414,
3056,
917,
198,
197,
44260,
82,
1797,
3056,
917,
198,
197,
27274,
917,
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 TestClient_azure_special(t *testing.T) {
client, _ := New("https://dev.azure.com", "org", "")
if client != nil {
t.Errorf("Want nil client, got %v", client)
}
client2, _ := New("https://dev.azure.com", "", "proj")
if client2 != nil {
t.Errorf("Want nil client, got %v", client2)
}
} | explode_data.jsonl/82300 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 122
} | [
2830,
3393,
2959,
62,
39495,
41629,
1155,
353,
8840,
836,
8,
341,
25291,
11,
716,
1669,
1532,
445,
2428,
1110,
3583,
70240,
905,
497,
330,
1775,
497,
14676,
743,
2943,
961,
2092,
341,
197,
3244,
13080,
445,
28823,
2092,
2943,
11,
2684... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUnsupported(t *testing.T) {
b := []byte{0xc0}
{
var v, r uintptr
_, err := msgpack.Marshal(v)
if !strings.Contains(err.Error(), "type(uintptr) is unsupported") {
t.Error("test error", err)
}
err = msgpack.Unmarshal(b, &r)
if !strings.Contains(err.Error(), "type(uintptr) is unsupported") {
t.Error("test error", err)
}
}
{
var v, r chan string
_, err := msgpack.Marshal(v)
if !strings.Contains(err.Error(), "type(chan) is unsupported") {
t.Error("test error", err)
}
err = msgpack.Unmarshal(b, &r)
if !strings.Contains(err.Error(), "type(chan) is unsupported") {
t.Error("test error", err)
}
}
{
var v, r func()
_, err := msgpack.Marshal(v)
if !strings.Contains(err.Error(), "type(func) is unsupported") {
t.Error("test error", err)
}
err = msgpack.Unmarshal(b, &r)
if !strings.Contains(err.Error(), "type(func) is unsupported") {
t.Error("test error", err)
}
}
{
// error reflect kind is invalid. current version set nil (0xc0)
var v, r error
bb, err := msgpack.Marshal(v)
if err != nil {
t.Error(err)
}
if bb[0] != def.Nil {
t.Errorf("code is different %d, %d", bb[0], def.Nil)
}
err = msgpack.Unmarshal(b, &r)
if err != nil {
t.Error(err)
}
if r != nil {
t.Error("error should be nil")
}
}
} | explode_data.jsonl/64221 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 594
} | [
2830,
3393,
41884,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
3056,
3782,
90,
15,
8148,
15,
532,
197,
515,
197,
2405,
348,
11,
435,
38190,
198,
197,
197,
6878,
1848,
1669,
3750,
4748,
37271,
3747,
340,
197,
743,
753,
18594,
11545,
39... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestListReviews(t *testing.T) {
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
t.Errorf("Bad method: %s", r.Method)
}
if r.URL.Path == "/repos/k8s/kuber/pulls/15/reviews" {
reviews := []Review{{ID: 1}}
b, err := json.Marshal(reviews)
if err != nil {
t.Fatalf("Didn't expect error: %v", err)
}
w.Header().Set("Link", fmt.Sprintf(`<blorp>; rel="first", <https://%s/someotherpath>; rel="next"`, r.Host))
fmt.Fprint(w, string(b))
} else if r.URL.Path == "/someotherpath" {
reviews := []Review{{ID: 2}}
b, err := json.Marshal(reviews)
if err != nil {
t.Fatalf("Didn't expect error: %v", err)
}
fmt.Fprint(w, string(b))
} else {
t.Errorf("Bad request path: %s", r.URL.Path)
}
}))
defer ts.Close()
c := getClient(ts.URL)
reviews, err := c.ListReviews("k8s", "kuber", 15)
if err != nil {
t.Errorf("Didn't expect error: %v", err)
} else if len(reviews) != 2 {
t.Errorf("Expected two reviews, found %d: %v", len(reviews), reviews)
} else if reviews[0].ID != 1 || reviews[1].ID != 2 {
t.Errorf("Wrong review IDs: %v", reviews)
}
} | explode_data.jsonl/6272 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 528
} | [
2830,
3393,
852,
45206,
1155,
353,
8840,
836,
8,
341,
57441,
1669,
54320,
70334,
7121,
13470,
1220,
2836,
19886,
89164,
18552,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
743,
435,
20798,
961,
1758,
20798,
1949,
341,
298,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestRecordingDecissionSuccessOnHeaderAdd(t *testing.T) {
tCases := []struct {
contentTypes []string
shouldRecord bool
}{
{[]string{"text/plain"}, false},
{[]string{"application/json"}, true},
{[]string{"application/json", "charset=utf-8"}, true},
{[]string{"application/json; charset=utf-8"}, true},
{[]string{"application/x-www-form-urlencoded"}, true},
{[]string{"charset=utf-8", "application/json"}, true},
{[]string{"charset=utf-8", "application/vnd.api+json"}, true},
}
for _, tCase := range tCases {
h := http.Header{}
for _, header := range tCase.contentTypes {
h.Add("Content-Type", header)
}
assert.Equal(t, tCase.shouldRecord, ShouldRecordBodyOfContentType(headerMapAccessor{h}))
}
} | explode_data.jsonl/2386 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 276
} | [
2830,
3393,
52856,
4900,
7558,
7188,
1925,
4047,
2212,
1155,
353,
8840,
836,
8,
341,
3244,
37302,
1669,
3056,
1235,
341,
197,
27751,
4173,
3056,
917,
198,
197,
197,
5445,
6471,
1807,
198,
197,
59403,
197,
197,
90,
1294,
917,
4913,
131... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFutureEpoch(t *testing.T) {
tf.UnitTest(t)
blockTime := clock.DefaultEpochDuration
genTime := time.Unix(1234567890, 1234567890%int64(time.Second))
fc := clock.NewFake(genTime)
mclock := clock.NewChainClockFromClock(uint64(genTime.Unix()), blockTime, fc)
validator := consensus.NewDefaultBlockValidator(mclock)
// Fails in future epoch
c := &block.Block{Height: 1, Timestamp: uint64(genTime.Add(blockTime).Unix())}
err := validator.NotFutureBlock(c)
assert.Error(t, err)
assert.Contains(t, err.Error(), "future epoch")
} | explode_data.jsonl/31027 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 195
} | [
2830,
3393,
24206,
44338,
1155,
353,
8840,
836,
8,
341,
3244,
69,
25159,
2271,
1155,
692,
47996,
1462,
1669,
8866,
13275,
44338,
12945,
198,
82281,
1462,
1669,
882,
10616,
941,
7,
16,
17,
18,
19,
20,
21,
22,
23,
24,
15,
11,
220,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestParallelValid(t *testing.T) {
parallelism := 100
numIters := 1000
wg := sync.WaitGroup{}
wg.Add(parallelism)
for i := 0; i < parallelism; i++ {
go func() {
defer wg.Done()
for j := 0; j < numIters; j++ {
tcase := validSQL[rand.Intn(len(validSQL))]
if tcase.output == "" {
tcase.output = tcase.input
}
tree, err := Parse(tcase.input)
if err != nil {
t.Errorf("Parse(%q) err: %v, want nil", tcase.input, err)
continue
}
out := String(tree)
if out != tcase.output {
t.Errorf("Parse(%q) = %q, want: %q", tcase.input, out, tcase.output)
}
}
}()
}
wg.Wait()
} | explode_data.jsonl/27179 | {
"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,
16547,
4088,
1155,
353,
8840,
836,
8,
341,
197,
46103,
2142,
1669,
220,
16,
15,
15,
198,
22431,
2132,
388,
1669,
220,
16,
15,
15,
15,
271,
72079,
1669,
12811,
28384,
2808,
16094,
72079,
1904,
31975,
7957,
2142,
340,
2023,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMapProxy_AddIndex(t *testing.T) {
mp2, _ := client.GetMap("mp2")
err := mp2.AddIndex("age", true)
if err != nil {
t.Fatal("addIndex failed")
}
mp2.Clear()
} | explode_data.jsonl/57024 | {
"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,
2227,
16219,
21346,
1552,
1155,
353,
8840,
836,
8,
341,
53230,
17,
11,
716,
1669,
2943,
2234,
2227,
445,
1307,
17,
1138,
9859,
1669,
10490,
17,
1904,
1552,
445,
424,
497,
830,
340,
743,
1848,
961,
2092,
341,
197,
3244,
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
] | 2 |
func TestTimeoutMostImportant(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
ctrl, ctx := gomock.WithContext(ctx, t)
defer ctrl.Finish()
ms := mock_store.NewMockStore(ctrl)
var s store.Store = ms
pod := createPodWithLabel(podNamespace, podLabel)
// vars
podFlag := events.PodCreatePodResponse
// Expectations
ms.EXPECT().GetPodFlag(pod, podFlag).Return(scenario.ResponseError, nil)
ms.EXPECT().GetNodeFlag(events.NodeCreatePodResponse).Return(scenario.ResponseTimeout, nil)
assert.NoError(t, ctx.Err())
// Run code under test
out, err := podResponse(responseArgs{
ctx: ctx,
provider: &Provider{Store: &s},
action: func() (i interface{}, err error) {
return tStr, nil
},
},
pod,
podFlag,
)
assert.Error(t, ctx.Err())
// Assert
assert.Nil(t, err)
assert.Nil(t, out)
} | explode_data.jsonl/35145 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 339
} | [
2830,
3393,
7636,
13319,
52280,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
11,
9121,
1669,
2266,
26124,
7636,
5378,
19047,
1507,
220,
16,
77053,
32435,
340,
16867,
9121,
2822,
84381,
11,
5635,
1669,
342,
316,
1176,
26... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetLoadBalancerSourceRanges(t *testing.T) {
checkError := func(v string) {
annotations := make(map[string]string)
annotations[v1.AnnotationLoadBalancerSourceRangesKey] = v
svc := v1.Service{}
svc.Annotations = annotations
_, err := GetLoadBalancerSourceRanges(&svc)
if err == nil {
t.Errorf("Expected error parsing: %q", v)
}
svc = v1.Service{}
svc.Spec.LoadBalancerSourceRanges = strings.Split(v, ",")
_, err = GetLoadBalancerSourceRanges(&svc)
if err == nil {
t.Errorf("Expected error parsing: %q", v)
}
}
checkError("10.0.0.1/33")
checkError("foo.bar")
checkError("10.0.0.1/32,*")
checkError("10.0.0.1/32,")
checkError("10.0.0.1/32, ")
checkError("10.0.0.1")
checkOK := func(v string) utilnet.IPNetSet {
annotations := make(map[string]string)
annotations[v1.AnnotationLoadBalancerSourceRangesKey] = v
svc := v1.Service{}
svc.Annotations = annotations
_, err := GetLoadBalancerSourceRanges(&svc)
if err != nil {
t.Errorf("Unexpected error parsing: %q", v)
}
svc = v1.Service{}
svc.Spec.LoadBalancerSourceRanges = strings.Split(v, ",")
cidrs, err := GetLoadBalancerSourceRanges(&svc)
if err != nil {
t.Errorf("Unexpected error parsing: %q", v)
}
return cidrs
}
cidrs := checkOK("192.168.0.1/32")
if len(cidrs) != 1 {
t.Errorf("Expected exactly one CIDR: %v", cidrs.StringSlice())
}
cidrs = checkOK("192.168.0.1/32,192.168.0.1/32")
if len(cidrs) != 1 {
t.Errorf("Expected exactly one CIDR (after de-dup): %v", cidrs.StringSlice())
}
cidrs = checkOK("192.168.0.1/32,192.168.0.2/32")
if len(cidrs) != 2 {
t.Errorf("Expected two CIDRs: %v", cidrs.StringSlice())
}
cidrs = checkOK(" 192.168.0.1/32 , 192.168.0.2/32 ")
if len(cidrs) != 2 {
t.Errorf("Expected two CIDRs: %v", cidrs.StringSlice())
}
// check LoadBalancerSourceRanges not specified
svc := v1.Service{}
cidrs, err := GetLoadBalancerSourceRanges(&svc)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if len(cidrs) != 1 {
t.Errorf("Expected exactly one CIDR: %v", cidrs.StringSlice())
}
if !IsAllowAll(cidrs) {
t.Errorf("Expected default to be allow-all: %v", cidrs.StringSlice())
}
// check SourceRanges annotation is empty
annotations := make(map[string]string)
annotations[v1.AnnotationLoadBalancerSourceRangesKey] = ""
svc = v1.Service{}
svc.Annotations = annotations
cidrs, err = GetLoadBalancerSourceRanges(&svc)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if len(cidrs) != 1 {
t.Errorf("Expected exactly one CIDR: %v", cidrs.StringSlice())
}
if !IsAllowAll(cidrs) {
t.Errorf("Expected default to be allow-all: %v", cidrs.StringSlice())
}
} | explode_data.jsonl/23291 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1163
} | [
2830,
3393,
1949,
5879,
93825,
3608,
74902,
1155,
353,
8840,
836,
8,
341,
25157,
1454,
1669,
2915,
3747,
914,
8,
341,
197,
197,
39626,
1669,
1281,
9147,
14032,
30953,
340,
197,
197,
39626,
16529,
16,
93292,
5879,
93825,
3608,
74902,
159... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHttpParser_censorPasswordPOST(t *testing.T) {
logp.TestingSetup(logp.WithSelectors("http", "httpdetailed"))
http := httpModForTests(nil)
http.hideKeywords = []string{"password"}
http.parserConfig.sendHeaders = true
http.parserConfig.sendAllHeaders = true
data1 :=
"POST /users/login HTTP/1.1\r\n" +
"HOST: www.example.com\r\n" +
"Content-Type: application/x-www-form-urlencoded\r\n" +
"Content-Length: 28\r\n" +
"\r\n" +
"username=ME&password=secret\r\n"
tp := newTestParser(http, data1)
msg, ok, complete := tp.parse()
assert.True(t, ok)
assert.True(t, complete)
rawMsg := tp.stream.data[tp.stream.message.start:tp.stream.message.end]
path, params, err := http.extractParameters(msg, rawMsg)
assert.Nil(t, err)
assert.Equal(t, "/users/login", path)
assert.False(t, strings.Contains(params, "secret"))
} | explode_data.jsonl/16508 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 343
} | [
2830,
3393,
2905,
6570,
666,
3805,
4876,
2946,
1155,
353,
8840,
836,
8,
341,
6725,
79,
8787,
287,
21821,
12531,
79,
26124,
96995,
445,
1254,
497,
330,
1254,
67,
10111,
28075,
28080,
1669,
1758,
4459,
2461,
18200,
27907,
340,
28080,
1824... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestLang_English_ToMonthString(t *testing.T) {
assert := assert.New(t)
tests := []struct {
input string // 输入值
expected string // 期望值
}{
{"", ""},
{"0", ""},
{"0000-00-00", ""},
{"00:00:00", ""},
{"0000-00-00 00:00:00", ""},
{"2020-01-05", "January"},
{"2020-02-05", "February"},
{"2020-03-05", "March"},
{"2020-04-05", "April"},
{"2020-05-05", "May"},
{"2020-06-05", "June"},
{"2020-07-05", "July"},
{"2020-08-05", "August"},
{"2020-09-05", "September"},
{"2020-10-05", "October"},
{"2020-11-05", "November"},
{"2020-12-05", "December"},
}
for index, test := range tests {
c := SetTimezone(PRC).Parse(test.input).SetLocale(english)
assert.Nil(c.Error)
assert.Equal(test.expected, c.ToMonthString(), "test index id is "+strconv.Itoa(index))
}
} | explode_data.jsonl/29473 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 367
} | [
2830,
3393,
26223,
2089,
968,
1672,
38346,
11318,
703,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
78216,
1669,
3056,
1235,
341,
197,
22427,
262,
914,
442,
69058,
25511,
198,
197,
42400,
914,
442,
220,
106076,
25511... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlainGenomeWriter_WriteNetworkNode_writeError(t *testing.T) {
errorWriter := ErrorWriter(1)
wr := plainGenomeWriter{w: bufio.NewWriterSize(&errorWriter, 1)}
err := wr.writeNetworkNode(network.NewNNode(1, network.InputNeuron))
assert.EqualError(t, err, alwaysErrorText)
} | explode_data.jsonl/18933 | {
"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,
26982,
9967,
635,
6492,
31825,
12320,
1955,
9165,
1454,
1155,
353,
8840,
836,
8,
341,
18290,
6492,
1669,
4600,
6492,
7,
16,
340,
6692,
81,
1669,
14396,
9967,
635,
6492,
90,
86,
25,
96917,
7121,
6492,
1695,
2099,
841,
6492,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHandlerServeCSRFToken(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
session := &model.Session{
UserId: th.BasicUser.Id,
CreateAt: model.GetMillis(),
Roles: model.SYSTEM_USER_ROLE_ID,
IsOAuth: false,
}
session.GenerateCSRF()
th.App.SetSessionExpireInDays(session, 1)
session, err := th.App.CreateSession(session)
if err != nil {
t.Errorf("Expected nil, got %s", err)
}
web := New(th.Server, th.Server.AppOptions, th.Server.Router)
handler := Handler{
GetGlobalAppOptions: web.GetGlobalAppOptions,
HandleFunc: handlerForCSRFToken,
RequireSession: true,
TrustRequester: false,
RequireMfa: false,
IsStatic: false,
}
cookie := &http.Cookie{
Name: model.SESSION_COOKIE_USER,
Value: th.BasicUser.Username,
}
cookie2 := &http.Cookie{
Name: model.SESSION_COOKIE_TOKEN,
Value: session.Token,
}
cookie3 := &http.Cookie{
Name: model.SESSION_COOKIE_CSRF,
Value: session.GetCSRF(),
}
// CSRF Token Used - Success Expected
request := httptest.NewRequest("POST", "/api/v4/test", nil)
request.AddCookie(cookie)
request.AddCookie(cookie2)
request.AddCookie(cookie3)
request.Header.Add(model.HEADER_CSRF_TOKEN, session.GetCSRF())
response := httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != 200 {
t.Errorf("Expected status 200, got %d", response.Code)
}
// No CSRF Token Used - Failure Expected
request = httptest.NewRequest("POST", "/api/v4/test", nil)
request.AddCookie(cookie)
request.AddCookie(cookie2)
request.AddCookie(cookie3)
response = httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != 401 {
t.Errorf("Expected status 401, got %d", response.Code)
}
// Fallback Behavior Used - Success expected
// ToDo (DSchalla) 2019/01/04: Remove once legacy CSRF Handling is removed
th.App.UpdateConfig(func(config *model.Config) {
*config.ServiceSettings.ExperimentalStrictCSRFEnforcement = false
})
request = httptest.NewRequest("POST", "/api/v4/test", nil)
request.AddCookie(cookie)
request.AddCookie(cookie2)
request.AddCookie(cookie3)
request.Header.Add(model.HEADER_REQUESTED_WITH, model.HEADER_REQUESTED_WITH_XML)
response = httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != 200 {
t.Errorf("Expected status 200, got %d", response.Code)
}
// Fallback Behavior Used with Strict Enforcement - Failure Expected
// ToDo (DSchalla) 2019/01/04: Remove once legacy CSRF Handling is removed
th.App.UpdateConfig(func(config *model.Config) {
*config.ServiceSettings.ExperimentalStrictCSRFEnforcement = true
})
response = httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != 401 {
t.Errorf("Expected status 200, got %d", response.Code)
}
// Handler with RequireSession set to false
handlerNoSession := Handler{
GetGlobalAppOptions: web.GetGlobalAppOptions,
HandleFunc: handlerForCSRFToken,
RequireSession: false,
TrustRequester: false,
RequireMfa: false,
IsStatic: false,
}
// CSRF Token Used - Success Expected
request = httptest.NewRequest("POST", "/api/v4/test", nil)
request.AddCookie(cookie)
request.AddCookie(cookie2)
request.AddCookie(cookie3)
request.Header.Add(model.HEADER_CSRF_TOKEN, session.GetCSRF())
response = httptest.NewRecorder()
handlerNoSession.ServeHTTP(response, request)
if response.Code != 200 {
t.Errorf("Expected status 200, got %d", response.Code)
}
// No CSRF Token Used - Failure Expected
request = httptest.NewRequest("POST", "/api/v4/test", nil)
request.AddCookie(cookie)
request.AddCookie(cookie2)
request.AddCookie(cookie3)
response = httptest.NewRecorder()
handlerNoSession.ServeHTTP(response, request)
if response.Code != 401 {
t.Errorf("Expected status 401, got %d", response.Code)
}
} | explode_data.jsonl/11784 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1474
} | [
2830,
3393,
3050,
60421,
6412,
17612,
3323,
1155,
353,
8840,
836,
8,
341,
70479,
1669,
18626,
1155,
568,
3803,
15944,
741,
16867,
270,
836,
682,
4454,
2822,
25054,
1669,
609,
2528,
20674,
515,
197,
197,
13504,
25,
256,
270,
48868,
1474,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreateOrUpdateIPAllocator(t *testing.T) {
stopCh := make(chan struct{})
defer close(stopCh)
controller := newController(nil)
controller.crdInformerFactory.Start(stopCh)
controller.crdInformerFactory.WaitForCacheSync(stopCh)
ipPool := newExternalIPPool("ipPoolA", "1.1.1.0/30", "", "")
changed := controller.createOrUpdateIPAllocator(ipPool)
assert.True(t, changed)
allocator, exists := controller.getIPAllocator(ipPool.Name)
require.True(t, exists)
assert.Equal(t, 1, len(allocator))
assert.Equal(t, 2, allocator.Total())
// Append a non-strict CIDR, it should handle it correctly.
ipPool.Spec.IPRanges = append(ipPool.Spec.IPRanges, antreacrds.IPRange{CIDR: "1.1.2.1/30"})
changed = controller.createOrUpdateIPAllocator(ipPool)
assert.True(t, changed)
allocator, exists = controller.getIPAllocator(ipPool.Name)
require.True(t, exists)
assert.Equal(t, 2, len(allocator))
assert.Equal(t, 4, allocator.Total())
ipPool.Spec.IPRanges = append(ipPool.Spec.IPRanges, antreacrds.IPRange{Start: "1.1.3.1", End: "1.1.3.10"})
changed = controller.createOrUpdateIPAllocator(ipPool)
assert.True(t, changed)
allocator, exists = controller.getIPAllocator(ipPool.Name)
require.True(t, exists)
assert.Equal(t, 3, len(allocator))
assert.Equal(t, 14, allocator.Total())
// IPv6 CIDR shouldn't exclude broadcast address, so total should be increased by 15.
ipPool.Spec.IPRanges = append(ipPool.Spec.IPRanges, antreacrds.IPRange{CIDR: "2021:3::aaa1/124"})
changed = controller.createOrUpdateIPAllocator(ipPool)
assert.True(t, changed)
allocator, exists = controller.getIPAllocator(ipPool.Name)
require.True(t, exists)
assert.Equal(t, 4, len(allocator))
assert.Equal(t, 29, allocator.Total())
// When there is no change, the method should do nothing and the return value should be false.
changed = controller.createOrUpdateIPAllocator(ipPool)
assert.False(t, changed)
allocator, exists = controller.getIPAllocator(ipPool.Name)
require.True(t, exists)
assert.Equal(t, 4, len(allocator))
assert.Equal(t, 29, allocator.Total())
} | explode_data.jsonl/10260 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 767
} | [
2830,
3393,
4021,
56059,
3298,
42730,
1155,
353,
8840,
836,
8,
341,
62644,
1143,
1669,
1281,
35190,
2036,
37790,
16867,
3265,
60170,
1143,
340,
61615,
1669,
501,
2051,
27907,
340,
61615,
520,
6498,
641,
34527,
4153,
12101,
60170,
1143,
34... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestStatus(t *testing.T) {
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("../../../report/authentication_suite.xml")
RunSpecsWithDefaultAndCustomReporters(t, "pkg/controller/authentication Suite", []Reporter{junitReporter})
} | explode_data.jsonl/79414 | {
"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,
2522,
1155,
353,
8840,
836,
8,
341,
79096,
19524,
3050,
7832,
604,
340,
12428,
3843,
52766,
1669,
19040,
7121,
56248,
52766,
445,
26744,
11736,
90577,
57239,
9028,
1138,
85952,
8327,
16056,
3675,
3036,
10268,
10361,
388,
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 |
func Test_genPodCgroupParentDirWithSystemdDriver(t *testing.T) {
system.SetupCgroupPathFormatter(system.Systemd)
defer system.SetupCgroupPathFormatter(system.Systemd)
tests := []struct {
name string
args *corev1.Pod
want string
}{
{
name: "Guaranteed",
args: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "111-222-333",
},
Status: corev1.PodStatus{
QOSClass: corev1.PodQOSGuaranteed,
},
},
want: "/kubepods-pod111_222_333.slice",
},
{
name: "BestEffort",
args: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "111-222-333",
},
Status: corev1.PodStatus{
QOSClass: corev1.PodQOSBestEffort,
},
},
want: "/kubepods-besteffort.slice/kubepods-besteffort-pod111_222_333.slice",
},
{
name: "Burstable",
args: &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "111-222-333",
},
Status: corev1.PodStatus{
QOSClass: corev1.PodQOSBurstable,
},
},
want: "/kubepods-burstable.slice/kubepods-burstable-pod111_222_333.slice",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := filepath.Join("/", genPodCgroupParentDir(tt.args))
if tt.want != got {
t.Errorf("genPodCgroupParentDir want %v but got %v", tt.want, got)
}
})
}
} | explode_data.jsonl/22682 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 633
} | [
2830,
3393,
16322,
23527,
34,
4074,
8387,
6184,
2354,
2320,
67,
11349,
1155,
353,
8840,
836,
8,
341,
40293,
39820,
34,
4074,
1820,
14183,
46006,
16620,
67,
340,
16867,
1849,
39820,
34,
4074,
1820,
14183,
46006,
16620,
67,
340,
78216,
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 TestLicense_String(t *testing.T) {
v := License{
Key: String(""),
Name: String(""),
URL: String(""),
SPDXID: String(""),
HTMLURL: String(""),
Featured: Bool(false),
Description: String(""),
Implementation: String(""),
Body: String(""),
}
want := `github.License{Key:"", Name:"", URL:"", SPDXID:"", HTMLURL:"", Featured:false, Description:"", Implementation:"", Body:""}`
if got := v.String(); got != want {
t.Errorf("License.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 248
} | [
2830,
3393,
9827,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
1876,
515,
197,
55242,
25,
310,
923,
445,
4461,
197,
21297,
25,
1843,
923,
445,
4461,
197,
79055,
25,
310,
923,
445,
4461,
197,
96174,
16591,
915,
25,
260,
923,
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... | 2 |
func TestSentry(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
client := &http.Client{Timeout: 5 * time.Second, Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}}
testDir, _ := fileutils.FindDir("tests")
t.Run("sentry is disabled, should not receive a report", func(t *testing.T) {
data := make(chan bool, 1)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Log("Received sentry request for some reason")
data <- true
}))
defer server.Close()
// make sure we don't report anything when sentry is disabled
_, port, _ := net.SplitHostPort(server.Listener.Addr().String())
dsn, err := sentry.NewDsn(fmt.Sprintf("http://test:test@localhost:%s/123", port))
require.NoError(t, err)
SentryDSN = dsn.String()
s, err := NewServer(func(server *Server) error {
configStore, _ := config.NewFileStore("config.json", true)
store, _ := config.NewStoreFromBacking(configStore, nil)
server.configStore = store
server.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ListenAddress = ":0"
*cfg.LogSettings.EnableSentry = false
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
*cfg.LogSettings.EnableDiagnostics = true
})
return nil
})
require.NoError(t, err)
// Route for just panicing
s.Router.HandleFunc("/panic", func(writer http.ResponseWriter, request *http.Request) {
panic("log this panic")
})
require.NoError(t, s.Start())
defer s.Shutdown()
resp, err := client.Get("https://localhost:" + strconv.Itoa(s.ListenAddr.Port) + "/panic")
require.Nil(t, resp)
require.True(t, errors.Is(err, io.EOF), fmt.Sprintf("unexpected error: %s", err))
sentry.Flush(time.Second)
select {
case <-data:
require.Fail(t, "Sentry received a message, even though it's disabled!")
case <-time.After(time.Second):
t.Log("Sentry request didn't arrive. Good!")
}
})
t.Run("sentry is enabled, report should be received", func(t *testing.T) {
data := make(chan bool, 1)
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Log("Received sentry request!")
data <- true
}))
defer server.Close()
_, port, _ := net.SplitHostPort(server.Listener.Addr().String())
dsn, err := sentry.NewDsn(fmt.Sprintf("http://test:test@localhost:%s/123", port))
require.NoError(t, err)
SentryDSN = dsn.String()
s, err := NewServer(func(server *Server) error {
configStore, _ := config.NewFileStore("config.json", true)
store, _ := config.NewStoreFromBacking(configStore, nil)
server.configStore = store
server.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ListenAddress = ":0"
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
*cfg.LogSettings.EnableSentry = true
*cfg.LogSettings.EnableDiagnostics = true
})
return nil
})
require.NoError(t, err)
// Route for just panicing
s.Router.HandleFunc("/panic", func(writer http.ResponseWriter, request *http.Request) {
panic("log this panic")
})
require.NoError(t, s.Start())
defer s.Shutdown()
resp, err := client.Get("https://localhost:" + strconv.Itoa(s.ListenAddr.Port) + "/panic")
require.Nil(t, resp)
require.True(t, errors.Is(err, io.EOF), fmt.Sprintf("unexpected error: %s", err))
sentry.Flush(time.Second)
select {
case <-data:
t.Log("Sentry request arrived. Good!")
case <-time.After(time.Second * 10):
require.Fail(t, "Sentry report didn't arrive")
}
})
} | explode_data.jsonl/47833 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1485
} | [
2830,
3393,
50,
4085,
1155,
353,
8840,
836,
8,
341,
743,
7497,
55958,
368,
341,
197,
3244,
57776,
7039,
741,
197,
630,
25291,
1669,
609,
1254,
11716,
90,
7636,
25,
220,
20,
353,
882,
32435,
11,
16742,
25,
609,
1254,
87669,
515,
197,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestAddIfNotPresent(t *testing.T) {
t.Parallel()
flight := newSyncU64set()
if !flight.AddIfNotPresent(10) {
t.Error("could not add the first value")
}
if flight.AddIfNotPresent(10) {
t.Error("value added twice")
}
} | explode_data.jsonl/7434 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 91
} | [
2830,
3393,
2212,
2679,
2623,
21195,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
1166,
4145,
1669,
501,
12154,
52,
21,
19,
746,
741,
743,
753,
38390,
1904,
2679,
2623,
21195,
7,
16,
15,
8,
341,
197,
3244,
6141,
445,
28077,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPostStoreGetPostsCreatedAt(t *testing.T) {
Setup()
createTime := model.GetMillis()
o0 := &model.Post{}
o0.ChannelId = model.NewId()
o0.UserId = model.NewId()
o0.Message = "zz" + model.NewId() + "b"
o0.CreateAt = createTime
o0 = (<-store.Post().Save(o0)).Data.(*model.Post)
o1 := &model.Post{}
o1.ChannelId = o0.Id
o1.UserId = model.NewId()
o1.Message = "zz" + model.NewId() + "b"
o0.CreateAt = createTime
o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
o2.UserId = model.NewId()
o2.Message = "zz" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o3 := &model.Post{}
o3.ChannelId = model.NewId()
o3.UserId = model.NewId()
o3.Message = "zz" + model.NewId() + "b"
o3.CreateAt = createTime
o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
r1 := (<-store.Post().GetPostsCreatedAt(o1.ChannelId, createTime)).Data.([]*model.Post)
if len(r1) != 2 {
t.Fatalf("Got the wrong number of posts.")
}
} | explode_data.jsonl/55957 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 510
} | [
2830,
3393,
4133,
6093,
1949,
19631,
70387,
1155,
353,
8840,
836,
8,
341,
197,
21821,
2822,
39263,
1462,
1669,
1614,
2234,
17897,
2822,
22229,
15,
1669,
609,
2528,
23442,
16094,
22229,
15,
38716,
764,
284,
1614,
7121,
764,
741,
22229,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMiddleware(t *testing.T) {
r := New()
r.GET("/foo", func(rw http.ResponseWriter, r *http.Request) {
rw.Write([]byte("bar"))
})
rec := request(t, r, "GET", "/foo")
if rec.Code != http.StatusOK {
t.Errorf("request failed")
}
if rec.Body.String() != "bar" {
t.Errorf("unexpected body")
}
} | explode_data.jsonl/10766 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 130
} | [
2830,
3393,
24684,
1155,
353,
8840,
836,
8,
341,
7000,
1669,
1532,
741,
7000,
17410,
4283,
7975,
497,
2915,
2601,
86,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197,
7000,
86,
4073,
10556,
3782,
445,
2257,
5455,
197,
8824,
67904,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetAllDomains(t *testing.T) {
e, _ := NewEnforcer("examples/rbac_with_domains_model.conf", "examples/rbac_with_domains_policy.csv")
testGetAllDomains(t, e, []string{"domain1", "domain2"})
} | explode_data.jsonl/65638 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 80
} | [
2830,
3393,
1949,
2403,
74713,
1155,
353,
8840,
836,
8,
341,
7727,
11,
716,
1669,
1532,
1702,
82010,
445,
51668,
7382,
55877,
6615,
70199,
5047,
13937,
497,
330,
51668,
7382,
55877,
6615,
70199,
22773,
11219,
5130,
18185,
1949,
2403,
7471... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestShouldSplitIntoEvenStringsOfFour(t *testing.T) {
input := testStringInput
arrayOfStrings := SliceString(input, 4)
assert.Equal(t, len(arrayOfStrings), 3)
assert.Equal(t, "abcd", arrayOfStrings[0])
assert.Equal(t, "efgh", arrayOfStrings[1])
assert.Equal(t, "ijkl", arrayOfStrings[2])
} | explode_data.jsonl/45960 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 121
} | [
2830,
3393,
14996,
20193,
26591,
13159,
20859,
2124,
26972,
1155,
353,
8840,
836,
8,
341,
22427,
1669,
1273,
703,
2505,
271,
11923,
2124,
20859,
1669,
56476,
703,
5384,
11,
220,
19,
692,
6948,
12808,
1155,
11,
2422,
6110,
2124,
20859,
7... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGetContinuousKlineData(t *testing.T) {
t.Parallel()
_, err := b.GetContinuousKlineData(context.Background(), "BTCUSD", "CURRENT_QUARTER", "1M", 5, time.Time{}, time.Time{})
if err != nil {
t.Error(err)
}
_, err = b.GetContinuousKlineData(context.Background(), "BTCUSD", "CURRENT_QUARTER", "1M", 5, time.Unix(1577836800, 0), time.Unix(1580515200, 0))
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/76603 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 169
} | [
2830,
3393,
1949,
94780,
42,
1056,
1043,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
197,
6878,
1848,
1669,
293,
2234,
94780,
42,
1056,
1043,
5378,
19047,
1507,
330,
59118,
26749,
497,
330,
44690,
16332,
2992,
640,
497,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestExecFailureCloseBefore(t *testing.T) {
t.Parallel()
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
closeConn(t, conn)
_, err := conn.Exec(context.Background(), "select 1")
require.Error(t, err)
assert.True(t, pgconn.SafeToRetry(err))
} | explode_data.jsonl/40010 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 104
} | [
2830,
3393,
10216,
17507,
7925,
10227,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
32917,
1669,
1969,
14611,
703,
1155,
11,
2643,
64883,
445,
11383,
55,
11641,
45510,
5455,
27873,
9701,
1155,
11,
4534,
692,
197,
6878,
1848,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestMapProxy_TryPutWithNilValue(t *testing.T) {
testKey := "testingKey"
_, err := mp.TryPut(testKey, nil)
AssertErrorNotNil(t, err, "tryPut did not return an error for nil value")
mp.Clear()
} | explode_data.jsonl/56963 | {
"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,
2227,
16219,
1139,
884,
19103,
2354,
19064,
1130,
1155,
353,
8840,
836,
8,
341,
18185,
1592,
1669,
330,
8840,
1592,
698,
197,
6878,
1848,
1669,
10490,
19824,
19103,
8623,
1592,
11,
2092,
340,
18017,
1454,
96144,
1155,
11,
18... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestCastTimeToDate(t *testing.T) {
store, clean := realtikvtest.CreateMockStoreAndSetup(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("set time_zone = '-8:00'")
date := time.Now().In(time.FixedZone("", -8*int(time.Hour/time.Second)))
tk.MustQuery("select cast(time('12:23:34') as date)").Check(testkit.Rows(date.Format("2006-01-02")))
tk.MustExec("set time_zone = '+08:00'")
date = time.Now().In(time.FixedZone("", 8*int(time.Hour/time.Second)))
tk.MustQuery("select cast(time('12:23:34') as date)").Check(testkit.Rows(date.Format("2006-01-02")))
} | explode_data.jsonl/5769 | {
"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,
18714,
1462,
76054,
1155,
353,
8840,
836,
8,
341,
57279,
11,
4240,
1669,
1931,
83,
1579,
85,
1944,
7251,
11571,
6093,
3036,
21821,
1155,
340,
16867,
4240,
2822,
3244,
74,
1669,
1273,
8226,
7121,
2271,
7695,
1155,
11,
3553,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdateFields(t *testing.T) {
resetTest()
req, err := http.NewRequest("GET", s.server.URL+"/updatefields", nil)
if err != nil {
t.Fatal(err)
}
var counter, counter2 string
{
resp, err := s.client.Do(req)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
counter = resp.Header.Get("x-counter")
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
}
{
resp, err := s.client.Do(req)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.Header.Get(XFromCache) != "1" {
t.Fatalf(`XFromCache header isn't "1": %v`, resp.Header.Get(XFromCache))
}
counter2 = resp.Header.Get("x-counter")
}
if counter == counter2 {
t.Fatalf(`both "x-counter" values are equal: %v %v`, counter, counter2)
}
} | explode_data.jsonl/77625 | {
"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,
4289,
8941,
1155,
353,
8840,
836,
8,
341,
70343,
2271,
741,
24395,
11,
1848,
1669,
1758,
75274,
445,
3806,
497,
274,
12638,
20893,
27569,
2386,
9007,
497,
2092,
340,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestAddServerIDV6(t *testing.T) {
req, err := dhcpv6.NewMessage()
if err != nil {
t.Fatal(err)
}
v6ServerID = makeTestDUID("0000000000000000")
req.MessageType = dhcpv6.MessageTypeRebind
dhcpv6.WithClientID(*makeTestDUID("1000000000000000"))(req)
stub, err := dhcpv6.NewReplyFromMessage(req)
if err != nil {
t.Fatal(err)
}
resp, _ := Handler6(req, stub)
if resp == nil {
t.Fatal("plugin did not return an answer")
}
if opt := resp.GetOneOption(dhcpv6.OptionServerID); opt == nil {
t.Fatal("plugin did not add a ServerID option")
} else {
sid := opt.(*dhcpv6.OptServerId)
if !sid.Sid.Equal(*v6ServerID) {
t.Fatalf("Got unexpected DUID: expected %v, got %v", v6ServerID, sid.Sid)
}
}
} | explode_data.jsonl/39208 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 302
} | [
2830,
3393,
2212,
5475,
915,
53,
21,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
85787,
85,
21,
7121,
2052,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
532,
5195,
21,
5475,
915,
284,
1281,
2271,
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... | 6 |
func TestIncident_ManageAlerts(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/incidents/1/alerts/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
_, _ = w.Write([]byte(`{"alerts": [{"id": "1"}]}`))
})
client := defaultTestClient(server.URL, "foo")
incidentID := "1"
input := &IncidentAlertList{
Alerts: []IncidentAlert{
{
APIObject: APIObject{
ID: "1",
},
},
},
}
res, _, err := client.ManageIncidentAlerts(incidentID, input)
want := &ListAlertsResponse{
Alerts: []IncidentAlert{
{
APIObject: APIObject{
ID: "1",
},
},
},
}
if err != nil {
t.Fatal(err)
}
testEqual(t, want, res)
} | explode_data.jsonl/76404 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 321
} | [
2830,
3393,
39245,
1713,
71628,
424,
9676,
82,
1155,
353,
8840,
836,
8,
341,
84571,
741,
16867,
49304,
2822,
2109,
2200,
63623,
4283,
2840,
6880,
14,
16,
79688,
82,
28105,
2915,
3622,
1758,
37508,
11,
435,
353,
1254,
9659,
8,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestJson2Struct_map_struct(t *testing.T) {
ret, err := Json2Struct("auto_name", `{"23":{"int": 23, "string": "2323"}, "1": {"int": 23, "string": "2323", "float": 23.2}}`, GoStructType)
fmt.Printf("ret:\n %s, %v\n", ret, err)
} | explode_data.jsonl/72757 | {
"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,
5014,
17,
9422,
5376,
15126,
1155,
353,
8840,
836,
8,
341,
11262,
11,
1848,
1669,
8308,
17,
9422,
445,
3902,
1269,
497,
1565,
4913,
17,
18,
22317,
396,
788,
220,
17,
18,
11,
330,
917,
788,
330,
17,
18,
17,
18,
14345,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommit(t *testing.T) {
db := openTestConn(t)
defer db.Close()
_, err := db.Exec("CREATE TEMP TABLE temp (a int)")
if err != nil {
t.Fatal(err)
}
sqlInsert := "INSERT INTO temp VALUES (1)"
sqlSelect := "SELECT * FROM temp"
tx, err := db.Begin()
if err != nil {
t.Fatal(err)
}
_, err = tx.Exec(sqlInsert)
if err != nil {
t.Fatal(err)
}
err = tx.Commit()
if err != nil {
t.Fatal(err)
}
var i int
err = db.QueryRow(sqlSelect).Scan(&i)
if err != nil {
t.Fatal(err)
}
if i != 1 {
t.Fatalf("expected 1, got %d", i)
}
} | explode_data.jsonl/63444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 259
} | [
2830,
3393,
33441,
1155,
353,
8840,
836,
8,
341,
20939,
1669,
1787,
2271,
9701,
1155,
340,
16867,
2927,
10421,
2822,
197,
6878,
1848,
1669,
2927,
30798,
445,
22599,
57431,
14363,
2730,
320,
64,
526,
19107,
743,
1848,
961,
2092,
341,
197... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestSizeof(t *testing.T) {
const _64bit = unsafe.Sizeof(uintptr(0)) == 8
var tests = []struct {
val interface{} // type as a value
_32bit uintptr // size on 32bit platforms
_64bit uintptr // size on 64bit platforms
}{
{Addr{}, 52, 80},
{LSym{}, 80, 136},
{Prog{}, 196, 288},
}
for _, tt := range tests {
want := tt._32bit
if _64bit {
want = tt._64bit
}
got := reflect.TypeOf(tt.val).Size()
if want != got {
t.Errorf("unsafe.Sizeof(%T) = %d, want %d", tt.val, got, want)
}
}
} | explode_data.jsonl/3290 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 244
} | [
2830,
3393,
1695,
1055,
1155,
353,
8840,
836,
8,
341,
4777,
716,
21,
19,
4489,
284,
19860,
2465,
1055,
8488,
3505,
7,
15,
593,
621,
220,
23,
271,
2405,
7032,
284,
3056,
1235,
341,
197,
19302,
262,
3749,
6257,
442,
943,
438,
264,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestDMap_Atomic_Incr(t *testing.T) {
cluster := testcluster.New(NewService)
s := cluster.AddMember(nil).(*Service)
defer cluster.Shutdown()
var wg sync.WaitGroup
var start chan struct{}
key := "incr"
ctx := context.Background()
incr := func(dm *DMap) {
<-start
defer wg.Done()
_, err := dm.Incr(ctx, key, 1)
if err != nil {
s.log.V(2).Printf("[ERROR] Failed to call Incr: %v", err)
return
}
}
dm, err := s.NewDMap("atomic_test")
require.NoError(t, err)
start = make(chan struct{})
for i := 0; i < 100; i++ {
wg.Add(1)
go incr(dm)
}
close(start)
wg.Wait()
gr, err := dm.Get(ctx, key)
require.NoError(t, err)
var res int
err = resp.Scan(gr.Value(), &res)
require.NoError(t, err)
require.Equal(t, 100, res)
} | explode_data.jsonl/64501 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 344
} | [
2830,
3393,
35,
2227,
55581,
3075,
25972,
5082,
1155,
353,
8840,
836,
8,
341,
197,
18855,
1669,
1273,
18855,
7121,
35063,
1860,
340,
1903,
1669,
10652,
1904,
9366,
27907,
568,
4071,
1860,
340,
16867,
10652,
10849,
18452,
2822,
2405,
63581... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReferencedBytesStat(t *testing.T) {
//overwrite package variables
smapsFilePathPattern = "testdata/smaps%d"
clearRefsFilePathPattern = "testdata/clear_refs%d"
pids := []int{4, 6, 8}
stat, err := referencedBytesStat(pids, 1, 3)
assert.Nil(t, err)
assert.Equal(t, uint64(416*1024), stat)
clearRefsFiles := []string{
"testdata/clear_refs4",
"testdata/clear_refs6",
"testdata/clear_refs8"}
//check if clear_refs files have proper values
assert.Equal(t, "0\n", getFileContent(t, clearRefsFiles[0]))
assert.Equal(t, "0\n", getFileContent(t, clearRefsFiles[1]))
assert.Equal(t, "0\n", getFileContent(t, clearRefsFiles[2]))
} | explode_data.jsonl/43789 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 267
} | [
2830,
3393,
47447,
5767,
7078,
15878,
1155,
353,
8840,
836,
8,
341,
197,
322,
64915,
6328,
7332,
198,
1903,
17640,
19090,
15760,
284,
330,
92425,
2687,
17640,
14841,
698,
40408,
82807,
19090,
15760,
284,
330,
92425,
2899,
1547,
60638,
148... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCert(t *testing.T) {
mc, err := GlobalCert.GetMITMConfig()
if err != nil {
t.Fatal(err)
}
proxy := martian.NewProxy()
proxy.SetRequestModifier(&Skip{})
proxy.SetMITM(mc)
listener, err := net.Listen("tcp", ":1080")
if err != nil {
t.Fatal(err)
}
err = proxy.Serve(listener)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/20570 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 149
} | [
2830,
3393,
36934,
1155,
353,
8840,
836,
8,
341,
97662,
11,
1848,
1669,
7962,
36934,
2234,
18330,
44,
2648,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
3964,
340,
197,
630,
197,
22803,
1669,
48195,
1103,
7121,
16219,
741,
197,
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... | 4 |
func TestStalledFrontendCycles(t *testing.T) {
t.Skip()
_, err := StalledFrontendCycles(
func() error { return nil },
)
if err != nil {
t.Fatal(err)
}
} | explode_data.jsonl/33110 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 70
} | [
2830,
3393,
623,
4736,
23395,
408,
34,
15805,
1155,
353,
8840,
836,
8,
341,
3244,
57776,
741,
197,
6878,
1848,
1669,
794,
4736,
23395,
408,
34,
15805,
1006,
197,
29244,
368,
1465,
314,
470,
2092,
1153,
197,
692,
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 |
func TestNoImageTargets(t *testing.T) {
f := newIBDFixture(t, k8s.EnvGKE)
defer f.TearDown()
targName := "some-k8s-manifest"
specs := []model.TargetSpec{
k8s.MustTarget(model.TargetName(targName), testyaml.LonelyPodYAML),
}
_, err := f.ibd.BuildAndDeploy(f.ctx, f.st, specs, store.BuildStateSet{})
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 0, f.docker.BuildCount, "expect no docker builds")
assert.Equalf(t, 1, strings.Count(f.k8s.Yaml, "image: gcr.io/windmill-public-containers/lonely-pod"),
"Expected lonely-pod image to appear once in YAML: %s", f.k8s.Yaml)
expectedLabelStr := fmt.Sprintf("%s: %s", k8s.ManagedByLabel, k8s.ManagedByValue)
assert.Equalf(t, 1, strings.Count(f.k8s.Yaml, expectedLabelStr),
"Expected \"%s\" label to appear once in YAML: %s", expectedLabelStr, f.k8s.Yaml)
// If we're not making updates in response to an image change, it's OK to
// leave the existing image pull policy.
assert.Contains(t, f.k8s.Yaml, "imagePullPolicy: Always")
} | explode_data.jsonl/38255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 414
} | [
2830,
3393,
2753,
1906,
49030,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
3256,
5262,
12735,
1155,
11,
595,
23,
82,
81214,
38,
3390,
340,
16867,
282,
836,
682,
4454,
2822,
3244,
858,
675,
1669,
330,
14689,
12646,
23,
82,
20477,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTerragruntVersionConstraints(t *testing.T) {
testCases := []struct {
name string
terragruntVersion string
terragruntConstraint string
shouldSucceed bool
}{
{
"version meets constraint equal",
"v0.23.18",
"terragrunt_version_constraint = \">= v0.23.18\"",
true,
},
{
"version meets constriant greater patch",
"v0.23.19",
"terragrunt_version_constraint = \">= v0.23.18\"",
true,
},
{
"version meets constriant greater major",
"v1.0.0",
"terragrunt_version_constraint = \">= v0.23.18\"",
true,
},
{
"version meets constriant less patch",
"v0.23.17",
"terragrunt_version_constraint = \">= v0.23.18\"",
false,
},
{
"version meets constriant less major",
"v0.22.18",
"terragrunt_version_constraint = \">= v0.23.18\"",
false,
},
}
for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) {
tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_READ_CONFIG)
rootPath := filepath.Join(tmpEnvPath, TEST_FIXTURE_READ_CONFIG, "with_constraints")
tmpTerragruntConfigPath := createTmpTerragruntConfigContent(t, testCase.terragruntConstraint, config.DefaultTerragruntConfigPath)
stdout := bytes.Buffer{}
stderr := bytes.Buffer{}
err := runTerragruntVersionCommand(t, testCase.terragruntVersion, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, rootPath), &stdout, &stderr)
logBufferContentsLineByLine(t, stdout, "stdout")
logBufferContentsLineByLine(t, stderr, "stderr")
if testCase.shouldSucceed {
require.NoError(t, err)
} else {
require.Error(t, err)
}
})
}
} | explode_data.jsonl/10174 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 791
} | [
2830,
3393,
51402,
68305,
3850,
5637,
12925,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
197,
465,
4101,
81,
3850,
5637,
262,
914,
198,
197,
197,
465,
4101,
81,
3850,
17890,
914,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestPreparedCommand_Output(t *testing.T) {
stdout := shx.RecordStdout()
defer stdout.Release()
stderr := shx.RecordStderr()
defer stderr.Release()
gotOutput, err := shx.Output("go", "run", "echo.go", "hello world")
gotStdout := stdout.Output()
gotStderr := stderr.Output()
if err != nil {
t.Fatal(err)
}
wantOutput := "hello world"
assert.Equal(t, wantOutput, gotOutput)
assert.Empty(t, gotStdout)
assert.Empty(t, gotStderr)
} | explode_data.jsonl/57102 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 184
} | [
2830,
3393,
4703,
7212,
4062,
65062,
1155,
353,
8840,
836,
8,
341,
6736,
411,
1669,
557,
87,
49959,
22748,
411,
741,
16867,
20075,
58693,
741,
6736,
615,
1669,
557,
87,
49959,
22748,
615,
741,
16867,
26436,
58693,
2822,
3174,
354,
5097,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAttributes_InsertValue(t *testing.T) {
testCases := []testCase{
// Ensure `attribute1` is set for spans with no attributes.
{
name: "InsertEmptyAttributes",
inputAttributes: map[string]pdata.AttributeValue{},
expectedAttributes: map[string]pdata.AttributeValue{
"attribute1": pdata.NewAttributeValueInt(123),
},
},
// Ensure `attribute1` is set.
{
name: "InsertKeyNoExists",
inputAttributes: map[string]pdata.AttributeValue{
"anotherkey": pdata.NewAttributeValueString("bob"),
},
expectedAttributes: map[string]pdata.AttributeValue{
"anotherkey": pdata.NewAttributeValueString("bob"),
"attribute1": pdata.NewAttributeValueInt(123),
},
},
// Ensures no insert is performed because the keys `attribute1` already exists.
{
name: "InsertKeyExists",
inputAttributes: map[string]pdata.AttributeValue{
"attribute1": pdata.NewAttributeValueString("bob"),
},
expectedAttributes: map[string]pdata.AttributeValue{
"attribute1": pdata.NewAttributeValueString("bob"),
},
},
}
cfg := &Settings{
Actions: []ActionKeyValue{
{Key: "attribute1", Action: INSERT, Value: 123},
},
}
ap, err := NewAttrProc(cfg)
require.Nil(t, err)
require.NotNil(t, ap)
for _, tt := range testCases {
runIndividualTestCase(t, tt, ap)
}
} | explode_data.jsonl/11507 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 508
} | [
2830,
3393,
10516,
76417,
1130,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
66194,
515,
197,
197,
322,
29279,
1565,
9116,
16,
63,
374,
738,
369,
44295,
448,
902,
8201,
624,
197,
197,
515,
298,
11609,
25,
310,
330,
13780,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.