...

Source file src/oss.terrastruct.com/d2/lib/xgif/xgif_test.go

Documentation: oss.terrastruct.com/d2/lib/xgif

     1  package xgif
     2  
     3  import (
     4  	_ "embed"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  //go:embed test_input1.png
    12  var test_input1 []byte
    13  
    14  //go:embed test_input2.png
    15  var test_input2 []byte
    16  
    17  //go:embed test_output.gif
    18  var test_output []byte
    19  
    20  func TestPngToGif(t *testing.T) {
    21  	boards := [][]byte{test_input1, test_input2}
    22  	interval := 1_000
    23  	gifBytes, err := AnimatePNGs(boards, interval)
    24  	assert.NoError(t, err)
    25  
    26  	// use this to update the test output
    27  	if false {
    28  		f, err := os.Create("test_output_2.gif")
    29  		assert.NoError(t, err)
    30  		defer f.Close()
    31  		f.Write(gifBytes)
    32  	}
    33  
    34  	assert.Equal(t, test_output, gifBytes)
    35  }
    36  

View as plain text