mirror of
https://github.com/vanng822/go-premailer.git
synced 2025-02-06 10:23:54 +00:00
Split up cmd. Add an empty test to make sure it build for now
This commit is contained in:
parent
9e5acafb5f
commit
fa7a3893b0
@ -19,4 +19,4 @@ install:
|
||||
- go get github.com/stretchr/testify/assert
|
||||
|
||||
script:
|
||||
- cd premailer && go test -v
|
||||
- make test
|
||||
|
8
Makefile
Normal file
8
Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
test:
|
||||
make -j test_premailer test_cmd-server test_cmd-script
|
||||
|
||||
test_premailer:
|
||||
cd premailer && go test -v
|
||||
|
||||
test_cmd-%:
|
||||
cd cmd/$* && go test -v
|
@ -3,10 +3,11 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/vanng822/go-premailer/premailer"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/vanng822/go-premailer/premailer"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -29,7 +30,10 @@ func main() {
|
||||
options := premailer.NewOptions()
|
||||
options.RemoveClasses = removeClasses
|
||||
options.CssToAttributes = !skipCssToAttributes
|
||||
prem := premailer.NewPremailerFromFile(inputFile, options)
|
||||
prem, err := premailer.NewPremailerFromFile(inputFile, options)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
html, err := prem.Transform()
|
||||
log.Printf("took: %v", time.Now().Sub(start))
|
||||
if err != nil {
|
16
cmd/script/main_test.go
Normal file
16
cmd/script/main_test.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
fmt.Println("Test starting")
|
||||
args := os.Args[:]
|
||||
retCode := m.Run()
|
||||
os.Args = args
|
||||
fmt.Println("Test ending")
|
||||
os.Exit(retCode)
|
||||
}
|
16
cmd/server/main_test.go
Normal file
16
cmd/server/main_test.go
Normal file
@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
fmt.Println("Test starting")
|
||||
args := os.Args[:]
|
||||
retCode := m.Run()
|
||||
os.Args = args
|
||||
fmt.Println("Test ending")
|
||||
os.Exit(retCode)
|
||||
}
|
@ -3,14 +3,15 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/unrolled/render"
|
||||
"github.com/vanng822/go-premailer/premailer"
|
||||
"github.com/vanng822/r2router"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/unrolled/render"
|
||||
"github.com/vanng822/go-premailer/premailer"
|
||||
"github.com/vanng822/r2router"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -46,8 +47,10 @@ func main() {
|
||||
if cssToAttributes == "false" {
|
||||
options.CssToAttributes = false
|
||||
}
|
||||
pre := premailer.NewPremailerFromString(html, options)
|
||||
result, _ = pre.Transform()
|
||||
pre, err := premailer.NewPremailerFromString(html, options)
|
||||
if err == nil {
|
||||
result, _ = pre.Transform()
|
||||
}
|
||||
} else {
|
||||
result = ""
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user