mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
fix section_test.go + minor lint issues
This commit is contained in:
parent
0e911b220a
commit
b7f22edb80
4 changed files with 27 additions and 23 deletions
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -712,7 +712,8 @@ func writeUsers(w http.ResponseWriter, u []entity.User) {
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("unable to writeUsers", err)
|
log.Error("unable to writeUsers", err)
|
||||||
u = []entity.User{}
|
writeServerError(w, "unabe to writeUsers", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSuccessBytes(w, j)
|
writeSuccessBytes(w, j)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -102,20 +102,20 @@ func TestOrganization(t *testing.T) {
|
||||||
|
|
||||||
_, err = p.GetOrganization("XXXXXXXXX")
|
_, err = p.GetOrganization("XXXXXXXXX")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("no error getting non-existant organization", err)
|
t.Error("no error getting non-existent organization", err)
|
||||||
}
|
}
|
||||||
p.testRollback(t)
|
p.testRollback(t)
|
||||||
|
|
||||||
err = p.UpdateOrganization(entity.Organization{BaseEntity: entity.BaseEntity{RefID: "XXXXXXXXX"}})
|
err = p.UpdateOrganization(entity.Organization{BaseEntity: entity.BaseEntity{RefID: "XXXXXXXXX"}})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("no error updating non-existant organization", err)
|
t.Error("no error updating non-existent organization", err)
|
||||||
}
|
}
|
||||||
p.testRollback(t)
|
p.testRollback(t)
|
||||||
|
|
||||||
err = p.RemoveOrganization("XXXXXXXXX")
|
err = p.RemoveOrganization("XXXXXXXXX")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("no error removing non-existant organization", err)
|
t.Error("no error removing non-existent organization", err)
|
||||||
}
|
}
|
||||||
p.testRollback(t)
|
p.testRollback(t)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,24 +14,26 @@ package section
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/documize/community/documize/section/provider"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testsection struct {
|
type testsection provider.TypeMeta
|
||||||
didRefresh bool
|
|
||||||
}
|
|
||||||
|
|
||||||
var ts testsection
|
var ts testsection
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
sectionsMap["testsection"] = &ts
|
provider.Register("testsection", &ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command is an end-point...
|
// Command is an end-point...
|
||||||
func (ts *testsection) Command(w http.ResponseWriter, r *http.Request) {}
|
func (ts *testsection) Command(w http.ResponseWriter, r *http.Request) {}
|
||||||
|
|
||||||
|
var didRefresh bool
|
||||||
|
|
||||||
// Refresh existing data, returning data in the format of the target system
|
// Refresh existing data, returning data in the format of the target system
|
||||||
func (ts *testsection) Refresh(meta, data string) string {
|
func (ts *testsection) Refresh(meta, data string) string {
|
||||||
ts.didRefresh = true
|
didRefresh = true
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +42,8 @@ func (*testsection) Render(meta, data string) string {
|
||||||
return "testsection " + data
|
return "testsection " + data
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*testsection) Meta() TypeMeta {
|
func (*testsection) Meta() provider.TypeMeta {
|
||||||
section := TypeMeta{}
|
section := provider.TypeMeta{}
|
||||||
|
|
||||||
section.ID = "TestGUID"
|
section.ID = "TestGUID"
|
||||||
section.Title = "TestSection"
|
section.Title = "TestSection"
|
||||||
|
@ -52,13 +54,13 @@ func (*testsection) Meta() TypeMeta {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSection(t *testing.T) {
|
func TestSection(t *testing.T) {
|
||||||
if _, ok := Refresh("testsection", "", ""); !ok {
|
if _, ok := provider.Refresh("testsection", "", ""); !ok {
|
||||||
t.Error("did not find 'testsection' smart section (1)")
|
t.Error("did not find 'testsection' smart section (1)")
|
||||||
}
|
}
|
||||||
if !ts.didRefresh {
|
if !didRefresh {
|
||||||
t.Error("did not run the test Refresh method")
|
t.Error("did not run the test Refresh method")
|
||||||
}
|
}
|
||||||
out, ok := Render("testsection", "meta", "dingbat")
|
out, ok := provider.Render("testsection", "meta", "dingbat")
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Error("did not find 'testsection' smart section (2)")
|
t.Error("did not find 'testsection' smart section (2)")
|
||||||
}
|
}
|
||||||
|
@ -66,7 +68,7 @@ func TestSection(t *testing.T) {
|
||||||
t.Error("wrong output from Render")
|
t.Error("wrong output from Render")
|
||||||
}
|
}
|
||||||
|
|
||||||
sects := GetSectionMeta()
|
sects := provider.GetSectionMeta()
|
||||||
for _, v := range sects {
|
for _, v := range sects {
|
||||||
if v.Title == "TestSection" {
|
if v.Title == "TestSection" {
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||||
//
|
//
|
||||||
// This software (Documize Community Edition) is licensed under
|
// This software (Documize Community Edition) is licensed under
|
||||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||||
//
|
//
|
||||||
// You can operate outside the AGPL restrictions by purchasing
|
// You can operate outside the AGPL restrictions by purchasing
|
||||||
// Documize Enterprise Edition and obtaining a commercial license
|
// Documize Enterprise Edition and obtaining a commercial license
|
||||||
// by contacting <sales@documize.com>.
|
// by contacting <sales@documize.com>.
|
||||||
//
|
//
|
||||||
// https://documize.com
|
// https://documize.com
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ package utility
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ import (
|
||||||
type HTML string
|
type HTML string
|
||||||
|
|
||||||
// write out the textual element of the html node, if present, then iterate through the child nodes.
|
// write out the textual element of the html node, if present, then iterate through the child nodes.
|
||||||
func writeText(n *html.Node, b *bytes.Buffer, isTest bool) {
|
func writeText(n *html.Node, b io.Writer, isTest bool) {
|
||||||
if !excluded(n) {
|
if !excluded(n) {
|
||||||
switch n.Type {
|
switch n.Type {
|
||||||
case html.TextNode:
|
case html.TextNode:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue