Skip to content

Commit

Permalink
Replace double by single quotes in element string output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ortuman authored Jan 3, 2022
2 parents cecb05b + a62dc86 commit 8ac052d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 37 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/check.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Check"
name: "CI"

on:
push:
Expand All @@ -15,7 +15,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
go-version: '^1.17.3'

- name: Setup Go linter
run: go get -u -v golang.org/x/tools/cmd/goimports golang.org/x/lint/golint
Expand All @@ -25,3 +25,23 @@ jobs:

- name: Run checks
run: make check

test:
name: test
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.13.1'

- name: Run tests
run: make test | make coverage

- name: Upload coverage report
uses: codecov/codecov-action@v1.0.7
with:
file: coverage.txt
26 changes: 0 additions & 26 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# stravaganza

[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fjackal-xmpp%2Fantenna%2Fbadge&style=flat)](https://actions-badge.atrox.dev/jackal-xmpp/stravaganza/goto)
![CI Status](https://github.com/jackal-xmpp/stravaganza/workflows/CI/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/jackal-xmpp/stravaganza?style=flat-square)](https://goreportcard.com/report/github.com/jackal-xmpp/stravaganza)
[![Coverage](https://codecov.io/gh/jackal-xmpp/stravaganza/branch/master/graph/badge.svg)](https://codecov.io/gh/jackal-xmpp/stravaganza)
[![Godoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/jackal-xmpp/stravaganza)
Expand Down Expand Up @@ -46,7 +46,7 @@ func main() {

Expected output:
```
<iq id="zid615d9" from="ortuman@jackal.im/yard" to="noelia@jackal.im/balcony" type="get"><ping xmlns="urn:xmpp:ping"/></iq>
<iq id='zid615d9' from='ortuman@jackal.im/yard' to='noelia@jackal.im/balcony' type='get'><ping xmlns='urn:xmpp:ping'/></iq>
```

### Contributing
Expand Down
6 changes: 3 additions & 3 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ func (e *element) ToXML(w io.Writer, includeClosing bool) error {
if len(attr.Value) == 0 {
continue
}
if _, err := io.WriteString(w, ` `); err != nil {
if _, err := io.WriteString(w, " "); err != nil {
return err
}
if _, err := io.WriteString(w, attr.Label); err != nil {
return err
}
if _, err := io.WriteString(w, `="`); err != nil {
if _, err := io.WriteString(w, "='"); err != nil {
return err
}
if _, err := io.WriteString(w, attr.Value); err != nil {
return err
}
if _, err := io.WriteString(w, `"`); err != nil {
if _, err := io.WriteString(w, "'"); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions element_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func TestElement_ToXML(t *testing.T) {
str := el.String()
goStr := el.GoString()

require.Equal(t, "<n1 l1=\"v1\">Where arth thou, my Juliet?<n2 xmlns=\"ns2\"/></n1>", buf1.String())
require.Equal(t, "<n1 l1=\"v1\">Where arth thou, my Juliet?<n2 xmlns=\"ns2\"/>", buf2.String())
require.Equal(t, "<n1 l1='v1'>Where arth thou, my Juliet?<n2 xmlns='ns2'/></n1>", buf1.String())
require.Equal(t, "<n1 l1='v1'>Where arth thou, my Juliet?<n2 xmlns='ns2'/>", buf2.String())

require.Equal(t, buf1.String(), str)
require.Equal(t, str, goStr)
Expand Down
4 changes: 2 additions & 2 deletions errors/stanza/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestStanzaError_Element(t *testing.T) {
seElem := se.Element()

// then
expectedOutput := `<message from="ortuman@jackal.im/balcony" to="noelia@jackal.im/yard" type="error"><body>Hi everyone!</body><error code="500" type="wait"><internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="es">Error interno de servidor</text><app-specific xmlns="app-ns"/></error></message>`
expectedOutput := "<message from='ortuman@jackal.im/balcony' to='noelia@jackal.im/yard' type='error'><body>Hi everyone!</body><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='es'>Error interno de servidor</text><app-specific xmlns='app-ns'/></error></message>"
require.Equal(t, expectedOutput, seElem.String())
}

Expand All @@ -168,7 +168,7 @@ func TestStanzaError_Stanza(t *testing.T) {
seStanza, _ := se.Stanza(true)

// then
expectedOutput := `<message from="ortuman@jackal.im/balcony" to="noelia@jackal.im/yard" type="error"><body>Hi everyone!</body><error code="500" type="wait"><internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="es">Error interno de servidor</text><app-specific xmlns="app-ns"/></error></message>`
expectedOutput := "<message from='ortuman@jackal.im/balcony' to='noelia@jackal.im/yard' type='error'><body>Hi everyone!</body><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='es'>Error interno de servidor</text><app-specific xmlns='app-ns'/></error></message>"
require.Equal(t, expectedOutput, seStanza.String())
}

Expand Down

0 comments on commit 8ac052d

Please sign in to comment.