github.com/exercism/configlet@v3.9.3-0.20200318193232-c70be6269e71+incompatible/cmd/tree_example_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	"github.com/exercism/configlet/ui"
     8  )
     9  
    10  func ExampleTree() {
    11  	treeTrack(filepath.FromSlash("../fixtures/tree/config.json"))
    12  	// Output:
    13  	// Numbers
    14  	// =======
    15  	//
    16  	// core
    17  	// ----
    18  	// ├─ one
    19  	// │  └─ five
    20  	// │
    21  	// ├─ two
    22  	// │  ├─ six
    23  	// │  │  ├─ ten
    24  	// │  │  └─ twelve
    25  	// │  └─ thirteen
    26  	// │
    27  	// ├─ nine
    28  	// │
    29  	// └─ eleven
    30  	//
    31  	// bonus
    32  	// -----
    33  	// seven
    34  	// eight
    35  }
    36  
    37  func ExampleTreeDifficulty() {
    38  
    39  	orig := withDifficulty
    40  	withDifficulty = true
    41  	defer func() { withDifficulty = orig }()
    42  
    43  	treeTrack(filepath.FromSlash("../fixtures/tree/config.json"))
    44  	// Output:
    45  	// Numbers
    46  	// =======
    47  	//
    48  	// core
    49  	// ----
    50  	// ├─ one [1]
    51  	// │  └─ five [2]
    52  	// │
    53  	// ├─ two [1]
    54  	// │  ├─ six [3]
    55  	// │  │  ├─ ten [6]
    56  	// │  │  └─ twelve [8]
    57  	// │  └─ thirteen [5]
    58  	// │
    59  	// ├─ nine [4]
    60  	// │
    61  	// └─ eleven [4]
    62  	//
    63  	// bonus
    64  	// -----
    65  	// seven [3]
    66  	// eight [5]
    67  }
    68  
    69  func ExampleTreeWarnings() {
    70  	orig := ui.ErrOut
    71  	ui.ErrOut = os.Stdout
    72  
    73  	defer func() { ui.ErrOut = orig }()
    74  
    75  	treeTrack(filepath.FromSlash("../fixtures/tree/config-outdated.json"))
    76  	// Output:
    77  	// Numbers
    78  	// =======
    79  	// -> Cannot find any unlockable exercises, this track may be missing a nextercism compatible configuration.
    80  	// -> Cannot find any core exercises, this track may be missing a nextercism compatible configuration.
    81  	//
    82  	// bonus
    83  	// -----
    84  	// one
    85  	// two
    86  }
    87  
    88  func ExampleInvalidUnlockedBy() {
    89  	orig := ui.ErrOut
    90  	ui.ErrOut = os.Stdout
    91  
    92  	defer func() { ui.ErrOut = orig }()
    93  
    94  	treeTrack(filepath.FromSlash("../fixtures/tree/config-invalid-unlocked-by.json"))
    95  	// Output:
    96  	// Numbers
    97  	// =======
    98  	// -> Exercise "six" has an invalid unlocked_by slug: "a non-existing exercise", this track may be missing a nextercism compatible configuration.
    99  	//
   100  	// core
   101  	// ----
   102  	// ├─ one
   103  	// │  └─ five
   104  	// │
   105  	// └─ two
   106  	//
   107  	// bonus
   108  	// -----
   109  	// seven
   110  }