Skip to content

Commit

Permalink
Rename and lisibility change in test
Browse files Browse the repository at this point in the history
* change in template to make it more easy to pickup
  • Loading branch information
Theo-Hafsaoui committed Sep 8, 2024
1 parent e22e973 commit f8f3c30
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 126 deletions.
8 changes: 4 additions & 4 deletions assets/latex/template/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@
\begin{document}

\begin{center}
\textbf{\Huge \scshape \textcolor{nblue}{Hafsaoui Theo}} \\ \vspace{1pt}
\small +33 6 26 26 50 07 $|$ \href{mailto:theo.ha@pm.me}{\underline{theo.ha@pm.me}} \\
\href{https://linkedin.com/in/theo-dev/}{\underline{linkedin.com/in/theo-dev}} $|$
\href{https://github.com/Theo-Hafsaoui}{\underline{github.com/Theo-Hafsaoui}}
\textbf{\Huge \scshape \textcolor{nblue}{Anemon Vincent}} \\ \vspace{1pt}
\small +33 6 26 26 50 07 $|$ \href{mailto:anemon@pm.me}{\underline{anemon@pm.me}} \\
\href{https://linkedin.com/in/anemon/}{\underline{linkedin.com/in/anemon}} $|$
\href{https://github.com/anemon}{\underline{github.com/anemon}}
\end{center}


Expand Down
8 changes: 4 additions & 4 deletions cmd/generate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"anemon/internal/parser"
m_lang "anemon/internal/markup_languages"
"anemon/internal/walker"
"errors"
"os"
Expand Down Expand Up @@ -32,16 +32,16 @@ var generateCmd = &cobra.Command{
//Use a CV map created by `getSectionMapFrom` and write for each lang key a latex CV using the given information
func createLatexCVFrom(dir string, CV map[string]map[string]string )(error){
for lang := range CV{
err := parser.Init_output(lang+"-CV",dir)
err := m_lang.Init_output(lang+"-CV",dir)
if err != nil{
return err
}
for sec_name := range CV[lang]{
sec, err := parser.Parse(CV[lang][sec_name])
sec, err := m_lang.Parse(CV[lang][sec_name])
if err != nil {
return err
}
_,err = parser.ApplyToSection(sec,sec_name,dir+"/assets/latex/output/"+lang+"-CV.tex")
_,err = m_lang.ApplyToSection(sec,sec_name,dir+"/assets/latex/output/"+lang+"-CV.tex")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser
package markuplanguages

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser
package markuplanguages

import (
"os"
Expand All @@ -9,7 +9,7 @@ import (


func TestIO(t *testing.T) {
t.Run("Count returns 1 lines with just one line", func (t *testing.T) {
t.Run("should read the template in assets", func (t *testing.T) {
dir := filepath.Join("../../assets", "latex", "template")
templateFile := filepath.Join(dir, "template.tex")
backupFile := filepath.Join(dir, "save.tex")
Expand Down Expand Up @@ -41,9 +41,8 @@ t.Run("Count returns 1 lines with just one line", func (t *testing.T) {
}
}
})
}

func TestWriteLatex(t *testing.T) {
t.Run("should write a new template in output", func (t *testing.T) {
err := writeTemplate("../../","Hello, world", "hello.tex")
if err != nil {
t.Fatalf("Failed to write file: %v", err)
Expand All @@ -52,9 +51,9 @@ func TestWriteLatex(t *testing.T) {
if err != nil {
t.Fatalf("Failed to remove file: %v", err)
}
}
})

func TestApplySection(t *testing.T) {
t.Run("should apply a section in output cv", func (t *testing.T) {
tests := []struct {
name string
section Section
Expand Down Expand Up @@ -138,5 +137,5 @@ func TestApplySection(t *testing.T) {
}
})
}
})
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser
package markuplanguages

import (
"errors"
Expand Down
89 changes: 89 additions & 0 deletions internal/markup_languages/markdown_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package markuplanguages

import (
"fmt"
"reflect"
"testing"
)

func TestParse(t *testing.T) {
t.Run("Happy path should return the wanted struct", func (t *testing.T) {
input := `
# Title
## Skill
### Date
#### Url
Item
Item2`
result, err := Parse(input)
if err != nil {
t.Fatalf("Unexecpted eroor :%s", err.Error())
}

first := "Title"
if result.first != first {
t.Fatalf("want %s got %s", first, result.first)
}


second := "Skill"
if result.second != second {
t.Fatalf("want %s got %s", second, result.second)
}

third := "Date"
if result.third != third {
t.Fatalf("want %s got %s", third, result.third)
}

fourth := "Url"
if result.fourth != fourth {
t.Fatalf("want %s got %s", fourth, result.fourth)
}


description := []string{"Item","Item2"}
if !reflect.DeepEqual(result.description, description){
fmt.Printf("want: %q, got: %q\n", description, result.description)
t.Fatalf("want %s got %s", description, result.description)
}
})

t.Run("should return an error if title is badly formarted", func (t *testing.T) {
input := `
#Title
## Skill
### Date
#### Url
Description`
_, err := Parse(input)
want := "Err: cannot parse this md line{#Title} # should be followed by space"

if err == nil {
t.Fatalf("expected an error")
}

if err.Error() != want {
t.Fatalf("should return a formating error, got %s should %s",err.Error(),want)
}

})
t.Run("should return an error if outside of allowed nb of #", func (t *testing.T) {
input := `
# Title
## Skill
### Date
#### Url
##### oups
Description`
_, err := Parse(input)
want := "Err: cannot parse this md line{##### oups}"

if err == nil {
t.Fatalf("expected an error")
}
if err.Error() != want {
t.Fatalf("should return a formating error, got %s should %s",err.Error(),want)
}
})
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package parser
package markuplanguages

const pro_item = "\\resumeItem{%ITEM%}\n"

Expand Down
21 changes: 0 additions & 21 deletions internal/parser/assets/latex/output/texput.log

This file was deleted.

87 changes: 0 additions & 87 deletions internal/parser/markdown_test.go

This file was deleted.

0 comments on commit f8f3c30

Please sign in to comment.