Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dehaansa committed Dec 12, 2024
1 parent a6caacf commit 97a9462
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/alloycli/automemlimit_nonlinux_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//go:build !linux
// +build !linux

package alloycli

import (
"bytes"
"log/slog"
"testing"

"github.com/KimMachineGun/automemlimit/memlimit"
"github.com/grafana/alloy/internal/runtime/logging"
"github.com/stretchr/testify/require"
)

func TestNoMemlimitErrorLogs(t *testing.T) {
buffer := bytes.NewBuffer(nil)

l, err := logging.New(buffer, logging.DefaultOptions)
require.NoError(t, err)

applyAutoMemLimit(l)

require.Equal(t, "", buffer.String())

// Linux behavior, to confirm error is logged
memlimit.SetGoMemLimitWithOpts(memlimit.WithLogger(slog.New(l.Handler())))

require.Contains(t, buffer.String(), "cgroups is not supported on this system")
}

0 comments on commit 97a9462

Please sign in to comment.