-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor dataCompetencia format (#5)
- Loading branch information
1 parent
bc0c3de
commit 5537831
Showing
5 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package entity | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestNewNFSe(t *testing.T) { | ||
|
@@ -18,3 +20,32 @@ func TestNewNFSe(t *testing.T) { | |
t.Errorf("EnviarPorEmail should not be false") | ||
} | ||
} | ||
|
||
func TestNFSeMarshalJSON(t *testing.T) { | ||
dataCompetencia, _ := time.Parse(time.RFC3339, "2006-01-02T15:04:05Z") | ||
|
||
n := NFSe{ | ||
ID: "e93ceafb-6fd9-4543-9106-e0aebac9ef8d", | ||
Ambiente: Homologacao, | ||
DataCompetencia: &dataCompetencia, | ||
Numero: 42, | ||
EnviarPorEmail: false, | ||
ValorTotal: 3.47, | ||
Cliente: Cliente{ | ||
Nome: "John Doe", | ||
Email: "[email protected]", | ||
CpfCnpj: "47142365471", | ||
Endereco: Endereco{}, | ||
}, | ||
} | ||
b, err := json.Marshal(n) | ||
if err != nil { | ||
t.Errorf("Expected no error, got %v", err) | ||
} | ||
|
||
expected := `{"id":"e93ceafb-6fd9-4543-9106-e0aebac9ef8d","ambienteEmissao":"Homologacao","numero":42,"enviarPorEmail":false,"valorTotal":3.47,"cliente":{"tipoPessoa":"F","nome":"John Doe","email":"[email protected]","cpfCnpj":"47142365471","endereco":{"logradouro":"","numero":"","bairro":"","cep":"","cidade":"","uf":""}},"servico":{"cnae":"","codigoServicoMunicicio":"","descricao":"","aliquotaIss":0,"issRetidoFonte":false,"valorPis":0,"valorCofins":0,"valorCsll":0,"valorInss":0,"valorIr":0},"dataCompetencia":"2006-01-02T15:04Z"}` | ||
if string(b) != expected { | ||
t.Errorf("Expected '%s', got %s", expected, string(b)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/padmoney/enotas-go | ||
|
||
go 1.15 | ||
|
||
require github.com/hashicorp/go-uuid v1.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= | ||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= |