8000 yeah yeah fine · coder/coder@5cf9b25 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5cf9b25

Browse files
committed
yeah yeah fine
1 parent cb6ff4a commit 5cf9b25

File tree

2 files changed

+18
-5
lines changed
  • util/lazy
  • 2 files changed

    +18
    -5
    lines changed

    coderd/files/cache_internal_test.go

    Lines changed: 10 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -8,12 +8,16 @@ import (
    88
    "testing"
    99
    "time"
    1010

    11-
    "github.com/coder/coder/v2/testutil"
    1211
    "github.com/google/uuid"
    12+
    "github.com/spf13/afero"
    1313
    "github.com/stretchr/testify/require"
    1414
    "golang.org/x/sync/errgroup"
    15+
    16+
    "github.com/coder/coder/v2/testutil"
    1517
    )
    1618

    19+
    var emptyFS fs.FS = afero.NewIOFS(afero.NewMemMapFs())
    20+
    1721
    func TestConcurrency(t *testing.T) {
    1822
    t.Parallel()
    1923

    @@ -23,7 +27,7 @@ func TestConcurrency(t *testing.T) {
    2327
    // Wait long enough before returning to make sure that all of the goroutines
    2428
    // will be waiting in line, ensuring that no one duplicated a fetch.
    2529
    time.Sleep(testutil.IntervalMedium)
    26-
    return nil, nil
    30+
    return emptyFS, nil
    2731
    })
    2832

    2933
    batches := 1000
    @@ -56,7 +60,7 @@ func TestRelease(t *testing.T) {
    5660
    t.Parallel()
    5761

    5862
    c := newTestCache(func(_ context.Context, _ uuid.UUID) (fs.FS, error) {
    59-
    return nil, nil
    63+
    return emptyFS, nil
    6064
    })
    6165

    6266
    batches := 100
    @@ -69,7 +73,9 @@ func TestRelease(t *testing.T) {
    6973
    batchSize := 10
    7074
    for _, id := range ids {
    7175
    for range batchSize {
    72-
    c.Acquire(t.Context(), id)
    76+
    fs, err := c.Acquire(t.Context(), id)
    77+
    require.NoError(t, err)
    78+
    require.Equal(t, emptyFS, fs)
    7379
    }
    7480
    }
    7581

    coderd/util/lazy/valuewitherror_test.go

    Lines changed: 8 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -3,12 +3,15 @@ package lazy_test
    33
    import (
    44
    "testing"
    55

    6-
    "github.com/coder/coder/v2/coderd/util/lazy"
    76
    "github.com/stretchr/testify/require"
    87
    "golang.org/x/xerrors"
    8+
    9+
    "github.com/coder/coder/v2/coderd/util/lazy"
    910
    )
    1011

    1112
    func TestLazyWithErrorOK(t *testing.T) {
    13+
    t.Parallel()
    14+
    1215
    l := lazy.NewWithError(func() (int, error) {
    1316
    return 1, nil
    1417
    })
    @@ -19,6 +22,8 @@ func TestLazyWithErrorOK(t *testing.T) {
    1922
    }
    2023

    2124
    func TestLazyWithErrorErr(t *testing.T) {
    25+
    t.Parallel()
    26+
    2227
    l := lazy.NewWithError(func() (int, error) {
    2328
    return 0, xerrors.New("oh no! everything that could went horribly wrong!")
    2429
    })
    @@ -29,6 +34,8 @@ func TestLazyWithErrorErr(t *testing.T) {
    2934
    }
    3035

    3136
    func TestLazyWithErrorPointers(t *testing.T) {
    37+
    t.Parallel()
    38+
    3239
    a := 1
    3340
    l := lazy.NewWithError(func() (*int, error) {
    3441
    return &a, nil

    0 commit comments

    Comments
     (0)
    0