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_write_uint64(t *testing.T) {
vals := []uint64{0, 1, 11, 111, 255, 999999, 0xfff, 0xffff, 0xfffff, 0xffffff, 0xfffffff, 0xffffffff,
0xfffffffff, 0xffffffffff, 0xfffffffffff, 0xffffffffffff, 0xfffffffffffff, 0xffffffffffffff,
0xfffffffffffffff, 0xffffffffffffffff}
for _, val := range vals {
t.Run(fmt.Sprintf("%v", val), func(t *testing.T) {
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(ConfigDefault, buf, 4096)
stream.WriteUint64(val)
stream.Flush()
should.Nil(stream.Error)
should.Equal(strconv.FormatUint(uint64(val), 10), buf.String())
})
t.Run(fmt.Sprintf("%v", val), func(t *testing.T) {
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(ConfigDefault, buf, 4096)
stream.WriteVal(val)
stream.Flush()
should.Nil(stream.Error)
should.Equal(strconv.FormatUint(uint64(val), 10), buf.String())
})
}
should := require.New(t)
buf := &bytes.Buffer{}
stream := NewStream(ConfigDefault, buf, 10)
stream.WriteRaw("a")
stream.WriteUint64(0xffffffff) // should clear buffer
stream.Flush()
should.Nil(stream.Error)
should.Equal("a4294967295", buf.String())
} | explode_data.jsonl/51203 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 498
} | [
2830,
3393,
9165,
15807,
21,
19,
1155,
353,
8840,
836,
8,
341,
19302,
82,
1669,
3056,
2496,
21,
19,
90,
15,
11,
220,
16,
11,
220,
16,
16,
11,
220,
16,
16,
16,
11,
220,
17,
20,
20,
11,
220,
24,
24,
24,
24,
24,
24,
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 |
func TestRevokeRemovedDevicesV2(t *testing.T) {
uid1 := keybase1.MakeTestUID(0x1)
uid2 := keybase1.MakeTestUID(0x2)
uid3 := keybase1.MakeTestUID(0x3)
key1 := kbfscrypto.MakeFakeCryptPublicKeyOrBust("key1")
key2 := kbfscrypto.MakeFakeCryptPublicKeyOrBust("key2")
key3 := kbfscrypto.MakeFakeCryptPublicKeyOrBust("key3")
half1a := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x1})
half1b := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x2})
half2a := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x3})
half2b := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x4})
half3a := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x5})
half3b := kbfscrypto.MakeTLFCryptKeyServerHalf([32]byte{0x6})
id1a, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid1, key1, half1a)
require.NoError(t, err)
id1b, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid1, key1, half1b)
require.NoError(t, err)
id2a, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid2, key2, half2a)
require.NoError(t, err)
id2b, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid2, key2, half2b)
require.NoError(t, err)
id3a, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid3, key3, half3a)
require.NoError(t, err)
id3b, err := kbfscrypto.MakeTLFCryptKeyServerHalfID(uid3, key3, half3b)
require.NoError(t, err)
tlfID := tlf.FakeID(1, tlf.Private)
bh, err := tlf.MakeHandle(
[]keybase1.UserOrTeamID{uid1.AsUserOrTeam(), uid2.AsUserOrTeam()},
[]keybase1.UserOrTeamID{uid3.AsUserOrTeam()}, nil, nil, nil)
require.NoError(t, err)
brmd, err := MakeInitialRootMetadataV2(tlfID, bh)
require.NoError(t, err)
brmd.WKeys = TLFWriterKeyGenerationsV2{
TLFWriterKeyBundleV2{
WKeys: UserDeviceKeyInfoMapV2{
uid1: DeviceKeyInfoMapV2{
key1.KID(): TLFCryptKeyInfo{
ServerHalfID: id1a,
EPubKeyIndex: 0,
},
},
uid2: DeviceKeyInfoMapV2{
key2.KID(): TLFCryptKeyInfo{
ServerHalfID: id2a,
EPubKeyIndex: 1,
},
},
},
},
TLFWriterKeyBundleV2{
WKeys: UserDeviceKeyInfoMapV2{
uid1: DeviceKeyInfoMapV2{
key1.KID(): TLFCryptKeyInfo{
ServerHalfID: id1b,
EPubKeyIndex: 0,
},
},
uid2: DeviceKeyInfoMapV2{
key2.KID(): TLFCryptKeyInfo{
ServerHalfID: id2b,
EPubKeyIndex: 0,
},
},
},
},
}
brmd.RKeys = TLFReaderKeyGenerationsV2{
TLFReaderKeyBundleV2{
RKeys: UserDeviceKeyInfoMapV2{
uid3: DeviceKeyInfoMapV2{
key3.KID(): TLFCryptKeyInfo{
ServerHalfID: id3a,
EPubKeyIndex: 0,
},
},
},
},
TLFReaderKeyBundleV2{
RKeys: UserDeviceKeyInfoMapV2{
uid3: DeviceKeyInfoMapV2{
key3.KID(): TLFCryptKeyInfo{
ServerHalfID: id3b,
EPubKeyIndex: 0,
},
},
},
},
}
updatedWriterKeys := UserDevicePublicKeys{
uid1: {key1: true},
}
updatedReaderKeys := UserDevicePublicKeys{
uid3: {key3: true},
}
removalInfo, err := brmd.RevokeRemovedDevices(
updatedWriterKeys, updatedReaderKeys, nil)
require.NoError(t, err)
require.Equal(t, ServerHalfRemovalInfo{
uid2: UserServerHalfRemovalInfo{
UserRemoved: true,
DeviceServerHalfIDs: DeviceServerHalfRemovalInfo{
key2: []kbfscrypto.TLFCryptKeyServerHalfID{id2a, id2b},
},
},
}, removalInfo)
expectedWKeys := TLFWriterKeyGenerationsV2{
TLFWriterKeyBundleV2{
WKeys: UserDeviceKeyInfoMapV2{
uid1: DeviceKeyInfoMapV2{
key1.KID(): TLFCryptKeyInfo{
ServerHalfID: id1a,
EPubKeyIndex: 0,
},
},
},
},
TLFWriterKeyBundleV2{
WKeys: UserDeviceKeyInfoMapV2{
uid1: DeviceKeyInfoMapV2{
key1.KID(): TLFCryptKeyInfo{
ServerHalfID: id1b,
EPubKeyIndex: 0,
},
},
},
},
}
require.Equal(t, expectedWKeys, brmd.WKeys)
expectedRKeys := TLFReaderKeyGenerationsV2{
TLFReaderKeyBundleV2{
RKeys: UserDeviceKeyInfoMapV2{
uid3: DeviceKeyInfoMapV2{
key3.KID(): TLFCryptKeyInfo{
ServerHalfID: id3a,
EPubKeyIndex: 0,
},
},
},
},
TLFReaderKeyBundleV2{
RKeys: UserDeviceKeyInfoMapV2{
uid3: DeviceKeyInfoMapV2{
key3.KID(): TLFCryptKeyInfo{
ServerHalfID: id3b,
EPubKeyIndex: 0,
},
},
},
},
}
require.Equal(t, expectedRKeys, brmd.RKeys)
} | explode_data.jsonl/8464 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2049
} | [
2830,
3393,
693,
7621,
42642,
40835,
53,
17,
1155,
353,
8840,
836,
8,
341,
197,
2423,
16,
1669,
1376,
3152,
16,
50133,
2271,
6463,
7,
15,
87,
16,
340,
197,
2423,
17,
1669,
1376,
3152,
16,
50133,
2271,
6463,
7,
15,
87,
17,
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 TestSetProcessesStats(t *testing.T) {
ret := info.ContainerStats{
Processes: info.ProcessStats{
ProcessCount: 1,
FdCount: 2,
},
}
s := &cgroups.Stats{
PidsStats: cgroups.PidsStats{
Current: 5,
Limit: 100,
},
}
setThreadsStats(s, &ret)
expected := info.ContainerStats{
Processes: info.ProcessStats{
ProcessCount: 1,
FdCount: 2,
ThreadsCurrent: s.PidsStats.Current,
ThreadsMax: s.PidsStats.Limit,
},
}
if expected.Processes.ProcessCount != ret.Processes.ProcessCount {
t.Fatalf("expected ProcessCount: %d == %d", ret.Processes.ProcessCount, expected.Processes.ProcessCount)
}
if expected.Processes.FdCount != ret.Processes.FdCount {
t.Fatalf("expected FdCount: %d == %d", ret.Processes.FdCount, expected.Processes.FdCount)
}
if expected.Processes.ThreadsCurrent != ret.Processes.ThreadsCurrent {
t.Fatalf("expected current threads: %d == %d", ret.Processes.ThreadsCurrent, expected.Processes.ThreadsCurrent)
}
if expected.Processes.ThreadsMax != ret.Processes.ThreadsMax {
t.Fatalf("expected max threads: %d == %d", ret.Processes.ThreadsMax, expected.Processes.ThreadsMax)
}
} | explode_data.jsonl/43787 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 457
} | [
2830,
3393,
1649,
92727,
16635,
1155,
353,
8840,
836,
8,
341,
11262,
1669,
3546,
33672,
16635,
515,
197,
197,
92727,
25,
3546,
29012,
16635,
515,
298,
197,
7423,
2507,
25,
220,
16,
345,
298,
12727,
67,
2507,
25,
414,
220,
17,
345,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRoundtrip(t *testing.T) {
ctx := context.Background()
// Validate that we successfully worked around the 4096 bytes restriction.
testString := strings.Repeat("test1234", 4096)
keyConfig := schema.AWSKMSEncryptionKey{
KeyId: testKeyID,
Region: "us-west-2",
Type: "awskms",
}
cf, save := newClientFactory(t, "awskms")
defer save(t)
// Create http cli with aws defaults.
cli, err := cf.Doer(func(c *http.Client) error {
c.Transport = awshttp.NewBuildableClient().GetTransport()
return nil
})
if err != nil {
t.Fatal(err)
}
// Build config options for aws config.
configOpts := awsConfigOptsForKeyConfig(keyConfig)
configOpts = append(configOpts, config.WithHTTPClient(cli))
configOpts = append(configOpts, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(
readEnvFallback("AWS_ACCESS_KEY_ID", "test"),
readEnvFallback("AWS_SECRET_ACCESS_KEY", "test"),
"",
)))
config, err := config.LoadDefaultConfig(ctx, configOpts...)
if err != nil {
t.Fatal(err)
}
k, err := newKey(ctx, keyConfig, config)
if err != nil {
t.Fatal(err)
}
ct, err := k.Encrypt(ctx, []byte(testString))
if err != nil {
t.Fatal(err)
}
res, err := k.Decrypt(ctx, ct)
if err != nil {
t.Fatal(err)
}
if res.Secret() != testString {
t.Fatalf("expected %s, got %s", testString, res.Secret())
}
} | explode_data.jsonl/41750 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 530
} | [
2830,
3393,
27497,
32981,
1155,
353,
8840,
836,
8,
341,
20985,
1669,
2266,
19047,
741,
197,
322,
23282,
429,
582,
7790,
6439,
2163,
279,
220,
19,
15,
24,
21,
5820,
19455,
624,
18185,
703,
1669,
9069,
2817,
10979,
445,
1944,
16,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestPaddedBigBytes(t *testing.T) {
tests := []struct {
num *big.Int
n int
result []byte
}{
{num: big.NewInt(0), n: 4, result: []byte{0, 0, 0, 0}},
{num: big.NewInt(1), n: 4, result: []byte{0, 0, 0, 1}},
{num: big.NewInt(512), n: 4, result: []byte{0, 0, 2, 0}},
{num: BigPow(2, 32), n: 4, result: []byte{1, 0, 0, 0, 0}},
}
for _, test := range tests {
if result := PaddedBigBytes(test.num, test.n); !bytes.Equal(result, test.result) {
t.Errorf("PaddedBigBytes(%d, %d) = %v, want %v", test.num, test.n, result, test.result)
}
}
} | explode_data.jsonl/35394 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
47,
16828,
15636,
7078,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22431,
262,
353,
16154,
7371,
198,
197,
9038,
414,
526,
198,
197,
9559,
3056,
3782,
198,
197,
59403,
197,
197,
90,
2413,
25,
2409,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlaceMultipleSpotOrders(t *testing.T) {
TestSetRealOrderDefaults(t)
ord := okgroup.PlaceOrderRequest{
InstrumentID: spotCurrency,
Type: order.Limit.Lower(),
Side: order.Buy.Lower(),
Size: "-100",
Price: "1",
}
request := []okgroup.PlaceOrderRequest{
ord,
}
_, errs := o.PlaceMultipleSpotOrders(request)
if len(errs) > 0 {
testStandardErrorHandling(t, errs[0])
}
} | explode_data.jsonl/30157 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
17371,
32089,
47049,
24898,
1155,
353,
8840,
836,
8,
341,
73866,
1649,
12768,
4431,
16273,
1155,
340,
197,
539,
1669,
5394,
4074,
86675,
4431,
1900,
515,
197,
197,
56324,
915,
25,
7702,
26321,
345,
197,
27725,
25,
260,
1973,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestStudentsTRand(t *testing.T) {
src := rand.New(rand.NewSource(1))
for cas, test := range []struct {
mean []float64
cov *mat.SymDense
nu float64
tolcov float64
}{
{
mean: []float64{0, 0},
cov: mat.NewSymDense(2, []float64{1, 0, 0, 1}),
nu: 4,
tolcov: 1e-2,
},
{
mean: []float64{3, 4},
cov: mat.NewSymDense(2, []float64{5, 1.2, 1.2, 6}),
nu: 8,
tolcov: 1e-2,
},
{
mean: []float64{3, 4, -2},
cov: mat.NewSymDense(3, []float64{5, 1.2, -0.8, 1.2, 6, 0.4, -0.8, 0.4, 2}),
nu: 8,
tolcov: 1e-2,
},
} {
s, ok := NewStudentsT(test.mean, test.cov, test.nu, src)
if !ok {
t.Fatal("bad test")
}
const nSamples = 1e6
dim := len(test.mean)
samps := mat.NewDense(nSamples, dim, nil)
for i := 0; i < nSamples; i++ {
s.Rand(samps.RawRowView(i))
}
estMean := make([]float64, dim)
for i := range estMean {
estMean[i] = stat.Mean(mat.Col(nil, i, samps), nil)
}
mean := s.Mean(nil)
if !floats.EqualApprox(estMean, mean, 1e-2) {
t.Errorf("Mean mismatch: want: %v, got %v", test.mean, estMean)
}
var cov, estCov mat.SymDense
s.CovarianceMatrix(&cov)
stat.CovarianceMatrix(&estCov, samps, nil)
if !mat.EqualApprox(&estCov, &cov, test.tolcov) {
t.Errorf("Case %d: Cov mismatch: want: %v, got %v", cas, &cov, &estCov)
}
}
} | explode_data.jsonl/3127 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 745
} | [
2830,
3393,
30952,
2378,
437,
1155,
353,
8840,
836,
8,
341,
41144,
1669,
10382,
7121,
37595,
7121,
3608,
7,
16,
1171,
2023,
4760,
11,
1273,
1669,
2088,
3056,
1235,
341,
197,
2109,
5307,
256,
3056,
3649,
21,
19,
198,
197,
1444,
859,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLazyCommit(t *testing.T) {
t.Parallel()
ctx := namespaces.WithNamespace(context.Background(), "buildkit-test")
tmpdir, err := ioutil.TempDir("", "cachemanager")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
snapshotter, err := native.NewSnapshotter(filepath.Join(tmpdir, "snapshots"))
require.NoError(t, err)
co, cleanup, err := newCacheManager(ctx, cmOpt{
tmpdir: tmpdir,
snapshotter: snapshotter,
snapshotterName: "native",
})
require.NoError(t, err)
cm := co.manager
active, err := cm.New(ctx, nil, nil, CachePolicyRetain)
require.NoError(t, err)
// after commit mutable is locked
snap, err := active.Commit(ctx)
require.NoError(t, err)
_, err = cm.GetMutable(ctx, active.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, ErrLocked))
// immutable refs still work
snap2, err := cm.Get(ctx, snap.ID())
require.NoError(t, err)
require.Equal(t, snap.ID(), snap2.ID())
err = snap.Release(ctx)
require.NoError(t, err)
err = snap2.Release(ctx)
require.NoError(t, err)
// immutable work after final release as well
snap, err = cm.Get(ctx, snap.ID())
require.NoError(t, err)
require.Equal(t, snap.ID(), snap2.ID())
// active can't be get while immutable is held
_, err = cm.GetMutable(ctx, active.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, ErrLocked))
err = snap.Release(ctx)
require.NoError(t, err)
// after release mutable becomes available again
active2, err := cm.GetMutable(ctx, active.ID())
require.NoError(t, err)
require.Equal(t, active2.ID(), active.ID())
// because ref was took mutable old immutable are cleared
_, err = cm.Get(ctx, snap.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, errNotFound))
snap, err = active2.Commit(ctx)
require.NoError(t, err)
// this time finalize commit
err = snap.(*immutableRef).finalizeLocked(ctx)
require.NoError(t, err)
err = snap.Release(ctx)
require.NoError(t, err)
// mutable is gone after finalize
_, err = cm.GetMutable(ctx, active2.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, errNotFound))
// immutable still works
snap2, err = cm.Get(ctx, snap.ID())
require.NoError(t, err)
require.Equal(t, snap.ID(), snap2.ID())
err = snap2.Release(ctx)
require.NoError(t, err)
// test restarting after commit
active, err = cm.New(ctx, nil, nil, CachePolicyRetain)
require.NoError(t, err)
// after commit mutable is locked
snap, err = active.Commit(ctx)
require.NoError(t, err)
err = cm.Close()
require.NoError(t, err)
cleanup()
// we can't close snapshotter and open it twice (especially, its internal bbolt store)
co, cleanup, err = newCacheManager(ctx, cmOpt{
tmpdir: tmpdir,
snapshotter: snapshotter,
snapshotterName: "native",
})
require.NoError(t, err)
cm = co.manager
snap2, err = cm.Get(ctx, snap.ID())
require.NoError(t, err)
err = snap2.Release(ctx)
require.NoError(t, err)
active, err = cm.GetMutable(ctx, active.ID())
require.NoError(t, err)
_, err = cm.Get(ctx, snap.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, errNotFound))
snap, err = active.Commit(ctx)
require.NoError(t, err)
err = cm.Close()
require.NoError(t, err)
cleanup()
co, cleanup, err = newCacheManager(ctx, cmOpt{
tmpdir: tmpdir,
snapshotter: snapshotter,
snapshotterName: "native",
})
require.NoError(t, err)
defer cleanup()
cm = co.manager
snap2, err = cm.Get(ctx, snap.ID())
require.NoError(t, err)
err = snap2.(*immutableRef).finalizeLocked(ctx)
require.NoError(t, err)
err = snap2.Release(ctx)
require.NoError(t, err)
_, err = cm.GetMutable(ctx, active.ID())
require.Error(t, err)
require.Equal(t, true, errors.Is(err, errNotFound))
} | explode_data.jsonl/3978 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1478
} | [
2830,
3393,
39766,
33441,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
20985,
1669,
58091,
26124,
22699,
5378,
19047,
1507,
330,
5834,
8226,
16839,
5130,
20082,
3741,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
66,
610,
336,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestVersionCheck(t *testing.T) {
f := NewDefaultTestFieldManager(schema.FromAPIVersionAndKind("apps/v1", "Deployment"))
appliedObj := &unstructured.Unstructured{Object: map[string]interface{}{}}
if err := yaml.Unmarshal([]byte(`{
"apiVersion": "apps/v1",
"kind": "Deployment",
}`), &appliedObj.Object); err != nil {
t.Fatalf("error decoding YAML: %v", err)
}
// patch has 'apiVersion: apps/v1' and live version is apps/v1 -> no errors
err := f.Apply(appliedObj, "fieldmanager_test", false)
if err != nil {
t.Fatalf("failed to apply object: %v", err)
}
appliedObj = &unstructured.Unstructured{Object: map[string]interface{}{}}
if err := yaml.Unmarshal([]byte(`{
"apiVersion": "apps/v1beta1",
"kind": "Deployment",
}`), &appliedObj.Object); err != nil {
t.Fatalf("error decoding YAML: %v", err)
}
// patch has 'apiVersion: apps/v2' but live version is apps/v1 -> error
err = f.Apply(appliedObj, "fieldmanager_test", false)
if err == nil {
t.Fatalf("expected an error from mismatched patch and live versions")
}
switch typ := err.(type) {
default:
t.Fatalf("expected error to be of type %T was %T", apierrors.StatusError{}, typ)
case apierrors.APIStatus:
if typ.Status().Code != http.StatusBadRequest {
t.Fatalf("expected status code to be %d but was %d",
http.StatusBadRequest, typ.Status().Code)
}
}
} | explode_data.jsonl/53743 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 514
} | [
2830,
3393,
5637,
3973,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
1532,
3675,
2271,
1877,
2043,
42735,
11439,
7082,
5637,
3036,
10629,
445,
27635,
5457,
16,
497,
330,
75286,
28075,
69898,
3440,
5261,
1669,
609,
359,
51143,
10616,
51143,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFindFitAllError(t *testing.T) {
predicates := map[string]algorithmpredicates.FitPredicate{"true": truePredicate, "matches": matchesPredicate}
nodes := makeNodeList([]string{"3", "2", "1"})
scheduler := makeScheduler(predicates, nodes)
_, predicateMap, err := scheduler.findNodesThatFit(&v1.Pod{}, nodes)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if len(predicateMap) != len(nodes) {
t.Errorf("unexpected failed predicate map: %v", predicateMap)
}
for _, node := range nodes {
t.Run(node.Name, func(t *testing.T) {
failures, found := predicateMap[node.Name]
if !found {
t.Errorf("failed to find node in %v", predicateMap)
}
if len(failures) != 1 || failures[0] != algorithmpredicates.ErrFakePredicate {
t.Errorf("unexpected failures: %v", failures)
}
})
}
} | explode_data.jsonl/6745 | {
"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,
9885,
23346,
2403,
1454,
1155,
353,
8840,
836,
8,
341,
3223,
1151,
24821,
1669,
2415,
14032,
60,
278,
6063,
1307,
1151,
24821,
991,
275,
36329,
4913,
1866,
788,
830,
36329,
11,
330,
19914,
788,
9071,
36329,
532,
79756,
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... | 4 |
func TestPlanningDuringSplitsAndMerges(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
const n = 100
const numNodes = 1
tc := serverutils.StartTestCluster(t, numNodes, base.TestClusterArgs{
ServerArgs: base.TestServerArgs{UseDatabase: "test"},
})
defer tc.Stopper().Stop(context.Background())
sqlutils.CreateTable(
t, tc.ServerConn(0), "t", "x INT PRIMARY KEY, xsquared INT",
n,
sqlutils.ToRowFn(sqlutils.RowIdxFn, func(row int) tree.Datum {
return tree.NewDInt(tree.DInt(row * row))
}),
)
// Start a worker that continuously performs splits in the background.
tc.Stopper().RunWorker(context.Background(), func(ctx context.Context) {
rng, _ := randutil.NewPseudoRand()
cdb := tc.Server(0).DB()
for {
select {
case <-tc.Stopper().ShouldStop():
return
default:
// Split the table at a random row.
var tableDesc *tabledesc.Immutable
require.NoError(t, cdb.Txn(ctx, func(ctx context.Context, txn *kv.Txn) error {
desc, err := catalogkv.UncachedPhysicalAccessor{}.GetObjectDesc(ctx,
txn, tc.Server(0).ClusterSettings(), keys.SystemSQLCodec,
"test", "public", "t",
tree.ObjectLookupFlagsWithRequiredTableKind(tree.ResolveAnyTableKind))
if err != nil {
return err
}
tableDesc = desc.(*tabledesc.Immutable)
return nil
}))
val := rng.Intn(n)
t.Logf("splitting at %d", val)
pik, err := rowenc.TestingMakePrimaryIndexKey(tableDesc, val)
if err != nil {
panic(err)
}
if _, _, err := tc.Server(0).SplitRange(pik); err != nil {
panic(err)
}
}
}
})
sumX, sumXSquared := 0, 0
for x := 1; x <= n; x++ {
sumX += x
sumXSquared += x * x
}
// Run queries continuously in parallel workers. We need more than one worker
// because some queries result in cache updates, and we want to verify
// race conditions when planning during cache updates (see #15249).
const numQueriers = 4
var wg sync.WaitGroup
wg.Add(numQueriers)
for i := 0; i < numQueriers; i++ {
go func(idx int) {
defer wg.Done()
// Create a gosql.DB for this worker.
pgURL, cleanupGoDB := sqlutils.PGUrl(
t, tc.Server(0).ServingSQLAddr(), fmt.Sprintf("%d", idx), url.User(security.RootUser),
)
defer cleanupGoDB()
pgURL.Path = "test"
goDB, err := gosql.Open("postgres", pgURL.String())
if err != nil {
t.Error(err)
return
}
defer func() {
if err := goDB.Close(); err != nil {
t.Error(err)
}
}()
// Limit to 1 connection because we set a session variable.
goDB.SetMaxOpenConns(1)
if _, err := goDB.Exec("SET DISTSQL = ALWAYS"); err != nil {
t.Error(err)
return
}
for run := 0; run < 20; run++ {
t.Logf("querier %d run %d", idx, run)
rows, err := goDB.Query("SELECT sum(x), sum(xsquared) FROM t")
if err != nil {
t.Error(err)
return
}
if !rows.Next() {
t.Errorf("no rows")
return
}
var sum, sumSq int
if err := rows.Scan(&sum, &sumSq); err != nil {
t.Error(err)
return
}
if sum != sumX || sumXSquared != sumSq {
t.Errorf("invalid results: expected %d, %d got %d, %d", sumX, sumXSquared, sum, sumSq)
return
}
if rows.Next() {
t.Errorf("more than one row")
return
}
}
}(i)
}
wg.Wait()
} | explode_data.jsonl/43679 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1479
} | [
2830,
3393,
82980,
16014,
50,
39033,
3036,
44,
2375,
288,
1155,
353,
8840,
836,
8,
341,
16867,
23352,
1944,
36892,
2271,
1155,
8,
741,
16867,
1487,
77940,
1155,
568,
7925,
1155,
692,
4777,
308,
284,
220,
16,
15,
15,
198,
4777,
1629,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServiceCreateFromYAMLWithOverrideError(t *testing.T) {
tempDir, err := ioutil.TempDir("", "kn-file")
defer os.RemoveAll(tempDir)
assert.NilError(t, err)
tempFile := filepath.Join(tempDir, "service.yaml")
err = ioutil.WriteFile(tempFile, []byte(serviceYAML), os.FileMode(0666))
assert.NilError(t, err)
_, _, _, err = fakeServiceCreate([]string{
"service", "create", "foo", "--filename", tempFile, "--image", "foo/bar", "--image", "bar/foo"}, false)
assert.Assert(t, err != nil)
assert.Assert(t, util.ContainsAll(err.Error(), "\"--image\"", "invalid", "argument", "only", "once"))
_, _, _, err = fakeServiceCreate([]string{
"service", "create", "foo", "--filename", tempFile, "--scale", "-1"}, false)
assert.Assert(t, err != nil)
assert.Assert(t, util.ContainsAll(err.Error(), "expected", "0", "<=", "2147483647", "autoscaling.knative.dev/maxScale"))
} | explode_data.jsonl/42466 | {
"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,
1860,
4021,
3830,
56,
31102,
2354,
2177,
1454,
1155,
353,
8840,
836,
8,
341,
16280,
6184,
11,
1848,
1669,
43144,
65009,
6184,
19814,
330,
19095,
14203,
1138,
16867,
2643,
84427,
9758,
6184,
340,
6948,
59678,
1454,
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 Test_StoreCreate(t *testing.T) {
store, mock, close_ := store(t)
defer close_()
mock.ExpectQuery(
"^INSERT INTO variables \\((.+)\\) VALUES \\((.+)\\) RETURNING id$",
).WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(10))
if _, err := store.Create(1, "PGADDR", "host=localhost port=5432"); err != nil {
t.Errorf("unexpected Create error: %s\n", errors.Cause(err))
}
} | explode_data.jsonl/29316 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
92684,
4021,
1155,
353,
8840,
836,
8,
341,
57279,
11,
7860,
11,
3265,
62,
1669,
3553,
1155,
340,
16867,
3265,
62,
2822,
77333,
81893,
2859,
1006,
197,
197,
86490,
12698,
12496,
7332,
24984,
1188,
13,
36197,
3422,
8,
14710,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestFilterParser(t *testing.T) {
testCases := []struct {
filterStr string
wantOK bool
wantFieldName string
wantOp operator
}{
// Supported ops.
{"x<", true, "x", lessThan},
{"x <", true, "x", lessThan},
{"x <", true, "x", lessThan},
{" x < ", true, "x", lessThan},
{"x <=", true, "x", lessEq},
{"x =", true, "x", equal},
{"x >=", true, "x", greaterEq},
{"x >", true, "x", greaterThan},
{"in >", true, "in", greaterThan},
{"in>", true, "in", greaterThan},
// Valid but (currently) unsupported ops.
{"x!=", false, "", 0},
{"x !=", false, "", 0},
{" x != ", false, "", 0},
{"x IN", false, "", 0},
{"x in", false, "", 0},
// Invalid ops.
{"x EQ", false, "", 0},
{"x lt", false, "", 0},
{"x <>", false, "", 0},
{"x >>", false, "", 0},
{"x ==", false, "", 0},
{"x =<", false, "", 0},
{"x =>", false, "", 0},
{"x !", false, "", 0},
{"x ", false, "", 0},
{"x", false, "", 0},
// Quoted and interesting field names.
{"x > y =", true, "x > y", equal},
{"` x ` =", true, " x ", equal},
{`" x " =`, true, " x ", equal},
{`" \"x " =`, true, ` "x `, equal},
{`" x =`, false, "", 0},
{`" x ="`, false, "", 0},
{"` x \" =", false, "", 0},
}
for _, tc := range testCases {
q := NewQuery("foo").Filter(tc.filterStr, 42)
if ok := q.err == nil; ok != tc.wantOK {
t.Errorf("%q: ok=%t, want %t", tc.filterStr, ok, tc.wantOK)
continue
}
if !tc.wantOK {
continue
}
if len(q.filter) != 1 {
t.Errorf("%q: len=%d, want %d", tc.filterStr, len(q.filter), 1)
continue
}
got, want := q.filter[0], filter{tc.wantFieldName, tc.wantOp, 42}
if got != want {
t.Errorf("%q: got %v, want %v", tc.filterStr, got, want)
continue
}
}
} | explode_data.jsonl/50245 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 833
} | [
2830,
3393,
5632,
6570,
1155,
353,
8840,
836,
8,
341,
18185,
37302,
1669,
3056,
1235,
341,
197,
50108,
2580,
257,
914,
198,
197,
50780,
3925,
286,
1807,
198,
197,
50780,
51241,
914,
198,
197,
50780,
7125,
286,
5675,
198,
197,
59403,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 6 |
func TestApi_InvalidHttpStatusCode(t *testing.T) {
server := NewAPITestServer(t, "/", "", 400)
defer server.Close()
client := NewAPITestClient(t, server, "", "")
req := &BaseRequest{
Method: "GET",
Resource: "/",
}
_, err := client.Do(req)
assert.Error(t, err)
} | explode_data.jsonl/50521 | {
"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,
6563,
62,
7928,
2905,
15872,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
1532,
2537,
952,
477,
5475,
1155,
11,
64657,
7342,
220,
19,
15,
15,
340,
16867,
3538,
10421,
2822,
25291,
1669,
1532,
2537,
952,
477,
2959,
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 TestAgentConnectCALeafCert_aclProxyTokenOther(t *testing.T) {
t.Parallel()
require := require.New(t)
a := NewTestAgent(t.Name(), TestACLConfig()+testAllowProxyConfig())
defer a.Shutdown()
// Register a service with a managed proxy
{
reg := &structs.ServiceDefinition{
ID: "test-id",
Name: "test",
Address: "127.0.0.1",
Port: 8000,
Check: structs.CheckType{
TTL: 15 * time.Second,
},
Connect: &structs.ServiceConnect{
Proxy: &structs.ServiceDefinitionConnectProxy{},
},
}
req, _ := http.NewRequest("PUT", "/v1/agent/service/register?token=root", jsonReader(reg))
resp := httptest.NewRecorder()
_, err := a.srv.AgentRegisterService(resp, req)
require.NoError(err)
require.Equal(200, resp.Code, "body: %s", resp.Body.String())
}
// Register another service
{
reg := &structs.ServiceDefinition{
ID: "wrong-id",
Name: "wrong",
Address: "127.0.0.1",
Port: 8000,
Check: structs.CheckType{
TTL: 15 * time.Second,
},
Connect: &structs.ServiceConnect{
Proxy: &structs.ServiceDefinitionConnectProxy{},
},
}
req, _ := http.NewRequest("PUT", "/v1/agent/service/register?token=root", jsonReader(reg))
resp := httptest.NewRecorder()
_, err := a.srv.AgentRegisterService(resp, req)
require.NoError(err)
require.Equal(200, resp.Code, "body: %s", resp.Body.String())
}
// Get the proxy token from the agent directly, since there is no API.
proxy := a.State.Proxy("wrong-id-proxy")
require.NotNil(proxy)
token := proxy.ProxyToken
require.NotEmpty(token)
req, _ := http.NewRequest("GET", "/v1/agent/connect/ca/leaf/test?token="+token, nil)
resp := httptest.NewRecorder()
_, err := a.srv.AgentConnectCALeafCert(resp, req)
require.Error(err)
require.True(acl.IsErrPermissionDenied(err))
} | explode_data.jsonl/33654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 733
} | [
2830,
3393,
16810,
14611,
49533,
68,
2577,
36934,
63692,
16219,
3323,
11409,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
17957,
1669,
1373,
7121,
1155,
340,
11323,
1669,
1532,
2271,
16810,
1155,
2967,
1507,
3393,
55393,
2648,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestJrpc_GetNodeInfo(t *testing.T) {
api := new(mocks.QueueProtocolAPI)
J := newJrpc(api)
req := &types.ReqNil{}
var result interface{}
node := &vt.Validator{
Address: []byte("aaa"),
PubKey: []byte("bbb"),
VotingPower: 10,
Accum: -1,
}
set := &vt.ValidatorSet{
Validators: []*vt.Validator{node},
Proposer: node,
}
api.On("QueryConsensusFunc", "tendermint", "NodeInfo", req).Return(set, nil)
err := J.GetNodeInfo(req, &result)
assert.Nil(t, err)
assert.EqualValues(t, set.Validators, result)
} | explode_data.jsonl/80573 | {
"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,
41,
29414,
13614,
1955,
1731,
1155,
353,
8840,
836,
8,
341,
54299,
1669,
501,
1255,
25183,
50251,
20689,
7082,
340,
17100,
1669,
501,
41,
29414,
24827,
340,
24395,
1669,
609,
9242,
2817,
80,
19064,
16094,
2405,
1102,
3749,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestServerConnStateNew(t *testing.T) {
sawNew := false // if the test is buggy, we'll race on this variable.
srv := &Server{
ConnState: func(c net.Conn, state ConnState) {
if state == StateNew {
sawNew = true // testing that this write isn't racy
}
},
Handler: HandlerFunc(func(w ResponseWriter, r *Request) {}), // irrelevant
}
srv.Serve(&oneConnListener{
conn: &rwTestConn{
Reader: strings.NewReader("GET / HTTP/1.1\r\nHost: foo\r\n\r\n"),
Writer: ioutil.Discard,
},
})
if !sawNew { // testing that this read isn't racy
t.Error("StateNew not seen")
}
} | explode_data.jsonl/22476 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 232
} | [
2830,
3393,
5475,
9701,
1397,
3564,
1155,
353,
8840,
836,
8,
341,
1903,
672,
3564,
1669,
895,
442,
421,
279,
1273,
374,
79311,
11,
582,
3278,
6957,
389,
419,
3890,
624,
1903,
10553,
1669,
609,
5475,
515,
197,
197,
9701,
1397,
25,
29... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMerge(t *testing.T) {
m1, m2 := testArtifacts()
m1.Merge(m2)
if len(m1) != 4 {
t.Errorf("expected %d got %d", 4, len(m1))
}
// coverage for short bail out condition
m1.Merge(nil)
if len(m1) != 4 {
t.Errorf("expected %d got %d", 4, len(m1))
}
} | explode_data.jsonl/78452 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 129
} | [
2830,
3393,
52096,
1155,
353,
8840,
836,
8,
1476,
2109,
16,
11,
296,
17,
1669,
1273,
9286,
26401,
741,
2109,
16,
93855,
1255,
17,
692,
743,
2422,
1255,
16,
8,
961,
220,
19,
341,
197,
3244,
13080,
445,
7325,
1018,
67,
2684,
1018,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestBufferedOverlap(t *testing.T) {
test(t, []testSequence{
{
in: layers.TCP{
SrcPort: 1,
DstPort: 2,
Seq: 1007,
BaseLayer: layers.BaseLayer{Payload: []byte{7, 8, 9, 0, 1, 2, 3, 4, 5}},
},
want: []Reassembly{},
},
{
in: layers.TCP{
SrcPort: 1,
DstPort: 2,
Seq: 1010,
BaseLayer: layers.BaseLayer{Payload: []byte{0, 1, 2, 3, 4, 5, 6, 7}},
},
want: []Reassembly{},
},
{
in: layers.TCP{
SrcPort: 1,
DstPort: 2,
SYN: true,
Seq: 1000,
BaseLayer: layers.BaseLayer{Payload: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}},
},
want: []Reassembly{
Reassembly{
Start: true,
Bytes: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0},
},
Reassembly{
Bytes: []byte{1, 2, 3, 4, 5},
},
Reassembly{
Bytes: []byte{6, 7},
},
},
},
})
} | explode_data.jsonl/9654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 558
} | [
2830,
3393,
4095,
291,
82171,
1155,
353,
8840,
836,
8,
972,
18185,
1155,
11,
3056,
1944,
14076,
1666,
197,
197,
1666,
298,
17430,
25,
13617,
836,
7123,
1666,
571,
7568,
1287,
7084,
25,
256,
220,
16,
1871,
571,
10957,
267,
7084,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSearchFileAndExtractExif(t *testing.T) {
testImageFilepath := getTestImageFilepath()
// Returns a slice starting with the EXIF data and going to the end of the
// image.
rawExif, err := SearchFileAndExtractExif(testImageFilepath)
log.PanicIf(err)
testExifData := getTestExifData()
if bytes.Compare(rawExif[:len(testExifData)], testExifData) != 0 {
t.Fatalf("found EXIF data not correct")
}
} | explode_data.jsonl/70132 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 146
} | [
2830,
3393,
5890,
1703,
3036,
28959,
840,
333,
1155,
353,
8840,
836,
8,
341,
18185,
1906,
1703,
2343,
1669,
633,
2271,
1906,
1703,
2343,
2822,
197,
322,
5184,
264,
15983,
5916,
448,
279,
4063,
2773,
821,
323,
2087,
311,
279,
835,
315,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestGetTaskDependsLogic(t *testing.T) {
testTasks := []*wfv1.DAGTask{
{
Name: "task-1",
},
{
Name: "task-2",
},
{
Name: "task-3",
},
}
ctx := &testContext{
testTasks: testTasks,
}
task := &wfv1.DAGTask{Depends: "(task-1 || task-2.Succeeded) && !task-3"}
depends := getTaskDependsLogic(task, ctx)
assert.Equal(t, "(task-1 || task-2.Succeeded) && !task-3", depends)
task = &wfv1.DAGTask{Dependencies: []string{"task-1", "task-2"}}
depends = getTaskDependsLogic(task, ctx)
assert.Equal(t, "(task-1.Succeeded || task-1.Skipped || task-1.Daemoned) && (task-2.Succeeded || task-2.Skipped || task-2.Daemoned)", depends)
} | explode_data.jsonl/48534 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 312
} | [
2830,
3393,
1949,
6262,
7839,
1412,
26751,
1155,
353,
8840,
836,
8,
341,
18185,
25449,
1669,
29838,
86,
27890,
16,
909,
1890,
6262,
515,
197,
197,
515,
298,
21297,
25,
330,
8202,
12,
16,
756,
197,
197,
1583,
197,
197,
515,
298,
2129... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestWriteTokenToFile(t *testing.T) {
token := `eyJhbGciOiJSUzI1NiJ9.eyJmaWxlcyI6W3sibmFtZSI6ImJ1bmRsZS8ubWFuaWZlc3QiLCJoYXNoIjoiZWUwZWRiZGZkMjgzNTBjNDk2ZjA4ODI3Y2E1Y2VhYjgwMzA2NzI0YjYyZGY1ZjY0MDRlNzBjYjc2NjYxNWQ5ZCIsImFsZ29yaXRobSI6IlNIQTI1NiJ9LHsibmFtZSI6ImJ1bmRsZS9odHRwL2V4YW1wbGUvYXV0aHovYXV0aHoucmVnbyIsImhhc2giOiI2MDJiZTcwMWIyYmE4ZTc3YTljNTNmOWIzM2QwZTkwM2MzNGMwMGMzMDkzM2Y2NDZiYmU3NGI3YzE2NGY2OGM2IiwiYWxnb3JpdGhtIjoiU0hBMjU2In0seyJuYW1lIjoiYnVuZGxlL3JvbGVzL2JpbmRpbmcvZGF0YS5qc29uIiwiaGFzaCI6ImIxODg1NTViZjczMGVlNDdkZjBiY2Y4MzVlYTNmNTQ1MjlmMzc4N2Y0ODQxZjFhZGE2MDM5M2RhYWZhZmJkYzciLCJhbGdvcml0aG0iOiJTSEEyNTYifV0sImtleWlkIjoiZm9vIiwic2NvcGUiOiJyZWFkIn0.YojuPnGWutdlDL7lwFGBXqPfDtxOG2BuZmShN5zm-G9zfMprI1AMqKDoPoNv4tuCGIBNXwoNsYHYiK538CHfJEfY1v4iDX3JFEWQlwx_CfJWDonwqT9SY9tHUW7PUUrI_WgJXZ5zei8RAMYMymKSb9hpSAtfGg_PU0kZr52WzjbPUj4SRiB19Swi61r0CFXYjbfx3GDJdjrGTNBSWrUCMrdhHYLEWqJPfSQ-fYfRrgQVhq3BJLwJJe66dgBEGnHEgA7XMuxkNIOv7mj3Y_EChbv2tjrD9NJPekDcYH1zCEc4BycHjNCcsGiQXDE6sFtoNZiCXLB2D0sLqUnBx4TCw27wTPfcOuL2KauLPahZitnH5mYvQD8NI76Pm4NSyJfevwdWjSsrT7vf0DCLS-dU6r9dJ79xM_hJU7136CT8ARcmSrk-EvCqfkrH2c4WwZyAzdyyyFumMZh4CYc2vcC7ap0NANHJT193fTud1i23mx1PBslwXdsIqXvBGlTbR7nb9o661m-B_mxbHMkG4nIeoGpZoaBJw8RVaA6-4D55gtk8aaMyLJIlIIlV2_AKOLk3nPG3ACHiLSndasLDOIRIYkCluIEaM2FLEEPEtJfKNR6e1K-EK2TvNKMDAEUtJW71ggOuGQ3b5otYOoVVENJLwm-PsO7qb2Tq6PyAquI3ExU`
expected := make(map[string]interface{})
expected["signatures"] = []string{token}
files := map[string]string{}
test.WithTempFS(files, func(rootDir string) {
err := writeTokenToFile(token, rootDir)
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
bs, err := ioutil.ReadFile(filepath.Join(rootDir, ".signatures.json"))
if err != nil {
t.Fatalf("Unexpected error %v", err)
}
expectedBytes, err := json.MarshalIndent(expected, "", " ")
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(expectedBytes, bs) {
t.Fatal("Unexpected content in \".signatures.json\" file")
}
})
} | explode_data.jsonl/46762 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1280
} | [
2830,
3393,
7985,
3323,
41550,
1155,
353,
8840,
836,
8,
1476,
43947,
1669,
1565,
84609,
49039,
38,
5855,
81096,
12545,
52,
89,
40,
16,
56494,
41,
24,
13,
84609,
1728,
54,
24310,
11130,
40,
21,
54,
18,
82,
579,
76,
37,
83,
57,
1381... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestBindParam(t *testing.T) {
e := New()
req := httptest.NewRequest(GET, "/", nil)
rec := httptest.NewRecorder()
c := e.NewContext(req, rec)
c.SetPath("/users/:id/:name")
c.SetParamNames("id", "name")
c.SetParamValues("1", "Jon Snow")
u := new(user)
err := c.Bind(u)
if assert.NoError(t, err) {
assert.Equal(t, 1, u.ID)
assert.Equal(t, "Jon Snow", u.Name)
}
// Second test for the absence of a param
c2 := e.NewContext(req, rec)
c2.SetPath("/users/:id")
c2.SetParamNames("id")
c2.SetParamValues("1")
u = new(user)
err = c2.Bind(u)
if assert.NoError(t, err) {
assert.Equal(t, 1, u.ID)
assert.Equal(t, "", u.Name)
}
// Bind something with param and post data payload
body := bytes.NewBufferString(`{ "name": "Jon Snow" }`)
e2 := New()
req2 := httptest.NewRequest(POST, "/", body)
req2.Header.Set(HeaderContentType, MIMEApplicationJSON)
rec2 := httptest.NewRecorder()
c3 := e2.NewContext(req2, rec2)
c3.SetPath("/users/:id")
c3.SetParamNames("id")
c3.SetParamValues("1")
u = new(user)
err = c3.Bind(u)
if assert.NoError(t, err) {
assert.Equal(t, 1, u.ID)
assert.Equal(t, "Jon Snow", u.Name)
}
} | explode_data.jsonl/72327 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 512
} | [
2830,
3393,
9950,
2001,
1155,
353,
8840,
836,
8,
341,
7727,
1669,
1532,
741,
24395,
1669,
54320,
70334,
75274,
62918,
11,
64657,
2092,
340,
67904,
1669,
54320,
70334,
7121,
47023,
741,
1444,
1669,
384,
7121,
1972,
6881,
11,
1395,
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... | 4 |
func TestMakeStatefulSetSpecAdditionalPeers(t *testing.T) {
a := monitoringv1.Alertmanager{}
a.Spec.Version = "v0.15.3"
replicas := int32(1)
a.Spec.Replicas = &replicas
a.Spec.AdditionalPeers = []string{"example.com"}
statefulSet, err := makeStatefulSetSpec(&a, defaultTestConfig)
if err != nil {
t.Fatal(err)
}
peerFound := false
amArgs := statefulSet.Template.Spec.Containers[0].Args
for _, arg := range amArgs {
if strings.Contains(arg, "example.com") {
peerFound = true
}
}
if !peerFound {
t.Fatal("Additional peers were not found.")
}
} | explode_data.jsonl/25248 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 219
} | [
2830,
3393,
8078,
1397,
1262,
1649,
8327,
29019,
10197,
388,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
16558,
85,
16,
40143,
13297,
16094,
11323,
36473,
35842,
284,
330,
85,
15,
13,
16,
20,
13,
18,
698,
73731,
52210,
1669,
526,
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... | 5 |
func TestLogHandler_DeleteLogEntries(t *testing.T) {
type fields struct {
logManager *fake.ILogManagerMock
}
tests := []struct {
name string
fields fields
request *http.Request
wantStatus int
wantDeleteLogsParams *models.DeleteLogParams
}{
{
name: "delete logs - no filter",
fields: fields{
&fake.ILogManagerMock{
DeleteLogEntriesFunc: func(params models.DeleteLogParams) error {
return nil
},
},
},
request: httptest.NewRequest(http.MethodDelete, "/log", nil),
wantStatus: http.StatusOK,
wantDeleteLogsParams: &models.DeleteLogParams{},
},
{
name: "delete logs - with filter",
fields: fields{
&fake.ILogManagerMock{
DeleteLogEntriesFunc: func(filter models.DeleteLogParams) error {
return nil
},
},
},
request: httptest.NewRequest(http.MethodDelete, "/log?nextPageKey=1&pageSize=2&integrationId=my-id&fromTime=from&beforeTime=to", nil),
wantStatus: http.StatusOK,
wantDeleteLogsParams: &models.DeleteLogParams{
LogFilter: models.LogFilter{
IntegrationID: "my-id",
FromTime: "from",
BeforeTime: "to",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
lh := handler.NewLogHandler(tt.fields.logManager)
router := gin.Default()
router.DELETE("/log", func(c *gin.Context) {
lh.DeleteLogEntries(c)
})
w := performRequest(router, tt.request)
require.Equal(t, tt.wantStatus, w.Code)
if tt.wantDeleteLogsParams != nil {
require.Len(t, tt.fields.logManager.DeleteLogEntriesCalls(), 1)
require.Equal(t, *tt.wantDeleteLogsParams, tt.fields.logManager.DeleteLogEntriesCalls()[0].Params)
}
})
}
} | explode_data.jsonl/71971 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 815
} | [
2830,
3393,
2201,
3050,
57418,
2201,
24533,
1155,
353,
8840,
836,
8,
341,
13158,
5043,
2036,
341,
197,
6725,
2043,
353,
30570,
13,
64909,
2043,
11571,
198,
197,
532,
78216,
1669,
3056,
1235,
341,
197,
11609,
338,
914,
198,
197,
55276,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestImporter_Close(t *testing.T) {
tree, err := NewMutableTree(db.NewMemDB(), 0)
require.NoError(t, err)
importer, err := tree.Import(1)
require.NoError(t, err)
err = importer.Add(&ExportNode{Key: []byte("key"), Value: []byte("value"), Version: 1, Height: 0})
require.NoError(t, err)
importer.Close()
has := tree.Has([]byte("key"))
require.False(t, has)
importer.Close()
} | explode_data.jsonl/25880 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 152
} | [
2830,
3393,
77289,
68185,
1155,
353,
8840,
836,
8,
341,
51968,
11,
1848,
1669,
1532,
11217,
6533,
9791,
7121,
18816,
3506,
1507,
220,
15,
340,
17957,
35699,
1155,
11,
1848,
340,
21918,
261,
11,
1848,
1669,
4916,
67275,
7,
16,
340,
179... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestReplaceAndAppendEnvVars(t *testing.T) {
var (
d = []string{"HOME=/"}
o = []string{"HOME=/root", "TERM=xterm"}
)
env := ReplaceOrAppendEnvValues(d, o)
if len(env) != 2 {
t.Fatalf("expected len of 2 got %d", len(env))
}
if env[0] != "HOME=/root" {
t.Fatalf("expected HOME=/root got '%s'", env[0])
}
if env[1] != "TERM=xterm" {
t.Fatalf("expected TERM=xterm got '%s'", env[1])
}
} | explode_data.jsonl/57525 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 189
} | [
2830,
3393,
23107,
3036,
23877,
14359,
28305,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
2698,
284,
3056,
917,
4913,
27546,
28,
11225,
532,
197,
22229,
284,
3056,
917,
4913,
27546,
23286,
2888,
497,
330,
49349,
25387,
4991,
16707,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestUpdate(
//valid
validNewPodTemplate("foo"),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*api.PodTemplate)
object.Template.Spec.NodeSelector = map[string]string{"a": "b"}
return object
},
)
} | explode_data.jsonl/1748 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 157
} | [
2830,
3393,
4289,
1155,
353,
8840,
836,
8,
341,
197,
16172,
11,
3538,
1669,
501,
5793,
1155,
340,
16867,
3538,
836,
261,
34016,
1155,
340,
16867,
5819,
38047,
57011,
9626,
741,
18185,
1669,
19424,
1944,
7121,
1155,
11,
5819,
38047,
340,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestOuterLinkV2WithMetadataPointerContainerDecode(t *testing.T) {
bytes, err := MsgpackEncode(map[string]interface{}{
"O": []byte{0x01, 0x02},
})
require.NoError(t, err)
var o outerLinkV2WithMetadataPointerContainer
err = MsgpackDecode(&o, bytes)
requireErrorHasSuffix(t, errCodecDecodeSelf, err)
} | explode_data.jsonl/72247 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 123
} | [
2830,
3393,
51322,
3939,
53,
17,
2354,
14610,
9084,
4502,
32564,
1155,
353,
8840,
836,
8,
341,
70326,
11,
1848,
1669,
24205,
4748,
32535,
9147,
14032,
31344,
67066,
197,
197,
1,
46,
788,
3056,
3782,
90,
15,
87,
15,
16,
11,
220,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestEth_GetBlockByNumber(t *testing.T) {
param := []interface{}{"0x1", false}
rpcRes := call(t, "eth_getBlockByNumber", param)
block := make(map[string]interface{})
err := json.Unmarshal(rpcRes.Result, &block)
require.NoError(t, err)
require.Equal(t, "0x", block["extraData"].(string))
require.Equal(t, []interface{}{}, block["uncles"].([]interface{}))
} | explode_data.jsonl/869 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 145
} | [
2830,
3393,
65390,
13614,
4713,
1359,
2833,
1155,
353,
8840,
836,
8,
341,
36037,
1669,
3056,
4970,
6257,
4913,
15,
87,
16,
497,
895,
532,
7000,
3992,
1061,
1669,
1618,
1155,
11,
330,
769,
3062,
4713,
1359,
2833,
497,
1685,
692,
47996,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDescribeImage(t *testing.T) {
tests := []struct {
image imagev1.Image
want []string
}{
{
image: imagev1.Image{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
DockerImageMetadata: runtime.RawExtension{Object: &dockerv10.DockerImage{}},
},
want: []string{"Name:.+test"},
},
{
image: imagev1.Image{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
DockerImageLayers: []imagev1.ImageLayer{
{Name: "sha256:1234", LayerSize: 3409},
{Name: "sha256:5678", LayerSize: 1024},
},
DockerImageMetadata: runtime.RawExtension{Object: &dockerv10.DockerImage{}},
},
want: []string{
"Layers:.+3.409kB\\ssha256:1234",
"1.024kB\\ssha256:5678",
"Image Size:.+0B in 2 layers",
},
},
{
image: imagev1.Image{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
DockerImageLayers: []imagev1.ImageLayer{
{Name: "sha256:1234", LayerSize: 3409},
{Name: "sha256:5678", LayerSize: 1024},
},
DockerImageMetadata: runtime.RawExtension{Object: &dockerv10.DockerImage{Size: 4430}},
},
want: []string{
"Layers:.+3.409kB\\ssha256:1234",
"1.024kB\\ssha256:5678",
"Image Size:.+4.43kB in 2 layers",
},
},
}
for i := range tests {
tt := tests[i]
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
out, err := DescribeImage(&tt.image, tt.image.Name)
if err != nil {
t.Fatal(err)
}
for _, match := range tt.want {
if got := out; !regexp.MustCompile(match).MatchString(got) {
t.Errorf("%s\nshould contain %q", got, match)
}
}
})
}
} | explode_data.jsonl/6488 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 786
} | [
2830,
3393,
74785,
1906,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
31426,
2168,
85,
16,
7528,
198,
197,
50780,
220,
3056,
917,
198,
197,
59403,
197,
197,
515,
298,
31426,
25,
2168,
85,
16,
7528,
515,
571,
2381... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestDB_CreateAndGet(t *testing.T) {
tests := []struct {
name string
quote Quote
wantErr bool
}{
{"Create007", Quote{Author: "007", Text: "Shaken, not stirred", Source: "Diamonds Are Forever"}, false},
{"Update007", Quote{Author: "007", Text: "Stirred, not shaken", Source: "Graphite is ephemeral"}, true},
{"CreateGopher", Quote{Author: "Gopher", Text: "Clear is better than clever.", Source: "Go Proverbs"}, false},
}
path := "testdata/creategetdb"
// Setup
d, err := Open(path)
if err != nil {
t.Fatalf("Open(): Cannot open %s", path)
}
// Test
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err = d.Create(&tt.quote)
if (err != nil) != tt.wantErr {
t.Errorf("DB.Create(): %v", err)
return
}
if tt.wantErr {
// We tested the error case for Create().
// Get and DeepEqual are not relevant anymore
// and so we can end this loop iteration.
return
}
q, err := d.Get(tt.quote.Author)
if q == nil || err != nil {
t.Errorf("DB.Get(): Cannot get record for %s: error = %v", tt.quote.Author, err)
return
}
if !reflect.DeepEqual(*q, tt.quote) {
t.Errorf("Expected: %#v, got: %#v", *q, tt.quote)
}
})
}
// Teardown
err = d.Close()
if err != nil {
t.Errorf("Cannot close %s", path)
}
err = os.Remove(path)
if err != nil {
t.Errorf("Cannot remove %s", path)
}
} | explode_data.jsonl/38330 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 589
} | [
2830,
3393,
3506,
34325,
97726,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
11609,
262,
914,
198,
197,
197,
2949,
256,
24535,
198,
197,
50780,
7747,
1807,
198,
197,
59403,
197,
197,
4913,
4021,
15,
15,
22,
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... | 6 |
func TestAppWithSecrets(t *testing.T) {
closer, client, err := ArgoCDClientset.NewApplicationClient()
assert.NoError(t, err)
defer io.Close(closer)
Given(t).
Path("secrets").
When().
CreateApp().
Sync().
Then().
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
res := FailOnErr(client.GetResource(context.Background(), &applicationpkg.ApplicationResourceRequest{
Namespace: app.Spec.Destination.Namespace,
Kind: kube.SecretKind,
Group: "",
Name: &app.Name,
Version: "v1",
ResourceName: "test-secret",
})).(*applicationpkg.ApplicationResourceResponse)
assetSecretDataHidden(t, res.Manifest)
manifests, err := client.GetManifests(context.Background(), &applicationpkg.ApplicationManifestQuery{Name: &app.Name})
errors.CheckError(err)
for _, manifest := range manifests.Manifests {
assetSecretDataHidden(t, manifest)
}
diffOutput := FailOnErr(RunCli("app", "diff", app.Name)).(string)
assert.Empty(t, diffOutput)
// make sure resource update error does not print secret details
_, err = RunCli("app", "patch-resource", "test-app-with-secrets", "--resource-name", "test-secret",
"--kind", "Secret", "--patch", `{"op": "add", "path": "/data", "value": "hello"}'`,
"--patch-type", "application/json-patch+json")
require.Error(t, err)
assert.Contains(t, err.Error(), fmt.Sprintf("failed to patch Secret %s/test-secret", DeploymentNamespace()))
assert.NotContains(t, err.Error(), "username")
assert.NotContains(t, err.Error(), "password")
// patch secret and make sure app is out of sync and diff detects the change
FailOnErr(KubeClientset.CoreV1().Secrets(DeploymentNamespace()).Patch(context.Background(),
"test-secret", types.JSONPatchType, []byte(`[
{"op": "remove", "path": "/data/username"},
{"op": "add", "path": "/stringData", "value": {"password": "foo"}}
]`), metav1.PatchOptions{}))
}).
When().
Refresh(RefreshTypeNormal).
Then().
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
And(func(app *Application) {
diffOutput, err := RunCli("app", "diff", app.Name)
assert.Error(t, err)
assert.Contains(t, diffOutput, "username: ++++++++")
assert.Contains(t, diffOutput, "password: ++++++++++++")
// local diff should ignore secrets
diffOutput = FailOnErr(RunCli("app", "diff", app.Name, "--local", "testdata/secrets")).(string)
assert.Empty(t, diffOutput)
// ignore missing field and make sure diff shows no difference
app.Spec.IgnoreDifferences = []ResourceIgnoreDifferences{{
Kind: kube.SecretKind, JSONPointers: []string{"/data"},
}}
FailOnErr(client.UpdateSpec(context.Background(), &applicationpkg.ApplicationUpdateSpecRequest{Name: &app.Name, Spec: app.Spec}))
}).
When().
Refresh(RefreshTypeNormal).
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
diffOutput := FailOnErr(RunCli("app", "diff", app.Name)).(string)
assert.Empty(t, diffOutput)
}).
// verify not committed secret also ignore during diffing
When().
WriteFile("secret3.yaml", `
apiVersion: v1
kind: Secret
metadata:
name: test-secret3
stringData:
username: test-username`).
Then().
And(func(app *Application) {
diffOutput := FailOnErr(RunCli("app", "diff", app.Name, "--local", "testdata/secrets")).(string)
assert.Empty(t, diffOutput)
})
} | explode_data.jsonl/35630 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1293
} | [
2830,
3393,
2164,
2354,
19773,
82,
1155,
353,
8840,
836,
8,
341,
1444,
69215,
11,
2943,
11,
1848,
1669,
1644,
3346,
6484,
2959,
746,
7121,
4988,
2959,
741,
6948,
35699,
1155,
11,
1848,
340,
16867,
6399,
10421,
1337,
69215,
692,
9600,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestThrottleMiddleware(t *testing.T) {
t.Parallel()
var (
topic = "test_topic"
channel = "test_channel"
errChan = make(chan error)
messageNum int32
currentMessageNum int32
messageThrottled int32
// testing expect
messageExpect = "test middleware throttling"
// to make sure that error is being sent back
errNil = errors.New("error should be nil")
)
// we are using fake consumer, this means the concurrency is always 1
// and the number of message buffer is 1 * _bufferMultiplier.
_buffMultiplier := 10
_concurrency := 1
consumer, err := fakensq.NewFakeConsumer(fakensq.ConsumerConfig{Topic: topic, Channel: channel, Concurrency: _concurrency, BufferMultiplier: _buffMultiplier})
if err != nil {
t.Error(err)
return
}
producer := fakensq.NewFakeProducer(consumer)
wc, err := WrapConsumers(ConsumerConfig{
LookupdsAddr: []string{"testing"},
}, consumer)
if err != nil {
t.Error(err)
return
}
tm := ThrottleMiddleware{TimeDelay: time.Millisecond * 100}
// use throttle middleware
wc.Use(
tm.Throttle,
)
wc.Handle(topic, channel, func(ctx context.Context, message *Message) error {
atomic.AddInt32(¤tMessageNum, 1)
if string(message.Message.Body) != messageExpect {
err := fmt.Errorf("epecting message %s but got %s", messageExpect, string(message.Message.Body))
errChan <- err
return err
}
// This means this is the first message, sleep to make other message to wait
// because if the handler is not finished, the worker is not back to consume state
// to make sure the buffer is filled first before consuming more message.
if currentMessageNum == 1 {
time.Sleep(time.Millisecond * 100)
}
// Check whether a throttled message is exists
// this message should exists because throttle middleware is used.
if message.Info.Throttled == 1 {
atomic.AddInt32(&messageThrottled, 1)
errChan <- errNil
return nil
}
// this means the test have reach the end of message
if currentMessageNum == messageNum {
if messageThrottled < 1 {
err := errors.New("message is never throttled")
errChan <- err
return err
}
errChan <- errNil
return nil
}
errChan <- errNil
return err
})
if err := wc.Start(); err != nil {
t.Error(err)
return
}
// Note that in this test, we set the bufferMultiplier to 10.
// Send messages as much as (bufferMultiplier/2) + 3 to tirgger the throttle mechanism.
//
// c = consumed
// d = done
// m = message in buffer
// <nil> = no message, buffer is empty
//
// _buffMultiplier/2 + 3 = 8 messages
// | m | m | m | m | m | m | m | m | <nil> | <nil> |
// 1 2 3 4 5 6 7 8 9 10
// message_length: 8
//
//
// When the program start, the message will be consumed into the worker right away
// then the worker will pause themself for a while, so message is not consumed.
// At this point, this is the look in the buffer:
// | m | m | m | m | m | m | m | m | <nil> | <nil> | <nil > |
// c 1 2 3 4 5 6 7 8 9 10
// Message_length: 7
//
// At this point when consuming more message which is message number 1, the buffer will become:
// | m | m | m | m | m | m | m | m | <nil> | <nil> | <nil > | <nil> |
// d c 1 2 3 4 5 6 7 8 9 10
// message_length: 6
//
// When consuming the message, evaluation of the buffer length will kick in,
// this is where the evaluator for thorttle knows that the number of messages
// is more than half of the buffer size. Then throttle mechanism will be invoked
// this is why, with lower number of messages the test won't pass,
// because it depends on messages number in the buffer.
for i := 1; i <= (_buffMultiplier/2)+3; i++ {
if err := producer.Publish(topic, []byte(messageExpect)); err != nil {
t.Error(err)
return
}
messageNum++
}
for i := 1; i <= int(messageNum); i++ {
err = <-errChan
if err != errNil {
t.Error(err)
return
}
}
close(errChan)
if err := wc.Stop(); err != nil {
t.Error(err)
return
}
} | explode_data.jsonl/29310 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1526
} | [
2830,
3393,
1001,
27535,
24684,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
2822,
2405,
2399,
197,
3244,
24810,
1797,
284,
330,
1944,
31414,
698,
197,
71550,
1843,
284,
330,
1944,
14571,
698,
197,
9859,
46019,
1843,
284,
1281,
3519... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMenuView_Erase_erases_one_line_per_entry(t *testing.T) {
out := bytes.NewBufferString("")
view := main.NewMenuView([]*main.MenuEntry{
{Key: 'a', Label: "command a"},
{Key: 'b', Label: "command b"},
})
assert.NoError(t, view.Erase(out))
assert.Equal(t, "\033[A\033[2K\033[A\033[2K", out.String())
} | explode_data.jsonl/25748 | {
"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,
3514,
851,
2089,
10632,
80604,
2264,
11667,
6528,
5678,
9078,
1155,
353,
8840,
836,
8,
341,
13967,
1669,
5820,
7121,
4095,
703,
31764,
36867,
1669,
1887,
7121,
3514,
851,
85288,
3817,
19621,
5874,
515,
197,
197,
90,
1592,
25... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestController_removeFinalizer(t *testing.T) {
t.Run("There is no finalizer", func(t *testing.T) {
lvg := lvgCR1
lvg.Finalizers = nil
c := setup(t, node1ID, lvg)
res, err := c.removeFinalizer(&lvg)
assert.Nil(t, err)
assert.Equal(t, ctrl.Result{Requeue: true}, res)
})
t.Run("Remove finalizer successfully", func(t *testing.T) {
lvg := lvgCR1
lvg.Finalizers = []string{lvgFinalizer}
c := setup(t, node1ID, lvg)
res, err := c.removeFinalizer(&lvg)
assert.Nil(t, err)
assert.Equal(t, ctrl.Result{}, res)
})
t.Run("Update LogicalVolumeGroup CR failed", func(t *testing.T) {
c := setup(t, node1ID)
lvg := lvgCR1
lvg.Finalizers = []string{lvgFinalizer}
res, err := c.removeFinalizer(&lvg)
assert.NotNil(t, err)
assert.Equal(t, ctrl.Result{Requeue: true}, res)
})
} | explode_data.jsonl/51728 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 356
} | [
2830,
3393,
2051,
18193,
19357,
3135,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
3862,
374,
902,
1590,
3135,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
8810,
7239,
1669,
326,
7239,
8973,
16,
198,
197,
8810,
7239,
991,
977,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNoSendNoDigest(t *testing.T) {
assert.Len(t, runLocalShardTest(t,
change(user1, alarm1, wire.StatusCritical, time1),
change(user2, alarm2, wire.StatusWarning, time2),
change(user3, alarm3, wire.StatusCleared, time3),
change(user1, alarm1, wire.StatusCritical, time4),
), 0)
} | explode_data.jsonl/3243 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
2753,
11505,
2753,
45217,
1155,
353,
8840,
836,
8,
341,
6948,
65819,
1155,
11,
1598,
7319,
2016,
567,
2271,
1155,
345,
197,
68380,
4277,
16,
11,
16624,
16,
11,
9067,
10538,
42008,
11,
882,
16,
1326,
197,
68380,
4277,
17,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestFromCLIContext_SetsDurationFlags(t *testing.T) {
runAppTest(t, []string{
"--file-polling-interval=42s",
"--hard-timeout=2h",
"--log-timeout=11m",
"--script-upload-timeout=2m",
"--startup-timeout=3m",
"--build-cache-fetch-timeout=7m",
"--build-cache-push-timeout=8m",
}, func(c *cli.Context) error {
cfg := FromCLIContext(c)
assert.Equal(t, 42*time.Second, cfg.FilePollingInterval, "FilePollingInterval")
assert.Equal(t, 2*time.Hour, cfg.HardTimeout, "HardTimeout")
assert.Equal(t, 11*time.Minute, cfg.LogTimeout, "LogTimeout")
assert.Equal(t, 2*time.Minute, cfg.ScriptUploadTimeout, "ScriptUploadTimeout")
assert.Equal(t, 3*time.Minute, cfg.StartupTimeout, "StartupTimeout")
assert.Equal(t, 7*time.Minute, cfg.BuildCacheFetchTimeout, "BuildCacheFetchTimeout")
assert.Equal(t, 8*time.Minute, cfg.BuildCachePushTimeout, "BuildCachePushTimeout")
return nil
})
} | explode_data.jsonl/6896 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 374
} | [
2830,
3393,
3830,
63959,
1972,
1098,
1415,
12945,
9195,
1155,
353,
8840,
836,
8,
341,
56742,
2164,
2271,
1155,
11,
3056,
917,
515,
197,
197,
74757,
1192,
2268,
965,
287,
20052,
6152,
28,
19,
17,
82,
756,
197,
197,
74757,
18703,
7246,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_Export_Curl_GenCurl(t *testing.T) {
req, err := http.NewRequest("POST", "http://127.0.0.1:8080/test/path?q1=v1", strings.NewReader("wo shi body"))
req.Header.Add("h1", "v1")
req.Header.Add("h1", "v2")
assert.NoError(t, err)
assert.NoError(t, GenCurl(req, true, os.Stdout))
} | explode_data.jsonl/43931 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 132
} | [
2830,
3393,
62,
16894,
920,
1085,
2646,
268,
34,
1085,
1155,
353,
8840,
836,
8,
341,
24395,
11,
1848,
1669,
1758,
75274,
445,
2946,
497,
330,
1254,
1110,
16,
17,
22,
13,
15,
13,
15,
13,
16,
25,
23,
15,
23,
15,
12697,
50976,
4378... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGlCanvas_ResizeWithModalPopUpOverlay(t *testing.T) {
c := NewCanvas().(*mobileCanvas)
c.SetContent(widget.NewLabel("Content"))
popup := widget.NewModalPopUp(widget.NewLabel("PopUp"), c)
popupBgSize := fyne.NewSize(200, 200)
popup.Show()
popup.Resize(popupBgSize)
canvasSize := fyne.NewSize(600, 700)
c.resize(canvasSize)
// get popup content padding dynamically
popupContentPadding := popup.MinSize().Subtract(popup.Content.MinSize())
assert.Equal(t, popupBgSize.Subtract(popupContentPadding), popup.Content.Size())
assert.Equal(t, canvasSize, popup.Size())
} | explode_data.jsonl/43166 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 220
} | [
2830,
3393,
31541,
18226,
62,
30561,
2354,
8080,
11598,
2324,
32755,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
1532,
18226,
1005,
4071,
14933,
18226,
692,
1444,
4202,
2762,
34690,
7121,
2476,
445,
2762,
28075,
3223,
27735,
1669,
9086,
712... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPBStandardDeviation(t *testing.T) {
tests := []struct {
inputs []float64
weights []int64
isValidator []bool
standardDeviation sdk.Dec
}{
{
// Supermajority one number
[]float64{1.0, 2.0, 10.0, 100000.0},
[]int64{1, 1, 100, 1},
[]bool{true, true, true, true},
sdk.NewDecWithPrec(4999500036300, OracleDecPrecision),
},
{
// Adding fake validator doesn't change outcome
[]float64{1.0, 2.0, 10.0, 100000.0, 10000000000},
[]int64{1, 1, 100, 1, 10000},
[]bool{true, true, true, true, false},
sdk.NewDecWithPrec(447213595075100600, OracleDecPrecision),
},
{
// Tie votes
[]float64{1.0, 2.0, 3.0, 4.0},
[]int64{1, 100, 100, 1},
[]bool{true, true, true, true},
sdk.NewDecWithPrec(122474500, OracleDecPrecision),
},
{
// No votes
[]float64{},
[]int64{},
[]bool{true, true, true, true},
sdk.NewDecWithPrec(0, 0),
},
}
base := math.Pow10(OracleDecPrecision)
for _, tc := range tests {
pb := ExchangeRateBallot{}
for i, input := range tc.inputs {
valAddr := sdk.ValAddress(secp256k1.GenPrivKey().PubKey().Address())
power := tc.weights[i]
if !tc.isValidator[i] {
power = 0
}
vote := NewVoteForTally(
sdk.NewDecWithPrec(int64(input*base), int64(OracleDecPrecision)),
core.MicroSDRDenom,
valAddr,
power,
)
pb = append(pb, vote)
}
require.Equal(t, tc.standardDeviation, pb.StandardDeviation(pb.WeightedMedianWithAssertion()))
}
} | explode_data.jsonl/38395 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 703
} | [
2830,
3393,
40637,
19781,
14592,
7101,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
22427,
82,
310,
3056,
3649,
21,
19,
198,
197,
197,
13327,
1843,
3056,
396,
21,
19,
198,
197,
19907,
14256,
981,
3056,
2641,
198,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestMakePostgresqlUserRespository_Ds(t *testing.T) {
db, mock, _, err := makeAndTestPgSmallRepo()
defer db.Close()
ok(t, err)
ok(t, mock.ExpectationsWereMet())
} | explode_data.jsonl/3815 | {
"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,
8078,
4133,
81624,
1474,
1061,
3099,
1557,
82,
1155,
353,
8840,
836,
8,
341,
20939,
11,
7860,
11,
8358,
1848,
1669,
1281,
3036,
2271,
82540,
25307,
25243,
741,
16867,
2927,
10421,
741,
59268,
1155,
11,
1848,
340,
59268,
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 |
func Test_UnsuccessfulDeploy_Execution_Works(t *testing.T) {
release := models.MockRelease(t)
release.Timeout = to.Intp(-10) // This will cause immediate timeout
// Should end in Alert Bad Thing Happened State
stateMachine := createTestStateMachine(t, models.MockAwsClients(release))
exec, err := stateMachine.Execute(release)
output := exec.Output
assert.Error(t, err)
assert.Equal(t, "FailureClean", output["Error"])
assert.Equal(t, []string{
"Validate",
"Lock",
"ValidateResources",
"Deploy",
"ReleaseLockFailure",
"FailureClean",
}, exec.Path())
} | explode_data.jsonl/3579 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 197
} | [
2830,
3393,
40687,
30950,
69464,
62,
20294,
2763,
73302,
1155,
353,
8840,
836,
8,
341,
17200,
1623,
1669,
4119,
24664,
16077,
1155,
340,
17200,
1623,
63977,
284,
311,
7371,
79,
4080,
16,
15,
8,
442,
1096,
686,
5240,
13922,
9632,
271,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRecreate_acceptorFail(t *testing.T) {
var deployment *kapi.ReplicationController
scaler := &cmdtest.FakeScaler{}
strategy := &RecreateDeploymentStrategy{
out: &bytes.Buffer{},
errOut: &bytes.Buffer{},
decoder: kapi.Codecs.UniversalDecoder(),
retryTimeout: 1 * time.Second,
retryPeriod: 1 * time.Millisecond,
scaler: scaler,
eventClient: fake.NewSimpleClientset().Core(),
}
acceptor := &testAcceptor{
acceptFn: func(deployment *kapi.ReplicationController) error {
return fmt.Errorf("rejected")
},
}
oldDeployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]))
deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(registered.GroupOrDie(kapi.GroupName).GroupVersions[0]))
strategy.rcClient = &fakeControllerClient{deployment: deployment}
err := strategy.DeployWithAcceptor(oldDeployment, deployment, 2, acceptor)
if err == nil {
t.Fatalf("expected a deployment failure")
}
t.Logf("got expected error: %v", err)
if e, a := 1, len(scaler.Events); e != a {
t.Fatalf("expected %d scale calls, got %d", e, a)
}
if e, a := uint(1), scaler.Events[0].Size; e != a {
t.Errorf("expected scale up to %d, got %d", e, a)
}
} | explode_data.jsonl/19097 | {
"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,
693,
3182,
35728,
269,
19524,
1155,
353,
8840,
836,
8,
341,
2405,
23172,
353,
74,
2068,
2817,
79,
1693,
2051,
198,
1903,
63084,
1669,
609,
8710,
1944,
991,
726,
59553,
31483,
11355,
10228,
1669,
609,
693,
3182,
75286,
19816,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGist_String(t *testing.T) {
v := Gist{
ID: String(""),
Description: String(""),
Public: Bool(false),
Owner: &User{},
Files: nil,
Comments: Int(0),
HTMLURL: String(""),
GitPullURL: String(""),
GitPushURL: String(""),
NodeID: String(""),
}
want := `github.Gist{ID:"", Description:"", Public:false, Owner:github.User{}, Files:map[], Comments:0, HTMLURL:"", GitPullURL:"", GitPushURL:"", NodeID:""}`
if got := v.String(); got != want {
t.Errorf("Gist.String = %v, want %v", got, want)
}
} | explode_data.jsonl/33236 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
38,
380,
31777,
1155,
353,
8840,
836,
8,
341,
5195,
1669,
479,
380,
515,
197,
29580,
25,
688,
923,
445,
4461,
197,
47414,
25,
923,
445,
4461,
197,
73146,
25,
414,
12608,
3576,
1326,
197,
197,
13801,
25,
981,
609,
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... | 2 |
func TestUnexported(t *testing.T) {
var pub Public
pub.S = "S"
pub.T = pub.A[:]
v := ValueOf(&pub)
isValid(v.Elem().Field(0))
isValid(v.Elem().Field(1))
isValid(v.Elem().Field(2))
isValid(v.Elem().FieldByName("X"))
isValid(v.Elem().FieldByName("Y"))
isValid(v.Elem().FieldByName("Z"))
isValid(v.Type().Method(0).Func)
m, _ := v.Type().MethodByName("M")
isValid(m.Func)
m, _ = v.Type().MethodByName("P")
isValid(m.Func)
isNonNil(v.Elem().Field(0).Interface())
isNonNil(v.Elem().Field(1).Interface())
isNonNil(v.Elem().Field(2).Field(2).Index(0))
isNonNil(v.Elem().FieldByName("X").Interface())
isNonNil(v.Elem().FieldByName("Y").Interface())
isNonNil(v.Elem().FieldByName("Z").Interface())
isNonNil(v.Elem().FieldByName("S").Index(0).Interface())
isNonNil(v.Type().Method(0).Func.Interface())
m, _ = v.Type().MethodByName("P")
isNonNil(m.Func.Interface())
var priv Private
v = ValueOf(&priv)
isValid(v.Elem().Field(0))
isValid(v.Elem().Field(1))
isValid(v.Elem().FieldByName("x"))
isValid(v.Elem().FieldByName("y"))
shouldPanic(func() { v.Elem().Field(0).Interface() })
shouldPanic(func() { v.Elem().Field(1).Interface() })
shouldPanic(func() { v.Elem().FieldByName("x").Interface() })
shouldPanic(func() { v.Elem().FieldByName("y").Interface() })
shouldPanic(func() { v.Type().Method(0) })
} | explode_data.jsonl/29586 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 581
} | [
2830,
3393,
1806,
1533,
291,
1155,
353,
8840,
836,
8,
341,
2405,
6675,
3066,
198,
62529,
808,
284,
330,
50,
698,
62529,
836,
284,
6675,
875,
77204,
5195,
1669,
5162,
2124,
2099,
9585,
340,
19907,
4088,
3747,
5142,
3433,
1005,
1877,
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 TestRouter_NewRouter_WithAutoMethodOptionsEnabled(t *testing.T) {
mainRouter := NewRouter(RouterConfig{
EnableAutoMethodOptions: true,
})
_ = mainRouter.Register(http.MethodGet, "/some", testHandlerFunc)
_ = mainRouter.Register(http.MethodDelete, "/some", testHandlerFunc)
req, _ := http.NewRequest(http.MethodGet, "/some", nil)
getResponse := httptest.NewRecorder()
mainRouter.ServeHTTP(getResponse, req)
assertEqual(t, http.StatusOK, getResponse.Code)
req, _ = http.NewRequest(http.MethodDelete, "/some", nil)
deleteResponse := httptest.NewRecorder()
mainRouter.ServeHTTP(deleteResponse, req)
assertEqual(t, http.StatusOK, deleteResponse.Code)
req, _ = http.NewRequest(http.MethodOptions, "/some", nil)
optionsResponse := httptest.NewRecorder()
mainRouter.ServeHTTP(optionsResponse, req)
assertEqual(t, http.StatusNoContent, optionsResponse.Code)
assertStringContains(t, "GET", optionsResponse.Header().Get("Allow"))
assertStringContains(t, "DELETE", optionsResponse.Header().Get("Allow"))
assertStringContains(t, "OPTIONS", optionsResponse.Header().Get("Allow"))
} | explode_data.jsonl/31747 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 366
} | [
2830,
3393,
9523,
39582,
9523,
62,
2354,
13253,
3523,
3798,
5462,
1155,
353,
8840,
836,
8,
341,
36641,
9523,
1669,
1532,
9523,
2785,
2676,
2648,
515,
197,
197,
11084,
13253,
3523,
3798,
25,
830,
345,
197,
8824,
197,
62,
284,
1887,
952... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCreation(t *testing.T) {
data := core.NewMemoryRws()
subject, err := core.NewPageStorage(data, noOpSync)
assertNoError(t, err)
err = subject.InitialiseDb()
assertNoError(t, err)
} | explode_data.jsonl/28105 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 73
} | [
2830,
3393,
32701,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
6200,
7121,
10642,
49,
8915,
741,
28624,
583,
11,
1848,
1669,
6200,
7121,
2665,
5793,
2592,
11,
902,
7125,
12154,
340,
6948,
2753,
1454,
1155,
11,
1848,
692,
9859,
284,
3832... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRcServer(t *testing.T) {
opt := rc.DefaultOpt
opt.HTTPOptions.ListenAddr = testBindAddress
opt.HTTPOptions.Template = testTemplate
opt.Enabled = true
opt.Serve = true
opt.Files = testFs
mux := http.NewServeMux()
rcServer := newServer(context.Background(), &opt, mux)
assert.NoError(t, rcServer.Serve())
defer func() {
rcServer.Close()
rcServer.Wait()
}()
testURL := rcServer.Server.URL()
// Do the simplest possible test to check the server is alive
// Do it a few times to wait for the server to start
var resp *http.Response
var err error
for i := 0; i < 10; i++ {
resp, err = http.Get(testURL + "file.txt")
if err == nil {
break
}
time.Sleep(10 * time.Millisecond)
}
require.NoError(t, err)
body, err := ioutil.ReadAll(resp.Body)
_ = resp.Body.Close()
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
assert.Equal(t, http.StatusOK, resp.StatusCode)
assert.Equal(t, "this is file1.txt\n", string(body))
} | explode_data.jsonl/12958 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 372
} | [
2830,
3393,
49,
66,
5475,
1155,
353,
8840,
836,
8,
341,
64838,
1669,
10192,
13275,
21367,
198,
64838,
13,
2545,
51,
2045,
1300,
68334,
13986,
284,
1273,
9950,
4286,
198,
64838,
13,
2545,
51,
2045,
1300,
52530,
284,
1273,
7275,
198,
64... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCheckRestoreNoLock(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
datafile := filepath.Join("testdata", "small-repo.tar.gz")
rtest.SetupTarTestFixture(t, env.base, datafile)
err := filepath.Walk(env.repo, func(p string, fi os.FileInfo, e error) error {
if e != nil {
return e
}
return os.Chmod(p, fi.Mode() & ^(os.FileMode(0222)))
})
rtest.OK(t, err)
env.gopts.NoLock = true
testRunCheck(t, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
if len(snapshotIDs) == 0 {
t.Fatalf("found no snapshots")
}
testRunRestore(t, env.gopts, filepath.Join(env.base, "restore"), snapshotIDs[0])
} | explode_data.jsonl/43568 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
3973,
56284,
2753,
11989,
1155,
353,
8840,
836,
8,
341,
57538,
11,
21290,
1669,
448,
2271,
12723,
1155,
340,
16867,
21290,
2822,
8924,
1192,
1669,
26054,
22363,
445,
92425,
497,
330,
9004,
5504,
5368,
28048,
20963,
1138,
7000,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestConsumes(test *testing.T) {
schema, err := parseRDLString(`
resource Any GET "/foo" {
consumes application/json, application/xml , text/plain // some comment
}
`)
if err != nil {
test.Errorf("cannot parse valid RDL with consumes: %v", err)
} else {
if len(schema.Resources) != 1 {
test.Errorf("Did not parse expected number of resources: %v", schema)
}
r := schema.Resources[0]
if len(r.Consumes) != 3 {
test.Errorf("Did not parse expected number of consumes: %v", len(r.Consumes))
}
if r.Consumes[0] != "application/json" {
test.Errorf("Did not parse consumes value correctly: %v (expected: application/json)", r.Consumes[0])
}
if r.Consumes[1] != "application/xml" {
test.Errorf("Did not parse consumes value correctly: %v (expected: application/xml)", r.Consumes[1])
}
if r.Consumes[2] != "text/plain" {
test.Errorf("Did not parse consumes value correctly: %v (expected: text/plain)", r.Consumes[2])
}
if r.Comment != "some comment" {
test.Errorf("Did not parse trailing comment correctly: %v", r.Comment)
}
}
} | explode_data.jsonl/74350 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 399
} | [
2830,
3393,
41966,
288,
8623,
353,
8840,
836,
8,
341,
1903,
3416,
11,
1848,
1669,
4715,
49,
16524,
703,
61528,
9233,
5765,
7890,
3521,
7975,
1,
341,
220,
59506,
3766,
8931,
11,
3766,
36524,
262,
1154,
256,
1467,
36971,
256,
442,
1045,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 8 |
func TestIntegrationBasicAuth(t *testing.T) {
if testing.Short() || testRundeckRunning() == false {
t.Skip("skipping integration testing")
}
client, err := rundeck.NewBasicAuthClient(testIntegrationUsername, testIntegrationPassword, testIntegrationURL)
require.NoError(t, err)
info, infoErr := client.GetSystemInfo()
require.NoError(t, infoErr)
require.NotNil(t, info)
} | explode_data.jsonl/63130 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 131
} | [
2830,
3393,
52464,
15944,
5087,
1155,
353,
8840,
836,
8,
341,
220,
421,
7497,
55958,
368,
1369,
1273,
49,
28865,
377,
18990,
368,
621,
895,
341,
197,
3244,
57776,
445,
4886,
5654,
17590,
7497,
1138,
197,
630,
25291,
11,
1848,
1669,
43... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestListLocksHandler(t *testing.T) {
adminTestBed, err := prepareAdminXLTestBed()
if err != nil {
t.Fatal("Failed to initialize a single node XL backend for admin handler tests.")
}
defer adminTestBed.TearDown()
// Initialize admin peers to make admin RPC calls.
globalMinioAddr = "127.0.0.1:9000"
initGlobalAdminPeers(mustGetNewEndpointList("http://127.0.0.1:9000/d1"))
testCases := []struct {
bucket string
prefix string
duration string
expectedStatus int
}{
// Test 1 - valid testcase
{
bucket: "mybucket",
prefix: "myobject",
duration: "1s",
expectedStatus: http.StatusOK,
},
// Test 2 - invalid duration
{
bucket: "mybucket",
prefix: "myprefix",
duration: "invalidDuration",
expectedStatus: http.StatusBadRequest,
},
// Test 3 - invalid bucket name
{
bucket: `invalid\\Bucket`,
prefix: "myprefix",
duration: "1h",
expectedStatus: http.StatusBadRequest,
},
// Test 4 - invalid prefix
{
bucket: "mybucket",
prefix: `invalid\\Prefix`,
duration: "1h",
expectedStatus: http.StatusBadRequest,
},
}
for i, test := range testCases {
queryVal := mkLockQueryVal(test.bucket, test.prefix, test.duration)
req, err := newTestRequest("GET", "/?"+queryVal.Encode(), 0, nil)
if err != nil {
t.Fatalf("Test %d - Failed to construct list locks request - %v", i+1, err)
}
req.Header.Set(minioAdminOpHeader, "list")
cred := serverConfig.GetCredential()
err = signRequestV4(req, cred.AccessKey, cred.SecretKey)
if err != nil {
t.Fatalf("Test %d - Failed to sign list locks request - %v", i+1, err)
}
rec := httptest.NewRecorder()
adminTestBed.mux.ServeHTTP(rec, req)
if test.expectedStatus != rec.Code {
t.Errorf("Test %d - Expected HTTP status code %d but received %d", i+1, test.expectedStatus, rec.Code)
}
}
} | explode_data.jsonl/7920 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 827
} | [
2830,
3393,
852,
11989,
82,
3050,
1155,
353,
8840,
836,
8,
341,
64394,
2271,
15686,
11,
1848,
1669,
10549,
7210,
36530,
2271,
15686,
741,
743,
1848,
961,
2092,
341,
197,
3244,
26133,
445,
9408,
311,
9468,
264,
3175,
2436,
29881,
19163,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestTransactionWithBlock(t *testing.T) {
// rollback
err := DB.Transaction(func(tx *gorm.DB) error {
u := User{Name: "transcation"}
if err := tx.Save(&u).Error; err != nil {
t.Errorf("No error should raise")
}
if err := tx.First(&User{}, "name = ?", "transcation").Error; err != nil {
t.Errorf("Should find saved record")
}
return errors.New("the error message")
})
if err.Error() != "the error message" {
t.Errorf("Transaction return error will equal the block returns error")
}
if err := DB.First(&User{}, "name = ?", "transcation").Error; err == nil {
t.Errorf("Should not find record after rollback")
}
// commit
DB.Transaction(func(tx *gorm.DB) error {
u2 := User{Name: "transcation-2"}
if err := tx.Save(&u2).Error; err != nil {
t.Errorf("No error should raise")
}
if err := tx.First(&User{}, "name = ?", "transcation-2").Error; err != nil {
t.Errorf("Should find saved record")
}
return nil
})
if err := DB.First(&User{}, "name = ?", "transcation-2").Error; err != nil {
t.Errorf("Should be able to find committed record")
}
// panic will rollback
assertPanic(t, func() {
DB.Transaction(func(tx *gorm.DB) error {
u3 := User{Name: "transcation-3"}
if err := tx.Save(&u3).Error; err != nil {
t.Errorf("No error should raise")
}
if err := tx.First(&User{}, "name = ?", "transcation-3").Error; err != nil {
t.Errorf("Should find saved record")
}
panic("force panic")
})
})
if err := DB.First(&User{}, "name = ?", "transcation-3").Error; err == nil {
t.Errorf("Should not find record after panic rollback")
}
} | explode_data.jsonl/28043 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 617
} | [
2830,
3393,
8070,
2354,
4713,
1155,
353,
8840,
836,
8,
341,
197,
322,
60414,
198,
9859,
1669,
5952,
29284,
18552,
27301,
353,
73281,
22537,
8,
1465,
341,
197,
10676,
1669,
2657,
63121,
25,
330,
1458,
64882,
16707,
197,
743,
1848,
1669,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestTCPAckBeforeAcceptV4(t *testing.T) {
c := context.New(t, defaultMTU)
defer c.Cleanup()
c.Create(-1)
if err := c.EP.Bind(tcpip.FullAddress{Port: context.StackPort}); err != nil {
t.Fatal("Bind failed:", err)
}
if err := c.EP.Listen(10); err != nil {
t.Fatal("Listen failed:", err)
}
irs, iss := executeHandshake(t, c, context.TestPort, false /* synCookiesInUse */)
// Send data before accepting the connection.
c.SendPacket([]byte{1, 2, 3, 4}, &context.Headers{
SrcPort: context.TestPort,
DstPort: context.StackPort,
Flags: header.TCPFlagAck,
SeqNum: irs + 1,
AckNum: iss + 1,
})
// Receive ACK for the data we sent.
checker.IPv4(t, c.GetPacket(), checker.TCP(
checker.DstPort(context.TestPort),
checker.TCPFlags(header.TCPFlagAck),
checker.TCPSeqNum(uint32(iss+1)),
checker.TCPAckNum(uint32(irs+5))))
} | explode_data.jsonl/75937 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 365
} | [
2830,
3393,
49896,
55559,
10227,
16646,
53,
19,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
2266,
7121,
1155,
11,
1638,
8505,
52,
340,
16867,
272,
727,
60639,
2822,
1444,
7251,
4080,
16,
692,
743,
1848,
1669,
272,
5142,
47,
32451,
98203... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestHighLevelEncoder_determineConsecutiveDigitCount(t *testing.T) {
msg := []byte(" 0123bc")
if r := HighLevelEncoder_determineConsecutiveDigitCount(msg, 0); r != 0 {
t.Fatalf("determineConsecutiveDigitCount = %v, expect 0", r)
}
if r := HighLevelEncoder_determineConsecutiveDigitCount(msg, 2); r != 0 {
t.Fatalf("determineConsecutiveDigitCount = %v, expect 0", r)
}
if r := HighLevelEncoder_determineConsecutiveDigitCount(msg, 3); r != 4 {
t.Fatalf("determineConsecutiveDigitCount = %v, expect 4", r)
}
if r := HighLevelEncoder_determineConsecutiveDigitCount(msg, 6); r != 1 {
t.Fatalf("determineConsecutiveDigitCount = %v, expect 1", r)
}
if r := HighLevelEncoder_determineConsecutiveDigitCount(msg, 7); r != 0 {
t.Fatalf("determineConsecutiveDigitCount = %v, expect 0", r)
}
} | explode_data.jsonl/32231 | {
"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,
11976,
4449,
19921,
814,
24308,
1109,
85780,
36420,
2507,
1155,
353,
8840,
836,
8,
341,
21169,
1669,
3056,
3782,
445,
256,
220,
15,
16,
17,
18,
8904,
1138,
743,
435,
1669,
5124,
4449,
19921,
814,
24308,
1109,
85780,
36420,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEtcdCreateFilesWithFlags(t *testing.T) {
var tests = []struct {
command string
additionalFlags []string
expectedFiles []string
}{
{
command: "local",
expectedFiles: []string{"etcd.yaml"},
additionalFlags: []string{},
},
}
for _, test := range tests {
// Create temp folder for the test case
tmpdir := testutil.SetupTempDir(t)
defer os.RemoveAll(tmpdir)
// Get subcommands working in the temporary directory
subCmds := getEtcdSubCommands(tmpdir, phaseTestK8sVersion)
// Execute the subcommand
certDirFlag := fmt.Sprintf("--cert-dir=%s", tmpdir)
allFlags := append(test.additionalFlags, certDirFlag)
cmdtestutil.RunSubCommand(t, subCmds, test.command, allFlags...)
// Checks that requested files are there
testutil.AssertFileExists(t, tmpdir, test.expectedFiles...)
}
} | explode_data.jsonl/33444 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 314
} | [
2830,
3393,
31860,
4385,
4021,
10809,
2354,
9195,
1155,
353,
8840,
836,
8,
1476,
2405,
7032,
284,
3056,
1235,
341,
197,
45566,
260,
914,
198,
197,
12718,
3005,
9195,
3056,
917,
198,
197,
42400,
10809,
256,
3056,
917,
198,
197,
59403,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestNewReconciler(t *testing.T) {
ctx, _ := SetupFakeContext(t)
ctx = webhook.WithOptions(ctx, webhook.Options{})
tests := []struct {
name string
selectorOption ReconcilerOption
wantSelector metav1.LabelSelector
}{
{
name: "no selector, use default",
wantSelector: ExclusionSelector,
},
{
name: "ExclusionSelector option",
selectorOption: WithSelector(ExclusionSelector),
wantSelector: ExclusionSelector,
},
{
name: "InclusionSelector option",
selectorOption: WithSelector(InclusionSelector),
wantSelector: InclusionSelector,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := kubeclient.Get(ctx)
mwhInformer := mwhinformer.Get(ctx)
secretInformer := secretinformer.Get(ctx)
withContext := func(ctx context.Context, b Bindable) (context.Context, error) {
return ctx, nil
}
var r *Reconciler
if tt.selectorOption == nil {
r = NewReconciler("foo", "/bar", "foosec", client, mwhInformer.Lister(), secretInformer.Lister(), withContext)
} else {
r = NewReconciler("foo", "/bar", "foosec", client, mwhInformer.Lister(), secretInformer.Lister(), withContext, tt.selectorOption)
}
if diff := cmp.Diff(r.selector, tt.wantSelector); diff != "" {
t.Errorf("Wrong selector configured. Got: %+v, want: %+v, diff: %v", r.selector, tt.wantSelector, diff)
}
})
}
} | explode_data.jsonl/42552 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 604
} | [
2830,
3393,
3564,
693,
40446,
5769,
1155,
353,
8840,
836,
8,
341,
20985,
11,
716,
1669,
18626,
52317,
1972,
1155,
340,
20985,
284,
75268,
26124,
3798,
7502,
11,
75268,
22179,
37790,
78216,
1669,
3056,
1235,
341,
197,
11609,
1843,
914,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestSetLimit(t *testing.T) {
src, err := Parse("select foo, bar from baz limit 4")
if err != nil {
t.Error(err)
}
limit := src.(*Select).Limit
dst, err := Parse("select * from t")
if err != nil {
t.Error(err)
}
dst.(*Select).SetLimit(limit)
buf := NewTrackedBuffer(nil)
dst.Format(buf)
want := "select * from t limit 4"
if buf.String() != want {
t.Errorf("limit: %q, want %s", buf.String(), want)
}
dst, err = Parse("select * from t union select * from s")
if err != nil {
t.Error(err)
}
dst.(*Union).SetLimit(limit)
buf = NewTrackedBuffer(nil)
dst.Format(buf)
want = "select * from t union select * from s limit 4"
if buf.String() != want {
t.Errorf("order: %q, want %s", buf.String(), want)
}
} | explode_data.jsonl/3372 | {
"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,
1649,
16527,
1155,
353,
8840,
836,
8,
341,
41144,
11,
1848,
1669,
14775,
445,
1742,
15229,
11,
3619,
504,
50247,
3930,
220,
19,
1138,
743,
1848,
961,
2092,
341,
197,
3244,
6141,
3964,
340,
197,
532,
8810,
2353,
1669,
2286,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestPlatform_GetTokenListByAddress(t *testing.T) {
server := httptest.NewServer(createMockedAPI())
defer server.Close()
p := Init(server.URL, "")
tokens, err := p.GetTokenListByAddress("bnb1w7puzjxu05ktc5zvpnzkndt6tyl720nsutzvpg")
assert.Nil(t, err)
res, err := json.Marshal(tokens)
assert.Nil(t, err)
assert.Equal(t, wantedTokens, string(res))
tokens, err = p.GetTokenListByAddress("bnb1w7puzjxu05ktc5zvpnzkndt6tyl720nsutzvpg")
assert.Nil(t, err)
res, err = json.Marshal(tokens)
assert.Nil(t, err)
assert.Equal(t, wantedTokens, string(res))
tokens, err = p.GetTokenListByAddress("bnb1w7puzjxu05ktc5zvpnzkndt6tyl720nsutzvpg")
assert.Nil(t, err)
res, err = json.Marshal(tokens)
assert.Nil(t, err)
assert.Equal(t, wantedTokens, string(res))
} | explode_data.jsonl/48633 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 349
} | [
2830,
3393,
17296,
13614,
3323,
852,
1359,
4286,
1155,
353,
8840,
836,
8,
341,
41057,
1669,
54320,
70334,
7121,
5475,
32602,
11571,
291,
7082,
2398,
16867,
3538,
10421,
741,
3223,
1669,
15690,
21421,
20893,
11,
85617,
3244,
9713,
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 |
func TestPeerIsolation(t *testing.T) {
// Scenario:
// Start 3 peers (peer0, peer1, peer2). Set peer1 as the bootstrap peer for all.
// Stop peer0 and peer1 for a while, start them again and test if peer2 still gets full membership
config := defaultTestConfig
// Use a smaller AliveExpirationTimeout than the default to reduce the running time of the test.
config.AliveExpirationTimeout = 2 * config.AliveTimeInterval
peersNum := 3
bootPeers := []string{bootPeer(7121)}
instances := []*gossipInstance{}
var inst *gossipInstance
// Start all peers and wait for full membership
for i := 0; i < peersNum; i++ {
id := fmt.Sprintf("d%d", i)
inst = createDiscoveryInstanceCustomConfig(7120+i, id, bootPeers, config)
instances = append(instances, inst)
}
assertMembership(t, instances, peersNum-1)
// Stop the first 2 peers so the third peer would stay alone
stopInstances(t, instances[:peersNum-1])
assertMembership(t, instances[peersNum-1:], 0)
// Sleep the same amount of time as it takes to remove a message from the aliveMsgStore (aliveMsgTTL)
// Add a second as buffer
time.Sleep(config.AliveExpirationTimeout*DefMsgExpirationFactor + time.Second)
// Start again the first 2 peers and wait for all the peers to get full membership.
// Especially, we want to test that peer2 won't be isolated
for i := 0; i < peersNum-1; i++ {
id := fmt.Sprintf("d%d", i)
inst = createDiscoveryInstanceCustomConfig(7120+i, id, bootPeers, config)
instances[i] = inst
}
assertMembership(t, instances, peersNum-1)
} | explode_data.jsonl/62280 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 496
} | [
2830,
3393,
30888,
3872,
34962,
1155,
353,
8840,
836,
8,
341,
197,
322,
58663,
510,
197,
322,
5145,
220,
18,
25029,
320,
16537,
15,
11,
14397,
16,
11,
14397,
17,
568,
2573,
14397,
16,
438,
279,
26925,
14397,
369,
678,
624,
197,
322,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestProvisionDeviceExternal(t *testing.T) {
t.Parallel()
var contextMatcher = func(tenantID string) interface{} {
return mock.MatchedBy(func(ctx context.Context) bool {
id := identity.FromContext(ctx)
if tenantID == "" && id == nil {
return true
} else {
if id != nil {
if id.Tenant == tenantID {
return true
}
}
}
return false
})
}
type testCase struct {
Name string
Request interface{}
TenantID string
App func(t *testing.T, self *testCase) *mocks.App
StatusCode int
RspHeaders http.Header
Error error
}
const uuidHexRegex = `[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}`
testCases := []testCase{{
Name: "ok",
Request: model.ExternalDeviceRequest{
ExternalDevice: model.ExternalDevice{
ID: "ef20a8b1-ef00-4e59-9a8a-fe5ef0be6b92",
Provider: "acme inc.",
Name: "niceAndShinySBC",
},
IDData: map[string]interface{}{
"niceAndShiny": true,
},
},
App: func(t *testing.T, self *testCase) *mocks.App {
app := new(mocks.App)
req := self.Request.(model.ExternalDeviceRequest)
app.On("ProvisionDevice",
contextMatcher(self.TenantID),
mock.AnythingOfType("*model.Device")).
Run(func(args mock.Arguments) {
dev := args.Get(1).(*model.Device)
assert.Equal(t, req.ID, dev.External.ID)
assert.Equal(t, req.IDData, dev.IdDataStruct)
assert.Equal(t, req.Provider, dev.External.Provider)
}).Return(nil)
return app
},
StatusCode: http.StatusCreated,
RspHeaders: http.Header{
"Location": {v2uriDevices + "/" + uuidHexRegex},
},
}, {
Name: "ok, id_data from external ID",
Request: model.ExternalDeviceRequest{
ExternalDevice: model.ExternalDevice{
ID: "ef20a8b1-ef00-4e59-9a8a-fe5ef0be6b92",
Provider: "acme inc.",
Name: "niceAndShinySBC",
},
},
TenantID: "123456789012345678901234",
App: func(t *testing.T, self *testCase) *mocks.App {
app := new(mocks.App)
req := self.Request.(model.ExternalDeviceRequest)
app.On("ProvisionDevice",
contextMatcher(self.TenantID),
mock.AnythingOfType("*model.Device")).
Run(func(args mock.Arguments) {
dev := args.Get(1).(*model.Device)
assert.Equal(t, req.ID, dev.External.ID)
assert.Equal(t, req.ExternalDevice.IDData(), dev.IdDataStruct)
assert.Equal(t, req.Provider, dev.External.Provider)
}).Return(nil)
return app
},
StatusCode: http.StatusCreated,
RspHeaders: http.Header{
"Location": {v2uriDevices + "/" + uuidHexRegex},
},
}, {
Name: "error, malformed request",
Request: []byte("this is gonna be a problem..."),
App: func(t *testing.T, self *testCase) *mocks.App {
return new(mocks.App)
},
StatusCode: http.StatusBadRequest,
Error: errors.New("malformed request body"),
}, {
Name: "error, invalid request parameters",
Request: model.ExternalDeviceRequest{
ExternalDevice: model.ExternalDevice{
ID: "ef20a8b1-ef00-4e59-9a8a-fe5ef0be6b92",
},
},
App: func(t *testing.T, self *testCase) *mocks.App {
return new(mocks.App)
},
StatusCode: http.StatusBadRequest,
Error: errors.New("invalid request parameter: name: cannot be blank; provider: cannot be blank."),
}, {
Name: "error, device exists",
Request: model.ExternalDeviceRequest{
ExternalDevice: model.ExternalDevice{
ID: "ef20a8b1-ef00-4e59-9a8a-fe5ef0be6b92",
Provider: "acme inc.",
Name: "niceAndShinySBC",
},
},
TenantID: "123456789012345678901234",
App: func(t *testing.T, self *testCase) *mocks.App {
app := new(mocks.App)
req := self.Request.(model.ExternalDeviceRequest)
app.On("ProvisionDevice",
contextMatcher(self.TenantID),
mock.AnythingOfType("*model.Device")).
Run(func(args mock.Arguments) {
dev := args.Get(1).(*model.Device)
assert.Equal(t, req.ID, dev.External.ID)
assert.Equal(t, req.ExternalDevice.IDData(), dev.IdDataStruct)
assert.Equal(t, req.Provider, dev.External.Provider)
}).Return(devauth.ErrDeviceExists)
return app
},
StatusCode: http.StatusConflict,
Error: devauth.ErrDeviceExists,
}, {
Name: "error, internal server error",
Request: model.ExternalDeviceRequest{
ExternalDevice: model.ExternalDevice{
ID: "ef20a8b1-ef00-4e59-9a8a-fe5ef0be6b92",
Provider: "acme inc.",
Name: "niceAndShinySBC",
},
},
TenantID: "123456789012345678901234",
App: func(t *testing.T, self *testCase) *mocks.App {
app := new(mocks.App)
req := self.Request.(model.ExternalDeviceRequest)
app.On("ProvisionDevice",
contextMatcher(self.TenantID),
mock.AnythingOfType("*model.Device")).
Run(func(args mock.Arguments) {
dev := args.Get(1).(*model.Device)
assert.Equal(t, req.ID, dev.External.ID)
assert.Equal(t, req.ExternalDevice.IDData(), dev.IdDataStruct)
assert.Equal(t, req.Provider, dev.External.Provider)
}).Return(errors.New("internal error"))
return app
},
StatusCode: http.StatusInternalServerError,
Error: errors.New("internal error"),
}}
for i := range testCases {
tc := testCases[i]
t.Run(tc.Name, func(t *testing.T) {
t.Parallel()
app := tc.App(t, &tc)
defer app.AssertExpectations(t)
URI := strings.ReplaceAll(uriTenantDevicesExternal, ":tid", tc.TenantID)
var b []byte
switch typ := tc.Request.(type) {
case []byte:
b = typ
default:
b, _ = json.Marshal(typ)
}
l := log.NewEmpty()
l.Logger.Out = io.Discard
ctx := log.WithContext(context.Background(), l)
req, _ := http.NewRequestWithContext(
ctx,
http.MethodPost,
URI,
bytes.NewReader(b),
)
req.Header.Set("X-Men-Requestid", "test")
handler := makeMockApiHandler(t, app, nil)
w := httptest.NewRecorder()
handler.ServeHTTP(w, req)
assert.Equal(t, tc.StatusCode, w.Code)
rspHdrs := w.Header()
for hdr := range tc.RspHeaders {
expectedRegex := tc.RspHeaders.Get(hdr)
actual := rspHdrs.Get(hdr)
assert.Regexpf(t, expectedRegex, actual,
"expected header '%s' does not match response", hdr,
)
}
if tc.Error != nil {
var rsp rest_utils.ApiError
err := json.Unmarshal(w.Body.Bytes(), &rsp)
if assert.NoError(t, err, "expected a rest (JSON) error response") {
assert.Regexp(t, tc.Error.Error(), rsp.Error())
}
}
})
}
} | explode_data.jsonl/628 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2835
} | [
2830,
3393,
1336,
13013,
6985,
25913,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
2405,
2266,
37554,
284,
2915,
1155,
25121,
915,
914,
8,
3749,
6257,
341,
197,
853,
7860,
1321,
34244,
1359,
18552,
7502,
2266,
9328,
8,
1807,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestCnsPermanentShouldBeValid(t *testing.T) {
doc, err := brdocs.NewCns("242912018460005")
internal_test.AssertValidDocument(t, doc, err)
} | explode_data.jsonl/52270 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 57
} | [
2830,
3393,
34,
4412,
78793,
14996,
3430,
4088,
1155,
353,
8840,
836,
8,
341,
59536,
11,
1848,
1669,
1411,
14120,
7121,
34,
4412,
445,
17,
19,
17,
24,
16,
17,
15,
16,
23,
19,
21,
15,
15,
15,
20,
1138,
33343,
4452,
11711,
4088,
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 |
func TestQueryTimeout(t *testing.T) {
opts := EngineOpts{
Logger: nil,
Reg: nil,
MaxSamples: 10,
Timeout: 5 * time.Millisecond,
}
engine := NewEngine(opts)
ctx, cancelCtx := context.WithCancel(context.Background())
defer cancelCtx()
query := engine.newTestQuery(func(ctx context.Context) error {
time.Sleep(100 * time.Millisecond)
return contextDone(ctx, "test statement execution")
})
res := query.Exec(ctx)
require.Error(t, res.Err, "expected timeout error but got none")
var e ErrQueryTimeout
require.True(t, errors.As(res.Err, &e), "expected timeout error but got: %s", res.Err)
} | explode_data.jsonl/35549 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 237
} | [
2830,
3393,
2859,
7636,
1155,
353,
8840,
836,
8,
341,
64734,
1669,
8200,
43451,
515,
197,
55861,
25,
257,
2092,
345,
197,
197,
3477,
25,
286,
2092,
345,
197,
197,
5974,
39571,
25,
220,
16,
15,
345,
197,
197,
7636,
25,
262,
220,
20... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestRootOrInflections_Basic(t *testing.T) {
if want, got := true, rootOrInflections([]rune("CHRISTENING"), "CHRISTEN"); want != got {
t.Fatalf("rootOrInflections error, Wanted %v, got %v", want, got)
}
} | explode_data.jsonl/9349 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 79
} | [
2830,
3393,
8439,
2195,
19433,
67679,
1668,
5971,
1155,
353,
8840,
836,
8,
341,
743,
1366,
11,
2684,
1669,
830,
11,
3704,
2195,
19433,
67679,
10556,
81,
2886,
445,
67196,
3846,
953,
1718,
3975,
330,
67196,
3846,
953,
5038,
1366,
961,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestAddRemoveMons(t *testing.T) {
var deploymentsUpdated *[]*apps.Deployment
updateDeploymentAndWait, deploymentsUpdated = testopk8s.UpdateDeploymentAndWaitStub()
monQuorumResponse := clienttest.MonInQuorumResponse()
executor := &exectest.MockExecutor{
MockExecuteCommandWithOutputFile: func(command string, outFileArg string, args ...string) (string, error) {
return monQuorumResponse, nil
},
}
clientset := test.New(t, 1)
configDir, _ := ioutil.TempDir("", "")
defer os.RemoveAll(configDir)
context := &clusterd.Context{
Clientset: clientset,
ConfigDir: configDir,
Executor: executor,
}
c := New(context, "ns", cephv1.ClusterSpec{}, metav1.OwnerReference{}, &sync.Mutex{})
setCommonMonProperties(c, 0, cephv1.MonSpec{Count: 5, AllowMultiplePerNode: true}, "myversion")
c.maxMonID = 0 // "a" is max mon id
c.waitForStart = false
defer os.RemoveAll(c.context.ConfigDir)
// checking the health will increase the mons as desired all in one go
err := c.checkHealth()
assert.Nil(t, err)
assert.Equal(t, 5, len(c.ClusterInfo.Monitors), fmt.Sprintf("mons: %v", c.ClusterInfo.Monitors))
assert.ElementsMatch(t, []string{
// b is created first, no updates
"rook-ceph-mon-b", // b updated when c created
"rook-ceph-mon-b", "rook-ceph-mon-c", // b and c updated when d created
"rook-ceph-mon-b", "rook-ceph-mon-c", "rook-ceph-mon-d", // etc.
"rook-ceph-mon-b", "rook-ceph-mon-c", "rook-ceph-mon-d", "rook-ceph-mon-e"},
testopk8s.DeploymentNamesUpdated(deploymentsUpdated))
testopk8s.ClearDeploymentsUpdated(deploymentsUpdated)
// reducing the mon count to 3 will reduce the mon count once each time we call checkHealth
monQuorumResponse = clienttest.MonInQuorumResponseFromMons(c.ClusterInfo.Monitors)
c.spec.Mon.Count = 3
err = c.checkHealth()
assert.Nil(t, err)
assert.Equal(t, 4, len(c.ClusterInfo.Monitors))
// No updates in unit tests w/ workaround
assert.ElementsMatch(t, []string{}, testopk8s.DeploymentNamesUpdated(deploymentsUpdated))
testopk8s.ClearDeploymentsUpdated(deploymentsUpdated)
// after the second call we will be down to the expected count of 3
monQuorumResponse = clienttest.MonInQuorumResponseFromMons(c.ClusterInfo.Monitors)
err = c.checkHealth()
assert.Nil(t, err)
assert.Equal(t, 3, len(c.ClusterInfo.Monitors))
// No updates in unit tests w/ workaround
assert.ElementsMatch(t, []string{}, testopk8s.DeploymentNamesUpdated(deploymentsUpdated))
testopk8s.ClearDeploymentsUpdated(deploymentsUpdated)
// now attempt to reduce the mons down to quorum size 1
monQuorumResponse = clienttest.MonInQuorumResponseFromMons(c.ClusterInfo.Monitors)
c.spec.Mon.Count = 1
err = c.checkHealth()
assert.Nil(t, err)
assert.Equal(t, 2, len(c.ClusterInfo.Monitors))
// No updates in unit tests w/ workaround
assert.ElementsMatch(t, []string{}, testopk8s.DeploymentNamesUpdated(deploymentsUpdated))
testopk8s.ClearDeploymentsUpdated(deploymentsUpdated)
// cannot reduce from quorum size of 2 to 1
monQuorumResponse = clienttest.MonInQuorumResponseFromMons(c.ClusterInfo.Monitors)
err = c.checkHealth()
assert.Nil(t, err)
assert.Equal(t, 2, len(c.ClusterInfo.Monitors))
// No updates in unit tests w/ workaround
assert.ElementsMatch(t, []string{}, testopk8s.DeploymentNamesUpdated(deploymentsUpdated))
testopk8s.ClearDeploymentsUpdated(deploymentsUpdated)
} | explode_data.jsonl/36574 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1235
} | [
2830,
3393,
2212,
13021,
44,
2382,
1155,
353,
8840,
836,
8,
341,
2405,
71542,
16196,
353,
1294,
9,
27635,
34848,
39130,
198,
27175,
75286,
92812,
11,
71542,
16196,
284,
1273,
453,
74,
23,
82,
16689,
75286,
92812,
33838,
2822,
197,
1645,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAccAzureRMLoadBalancerNatRule_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_lb_nat_rule", "test")
r := LoadBalancerNatRule{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data, "Standard"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.complete(data, "Standard"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basic(data, "Standard"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
} | explode_data.jsonl/29070 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 301
} | [
2830,
3393,
14603,
78107,
49,
2668,
2731,
93825,
65214,
11337,
8882,
1155,
353,
8840,
836,
8,
341,
8924,
1669,
25505,
25212,
83920,
1155,
11,
330,
1370,
324,
4195,
63601,
38169,
21124,
497,
330,
1944,
1138,
7000,
1669,
8893,
93825,
65214,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestIgnoresNilObject(t *testing.T) {
attrs := admission.NewAttributesRecord(nil, nil, api.Kind("Pod").WithVersion("version"), "myns", "myname", api.Resource("pods").WithVersion("version"), "", admission.Create, false, nil)
err := NewServiceAccount().Admit(attrs)
if err != nil {
t.Errorf("Expected nil object allowed allowed, got err: %v", err)
}
} | explode_data.jsonl/61337 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 120
} | [
2830,
3393,
40,
70,
2152,
416,
19064,
1190,
1155,
353,
8840,
836,
8,
341,
197,
20468,
1669,
25293,
7121,
10516,
6471,
27907,
11,
2092,
11,
6330,
54199,
445,
23527,
1827,
2354,
5637,
445,
4366,
3975,
330,
76,
1872,
82,
497,
330,
2408,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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_SqlDatabaseThroughputSetting_WhenSerializedToJson_DeserializesAsEqual(t *testing.T) {
t.Parallel()
parameters := gopter.DefaultTestParameters()
parameters.MaxSize = 10
properties := gopter.NewProperties(parameters)
properties.Property(
"Round trip of SqlDatabaseThroughputSetting via JSON returns original",
prop.ForAll(RunJSONSerializationTestForSqlDatabaseThroughputSetting, SqlDatabaseThroughputSettingGenerator()))
properties.TestingRun(t, gopter.NewFormatedReporter(true, 240, os.Stdout))
} | explode_data.jsonl/21815 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 158
} | [
2830,
3393,
1098,
1470,
5988,
23857,
628,
15400,
62,
4498,
77521,
78967,
98054,
2848,
4756,
2121,
2993,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
67543,
1669,
728,
73137,
13275,
2271,
9706,
741,
67543,
14535,
1695,
284,
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 |
func TestService_Run(t *testing.T) {
var l = zaptest.NewLogger(t).Sugar()
aws, _ := utils.AWSSession(utils.AWSConfig(true))
s, err := New(aws, l, Opts{})
if err != nil {
t.Error(err)
return
}
// stub run
go s.Run("", "")
time.Sleep(time.Millisecond)
s.Stop()
} | explode_data.jsonl/22350 | {
"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,
1860,
84158,
1155,
353,
8840,
836,
8,
341,
2405,
326,
284,
32978,
1944,
7121,
7395,
1155,
568,
83414,
741,
197,
8635,
11,
716,
1669,
12439,
875,
54,
1220,
1338,
64166,
91670,
2648,
3715,
1171,
1903,
11,
1848,
1669,
1532,
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... | 2 |
func TestProxyFunction(t *testing.T) {
c := &CloudWatch{
HTTPProxy: proxy.HTTPProxy{HTTPProxyURL: "http://www.penguins.com"},
}
proxyFunction, err := c.HTTPProxy.Proxy()
require.NoError(t, err)
proxyResult, err := proxyFunction(&http.Request{})
require.NoError(t, err)
require.Equal(t, "www.penguins.com", proxyResult.Host)
} | explode_data.jsonl/56722 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 125
} | [
2830,
3393,
16219,
5152,
1155,
353,
8840,
836,
8,
341,
1444,
1669,
609,
16055,
14247,
515,
197,
197,
9230,
16219,
25,
13291,
27358,
16219,
90,
9230,
16219,
3144,
25,
330,
1254,
1110,
2136,
556,
55358,
905,
7115,
197,
630,
197,
22803,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestNewRunCommandScriptNotFound(t *testing.T) {
f := newFakeKoolRun([]builder.Command{}, nil)
cmd := NewRunCommand(f)
cmd.SetArgs([]string{"script"})
if err := cmd.Execute(); err != nil {
t.Errorf("unexpected error executing run command; error: %v", err)
}
if !f.out.(*shell.FakeOutputWriter).CalledError {
t.Error("did not call Error for not found script error")
}
expectedError := ErrKoolScriptNotFound.Error()
if gotError := f.out.(*shell.FakeOutputWriter).Err.Error(); gotError != expectedError {
t.Errorf("expecting error '%s', got '%s'", expectedError, gotError)
}
if !f.exiter.(*shell.FakeExiter).Exited() {
t.Error("got an not found script error, but command did not exit")
}
} | explode_data.jsonl/60857 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 252
} | [
2830,
3393,
3564,
6727,
4062,
5910,
10372,
1155,
353,
8840,
836,
8,
341,
1166,
1669,
501,
52317,
42,
1749,
6727,
10556,
17850,
12714,
22655,
2092,
340,
25920,
1669,
1532,
6727,
4062,
955,
692,
25920,
4202,
4117,
10556,
917,
4913,
2282,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestViperProvider_DSN(t *testing.T) {
t.Run("case=dsn: memory", func(t *testing.T) {
p := config.MustNew(t, logrusx.New("", ""), configx.SkipValidation())
p.MustSet(config.ViperKeyDSN, "memory")
assert.Equal(t, config.DefaultSQLiteMemoryDSN, p.DSN())
})
t.Run("case=dsn: not memory", func(t *testing.T) {
p := config.MustNew(t, logrusx.New("", ""), configx.SkipValidation())
dsn := "sqlite://foo.db?_fk=true"
p.MustSet(config.ViperKeyDSN, dsn)
assert.Equal(t, dsn, p.DSN())
})
t.Run("case=dsn: not set", func(t *testing.T) {
dsn := ""
var exitCode int
l := logrusx.New("", "", logrusx.WithExitFunc(func(i int) {
exitCode = i
}), logrusx.WithHook(InterceptHook{}))
p := config.MustNew(t, l, configx.SkipValidation())
assert.Equal(t, dsn, p.DSN())
assert.NotEqual(t, 0, exitCode)
})
} | explode_data.jsonl/52913 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 377
} | [
2830,
3393,
53,
12858,
5179,
1557,
18966,
1155,
353,
8840,
836,
8,
341,
3244,
16708,
445,
5638,
28,
75136,
25,
4938,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
3223,
1669,
2193,
50463,
3564,
1155,
11,
1487,
20341,
87,
7121,
19814,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestParsePushEvent(t *testing.T) {
assert := assert.New(t)
repo, client := helpers.CreateHgRepo(t, "hg-repo")
defer helpers.CleanupHgRepo(t, client)
fmt.Println("====== CWD: ", repo.Path)
files := []map[string][]byte{
{"foo": []byte("foo")},
{"bar": []byte("bar")},
{"baz": []byte("baz")},
{"qux": []byte("qux")},
}
nodes := make([]string, 0, 5)
for i, filesToAdd := range files[:3] {
helpers.CreateAndAddFilesHg(t, repo.Path, client, filesToAdd)
commitId := helpers.CommitHg(t, client, fmt.Sprintf("Commit %d", i), helpers.DefaultAuthor)
nodes = append(nodes, commitId)
}
tagId := helpers.CreateHgTag(t, client, nodes[2], "commit-2", "Tag commit-2", helpers.DefaultAuthor)
nodes = append(nodes, tagId)
for i, filesToAdd := range files[3:] {
helpers.CreateAndAddFilesHg(t, repo.Path, client, filesToAdd)
commitId := helpers.CommitHg(t, client, fmt.Sprintf("Commit %d", 3+i), helpers.DefaultAuthor)
nodes = append(nodes, commitId)
}
helpers.CreateHgBookmark(t, client, nodes[4], "bookmark-1")
env := map[string]string{
"HG_NODE": nodes[1],
"HG_NODE_LAST": nodes[4],
}
var payload events.Payload
var err error
helpers.WithEnv(t, env, func() {
payload, err = repo.ParseEventPayload(events.PushEvent, nil)
})
assert.Nil(err)
expected := events.PushPayload{
Repository: repo.Name,
Commits: []events.PushPayloadCommit{
{
Id: nodes[1],
Message: "Commit 1",
Target: events.PushPayloadCommitTarget{
Branch: "default",
},
},
{
Id: nodes[2],
Message: "Commit 2",
Target: events.PushPayloadCommitTarget{
Branch: "default",
Tags: []string{"commit-2"},
},
},
{
Id: nodes[3],
Message: "Tag commit-2",
Target: events.PushPayloadCommitTarget{
Branch: "default",
},
},
{
Id: nodes[4],
Message: "Commit 3",
Target: events.PushPayloadCommitTarget{
Branch: "default",
Bookmarks: []string{"bookmark-1"},
Tags: []string{"tip"},
},
},
},
}
assert.Equal(expected, payload)
} | explode_data.jsonl/57193 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 934
} | [
2830,
3393,
14463,
16644,
1556,
1155,
353,
8840,
836,
8,
341,
6948,
1669,
2060,
7121,
1155,
692,
17200,
5368,
11,
2943,
1669,
30187,
7251,
39,
70,
25243,
1155,
11,
330,
66602,
5504,
5368,
1138,
16867,
30187,
727,
60639,
39,
70,
25243,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestAddMessageID(t *testing.T) {
message, id, err := addMessageID(&amqp.Message{}, uuid.NewV4)
require.NoError(t, err)
require.NotEmpty(t, id)
require.EqualValues(t, message.Properties.MessageID, id)
m := &amqp.Message{
Data: [][]byte{[]byte("hello world")},
Properties: &amqp.MessageProperties{
UserID: []byte("my user ID"),
MessageID: "is that will not be copied"},
}
message, id, err = addMessageID(m, uuid.NewV4)
require.NoError(t, err)
require.NotEmpty(t, id)
require.EqualValues(t, message.Properties.MessageID, id)
require.EqualValues(t, message.Properties.UserID, []byte("my user ID"))
require.EqualValues(t, message.Data[0], []byte("hello world"))
} | explode_data.jsonl/57206 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 271
} | [
2830,
3393,
2212,
2052,
915,
1155,
353,
8840,
836,
8,
341,
24753,
11,
877,
11,
1848,
1669,
912,
2052,
915,
2099,
309,
32763,
8472,
22655,
16040,
7121,
53,
19,
340,
17957,
35699,
1155,
11,
1848,
340,
17957,
15000,
3522,
1155,
11,
877,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestUserService_CreateAfterDelete(t *testing.T) {
client := newTestClient(t)
us := NewUserService(func(context.Context, string) (*ent.Client, error) { return client, nil })
ctx := authz.NewContext(context.Background(), authz.AdminPermissions())
u := client.User.Create().SetAuthID("YYY").SaveX(ctx)
require.Equal(t, user.StatusACTIVE, u.Status)
_, err := us.Delete(ctx, &UserInput{Tenant: "XXX", Id: "YYY"})
require.NoError(t, err)
_, err = us.Create(ctx, &AddUserInput{Tenant: "XXX", Id: "YYY", IsOwner: true})
require.NoError(t, err)
userObject, err := client.User.Get(ctx, u.ID)
require.NoError(t, err)
require.Equal(t, user.StatusACTIVE, userObject.Status)
require.Equal(t, user.RoleOWNER, userObject.Role)
} | explode_data.jsonl/70876 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 274
} | [
2830,
3393,
60004,
34325,
6025,
6435,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
501,
2271,
2959,
1155,
340,
70175,
1669,
1532,
60004,
18552,
5378,
9328,
11,
914,
8,
4609,
306,
11716,
11,
1465,
8,
314,
470,
2943,
11,
2092,
2751,
20985... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestLimit(t *testing.T) {
client := v1.New(nil)
assert.Equal(t, client.Limit.Remain(false), v1.NewLimit(1).Remain(false))
assert.Equal(t, client.Limit.Remain(true), v1.NewLimit(1).Remain(true))
} | explode_data.jsonl/41194 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 86
} | [
2830,
3393,
16527,
1155,
353,
8840,
836,
8,
341,
25291,
1669,
348,
16,
7121,
27907,
340,
6948,
12808,
1155,
11,
2943,
1214,
2353,
11398,
466,
3576,
701,
348,
16,
7121,
16527,
7,
16,
568,
6590,
466,
3576,
1171,
6948,
12808,
1155,
11,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
func TestStartConsumer(t *testing.T) {
t.Run("manual stop consumer", func(t *testing.T) {
q, _ := memq.NewQueue("default")
q.Publish(0, 1, 2, 3, 4)
ctx, cancel := context.WithCancel(context.Background())
c, err := q.Consumer(&queue.ConsumerOption{
MaxNumWorker: 1,
Handler: queue.H(func(m queue.Message) {
time.Sleep(100 * time.Millisecond)
m.Ack()
}),
})
assert.Nil(t, err)
c.Start(ctx)
time.Sleep(50 * time.Millisecond)
cancel()
time.Sleep(1000 * time.Millisecond)
assert.NotEqual(t, 0, q.Size())
})
t.Run("start multi times", func(t *testing.T) {
q, _ := memq.NewQueue("default")
ctx, stop := context.WithCancel(context.Background())
c, err := q.Consumer(nil)
assert.Nil(t, err)
assert.Nil(t, c.Start(ctx))
assert.NotNil(t, c.Start(ctx))
stop()
time.Sleep(200 * time.Millisecond)
assert.Nil(t, c.Start(ctx))
assert.NotNil(t, c.Start(ctx))
})
} | explode_data.jsonl/62407 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 408
} | [
2830,
3393,
3479,
29968,
1155,
353,
8840,
836,
8,
1476,
3244,
16708,
445,
19730,
2936,
11502,
497,
2915,
1155,
353,
8840,
836,
8,
341,
197,
18534,
11,
716,
1669,
1833,
80,
7121,
7554,
445,
2258,
1138,
197,
18534,
83935,
7,
15,
11,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
func TestGenerateSignatureWithPlugin(t *testing.T) {
signatures := SignaturesConfig{Signatures: []string{"some_token"}, Plugin: "_foo"}
bundle := Bundle{
Data: map[string]interface{}{
"foo": map[string]interface{}{
"bar": []interface{}{json.Number("1"), json.Number("2"), json.Number("3")},
"baz": true,
"qux": "hello",
},
},
Modules: []ModuleFile{
{
URL: "/foo/corge/corge.rego",
Path: "/foo/corge/corge.rego",
Parsed: ast.MustParseModule(`package foo.corge`),
Raw: []byte("package foo.corge\n"),
},
},
Wasm: []byte("modules-compiled-as-wasm-binary"),
Manifest: Manifest{
Revision: "quickbrownfaux",
},
Signatures: signatures,
}
defaultSigner, _ := GetSigner(defaultSignerID)
defaultVerifier, _ := GetVerifier(defaultVerifierID)
if err := RegisterSigner("_foo", defaultSigner); err != nil {
t.Fatal(err)
}
if err := RegisterVerifier("_foo", defaultVerifier); err != nil {
t.Fatal(err)
}
sc := NewSigningConfig("secret", "HS256", "").WithPlugin("_foo")
err := bundle.GenerateSignature(sc, "", false)
if err != nil {
t.Fatal("Unexpected error:", err)
}
if reflect.DeepEqual(signatures, bundle.Signatures) {
t.Fatal("Expected signatures to be different")
}
current := bundle.Signatures
err = bundle.GenerateSignature(sc, "", false)
if err != nil {
t.Fatal("Unexpected error:", err)
}
if !reflect.DeepEqual(current, bundle.Signatures) {
t.Fatal("Expected signatures to be same")
}
} | explode_data.jsonl/55384 | {
"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,
31115,
25088,
2354,
11546,
1155,
353,
8840,
836,
8,
341,
69054,
2789,
1669,
7075,
2789,
2648,
90,
7264,
2789,
25,
3056,
917,
4913,
14689,
6458,
14345,
21245,
25,
9000,
7975,
63159,
2233,
4206,
1669,
13182,
515,
197,
40927,
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... | 7 |
func TestTemplateMain(t *testing.T) {
var (
d1 AbstractDisplay = NewCharDisplay('H')
d2 AbstractDisplay = NewStringDisplay("Hello world.")
)
d1.Display()
d2.Display()
} | explode_data.jsonl/46299 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 64
} | [
2830,
3393,
7275,
6202,
1155,
353,
8840,
836,
8,
341,
2405,
2399,
197,
2698,
16,
13513,
7020,
284,
1532,
4768,
7020,
492,
39,
1305,
197,
2698,
17,
13513,
7020,
284,
1532,
703,
7020,
445,
9707,
1879,
13053,
197,
692,
2698,
16,
22411,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestMergedSeriesSet(t *testing.T) {
cases := []struct {
// The input sets in order (samples in series in b are strictly
// after those in a).
a, b storage.SeriesSet
// The composition of a and b in the partition series set must yield
// results equivalent to the result series set.
exp storage.SeriesSet
}{
{
a: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"a": "a",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
}),
}),
b: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"a": "a",
}, []tsdbutil.Sample{
sample{t: 2, v: 2},
}),
newSeries(map[string]string{
"b": "b",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
}),
}),
exp: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"a": "a",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
sample{t: 2, v: 2},
}),
newSeries(map[string]string{
"b": "b",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
}),
}),
},
{
a: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"handler": "prometheus",
"instance": "127.0.0.1:9090",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
}),
newSeries(map[string]string{
"handler": "prometheus",
"instance": "localhost:9090",
}, []tsdbutil.Sample{
sample{t: 1, v: 2},
}),
}),
b: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"handler": "prometheus",
"instance": "127.0.0.1:9090",
}, []tsdbutil.Sample{
sample{t: 2, v: 1},
}),
newSeries(map[string]string{
"handler": "query",
"instance": "localhost:9090",
}, []tsdbutil.Sample{
sample{t: 2, v: 2},
}),
}),
exp: newMockSeriesSet([]storage.Series{
newSeries(map[string]string{
"handler": "prometheus",
"instance": "127.0.0.1:9090",
}, []tsdbutil.Sample{
sample{t: 1, v: 1},
sample{t: 2, v: 1},
}),
newSeries(map[string]string{
"handler": "prometheus",
"instance": "localhost:9090",
}, []tsdbutil.Sample{
sample{t: 1, v: 2},
}),
newSeries(map[string]string{
"handler": "query",
"instance": "localhost:9090",
}, []tsdbutil.Sample{
sample{t: 2, v: 2},
}),
}),
},
}
Outer:
for _, c := range cases {
res := NewMergedSeriesSet([]storage.SeriesSet{c.a, c.b})
for {
eok, rok := c.exp.Next(), res.Next()
testutil.Equals(t, eok, rok)
if !eok {
continue Outer
}
sexp := c.exp.At()
sres := res.At()
testutil.Equals(t, sexp.Labels(), sres.Labels())
smplExp, errExp := expandSeriesIterator(sexp.Iterator())
smplRes, errRes := expandSeriesIterator(sres.Iterator())
testutil.Equals(t, errExp, errRes)
testutil.Equals(t, smplExp, smplRes)
}
}
} | explode_data.jsonl/50257 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1417
} | [
2830,
3393,
44,
51525,
25544,
1649,
1155,
353,
8840,
836,
8,
341,
1444,
2264,
1669,
3056,
1235,
341,
197,
197,
322,
576,
1946,
7289,
304,
1973,
320,
41118,
304,
4013,
304,
293,
525,
25470,
198,
197,
197,
322,
1283,
1846,
304,
264,
4... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
func TestOpRowsSerialization(t *testing.T) {
operation := Operation{
Op: "insert",
Table: "Interface",
}
iface1 := make(map[string]interface{})
iface1["name"] = "test-iface1"
iface1["mac"] = "0000ffaaaa"
iface1["ofport"] = 1
iface2 := make(map[string]interface{})
iface2["name"] = "test-iface2"
iface2["mac"] = "0000ffaabb"
iface2["ofport"] = 2
operation.Rows = []map[string]interface{}{iface1, iface2}
str, err := json.Marshal(operation)
if err != nil {
log.Fatal("serialization error:", err)
}
expected := `{"op":"insert","table":"Interface","rows":[{"mac":"0000ffaaaa","name":"test-iface1","ofport":1},{"mac":"0000ffaabb","name":"test-iface2","ofport":2}]}`
if string(str) != expected {
t.Error("Expected: ", expected, "Got", string(str))
}
} | explode_data.jsonl/37843 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 309
} | [
2830,
3393,
7125,
9024,
35865,
1155,
353,
8840,
836,
8,
341,
197,
9262,
1669,
16730,
515,
197,
197,
7125,
25,
262,
330,
4208,
756,
197,
197,
2556,
25,
330,
5051,
756,
197,
630,
743,
578,
16,
1669,
1281,
9147,
14032,
31344,
37790,
74... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetProfileType10(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleGet1Successfully(t, ExpectedProfileType1.Name)
actual, err := profiletypes.Get(fake.ServiceClient(), ExpectedProfileType1.Name).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, ExpectedProfileType1, *actual)
} | explode_data.jsonl/49315 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 114
} | [
2830,
3393,
1949,
8526,
929,
16,
15,
1155,
353,
8840,
836,
8,
341,
70479,
39820,
9230,
741,
16867,
270,
94849,
37496,
9230,
2822,
197,
6999,
1949,
16,
35959,
1155,
11,
31021,
8526,
929,
16,
2967,
692,
88814,
11,
1848,
1669,
5526,
9242... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestGetRegion(t *testing.T) {
gce := &GCECloud{
zone: "us-central1-b",
}
zones, ok := gce.Zones()
if !ok {
t.Fatalf("Unexpected missing zones impl")
}
zone, err := zones.GetZone()
if err != nil {
t.Fatalf("unexpected error %v", err)
}
if zone.Region != "us-central1" {
t.Errorf("Unexpected region: %s", zone.Region)
}
} | explode_data.jsonl/54768 | {
"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,
1949,
14091,
1155,
353,
8840,
836,
8,
341,
3174,
346,
1669,
609,
38,
2104,
16055,
515,
197,
197,
8684,
25,
330,
355,
84081,
16,
1455,
756,
197,
532,
20832,
3154,
11,
5394,
1669,
342,
346,
13476,
3154,
741,
743,
753,
562,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCommandWithArch(t *testing.T) {
uname := syscall.Utsname{}
if err := syscall.Uname(&uname); err != nil {
t.Errorf(err.Error())
}
arch := ""
for _, c := range uname.Machine {
if c == 0 {
break
}
arch += string(byte(c))
}
if arch != "x86_64" && arch != "i686" {
t.Skip("skipping architecture test, not on x86")
}
c, err := NewContainer(ContainerName)
if err != nil {
t.Errorf(err.Error())
}
options := DefaultAttachOptions
options.Arch = X86
args := []string{"/bin/sh", "-c", "test `uname -m` = i686"}
ok, err := c.RunCommand(args, options)
if err != nil {
t.Errorf(err.Error())
}
if ok != true {
t.Errorf("Expected success")
}
} | explode_data.jsonl/2799 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 286
} | [
2830,
3393,
4062,
2354,
18727,
1155,
353,
8840,
836,
8,
341,
20479,
373,
1669,
49345,
5255,
2576,
606,
16094,
743,
1848,
1669,
49345,
5255,
606,
2099,
40379,
1215,
1848,
961,
2092,
341,
197,
3244,
13080,
3964,
6141,
2398,
197,
630,
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... | 9 |
func Test_UnsafeSetDifference(t *testing.T) {
a := NewThreadUnsafeSet()
a.Add(1)
a.Add(2)
a.Add(3)
b := NewThreadUnsafeSet()
b.Add(1)
b.Add(3)
b.Add(4)
b.Add(5)
b.Add(6)
b.Add(99)
c := a.Difference(b)
if !(c.Cardinality() == 1 && c.Contains(2)) {
t.Error("the difference of set a to b is the set of 1 item: 2")
}
} | explode_data.jsonl/195 | {
"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,
40687,
18675,
1649,
62707,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
1532,
6855,
78770,
1649,
741,
11323,
1904,
7,
16,
340,
11323,
1904,
7,
17,
340,
11323,
1904,
7,
18,
692,
2233,
1669,
1532,
6855,
78770,
1649,
741,
2233,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestFetchWithdrawalHistory(t *testing.T) {
t.Parallel()
if !areTestAPIKeysSet() {
t.Skip()
}
_, err := f.FetchWithdrawalHistory(context.Background())
if err != nil {
t.Error(err)
}
} | explode_data.jsonl/15182 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 84
} | [
2830,
3393,
20714,
92261,
278,
13424,
1155,
353,
8840,
836,
8,
341,
3244,
41288,
7957,
741,
743,
753,
546,
2271,
7082,
8850,
1649,
368,
341,
197,
3244,
57776,
741,
197,
532,
197,
6878,
1848,
1669,
282,
78506,
92261,
278,
13424,
5378,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestCharsetReader(t *testing.T) {
var testTable = []struct {
charset string
input []byte
want string
}{
{"utf-8", []byte("abcABC\u2014"), "abcABC\u2014"},
{"windows-1250", []byte{'a', 'Z', 0x96}, "aZ\u2013"},
{"big5", []byte{0xa1, 0x5d, 0xa1, 0x61, 0xa1, 0x71}, "\uff08\uff5b\u3008"},
{"utf-7", []byte("Hello, World+ACE- 1 +- 1 +AD0- 2"), "Hello, World! 1 + 1 = 2"},
}
for _, tt := range testTable {
inputReader := bytes.NewReader(tt.input)
outputReader, err := coding.NewCharsetReader(tt.charset, inputReader)
if err != nil {
t.Error("err should be nil, got:", err)
}
result, err := ioutil.ReadAll(outputReader)
if err != nil {
t.Error("err should be nil, got:", err)
}
got := string(result)
if got != tt.want {
t.Errorf("NewCharsetReader(%q, %q) = %q, want: %q", tt.charset, tt.input, got, tt.want)
}
}
} | explode_data.jsonl/69513 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 397
} | [
2830,
3393,
78172,
5062,
1155,
353,
8840,
836,
8,
341,
2405,
1273,
2556,
284,
3056,
1235,
341,
197,
7450,
746,
914,
198,
197,
22427,
256,
3056,
3782,
198,
197,
50780,
262,
914,
198,
197,
59403,
197,
197,
4913,
4762,
12,
23,
497,
305... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestRuntime_ExportToCallable(t *testing.T) {
const SCRIPT = `
function f(param) {
return +param + 2;
}
`
vm := New()
_, err := vm.RunString(SCRIPT)
if err != nil {
t.Fatal(err)
}
var c Callable
err = vm.ExportTo(vm.Get("f"), &c)
if err != nil {
t.Fatal(err)
}
res, err := c(Undefined(), vm.ToValue("40"))
if err != nil {
t.Fatal(err)
} else if !res.StrictEquals(vm.ToValue(42)) {
t.Fatalf("Unexpected value: %v", res)
}
} | explode_data.jsonl/10479 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 208
} | [
2830,
3393,
15123,
62,
16894,
1249,
40410,
1155,
353,
8840,
836,
8,
341,
4777,
53679,
284,
22074,
7527,
282,
9743,
8,
341,
197,
853,
488,
903,
488,
220,
17,
280,
197,
532,
197,
3989,
54879,
1669,
1532,
741,
197,
6878,
1848,
1669,
10... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestConfiguration_Clone(t *testing.T) {
a := Configuration{0, 2, 7, 0}
b := a.Clone()
if !a.Is(b) {
t.Errorf("Expected %v to equal %v.", a, b)
}
a[0] = 2
if a[0] == b[0] {
t.Errorf("Expected cloned value not to change.")
}
} | explode_data.jsonl/6768 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 115
} | [
2830,
3393,
7688,
85110,
603,
1155,
353,
8840,
836,
8,
341,
11323,
1669,
12221,
90,
15,
11,
220,
17,
11,
220,
22,
11,
220,
15,
532,
2233,
1669,
264,
64463,
2822,
743,
753,
64,
4506,
1883,
8,
341,
197,
3244,
13080,
445,
18896,
1018... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestListOptsWithValidator(t *testing.T) {
// Re-using logOptsvalidator (used by MapOpts)
o := NewListOpts(logOptsValidator)
o.Set("foo")
if o.String() != "" {
t.Errorf(`%s != ""`, o.String())
}
o.Set("foo=bar")
if o.String() != "" {
t.Errorf(`%s != ""`, o.String())
}
o.Set("max-file=2")
if o.Len() != 1 {
t.Errorf("%d != 1", o.Len())
}
if !o.Get("max-file=2") {
t.Error("o.Get(\"max-file=2\") == false")
}
if o.Get("baz") {
t.Error("o.Get(\"baz\") == true")
}
o.Delete("max-file=2")
if o.String() != "" {
t.Errorf(`%s != ""`, o.String())
}
} | explode_data.jsonl/26381 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 289
} | [
2830,
3393,
852,
43451,
2354,
14256,
1155,
353,
8840,
836,
8,
341,
197,
322,
1032,
92775,
1487,
43451,
16112,
320,
2591,
553,
5027,
43451,
340,
22229,
1669,
1532,
852,
43451,
12531,
43451,
14256,
340,
22229,
4202,
445,
7975,
1138,
743,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
func TestIDPMakeAssertion(t *testing.T) {
test := NewIdentifyProviderTest(t)
req := IdpAuthnRequest{
Now: TimeNow(),
IDP: &test.IDP,
RequestBuffer: []byte("" +
"<AuthnRequest xmlns=\"urn:oasis:names:tc:SAML:2.0:protocol\" " +
" AssertionConsumerServiceURL=\"https://sp.example.com/saml2/acs\" " +
" Destination=\"https://idp.example.com/saml/sso\" " +
" ID=\"id-00020406080a0c0e10121416181a1c1e\" " +
" IssueInstant=\"2015-12-01T01:57:09Z\" ProtocolBinding=\"\" " +
" Version=\"2.0\">" +
" <Issuer xmlns=\"urn:oasis:names:tc:SAML:2.0:assertion\" " +
" Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:entity\">https://sp.example.com/saml2/metadata</Issuer>" +
" <NameIDPolicy xmlns=\"urn:oasis:names:tc:SAML:2.0:protocol\" " +
" AllowCreate=\"true\">urn:oasis:names:tc:SAML:2.0:nameid-format:transient</NameIDPolicy>" +
"</AuthnRequest>"),
}
req.HTTPRequest, _ = http.NewRequest("POST", "http://idp.example.com/saml/sso", nil)
assert.Check(t, req.Validate())
err := DefaultAssertionMaker{}.MakeAssertion(&req, &Session{
ID: "f00df00df00d",
UserName: "alice",
})
assert.Check(t, err)
expected := &Assertion{
ID: "id-00020406080a0c0e10121416181a1c1e20222426",
IssueInstant: TimeNow(),
Version: "2.0",
Issuer: Issuer{
Format: "urn:oasis:names:tc:SAML:2.0:nameid-format:entity",
Value: "https://idp.example.com/saml/metadata",
},
Signature: nil,
Subject: &Subject{
NameID: &NameID{Format: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", NameQualifier: "https://idp.example.com/saml/metadata", SPNameQualifier: "https://sp.example.com/saml2/metadata", Value: ""},
SubjectConfirmations: []SubjectConfirmation{
{
Method: "urn:oasis:names:tc:SAML:2.0:cm:bearer",
SubjectConfirmationData: &SubjectConfirmationData{
Address: "",
InResponseTo: "id-00020406080a0c0e10121416181a1c1e",
NotOnOrAfter: TimeNow().Add(MaxIssueDelay),
Recipient: "https://sp.example.com/saml2/acs",
},
},
},
},
Conditions: &Conditions{
NotBefore: TimeNow(),
NotOnOrAfter: TimeNow().Add(MaxIssueDelay),
AudienceRestrictions: []AudienceRestriction{
{
Audience: Audience{Value: "https://sp.example.com/saml2/metadata"},
},
},
},
AuthnStatements: []AuthnStatement{
{
AuthnInstant: time.Time{},
SessionIndex: "",
SubjectLocality: &SubjectLocality{},
AuthnContext: AuthnContext{
AuthnContextClassRef: &AuthnContextClassRef{Value: "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"},
},
},
},
AttributeStatements: []AttributeStatement{
{
Attributes: []Attribute{
{
FriendlyName: "uid",
Name: "urn:oid:0.9.2342.19200300.100.1.1",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "alice",
},
},
},
},
},
},
}
assert.Check(t, is.DeepEqual(expected, req.Assertion))
err = DefaultAssertionMaker{}.MakeAssertion(&req, &Session{
ID: "f00df00df00d",
CreateTime: TimeNow(),
ExpireTime: TimeNow().Add(time.Hour),
Index: "9999",
NameID: "ba5eba11",
Groups: []string{"Users", "Administrators", "♀"},
UserName: "alice",
UserEmail: "alice@example.com",
UserCommonName: "Alice Smith",
UserSurname: "Smith",
UserGivenName: "Alice",
})
assert.Check(t, err)
expectedAttributes :=
[]Attribute{
{
FriendlyName: "uid",
Name: "urn:oid:0.9.2342.19200300.100.1.1",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "alice",
},
},
},
{
FriendlyName: "eduPersonPrincipalName",
Name: "urn:oid:1.3.6.1.4.1.5923.1.1.1.6",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "alice@example.com",
},
},
},
{
FriendlyName: "sn",
Name: "urn:oid:2.5.4.4",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "Smith",
},
},
},
{
FriendlyName: "givenName",
Name: "urn:oid:2.5.4.42",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "Alice",
},
},
},
{
FriendlyName: "cn",
Name: "urn:oid:2.5.4.3",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "Alice Smith",
},
},
},
{
FriendlyName: "eduPersonAffiliation",
Name: "urn:oid:1.3.6.1.4.1.5923.1.1.1.1",
NameFormat: "urn:oasis:names:tc:SAML:2.0:attrname-format:uri",
Values: []AttributeValue{
{
Type: "xs:string",
Value: "Users",
},
{
Type: "xs:string",
Value: "Administrators",
},
{
Type: "xs:string",
Value: "♀",
},
},
},
}
assert.Check(t, is.DeepEqual(expectedAttributes, req.Assertion.AttributeStatements[0].Attributes))
} | explode_data.jsonl/19829 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 2696
} | [
2830,
3393,
915,
47,
8078,
68639,
1155,
353,
8840,
836,
8,
341,
18185,
1669,
1532,
28301,
1437,
5179,
2271,
1155,
340,
24395,
1669,
5223,
79,
5087,
77,
1900,
515,
197,
197,
7039,
25,
4120,
7039,
3148,
197,
29580,
47,
25,
609,
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... | 1 |
func TestCheckRecord(t *testing.T) {
var testCase = []struct {
n int
m int
}{
{
n: 1,
m: 3,
},
{
n: 3,
m: 19,
},
{
n: 2,
m: 8,
},
}
should := require.New(t)
for _, tc := range testCase {
should.Equal(tc.m, checkRecord(tc.n), "n: %d", tc.n)
}
} | explode_data.jsonl/52255 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 164
} | [
2830,
3393,
3973,
6471,
1155,
353,
8840,
836,
8,
341,
2405,
54452,
284,
3056,
1235,
341,
197,
9038,
526,
198,
197,
2109,
526,
198,
197,
59403,
197,
197,
515,
298,
9038,
25,
220,
16,
345,
298,
2109,
25,
220,
18,
345,
197,
197,
1583... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
func TestCollect(t *testing.T) {
convErr := errors.New("conv error")
p := func(v string) (int, error) {
if len(v) <= 2 {
a, err := strconv.Atoi(v)
if err == nil {
return a, nil
}
return a, convErr
}
return 0, gs.ErrUnsatisfied
}
assertTry(t, gs.Success(1), try.Collect(gs.Success("1"), p))
assertTry(
t,
gs.Failure[int](gs.ErrUnsatisfied),
try.Collect(gs.Success("100"), p),
)
assertTry(
t,
gs.Failure[int](convErr),
try.Collect(gs.Success("ab"), p),
)
} | explode_data.jsonl/23074 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 238
} | [
2830,
3393,
47504,
1155,
353,
8840,
836,
8,
341,
197,
12027,
7747,
1669,
5975,
7121,
445,
12027,
1465,
5130,
3223,
1669,
2915,
3747,
914,
8,
320,
396,
11,
1465,
8,
341,
197,
743,
2422,
3747,
8,
2651,
220,
17,
341,
298,
11323,
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... | 3 |
func TestRebalance(t *testing.T) {
setup(t, func(t *testing.T, ctrl, ctrl2 *gomock.Controller) {
mockState := mocks.NewMockState(ctrl)
mockGateway := mocks.NewMockGateway(ctrl)
mockCluster := mocks.NewMockCluster(ctrl)
mockNode := mocks.NewMockNode(ctrl)
mockTx := mocks.NewMockTx(ctrl2)
mockResult := mocks.NewMockResult(ctrl2)
mockQuery := mocks.NewMockQuery(ctrl2)
mockConfigProvider := mocks.NewMockClusterConfigProvider(ctrl2)
mockClock := mocks.NewMockClock(ctrl2)
nodeTx := db.NewNodeTxWithQuery(mockTx, mockQuery)
nodeMatcher := NodeTransactionMatcher(nodeTx)
clusterTx := db.NewClusterTxWithQuery(mockTx, int64(1), mockQuery)
clusterMatcher := ClusterTransactionMatcher(clusterTx)
configMap, err := config.New(clusterconfig.Schema, map[string]string{
"core.proxy_http": "[::]:8443",
"core.proxy_https": "[::]:8443",
"cluster.offline_threshold": "20",
})
if err != nil {
t.Errorf("expected err to be nil")
}
raftNodes := []db.RaftNode{
{
ID: int64(1),
Address: "10.0.0.1",
},
}
clusterConfig := clusterconfig.NewConfig(
configMap,
clusterconfig.WithNodeTx(clusterTx),
)
nodeInfo := []db.NodeInfo{
{
ID: int64(1),
Name: "node1",
Address: "10.0.0.1",
APIExtensions: 1,
Schema: 1,
Heartbeat: time.Now(),
},
{
ID: int64(2),
Name: "node2",
Address: "10.0.0.2",
APIExtensions: 1,
Schema: 1,
Heartbeat: time.Now(),
},
}
nodeInfoMatcher := NodeInfoDestSelectObjectsMatcher(nodeInfo)
mockGateway.EXPECT().RaftNodes().Return(raftNodes, nil)
// Cluster actions
mockState.EXPECT().Cluster().Return(mockCluster)
mockCluster.EXPECT().Transaction(clusterMatcher).Return(nil)
mockConfigProvider.EXPECT().ConfigLoad(clusterTx, clusterconfig.Schema).Return(clusterConfig, nil)
mockQuery.EXPECT().SelectObjects(mockTx, nodeInfoMatcher, gomock.Any(), 0).Return(nil)
mockClock.EXPECT().Now().Return(time.Now())
// DB actions
mockGateway.EXPECT().DB().Return(mockNode)
mockNode.EXPECT().Transaction(nodeMatcher).Return(nil)
mockQuery.EXPECT().UpsertObject(mockTx, "raft_nodes", []string{
"address",
}, []interface{}{
"10.0.0.2",
}).Return(int64(2), nil)
mockTx.EXPECT().Exec(gomock.Any()).Return(mockResult, nil)
mockQuery.EXPECT().UpsertObject(mockTx, "raft_nodes", []string{
"id", "address",
}, []interface{}{
int64(1), "10.0.0.1",
}).Return(int64(1), nil)
mockQuery.EXPECT().UpsertObject(mockTx, "raft_nodes", []string{
"id", "address",
}, []interface{}{
int64(2), "10.0.0.2",
}).Return(int64(2), nil)
rebalance := membership.NewRebalance(
mockState, mockGateway,
clusterconfig.Schema,
membership.WithConfigForRebalance(mockConfigProvider),
membership.WithClockForRebalance(mockClock),
)
address, nodes, err := rebalance.Run()
if err != nil {
t.Errorf("expected err to be nil")
}
if expected, actual := "10.0.0.2", address; expected != actual {
t.Errorf("expected: %v, actual: %v", expected, actual)
}
if expected, actual := []db.RaftNode{
{
ID: int64(1),
Address: "10.0.0.1",
},
{
ID: int64(2),
Address: "10.0.0.2",
},
}, nodes; !reflect.DeepEqual(expected, actual) {
t.Errorf("expected: %v, actual: %v", expected, actual)
}
})
} | explode_data.jsonl/23747 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 1564
} | [
2830,
3393,
693,
21571,
1155,
353,
8840,
836,
8,
341,
84571,
1155,
11,
2915,
1155,
353,
8840,
836,
11,
23743,
11,
23743,
17,
353,
36083,
1176,
29112,
8,
341,
197,
77333,
1397,
1669,
68909,
7121,
11571,
1397,
62100,
340,
197,
77333,
40... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 5 |
func TestProcessInputAim(t *testing.T) {
pos, err := ProcessInput(testInput, Position2D{}, AppliedCommandAim)
testutil.CheckUnexpectedError(t, err)
exp := Position2D{
X: 15,
Depth: 60,
Aim: 10,
}
if pos != exp {
t.Fatalf("want %v, have %v", exp, pos)
}
} | explode_data.jsonl/39654 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 118
} | [
2830,
3393,
7423,
2505,
32,
318,
1155,
353,
8840,
836,
8,
341,
28164,
11,
1848,
1669,
8603,
2505,
8623,
2505,
11,
12380,
17,
35,
22655,
42508,
4062,
32,
318,
340,
18185,
1314,
10600,
29430,
1454,
1155,
11,
1848,
692,
48558,
1669,
1238... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestClusterValidateAndAssignIDsBad(t *testing.T) {
tests := []struct {
clmembs []*Member
membs []*Member
}{
{
// unmatched length
[]*Member{
newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
},
[]*Member{},
},
{
// unmatched peer urls
[]*Member{
newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
},
[]*Member{
newTestMember(1, []string{"http://127.0.0.1:4001"}, "", nil),
},
},
{
// unmatched peer urls
[]*Member{
newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
newTestMember(2, []string{"http://127.0.0.2:2379"}, "", nil),
},
[]*Member{
newTestMember(1, []string{"http://127.0.0.1:2379"}, "", nil),
newTestMember(2, []string{"http://127.0.0.2:4001"}, "", nil),
},
},
}
for i, tt := range tests {
ecl := newTestCluster(tt.clmembs)
lcl := newTestCluster(tt.membs)
if err := ValidateClusterAndAssignIDs(lcl, ecl); err == nil {
t.Errorf("#%d: unexpected update success", i)
}
}
} | explode_data.jsonl/52334 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 488
} | [
2830,
3393,
28678,
17926,
3036,
28933,
30466,
17082,
1155,
353,
8840,
836,
8,
341,
78216,
1669,
3056,
1235,
341,
197,
39407,
10536,
1279,
29838,
9366,
198,
197,
14145,
1279,
256,
29838,
9366,
198,
197,
59403,
197,
197,
515,
298,
197,
32... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
func TestStoreWatchNoRefresh(t *testing.T) {
s := newStore()
fc := newFakeClock()
s.clock = fc
var eidx uint64
s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true})
// Should be no-op
fc.Advance(200 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
// Update key's TTL with setting `TTLOptionSet.Refresh` to false will cause an update event
s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: false})
w, _ := s.Watch("/", true, false, 2)
fc.Advance(700 * time.Millisecond)
s.DeleteExpiredKeys(fc.Now())
eidx = 2
testutil.AssertEqual(t, w.StartIndex(), eidx)
e := nbselect(w.EventChan())
testutil.AssertEqual(t, e.EtcdIndex, eidx)
testutil.AssertEqual(t, e.Action, "update")
testutil.AssertEqual(t, e.Node.Key, "/foo")
testutil.AssertEqual(t, *e.PrevNode.Value, "bar")
} | explode_data.jsonl/44125 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 363
} | [
2830,
3393,
6093,
14247,
2753,
14567,
1155,
353,
8840,
836,
8,
341,
1903,
1669,
501,
6093,
741,
1166,
66,
1669,
501,
52317,
26104,
741,
1903,
50546,
284,
25563,
271,
2405,
384,
6361,
2622,
21,
19,
198,
1903,
7251,
4283,
7975,
497,
895... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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 TestEventBuildWithEventRTT(t *testing.T) {
b := builder
b.FetchDuration = 0
expectedRTT := time.Duration(time.Microsecond)
b.Event = common.MapStr{mb.RTTKey: expectedRTT}
event, err := b.Build()
if err != nil {
t.Fatal(err)
}
metricset := event.Fields["metricset"].(common.MapStr)
rttUs := metricset["rtt"]
assert.EqualValues(t, 1, rttUs)
} | explode_data.jsonl/22665 | {
"file_path": "/home/dung/Study/Code/Cross_test_gen/training_dataset/dedup_data/clean_data_go/data/explode_data.jsonl",
"token_count": 148
} | [
2830,
3393,
1556,
11066,
2354,
1556,
5350,
51,
1155,
353,
8840,
836,
8,
341,
2233,
1669,
7363,
198,
2233,
78506,
12945,
284,
220,
15,
198,
42400,
5350,
51,
1669,
882,
33795,
9730,
1321,
2754,
5569,
340,
2233,
6904,
284,
4185,
10104,
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.