ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //proc/self/root/opt/go/pkg/mod/github.com/aws/[email protected]/aws/csm/metric_chan_test.go
package csm

import (
	"testing"
)

func TestMetricChanPush(t *testing.T) {
	ch := newMetricChan(5)
	defer close(ch.ch)

	pushed := ch.Push(metric{})
	if !pushed {
		t.Errorf("expected metrics to be pushed")
	}

	if e, a := 1, len(ch.ch); e != a {
		t.Errorf("expected %d, but received %d", e, a)
	}
}

func TestMetricChanPauseContinue(t *testing.T) {
	ch := newMetricChan(5)
	defer close(ch.ch)
	ch.Pause()

	if !ch.IsPaused() {
		t.Errorf("expected to be paused, but did not pause properly")
	}

	ch.Continue()
	if ch.IsPaused() {
		t.Errorf("expected to be not paused, but did not continue properly")
	}

	pushed := ch.Push(metric{})
	if !pushed {
		t.Errorf("expected metrics to be pushed")
	}

	if e, a := 1, len(ch.ch); e != a {
		t.Errorf("expected %d, but received %d", e, a)
	}
}

func TestMetricChanPushWhenPaused(t *testing.T) {
	ch := newMetricChan(5)
	defer close(ch.ch)
	ch.Pause()

	pushed := ch.Push(metric{})
	if pushed {
		t.Errorf("expected metrics to not be pushed")
	}

	if e, a := 0, len(ch.ch); e != a {
		t.Errorf("expected %d, but received %d", e, a)
	}
}

func TestMetricChanNonBlocking(t *testing.T) {
	ch := newMetricChan(0)
	defer close(ch.ch)

	pushed := ch.Push(metric{})
	if pushed {
		t.Errorf("expected metrics to be not pushed")
	}

	if e, a := 0, len(ch.ch); e != a {
		t.Errorf("expected %d, but received %d", e, a)
	}
}