~mendelmaleh/pfin

ref: 5c1e70a0b8446799b943f837d8b7debc689ddd96 pfin/parser/personal/parse_test.go -rw-r--r-- 675 bytes
5c1e70a0Mendel E Fixups 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package personal

import (
	"testing"
	"time"

	"git.sr.ht/~mendelmaleh/pfin/parser/util"
	"github.com/stretchr/testify/assert"
)

func TestParse(t *testing.T) {
	data := []byte(`
date    	amount	media	description
----    	------	-----	-----------
- some comment
2022-04-26	31.41	card	some purchase
`)

	txns := []Transaction{{Raw: Raw{
		Date:        util.DateISO{time.Date(2022, time.April, 26, 0, 0, 0, 0, time.UTC)},
		Amount:      31.41,
		Media:       "card",
		Description: "some purchase",
	}}}

	raw, err := Parse(data)
	if err != nil {
		t.Errorf("error parsing data: %s", err)
	}

	assert := assert.New(t)

	for i, v := range raw {
		assert.Equal(txns[i], v)
	}
}