This removes the minimum on width and height, instead it will just used the largest width, height seen as the initial size for the asciicast. This also provides the ability to still set a minimum via options to convert.ToAsciicast if the caller has a known minimum size. Also note that in cases where there is no size information, ie if there was no pty request, this will still pick a default size of 80x24.
40 lines
986 B
Go
40 lines
986 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package convert
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Test_GetOpts provides unit tests for GetOpts and all the options
|
|
func Test_GetOpts(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("WithChannelId", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
channelId := "channel-id"
|
|
opts := getOpts(WithChannelId(channelId))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withChannelId = channelId
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
t.Run("WithMinWidth", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
width := uint32(23)
|
|
opts := getOpts(WithMinWidth(width))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withMinWidth = width
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
t.Run("WithMinHeight", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
height := uint32(64)
|
|
opts := getOpts(WithMinHeight(height))
|
|
testOpts := getDefaultOptions()
|
|
testOpts.withMinHeight = height
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
}
|