package devices

import "sync"

func NewTest(initialStatus bool) Device {
	device := &test{
		lock:   sync.Mutex{},
		status: initialStatus,
	}
	return device
}

type test struct {
	lock   sync.Mutex
	status bool
}

func (d *test) Status() (bool, error) {
	d.lock.Lock()
	defer d.lock.Unlock()

	return d.status, nil
}

func (d *test) PushPowerButton() error {
	d.lock.Lock()
	defer d.lock.Unlock()

	d.status = !d.status
	return nil
}