Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/cmd/guide.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func generateGuide(currentDir string) error {
{"README.md", readme},
{"01-example-unit/00-hello-world.md", helloWorldMd},
{"01-example-unit/01-configuration.md", configurationMd},
{"01-example-unit/02-publishng.md", publishingMd},
{"01-example-unit/02-publishing.md", publishingMd},
{"01-example-unit/03-markdown-examples.md", markdownExamplesMd},
{"01-example-unit/04-challenges.md", challengesMd},
{"01-example-unit/05-checkpoint.md", checkpointMd},
Expand Down
3 changes: 3 additions & 0 deletions app/cmd/preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ func (p *previewBuilder) parseConfigAndGatherPaths() error {

for _, std := range config.Standards {
for _, cf := range std.ContentFiles {
if strings.ToLower(cf.Type) == "external" {
continue
}
contents, err := ioutil.ReadFile(p.target + cf.Path)
if err != nil {
return fmt.Errorf("Failure to read file '%s'. Err: %s", string(contents), err)
Expand Down
27 changes: 27 additions & 0 deletions app/cmd/preview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,33 @@ func Test_createNewTarget_DockerDirectoryDoubleNestedMd(t *testing.T) {
}
}

func Test_ParseConfigFileSkipsExternalType(t *testing.T) {
source := "../../fixtures/test-block-with-external"
p := previewBuilder{target: source}
err := p.parseConfigAndGatherPaths()
if err != nil {
t.Errorf("parseConfigAndGatherPaths should not error when external content files are present: %s", err)
}

// The external content file should not be in configYamlPaths
for _, path := range p.configYamlPaths {
if strings.Contains(path, "external-link") {
t.Errorf("configYamlPaths should not contain external content file path, but found: %s", path)
}
}

// The lesson file should still be present
foundLesson := false
for _, path := range p.configYamlPaths {
if strings.Contains(path, "lesson.md") {
foundLesson = true
}
}
if !foundLesson {
t.Errorf("configYamlPaths should contain the lesson content file path")
}
}

func testFilesExist(t *testing.T, paths []string) {
for _, file := range paths {
if _, err := os.Stat(fmt.Sprintf("single-file-upload/%s", file)); os.IsNotExist(err) {
Expand Down
13 changes: 13 additions & 0 deletions fixtures/test-block-with-external/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Standards:
- Title: Unit with External
UID: abc123
Description: A unit with an external content file
SuccessCriteria:
- success criteria
ContentFiles:
- Type: Lesson
Path: /units/lesson.md
UID: def456
- Type: External
Path: https://gitlab.galvanize.com/galvanize-it/sandboxes/grunde/test-repo/-/blob/main/sample-report.pdf
UID: ghi789
3 changes: 3 additions & 0 deletions fixtures/test-block-with-external/units/lesson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A Lesson

This is a lesson.
Loading