~evanj/cms

dfe8c02818cc433c9250cae940d3ab7455b9d54f — Evan M Jones 4 months ago 45d8096
Feat(go.mod): Dependency cleanup. Removed some.
13 files changed, 4 insertions(+), 403 deletions(-)

M TODO
M go.mod
M go.sum
M internal/s/db/db_test.go
M pkg/e3/e3_test.go
D vendor/github.com/go-playground/assert/v2/.gitignore
D vendor/github.com/go-playground/assert/v2/.travis.yml
D vendor/github.com/go-playground/assert/v2/LICENSE
D vendor/github.com/go-playground/assert/v2/README.md
D vendor/github.com/go-playground/assert/v2/assert.go
D vendor/github.com/go-playground/assert/v2/doc.go
D vendor/github.com/go-playground/assert/v2/go.mod
M vendor/modules.txt
M TODO => TODO +2 -0
@@ 8,6 8,8 @@ Provide a Go API under git.sr.ht/~evanj/cms (move from
  with content/contentype search APIs.
Add "after" pagination option.
In ContentSearch use transaction on ContentGet.
Make content create have name field be StringSmall, StringBig works for example (if cURLing).


[revisit] 
Fullscreen takeover for html/markdown editors.

M go.mod => go.mod +0 -1
@@ 6,7 6,6 @@ require (
	git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997
	github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
	github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
	github.com/go-playground/assert/v2 v2.0.1
	github.com/go-sql-driver/mysql v1.5.0
	github.com/golang/mock v1.4.3
	github.com/google/uuid v1.1.1

M go.sum => go.sum +0 -2
@@ 8,8 8,6 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pO
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=

M internal/s/db/db_test.go => internal/s/db/db_test.go +1 -1
@@ 13,7 13,7 @@ import (
	"git.sr.ht/~evanj/cms/internal/m/valuetype"
	"git.sr.ht/~evanj/cms/internal/s/db"
	"git.sr.ht/~evanj/security"
	"github.com/go-playground/assert/v2"
	"github.com/bmizerany/assert"
)

var conn, dberr = setup()

M pkg/e3/e3_test.go => pkg/e3/e3_test.go +1 -1
@@ 8,7 8,7 @@ import (
	"testing"

	"git.sr.ht/~evanj/cms/pkg/e3"
	"github.com/go-playground/assert/v2"
	"github.com/bmizerany/assert"
)

var objectstorage = e3.New(

D vendor/github.com/go-playground/assert/v2/.gitignore => vendor/github.com/go-playground/assert/v2/.gitignore +0 -24
@@ 1,24 0,0 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

D vendor/github.com/go-playground/assert/v2/.travis.yml => vendor/github.com/go-playground/assert/v2/.travis.yml +0 -21
@@ 1,21 0,0 @@
language: go
go:
  - 1.13.1
  - tip
matrix:
  allow_failures:
    - go: tip

notifications:
  email:
    recipients: dean.karn@gmail.com
    on_success: change
    on_failure: always

# Only clone the most recent commit.
git:
  depth: 1

script:
  - go test -v -race ./...


D vendor/github.com/go-playground/assert/v2/LICENSE => vendor/github.com/go-playground/assert/v2/LICENSE +0 -22
@@ 1,22 0,0 @@
The MIT License (MIT)

Copyright (c) 2015 Dean Karn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


D vendor/github.com/go-playground/assert/v2/README.md => vendor/github.com/go-playground/assert/v2/README.md +0 -80
@@ 1,80 0,0 @@
Package assert
==============

[![Build Status](https://travis-ci.org/go-playground/assert.svg?branch=master)](https://travis-ci.org/go-playground/assert)
[![GoDoc](https://godoc.org/github.com/go-playground/assert?status.svg)](https://godoc.org/gopkg.in/go-playground/assert.v1)

Package assert is a Basic Assertion library used along side native go testing

Installation
------------

Use go get.

	go get github.com/go-playground/assert

Then import the assert package into your own code.

	import . "github.com/go-playground/assert/v2"

Usage and documentation
------

Please see http://godoc.org/github.com/go-playground/assert for detailed usage docs.

##### Example:
```go
package whatever

import (
	"errors"
	"testing"
	. "github.com/go-playground/assert/v2"
)

func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
	val, ok := errs[key]

	// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function
	EqualSkip(t, 2, ok, true)
	NotEqualSkip(t, 2, val, nil)
	EqualSkip(t, 2, val, expected)
}

func TestEqual(t *testing.T) {

	// error comes from your package/library
	err := errors.New("my error")
	NotEqual(t, err, nil)
	Equal(t, err.Error(), "my error")

	err = nil
	Equal(t, err, nil)

	fn := func() {
		panic("omg omg omg!")
	}

	PanicMatches(t, func() { fn() }, "omg omg omg!")
	PanicMatches(t, func() { panic("omg omg omg!") }, "omg omg omg!")

	// errs would have come from your package/library
	errs := map[string]string{}
	errs["Name"] = "User Name Invalid"
	errs["Email"] = "User Email Invalid"

	AssertCustomErrorHandler(t, errs, "Name", "User Name Invalid")
	AssertCustomErrorHandler(t, errs, "Email", "User Email Invalid")
}
```

How to Contribute
------
Make a PR.

I strongly encourage everyone whom creates a usefull custom assertion function to contribute them and
help make this package even better.

License
------
Distributed under MIT License, please see license file in code for more details.

D vendor/github.com/go-playground/assert/v2/assert.go => vendor/github.com/go-playground/assert/v2/assert.go +0 -197
@@ 1,197 0,0 @@
package assert

import (
	"fmt"
	"path"
	"reflect"
	"regexp"
	"runtime"
	"testing"
)

// IsEqual returns whether val1 is equal to val2 taking into account Pointers, Interfaces and their underlying types
func IsEqual(val1, val2 interface{}) bool {
	v1 := reflect.ValueOf(val1)
	v2 := reflect.ValueOf(val2)

	if v1.Kind() == reflect.Ptr {
		v1 = v1.Elem()
	}

	if v2.Kind() == reflect.Ptr {
		v2 = v2.Elem()
	}

	if !v1.IsValid() && !v2.IsValid() {
		return true
	}

	switch v1.Kind() {
	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
		if v1.IsNil() {
			v1 = reflect.ValueOf(nil)
		}
	}

	switch v2.Kind() {
	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
		if v2.IsNil() {
			v2 = reflect.ValueOf(nil)
		}
	}

	v1Underlying := reflect.Zero(reflect.TypeOf(v1)).Interface()
	v2Underlying := reflect.Zero(reflect.TypeOf(v2)).Interface()

	if v1 == v1Underlying {
		if v2 == v2Underlying {
			goto CASE4
		} else {
			goto CASE3
		}
	} else {
		if v2 == v2Underlying {
			goto CASE2
		} else {
			goto CASE1
		}
	}

CASE1:
	return reflect.DeepEqual(v1.Interface(), v2.Interface())
CASE2:
	return reflect.DeepEqual(v1.Interface(), v2)
CASE3:
	return reflect.DeepEqual(v1, v2.Interface())
CASE4:
	return reflect.DeepEqual(v1, v2)
}

// NotMatchRegex validates that value matches the regex, either string or *regex
// and throws an error with line number
func NotMatchRegex(t *testing.T, value string, regex interface{}) {
	NotMatchRegexSkip(t, 2, value, regex)
}

// NotMatchRegexSkip validates that value matches the regex, either string or *regex
// and throws an error with line number
// but the skip variable tells NotMatchRegexSkip how far back on the stack to report the error.
// This is a building block to creating your own more complex validation functions.
func NotMatchRegexSkip(t *testing.T, skip int, value string, regex interface{}) {

	if r, ok, err := regexMatches(regex, value); ok || err != nil {
		_, file, line, _ := runtime.Caller(skip)

		if err != nil {
			fmt.Printf("%s:%d %v error compiling regex %v\n", path.Base(file), line, value, r.String())
		} else {
			fmt.Printf("%s:%d %v matches regex %v\n", path.Base(file), line, value, r.String())
		}

		t.FailNow()
	}
}

// MatchRegex validates that value matches the regex, either string or *regex
// and throws an error with line number
func MatchRegex(t *testing.T, value string, regex interface{}) {
	MatchRegexSkip(t, 2, value, regex)
}

// MatchRegexSkip validates that value matches the regex, either string or *regex
// and throws an error with line number
// but the skip variable tells MatchRegexSkip how far back on the stack to report the error.
// This is a building block to creating your own more complex validation functions.
func MatchRegexSkip(t *testing.T, skip int, value string, regex interface{}) {

	if r, ok, err := regexMatches(regex, value); !ok {
		_, file, line, _ := runtime.Caller(skip)

		if err != nil {
			fmt.Printf("%s:%d %v error compiling regex %v\n", path.Base(file), line, value, r.String())
		} else {
			fmt.Printf("%s:%d %v does not match regex %v\n", path.Base(file), line, value, r.String())
		}

		t.FailNow()
	}
}

func regexMatches(regex interface{}, value string) (*regexp.Regexp, bool, error) {

	var err error

	r, ok := regex.(*regexp.Regexp)

	// must be a string
	if !ok {
		if r, err = regexp.Compile(regex.(string)); err != nil {
			return r, false, err
		}
	}

	return r, r.MatchString(value), err
}

// Equal validates that val1 is equal to val2 and throws an error with line number
func Equal(t *testing.T, val1, val2 interface{}) {
	EqualSkip(t, 2, val1, val2)
}

// EqualSkip validates that val1 is equal to val2 and throws an error with line number
// but the skip variable tells EqualSkip how far back on the stack to report the error.
// This is a building block to creating your own more complex validation functions.
func EqualSkip(t *testing.T, skip int, val1, val2 interface{}) {

	if !IsEqual(val1, val2) {
		_, file, line, _ := runtime.Caller(skip)
		fmt.Printf("%s:%d %v does not equal %v\n", path.Base(file), line, val1, val2)
		t.FailNow()
	}
}

// NotEqual validates that val1 is not equal val2 and throws an error with line number
func NotEqual(t *testing.T, val1, val2 interface{}) {
	NotEqualSkip(t, 2, val1, val2)
}

// NotEqualSkip validates that val1 is not equal to val2 and throws an error with line number
// but the skip variable tells NotEqualSkip how far back on the stack to report the error.
// This is a building block to creating your own more complex validation functions.
func NotEqualSkip(t *testing.T, skip int, val1, val2 interface{}) {

	if IsEqual(val1, val2) {
		_, file, line, _ := runtime.Caller(skip)
		fmt.Printf("%s:%d %v should not be equal %v\n", path.Base(file), line, val1, val2)
		t.FailNow()
	}
}

// PanicMatches validates that the panic output of running fn matches the supplied string
func PanicMatches(t *testing.T, fn func(), matches string) {
	PanicMatchesSkip(t, 2, fn, matches)
}

// PanicMatchesSkip validates that the panic output of running fn matches the supplied string
// but the skip variable tells PanicMatchesSkip how far back on the stack to report the error.
// This is a building block to creating your own more complex validation functions.
func PanicMatchesSkip(t *testing.T, skip int, fn func(), matches string) {

	_, file, line, _ := runtime.Caller(skip)

	defer func() {
		if r := recover(); r != nil {
			err := fmt.Sprintf("%s", r)

			if err != matches {
				fmt.Printf("%s:%d Panic...  expected [%s] received [%s]", path.Base(file), line, matches, err)
				t.FailNow()
			}
		} else {
			fmt.Printf("%s:%d Panic Expected, none found...  expected [%s]", path.Base(file), line, matches)
			t.FailNow()
		}
	}()

	fn()
}

D vendor/github.com/go-playground/assert/v2/doc.go => vendor/github.com/go-playground/assert/v2/doc.go +0 -49
@@ 1,49 0,0 @@
/*
Package assert provides some basic assertion functions for testing and
also provides the building blocks for creating your own more complex
validations.

	package whatever

	import (
		"errors"
		"testing"
		. "github.com/go-playground/assert.v1"
	)

	func AssertCustomErrorHandler(t *testing.T, errs map[string]string, key, expected string) {
		val, ok := errs[key]

		// using EqualSkip and NotEqualSkip as building blocks for my custom Assert function
		EqualSkip(t, 2, ok, true)
		NotEqualSkip(t, 2, val, nil)
		EqualSkip(t, 2, val, expected)
	}

	func TestEqual(t *testing.T) {

		// error comes from your package/library
		err := errors.New("my error")
		NotEqual(t, err, nil)
		Equal(t, err.Error(), "my error")

		err = nil
		Equal(t, err, nil)

		fn := func() {
			panic("omg omg omg!")
		}

		PanicMatches(t, func() { fn() }, "omg omg omg!")
		PanicMatches(t, func() { panic("omg omg omg!") }, "omg omg omg!")

		// errs would have come from your package/library
		errs := map[string]string{}
		errs["Name"] = "User Name Invalid"
		errs["Email"] = "User Email Invalid"

		AssertCustomErrorHandler(t, errs, "Name", "User Name Invalid")
		AssertCustomErrorHandler(t, errs, "Email", "User Email Invalid")
	}
*/
package assert

D vendor/github.com/go-playground/assert/v2/go.mod => vendor/github.com/go-playground/assert/v2/go.mod +0 -3
@@ 1,3 0,0 @@
module github.com/go-playground/assert/v2

go 1.13

M vendor/modules.txt => vendor/modules.txt +0 -2
@@ 6,8 6,6 @@ github.com/bmizerany/assert
github.com/bradfitz/gomemcache/memcache
# github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/dgrijalva/jwt-go
# github.com/go-playground/assert/v2 v2.0.1
github.com/go-playground/assert/v2
# github.com/go-sql-driver/mysql v1.5.0
github.com/go-sql-driver/mysql
# github.com/golang/mock v1.4.3